/* =====================================================================
   EASEL GACHA - same look as EASEL WEB (panels, 3px borders, Nunito)
   Two themes, switched with the button in the top bar:
     Night (default) = EASEL WEB colors
     Blue            = EASEL Market "blue" colors
   Colors live ONLY in the tokens below; components never use raw hex.
   ===================================================================== */

:root {
  --bg:        #0a0c12;
  --side:      #10131d;
  --panel:     #151a28;
  --panel-2:   #1d2335;
  --panel-3:   #252c42;
  --border:    #373c4f;
  --border-hi: #5b627a;
  --text:      #ffffff;
  --muted:     #9aa3b8;
  --good:      #34d399;
  --bad:       #f87171;
  --gold:      #fbbf24;
  --accent:    #8f9dff;
  --on-accent: #0d1030;
  --glow:      rgba(120,150,255,.35);
  --shade:     rgba(6,8,13,.88);
  --scroll-track: #0d1018;
  --scroll-thumb: #2c3350;
  --radius:    10px;
  color-scheme: dark;
}
html[data-theme="blue"] {
  --bg:        #1b4560;
  --side:      #173f5a;
  --panel:     #1f5f84;   /* white text >= 6:1 */
  --panel-2:   #2a6f96;
  --panel-3:   #3a8bb5;
  --border:    #ffffff;
  --border-hi: #ffd24a;
  --text:      #ffffff;
  --muted:     #dbeef8;
  --good:      #3ddc84;
  --bad:       #ff6b6b;
  --gold:      #ffd24a;
  --accent:    #ffd24a;
  --on-accent: #1b2a3a;
  --glow:      rgba(255,210,74,.35);
  --shade:     rgba(14,40,58,.85);
  --scroll-track: #173f5a;
  --scroll-thumb: #4a9ccb;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scrollbar-color: var(--scroll-thumb) var(--scroll-track); scrollbar-width: thin; }
body {
  font-family: "Nunito", "Segoe UI", Verdana, sans-serif;
  font-weight: 700;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- scrollbar (WebKit / Chromium; Firefox uses scrollbar-color above) ---------- */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: var(--scroll-track); }
::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 999px;
  border: 3px solid var(--scroll-track);
  transition: background .2s;
}
::-webkit-scrollbar-thumb:hover { background: var(--accent); }
::-webkit-scrollbar-corner { background: var(--scroll-track); }

.panel { background: var(--panel); border: 3px solid var(--border); border-radius: var(--radius); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--side);
  border-bottom: 3px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { width: 120px; height: 40px; object-fit: cover; display: block; }
main:focus { outline: none; }   /* focus is moved here on navigation for screen readers only */
.brand b { font-size: 18px; font-weight: 800; letter-spacing: 1px; white-space: nowrap; }
.brand em { font-style: normal; color: var(--accent); font-size: 11px; letter-spacing: 3px; display: block; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px;
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px; font-weight: 800;
  transition: border-color .15s ease, filter .15s ease;
  white-space: nowrap;
}
button.pill:hover, a.pill:hover { border-color: var(--border-hi); filter: brightness(1.1); }
.pill .ic { width: 18px; height: 18px; flex: none; }
.bal-pill b { color: var(--good); font-size: 15px; }
.bal-pill.bump { animation: bump .45s ease; }
.bal-pill img { width: 22px; height: 22px; image-rendering: pixelated; }
/* PWL balance pill (gold, as on EASEL WEB) and the signed-in user pill */
.pwl-pill { border-color: rgba(251, 191, 36, .5); background: linear-gradient(135deg, rgba(251, 191, 36, .12), var(--panel)); }
.bal-pill.pwl-pill b { color: var(--gold); }
.user-pill { cursor: default; }
.logout-pill { color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--bad); flex: none; }
.dot.ok { background: var(--good); box-shadow: 0 0 8px var(--good); }

/* ---------- wallet dialogs ---------- */
.code-box {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--panel-2); border: 2px solid var(--border); border-radius: 10px; padding: 12px 14px;
}
.code-box .lbl { display: block; }
.code-box b { font-size: 16px; }
.code-box b.good, .good { color: var(--good); }
.code-box .code { font-size: 26px; letter-spacing: 5px; color: var(--gold); font-family: ui-monospace, Consolas, monospace; }
.steps { padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; color: var(--muted); margin-top: 12px; }
.steps b { color: var(--text); }
.steps code { background: var(--side); border: 1px solid var(--border); border-radius: 6px; padding: 1px 7px; color: var(--gold); font-weight: 800; }
@keyframes bump { 40% { transform: scale(1.08); } }

/* ---------- layout ---------- */
.wrap { max-width: 1280px; margin: 0 auto; padding: 16px 14px 40px; display: flex; flex-direction: column; gap: 18px; }
.hero {
  position: relative; overflow: hidden;
  padding: 26px 26px 24px;
  background: linear-gradient(120deg, var(--panel-2), var(--panel) 60%);
}
.hero h1 { font-size: clamp(22px, 3.4vw, 34px); font-weight: 800; line-height: 1.15; }
.hero p { color: var(--muted); font-size: 15px; margin-top: 6px; max-width: 640px; }
.hero .chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.chip { font-size: 12px; padding: 4px 11px; border-radius: 999px; background: var(--panel-3); border: 2px solid var(--border); }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.section-head h2 { font-size: 18px; }
.block { padding: 20px 20px 22px; }

/* ---------- game grid (same feel as EASEL WEB activities) ---------- */
.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.game-card {
  position: relative;
  display: flex; flex-direction: column; justify-content: flex-end;
  aspect-ratio: 1 / 1.08;
  padding: 12px 13px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--panel-2);
  background-size: cover; background-position: center;
  overflow: hidden;
  text-align: left;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.game-card::before { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, var(--shade), rgba(0,0,0,0) 62%); }
.game-card > * { position: relative; }
.game-card:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: 0 0 16px var(--glow); }
.game-card:active { transform: scale(.98); }
.game-card h3 { font-size: 17px; font-weight: 800; }
.game-card p { font-size: 12px; color: var(--muted); }
.game-card .badge {
  position: absolute; top: 9px; right: 9px;
  font-size: 10px; padding: 2px 8px; border-radius: 999px;
  background: var(--accent); color: var(--on-accent);
}
.game-card .art-icon { position: absolute; inset: 0 0 30% 0; display: grid; place-items: center; }
.game-card .art-icon svg { width: 46%; height: auto; opacity: .95; filter: drop-shadow(0 6px 14px rgba(0,0,0,.4)); }
.game-card.closed { opacity: .5; pointer-events: none; }

/* ---------- live bets ---------- */
.feed { display: flex; flex-direction: column; gap: 6px; max-height: 360px; overflow-y: auto; padding-right: 4px; }
.feed-row {
  display: grid; grid-template-columns: 1.2fr 1fr .9fr 1fr; gap: 8px; align-items: center;
  padding: 8px 12px; border-radius: 8px; background: var(--panel-2); font-size: 13px;
}
.feed-row.head { background: none; color: var(--muted); font-size: 12px; padding-top: 0; padding-bottom: 0; }
.feed-row .win { color: var(--good); }
.feed-row .loss { color: var(--muted); }

/* ---------- game screen ---------- */
.game-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.game-top h2 { font-size: 22px; }
.game-top p { color: var(--muted); font-size: 13px; }
.game-layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 14px; align-items: start; }
.game-layout > *, .wrap > * { min-width: 0; }   /* let wide boards shrink / scroll inside instead of widening the page */
.controls { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.board {
  position: relative; min-height: 420px;
  padding: 18px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: radial-gradient(ellipse at top, var(--panel-2), var(--panel) 70%);
  overflow: hidden;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .lbl { font-size: 12px; color: var(--muted); }
.input {
  width: 100%; min-height: 44px;
  background: var(--side); border: 2px solid var(--border); border-radius: 8px;
  padding: 9px 12px; font-weight: 800;
}
.input:focus { outline: none; border-color: var(--accent); }
.bet-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 6px; }
.mini {
  min-width: 44px; min-height: 44px; padding: 0 10px;
  background: var(--panel-2); border: 2px solid var(--border); border-radius: 8px; font-size: 13px; font-weight: 800;
}
.mini:hover { border-color: var(--border-hi); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; }
.seg button {
  min-height: 44px; padding: 6px 8px; border-radius: 8px;
  background: var(--panel-2); border: 2px solid var(--border); font-size: 13px; font-weight: 800;
}
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.seg button:disabled { opacity: .45; cursor: not-allowed; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 48px; padding: 11px 18px;
  background: var(--accent); color: var(--on-accent);
  border: 0; border-radius: 8px; font-size: 15px; font-weight: 800;
  transition: transform .12s ease, filter .15s ease, opacity .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.good { background: var(--good); color: #062014; }
.btn.bad { background: var(--bad); color: #2a0707; }
.btn.ghost { background: var(--panel-2); color: var(--text); border: 2px solid var(--border); }
.btn .spin { width: 16px; height: 16px; border-radius: 50%; border: 3px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: var(--panel-2); border: 2px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.stat span { display: block; font-size: 11px; color: var(--muted); }
.stat b { font-size: 16px; font-variant-numeric: tabular-nums; }
.stat b.good { color: var(--good); }
.note { font-size: 12px; color: var(--muted); font-weight: 600; }

/* result banner over the board */
.result {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(.9);
  min-width: 190px; padding: 14px 22px; text-align: center;
  background: var(--panel); border: 3px solid var(--good); border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0,0,0,.45);
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .25s ease; z-index: 5;
}
.result.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.result.lose { border-color: var(--bad); }
.result b { display: block; font-size: 28px; color: var(--good); font-variant-numeric: tabular-nums; }
.result.lose b { color: var(--bad); }
.result span { font-size: 13px; color: var(--muted); }

/* ---------- shared board pieces ---------- */
.grid-tiles { display: grid; gap: 8px; width: min(100%, 440px); }
.tile {
  aspect-ratio: 1; border-radius: 10px;
  background: var(--panel-3); border: 2px solid var(--border);
  display: grid; place-items: center;
  transition: transform .12s ease, background .2s, border-color .2s;
}
.tile:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--accent); }
.tile:disabled { cursor: default; }
.tile img { width: 64%; height: 64%; object-fit: contain; }
.tile.safe { background: rgba(52,211,153,.18); border-color: var(--good); }
.tile.boom { background: rgba(248,113,113,.25); border-color: var(--bad); }
.tile.dim { opacity: .45; }
.tile.flip { animation: flip .3s ease; }
@keyframes flip { 50% { transform: rotateY(90deg); } }

.mult-strip { display: flex; gap: 6px; overflow-x: auto; width: 100%; padding-bottom: 4px; }
.mult-strip span {
  flex: none; padding: 5px 10px; border-radius: 999px; font-size: 12px;
  background: var(--panel-2); border: 2px solid var(--border); font-variant-numeric: tabular-nums;
}
.mult-strip span.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.mult-strip span.done { border-color: var(--good); color: var(--good); }

.playing-card {
  width: 74px; height: 104px; border-radius: 9px; flex: none;
  background: #f8fafc; color: #111827; border: 2px solid #cbd5e1;
  display: flex; flex-direction: column; justify-content: space-between; padding: 6px 8px;
  font-size: 20px; font-weight: 900; box-shadow: 0 6px 16px rgba(0,0,0,.35);
  animation: deal .25s ease;
}
.playing-card.red { color: #dc2626; }
.playing-card .s2 { align-self: flex-end; transform: rotate(180deg); }
.playing-card.back { background: repeating-linear-gradient(45deg, var(--accent), var(--accent) 6px, var(--panel-3) 6px, var(--panel-3) 12px); border-color: var(--border); }
.playing-card.big { width: 110px; height: 154px; font-size: 30px; }
@keyframes deal { from { transform: translateY(-14px); opacity: 0; } }
.hand { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.hand-label { font-size: 13px; color: var(--muted); text-align: center; }

/* ---------- dialogs ---------- */
.dlg {
  border: 3px solid var(--border); border-radius: var(--radius);
  background: var(--panel); color: var(--text);
  width: min(460px, calc(100vw - 24px)); max-height: min(88vh, 760px);
  padding: 0; margin: auto; overflow: hidden;
}
.dlg.wide { width: min(980px, calc(100vw - 24px)); }
.dlg[open] { display: flex; flex-direction: column; }
.dlg::backdrop { background: rgba(3,4,8,.78); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 2px solid var(--border); }
.dlg-head h2 { font-size: 17px; }
.dlg-body { overflow-y: auto; padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 12px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dlg.small { width: min(400px, calc(100vw - 24px)); }
/* connected-character pop-up, log out confirmation (same layout as EASEL WEB) */
.acct-bals { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.bal-line { display: flex; align-items: center; gap: 6px; font-size: 18px !important; }
.bal-line img { width: 22px; height: 22px; image-rendering: pixelated; }
.gold { color: var(--gold); }
.acts { display: grid; grid-template-columns: 1fr 1.6fr; gap: 8px; }
.acts[hidden], .acct-confirm[hidden] { display: none; }
.acct-confirm { display: flex; flex-direction: column; gap: 10px; }
.btn.unlink { color: var(--bad); border-color: var(--bad); }
.warn {
  font-size: 13px; font-weight: 700; color: var(--gold);
  background: rgba(251, 191, 36, .1); border: 2px solid rgba(251, 191, 36, .35);
  border-radius: 10px; padding: 9px 12px;
}
@media (max-width: 420px) { .acct-bals { grid-template-columns: 1fr; } }
.err { color: var(--bad); font-size: 13px; min-height: 18px; }

/* ---------- toast ---------- */
.toast {
  /* top center under the sticky top bar, as on EASEL WEB */
  position: fixed; left: 50%; top: 76px; transform: translateX(-50%);
  z-index: 100; width: max-content; max-width: min(640px, calc(100vw - 32px)); text-align: center;
  background: var(--panel); border: 2px solid var(--good); border-radius: 12px;
  padding: 10px 18px; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.4);
  transition: opacity .2s ease;
}
.toast.err { border-color: var(--bad); }
.toast.hidden { display: block !important; opacity: 0; pointer-events: none; }

.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 4px 0 10px; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .game-layout { grid-template-columns: minmax(0, 1fr); }
  .board { order: -1; min-height: 340px; }
}
@media (max-width: 600px) {
  .topbar { padding: 8px 10px; gap: 6px; }
  .brand img { width: 84px; height: 32px; }
  .brand span { display: none; }
  .brand img { width: 72px; }
  .top-actions { flex-wrap: nowrap; gap: 6px; }
  .pill { padding: 6px 10px; min-width: 40px; }
  .bal-pill b { font-size: 14px; }
  .pill .txt { display: none; }
  .games { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .hero { padding: 18px 16px; }
  .block { padding: 16px 14px 18px; }
  .feed-row { grid-template-columns: 1.1fr 1fr 1fr; }
  .feed-row .hide-sm { display: none; }
  .playing-card { width: 60px; height: 86px; font-size: 17px; }
  .playing-card.big { width: 92px; height: 128px; font-size: 26px; }
}
@media (max-width: 1100px) {
  #themeBtn .txt, #logoutBtn .txt { display: none; }   /* icons only, so the top bar stays on one row */
}
@media (max-width: 600px) {
  .user-pill { display: none !important; }   /* the name is in the Log out dialog; keep the row short */
  .toast { top: 64px; }
  /* the actions are one row that scrolls sideways if a phone is too narrow */
  .top-actions { overflow-x: auto; scrollbar-width: none; min-width: 0; }
  .top-actions::-webkit-scrollbar { display: none; }
  .top-actions > * { flex: none; }
}
@media (max-width: 440px) {
  .brand { display: none; }          /* back, theme, WL, PWL, connection, account must fit one row */
  .top-actions { margin-left: auto; }
  .pill { padding: 6px 9px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
