:root {
  --bg: #2a3442;
  --bg-2: #36475e;
  --bar: #1b2330;
  --bar-2: #131a24;
  --slot: rgba(10, 16, 26, .42);
  --slot-edge: rgba(255, 255, 255, .08);
  --ink: #141a22;
  --tile: #ffffff;
  --tile-edge: #c3cad4;
  --accent: #7cc4ff;
  --blue: #2f63dc;
  --blue-2: #6f9bff;
  --steel: #56657d;
  --primary: #2f6fe0;
  --cyan: #2aa0c8;
  --gold: #f3b02b;
  --sapphire: #3b82f6;
  --ruby: #e33452;
  --emerald: #26b04a;
  --cell: clamp(46px, min(10.6vh, 8.6vw), 96px);
  --gap: calc(var(--cell) * .12);
  --r: calc(var(--cell) * .1);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'FredokaLocal', 'Fredoka', ui-rounded, system-ui, sans-serif;
  color: #fff;
  background-color: var(--bg);
  background-image:
    linear-gradient(45deg, rgba(255,255,255,.035) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.035) 75%),
    linear-gradient(-45deg, rgba(255,255,255,.035) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.035) 75%),
    radial-gradient(ellipse at 50% 40%, var(--bg-2), var(--bg) 70%);
  background-size: 56px 56px, 56px 56px, 100% 100%;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
@font-face {
  font-family: 'FredokaLocal';
  src: url('assets/fonts/fredoka-latin.woff2') format('woff2');
  font-weight: 300 700; font-style: normal; font-display: swap;
}
button { font-family: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:disabled { cursor: not-allowed; }
[hidden] { display: none !important; }

#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 8px 16px;
  background: linear-gradient(var(--bar), var(--bar-2));
  border-bottom: 3px solid rgba(255,255,255,.12);
  font-weight: 700; letter-spacing: .02em;
}
.icon-btn {
  width: 40px; height: 40px; border-radius: 8px;
  background: #3a4a60; color: #fff; display: grid; place-items: center;
}
.icon-btn svg { width: 24px; height: 24px; }
.tb-title { font-size: clamp(16px, 2.2vw, 24px); min-width: 120px; }
.tb-title.right { text-align: right; }
.tb-score { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.tb-score-text { font-size: clamp(16px, 2.2vw, 24px); }
.tb-progress { width: min(320px, 90%); height: 8px; border-radius: 99px; background: rgba(0,0,0,.35); overflow: hidden; }
#scoreFill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #a5d8ff); transition: width .5s cubic-bezier(.2,.9,.3,1.2); }
#scoreFill.done { background: linear-gradient(90deg, #3fe08a, #b7ff6b); }
.tb-money {
  font-size: clamp(16px, 2.2vw, 22px); color: #ffd25e;
  background: rgba(0,0,0,.25); padding: 4px 12px; border-radius: 99px;
}
.tb-money.bump { animation: bump .35s; }
@keyframes bump { 50% { transform: scale(1.25); } }

/* ---------- layout ---------- */
.stage {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 170px 1fr 110px;
  gap: 12px; padding: 12px 16px;
}
.board { display: flex; flex-direction: column; align-items: center; gap: 12px; min-width: 0; }

/* ---------- charms ---------- */
.charms {
  display: flex; flex-direction: column; gap: 10px;
  background: rgba(12, 18, 28, .35); border-radius: 16px; padding: 10px;
  overflow-y: auto;
}
.charm {
  position: relative; display: flex; min-height: 70px;
  border-radius: 10px; border: 3px solid var(--blue-2);
  background: var(--blue); overflow: hidden;
  box-shadow: 0 3px 0 rgba(0,0,0,.25);
  transition: transform .15s;
}
.charm:hover { transform: translateY(-2px); }
.charm.r2 { border-color: #8f9cff; background: #3f4fc4; }
.charm.r3 { border-color: #6fd3f2; background: #0e8fb8; }
.charm .txt {
  flex: 1; padding: 6px 8px; font-size: 13px; font-weight: 600; line-height: 1.15;
  display: flex; align-items: center; justify-content: center; text-align: center;
}
.charm .tab {
  width: 42px; display: grid; place-items: center;
  background: rgba(255,255,255,.18); font-weight: 700; font-size: 15px;
}
.charm.fire { animation: fire .5s; }
@keyframes fire { 30% { transform: scale(1.08); filter: brightness(1.5); } }
.charm.empty { border: 3px dashed rgba(255,255,255,.15); background: transparent; box-shadow: none; }
.charm.sellable { cursor: pointer; }
.charm.sellable::after {
  content: attr(data-sell); position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(0,0,0,.6); font-weight: 700; opacity: 0; transition: opacity .15s;
}
.charm.sellable:hover::after { opacity: 1; }

/* ---------- banner ---------- */
.banner {
  padding: 8px 28px; border-radius: 99px;
  background: rgba(12, 18, 28, .55); border: 2px solid rgba(255,255,255,.12);
  font-size: clamp(15px, 1.9vw, 22px); font-weight: 600; text-align: center;
  min-height: 1.6em;
}
.banner .hl { color: var(--accent); }
.banner.bad { animation: shake .35s; }
.banner.bad .hl { color: #c9dcf0; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* ---------- tiles ---------- */
.tile, .slot {
  position: relative; width: var(--cell); height: var(--cell); border-radius: var(--r);
  flex: none;
}
.slot { background: var(--slot); box-shadow: inset 0 0 0 2px var(--slot-edge); }
.tile {
  background: var(--tile); color: var(--ink);
  box-shadow: 0 calc(var(--cell) * .06) 0 var(--tile-edge), 0 calc(var(--cell) * .08) 6px rgba(0,0,0,.25);
  display: grid; place-items: center; overflow: hidden;
  transition: transform .1s, box-shadow .1s;
}
.tile .L { font-size: calc(var(--cell) * .58); font-weight: 700; line-height: 1; position: relative; z-index: 1; }
.tile .L small { font-size: .55em; }
.tile .v { position: absolute; top: 5%; right: 8%; font-size: calc(var(--cell) * .17); font-weight: 600; z-index: 2; }
.tile .bonus { position: absolute; bottom: 4%; left: 8%; font-size: calc(var(--cell) * .15); font-weight: 700; color: #1d4ed8; z-index: 2; }
.tile::before { /* modifier corner */
  content: ''; position: absolute; top: 0; right: 0; width: 34%; height: 34%;
  clip-path: polygon(0 0, 100% 0, 100% 100%); background: transparent;
}
.tile.mod-gold::before { background: var(--gold); }
.tile.mod-sapphire::before { background: var(--sapphire); }
.tile.mod-ruby::before { background: var(--ruby); }
.tile.mod-sapphire .v, .tile.mod-ruby .v { color: #fff; }
.tile.mod-emerald { background: linear-gradient(160deg, #47d86a, var(--emerald)); box-shadow: 0 calc(var(--cell) * .06) 0 #13782d, 0 calc(var(--cell) * .08) 6px rgba(0,0,0,.25); }
.tile.mod-glass {
  background: linear-gradient(135deg, rgba(220,250,255,.95), rgba(160,225,245,.85) 50%, rgba(230,255,255,.95));
  box-shadow: 0 calc(var(--cell) * .06) 0 #79b9cc, 0 calc(var(--cell) * .08) 6px rgba(0,0,0,.25), inset 0 0 0 2px rgba(255,255,255,.9);
}
.tile.special { background: #1e293b; color: #fff; box-shadow: 0 calc(var(--cell) * .06) 0 #0b111c, 0 calc(var(--cell) * .08) 6px rgba(0,0,0,.25); }
.tile.special svg { width: 56%; height: 56%; }
.tile.special .nm { position: absolute; bottom: 5%; font-size: calc(var(--cell) * .13); font-weight: 700; letter-spacing: .05em; opacity: .85; }
.tile.special.sp-wild { background: linear-gradient(135deg, #ff7ac6, #8a5cff 50%, #3fd0ff); }

.grid .tile { cursor: pointer; }
.grid .tile.sel {
  transform: translateY(calc(var(--cell) * -.05));
  box-shadow: 0 calc(var(--cell) * .06) 0 #e0a100, 0 0 0 4px #ffd34d, 0 6px 14px rgba(0,0,0,.35);
}
.grid .tile.sel.valid { box-shadow: 0 calc(var(--cell) * .06) 0 #149a5f, 0 0 0 4px #4dff9c, 0 6px 14px rgba(0,0,0,.35); }
.grid .tile.dim { filter: brightness(.82); }
.grid .tile.special:not(.sp-wild) { cursor: default; }
.tile.pop { animation: pop .45s; }
@keyframes pop { 40% { transform: scale(1.15) rotate(-3deg); } }
.tile.shatter { animation: shatter .5s forwards; }
@keyframes shatter { to { transform: scale(1.4) rotate(20deg); opacity: 0; } }

/* ---------- word bar ---------- */
.wordbar-wrap { position: relative; display: flex; flex-direction: column; align-items: center; }
.wordbar { display: flex; gap: calc(var(--gap) * .8); --cell: calc(clamp(36px, min(8.4vh, 6.4vw), 76px) * var(--wscale, 1)); }
.wordbar .ghost {
  width: var(--cell); height: var(--cell); border-radius: var(--r);
  background: rgba(12, 18, 28, .4); box-shadow: inset 0 0 0 2px rgba(255,255,255,.07);
  display: grid; place-items: center; position: relative; color: rgba(140, 190, 255, .5);
  font-weight: 700; font-size: calc(var(--cell) * .3);
}
.wordbar .ghost .n { position: absolute; bottom: 4%; right: 8%; font-size: calc(var(--cell) * .2); color: rgba(255,255,255,.35); }
.preview {
  position: absolute; bottom: calc(100% + 6px); white-space: nowrap;
  padding: 3px 12px; border-radius: 8px; font-weight: 700; font-size: 16px;
  background: var(--primary); box-shadow: 0 3px 0 rgba(0,0,0,.25);
  opacity: 0; transform: translateY(6px); transition: .15s;
}
.preview.show { opacity: 1; transform: none; }
.preview .c { color: #9fd8ff; } .preview .m { color: #a5b4fc; }

/* ---------- grid ---------- */
.grid-wrap { position: relative; }
.grid {
  display: grid; grid-template-columns: repeat(5, var(--cell)); grid-auto-rows: var(--cell);
  gap: var(--gap); padding: var(--gap); border-radius: calc(var(--r) * 2);
  background: rgba(12, 18, 28, .28); touch-action: none;
}
.reels {
  position: absolute; inset: 0; display: grid; grid-template-columns: repeat(5, var(--cell));
  gap: var(--gap); padding: var(--gap); pointer-events: none;
}
.reel { overflow: hidden; height: calc(var(--cell) * 4 + var(--gap) * 3); border-radius: var(--r); position: relative; padding-bottom: 6px; }
.reel .strip { display: flex; flex-direction: column; gap: var(--gap); will-change: transform; }
.reel.spinning .strip { filter: blur(1px); }
.fx { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.float {
  position: absolute; transform: translate(-50%, -50%); font-weight: 700; font-size: 20px;
  text-shadow: 0 2px 0 rgba(0,0,0,.5); animation: floatUp 1.1s forwards; white-space: nowrap; z-index: 5;
}
.float.money { color: #ffd25e; } .float.chips { color: #9fd8ff; } .float.mult { color: #a5b4fc; }
.float.boom { color: #ff9a4d; } .float.play { color: #7dffb5; } .float.luck { color: #7dffb5; }
.float.big { font-size: 40px; color: #fff; }
@keyframes floatUp { 0% { opacity: 0; transform: translate(-50%, -20%) scale(.6); } 15% { opacity: 1; transform: translate(-50%, -60%) scale(1.1); } 100% { opacity: 0; transform: translate(-50%, -180%) scale(1); } }

/* ---------- lever ---------- */
.lever {
  margin-top: 4px; min-width: 220px; padding: 12px 36px; border-radius: 99px;
  background: linear-gradient(#5b93f0, var(--primary)); font-size: 24px; font-weight: 700; letter-spacing: .06em;
  box-shadow: 0 5px 0 #173d85, 0 8px 16px rgba(0,0,0,.3);
  transition: transform .08s, box-shadow .08s;
}
.lever:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 #173d85; }
.lever.alt { background: linear-gradient(#52bde0, var(--cyan)); box-shadow: 0 5px 0 #11577a, 0 8px 16px rgba(0,0,0,.3); }
.lever.gold { background: linear-gradient(#ffd35e, #e9a200); color: #3b2300; box-shadow: 0 5px 0 #8a5f00, 0 8px 16px rgba(0,0,0,.3); }
.lever:disabled { filter: grayscale(.7) brightness(.8); }

/* ---------- action buttons ---------- */
.actions {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: rgba(12, 18, 28, .35); border-radius: 60px; padding: 18px 10px; align-self: center;
}
.round-btn {
  position: relative; width: 78px; height: 78px; border-radius: 50%;
  display: grid; place-items: center; box-shadow: 0 4px 0 rgba(0,0,0,.3);
  transition: transform .08s, filter .15s;
}
.round-btn svg { width: 46%; height: 46%; }
.round-btn:active:not(:disabled) { transform: translateY(3px); }
.round-btn:disabled { filter: grayscale(.8) brightness(.6); }
.round-btn.white { background: #fff; color: #141a22; }
.round-btn.steel { background: var(--steel); border: 4px solid #8b99ae; }
.round-btn.blue { background: var(--primary); border: 4px solid #8db5ff; }
.round-btn.cyan { background: var(--cyan); border: 4px solid #8fdcf5; }
.round-btn.cyan.ready { animation: glow 1s infinite alternate; }
.btn-cap {
  position: absolute; bottom: -10px; left: 50%; transform: translateX(-50%); white-space: nowrap;
  background: #eee; color: #222; border-radius: 6px; padding: 1px 6px; font-size: 11px; font-weight: 700;
  box-shadow: 0 2px 0 rgba(0,0,0,.35);
}
.lever .pts { opacity: .85; font-size: .8em; margin-left: 8px; }
.up-arrow { font-size: 22px; font-weight: 700; color: #ffd25e; }
.up-pair { display: flex; align-items: center; gap: 10px; }
.up-pair .tile { --cell: 70px; }
.card.chosen { border-color: #ffd25e; transform: translateY(-4px); }
.card.dimmed { opacity: .4; }
.result { font-size: 22px; font-weight: 700; text-align: center; margin-top: 14px; min-height: 1.4em; }
.result.ok { color: #7dffb5; } .result.fail { color: #c9dcf0; }
.tile .v.up { color: #0f9d58; }
@keyframes glow { to { box-shadow: 0 4px 0 rgba(0,0,0,.3), 0 0 22px 6px rgba(140,220,245,.7); } }
.badge {
  position: absolute; right: -8px; bottom: -6px; min-width: 32px; padding: 2px 6px;
  background: #eee; color: #222; border-radius: 6px; font-weight: 700; font-size: 15px;
  box-shadow: 0 2px 0 rgba(0,0,0,.35);
}
.bag-count { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -10%); font-size: 13px; font-weight: 700; color: var(--primary); }

/* ---------- bottom bar ---------- */
.bottombar {
  display: flex; align-items: center; gap: 16px; padding: 8px 16px; min-height: 52px;
  background: linear-gradient(var(--bar-2), #0e141c); border-top: 3px solid rgba(255,255,255,.08);
}
.plays-label { font-weight: 700; font-size: 20px; display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.pips { display: inline-flex; gap: 6px; }
.pip { width: 14px; height: 14px; border-radius: 50%; background: rgba(255,255,255,.18); }
.pip.on { background: #8fdcf5; box-shadow: 0 0 8px #8fdcf5; }
.played { display: flex; gap: 8px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.played .w { background: rgba(255,255,255,.1); padding: 4px 10px; border-radius: 8px; font-weight: 600; white-space: nowrap; }
.played .w b { color: #ffd25e; margin-left: 6px; }

/* ---------- modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(8, 12, 18, .72); backdrop-filter: blur(3px);
  display: grid; place-items: center; z-index: 50; padding: 16px;
}
.modal {
  width: min(860px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto;
  background: linear-gradient(#2f3b4d, #1f2836); border: 3px solid rgba(255,255,255,.15);
  border-radius: 22px; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.5);
  animation: modalIn .25s cubic-bezier(.2,.9,.3,1.3);
}
@keyframes modalIn { from { transform: scale(.9); opacity: 0; } }
.modal h2 { margin: 0 0 4px; font-size: 30px; text-align: center; letter-spacing: .03em; }
.modal h3 { margin: 18px 0 8px; font-size: 18px; color: #a8d4ff; letter-spacing: .05em; text-transform: uppercase; }
.modal p.sub { margin: 0 0 16px; text-align: center; opacity: .8; }
.modal p { line-height: 1.45; }
.cards { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.card {
  width: 200px; background: rgba(0,0,0,.25); border-radius: 16px; padding: 16px 14px;
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
  border: 2px solid rgba(255,255,255,.1); transition: transform .12s, border-color .12s;
}
.card:hover { transform: translateY(-4px); border-color: rgba(255,255,255,.35); }
.card .tile { --cell: 84px; }
.card .name { font-weight: 700; font-size: 18px; }
.card .desc { font-size: 14px; opacity: .85; min-height: 2.4em; }
.card .rar { font-size: 12px; font-weight: 700; letter-spacing: .08em; padding: 2px 8px; border-radius: 99px; }
.rar.r1 { background: #2f63dc; } .rar.r2 { background: #3f4fc4; } .rar.r3 { background: #0e8fb8; }
.card .charm { width: 100%; min-height: 84px; }
.card.mine { width: 170px; }
.btn {
  padding: 10px 20px; border-radius: 12px; font-weight: 700; font-size: 16px;
  background: var(--cyan); box-shadow: 0 4px 0 #11577a;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #11577a; }
.btn.grey { background: #4a5566; box-shadow: 0 4px 0 #262d38; }
.btn.gold { background: #e9a200; color: #2d1b00; box-shadow: 0 4px 0 #8a5f00; }
.btn.red { background: #b84a5a; box-shadow: 0 4px 0 #6e2430; }
.btn:disabled { filter: grayscale(1) brightness(.7); }
.row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.income { width: min(360px, 100%); margin: 0 auto; }
.income div { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px dashed rgba(255,255,255,.15); }
.income div b { color: #ffd25e; }
.bag-grid { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.bag-grid .tile { --cell: 56px; }
.bag-grid.selectable .tile { cursor: pointer; }
.bag-grid.selectable .tile:hover { transform: translateY(-3px) scale(1.05); }
.services { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.service { background: rgba(0,0,0,.25); border-radius: 14px; padding: 12px 16px; text-align: center; width: 220px; }
.service .desc { font-size: 14px; opacity: .85; margin: 4px 0 10px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: min(380px, 100%); margin: 12px auto; }
.stats div { background: rgba(0,0,0,.25); border-radius: 10px; padding: 8px 12px; }
.stats span { display: block; font-size: 12px; opacity: .7; text-transform: uppercase; letter-spacing: .06em; }
.stats b { font-size: 20px; }
.legend { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; align-items: center; }
.legend .tile { --cell: 44px; }

.tooltip {
  position: fixed; z-index: 60; max-width: 240px; padding: 8px 12px; border-radius: 10px;
  background: #121822; border: 2px solid rgba(255,255,255,.2); font-size: 14px; pointer-events: none;
  box-shadow: 0 8px 20px rgba(0,0,0,.4);
}
.tooltip b { display: block; margin-bottom: 2px; }

/* ---------- responsive ---------- */
@media (max-width: 820px) {
  :root { --cell: min(16vw, 9.5vh, 76px); }
  body { overflow: auto; }
  .topbar { gap: 8px; padding: 6px 12px; flex-wrap: wrap; }
  .tb-title { min-width: 0; font-size: 15px; }
  .tb-score { order: 5; flex-basis: 100%; }
  .stage { grid-template-columns: 1fr; padding: 8px 16px; gap: 8px; }
  .charms { flex-direction: row; overflow-x: auto; padding: 6px; order: -1; min-height: 64px; }
  .charm { min-width: 128px; min-height: 52px; }
  .charm .txt { font-size: 11px; }
  .charm .tab { width: 32px; font-size: 12px; }
  .actions { flex-direction: row; border-radius: 60px; padding: 8px 14px; gap: 14px; }
  .round-btn { width: 58px; height: 58px; }
  .wordbar { --cell: calc(min(10vw, 44px) * var(--wscale, 1)); gap: 3px; }
  .lever { min-width: 180px; padding: 10px 24px; font-size: 20px; }
  .banner { font-size: 14px; padding: 6px 16px; }
  .bottombar { min-height: 44px; }
  .plays-label { font-size: 16px; }
}

/* ---------- gem reveal ---------- */
.reveal-stage { position: relative; height: 240px; display: grid; place-items: center; overflow: visible; }
.reveal-tile .tile { --cell: 140px; }
.reveal-tile.shaking { animation: rattle 1.3s linear forwards; }
@keyframes rattle {
  0% { transform: none; }
  10% { transform: translate(-2px, 1px) rotate(-2deg); }
  20% { transform: translate(2px, -1px) rotate(2deg); }
  30% { transform: translate(-3px, 2px) rotate(-3deg); }
  40% { transform: translate(4px, -2px) rotate(4deg) scale(1.02); }
  50% { transform: translate(-5px, 2px) rotate(-5deg) scale(1.03); }
  60% { transform: translate(6px, -3px) rotate(6deg) scale(1.04); }
  70% { transform: translate(-7px, 3px) rotate(-7deg) scale(1.05); }
  80% { transform: translate(8px, -4px) rotate(8deg) scale(1.07); }
  90% { transform: translate(-9px, 4px) rotate(-9deg) scale(1.09); filter: brightness(1.4); }
  100% { transform: scale(1.12); filter: brightness(2.2); }
}
.reveal-tile.revealed { animation: revealPop .55s cubic-bezier(.2,1.6,.4,1); }
@keyframes revealPop { 0% { transform: scale(1.3); filter: brightness(2.2); } 100% { transform: none; filter: none; } }
.confetti { position: absolute; width: 10px; height: 14px; border-radius: 2px; pointer-events: none; z-index: 3; }
.reveal-info { text-align: center; font-size: 18px; line-height: 1.45; min-height: 2.9em; max-width: 46ch; margin: 0 auto; }
@media (prefers-reduced-motion: reduce) { .reveal-tile.revealed { animation: none; } }

/* ---------- spin cover (between spins) ---------- */
.spin-cover {
  position: absolute; inset: -6px; z-index: 6; border-radius: calc(var(--r) * 2.4);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 16px; text-align: center;
  background: #3b4452;
  border: 2px solid rgba(255, 255, 255, .1);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .4);
  animation: coverIn .25s ease-out;
}
.spin-cover.leaving { animation: coverOut .2s ease-in forwards; }
@keyframes coverIn { from { opacity: 0; } }
@keyframes coverOut { to { opacity: 0; } }
.sc-label { font-size: clamp(13px, 1.5vw, 16px); font-weight: 700; letter-spacing: .14em; color: #b8c4d4; }
.sc-goal { font-size: clamp(18px, 2.3vw, 26px); font-weight: 600; color: #fff; }
.sc-goal b { color: #ffd25e; }
.spin-big {
  margin-top: 14px; min-width: min(240px, 100%); padding: 16px 56px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  background: linear-gradient(#4f8ff2, #2f6fe0); color: #fff;
  font-size: clamp(22px, 2.4vw, 28px); font-weight: 700; letter-spacing: .12em;
  box-shadow: 0 6px 0 #173d85, 0 10px 22px rgba(0, 0, 0, .35);
  transition: transform .08s, box-shadow .08s, filter .15s;
}
.spin-big:hover { filter: brightness(1.08); }
.spin-big:active { transform: translateY(5px); box-shadow: 0 1px 0 #173d85, 0 4px 10px rgba(0, 0, 0, .35); }
.spin-big:focus-visible { outline: 4px solid #ffd25e; outline-offset: 4px; }
.sc-hint { font-size: 13px; color: #b8c4d4; opacity: .7; }
@media (prefers-reduced-motion: reduce) { .spin-cover, .spin-cover.leaving { animation: none; } }

/* ---------- start screen / menu ---------- */
.diffs { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.diff {
  display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 12px 14px; border-radius: 14px;
  background: rgba(0,0,0,.25); border: 2px solid rgba(255,255,255,.1); transition: border-color .12s, transform .12s;
}
.diff:hover { transform: translateY(-2px); border-color: rgba(255,255,255,.3); }
.diff.on { border-color: #7cc4ff; background: rgba(47, 111, 224, .28); }
.diff b { font-size: 18px; }
.diff span { font-size: 13px; opacity: .85; line-height: 1.3; }
.diff small { font-size: 12px; opacity: .6; margin-top: 2px; }
.menu-list { display: flex; flex-direction: column; gap: 10px; width: min(300px, 100%); margin: 8px auto 0; }
.menu-list .btn { width: 100%; }

/* ---------- tutorial ---------- */
.tut { display: flex; flex-direction: column; align-items: center; }
.tut-step { font-size: 13px; font-weight: 700; letter-spacing: .14em; color: #a8d4ff; margin-bottom: 4px; }
.tut-visual {
  width: 100%; min-height: 230px; margin: 12px 0; padding: 16px; border-radius: 16px; background: rgba(0,0,0,.22);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
}
.tut-text { max-width: 52ch; text-align: center; margin: 0 0 6px; font-size: 17px; }
.tut-text .c, .tut-eq .c { color: #9fd8ff; } .tut-text .m, .tut-eq .m { color: #a5b4fc; }
.tut-grid { display: grid; gap: 6px; --cell: 46px; }
.tut-cell { position: relative; }
.tut-drop .tut-cell { animation: tutDrop 3s cubic-bezier(.3,1.4,.5,1) infinite; animation-delay: calc(var(--i) * 60ms); }
@keyframes tutDrop { 0% { transform: translateY(-60px); opacity: 0; } 18%, 85% { transform: none; opacity: 1; } 100% { opacity: 0; } }
.tut-pill { padding: 8px 34px; border-radius: 999px; background: linear-gradient(#4f8ff2, #2f6fe0); font-weight: 700; letter-spacing: .12em; box-shadow: 0 4px 0 #173d85; }
.tut-path .tut-cell.p .tile { animation: tutSel 4s infinite; animation-delay: calc(var(--d) * 400ms); }
@keyframes tutSel {
  0%, 8% { transform: none; box-shadow: 0 3px 0 var(--tile-edge); }
  12%, 60% { transform: translateY(-3px); box-shadow: 0 3px 0 #e0a100, 0 0 0 3px #ffd34d; }
  64%, 82% { transform: translateY(-3px); box-shadow: 0 3px 0 #149a5f, 0 0 0 3px #4dff9c; }
  90%, 100% { transform: none; box-shadow: 0 3px 0 var(--tile-edge); }
}
.tut-word { display: flex; gap: 6px; } .tut-word .tile { --cell: 52px; }
.tut-eq { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; font-size: 18px; font-weight: 600; }
.tut-eq .pill { padding: 4px 12px; border-radius: 999px; background: rgba(0,0,0,.3); font-size: 15px; }
.tut-eq b { font-size: 26px; color: #ffd25e; }
.tut-ups { display: flex; gap: 28px; flex-wrap: wrap; justify-content: center; }
.tut-ups .tile { --cell: 60px; }
.tut-goal { width: min(320px, 100%); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.tut-goal-text { font-size: 26px; font-weight: 700; }
.tut-bar { width: 100%; height: 12px; border-radius: 99px; background: rgba(0,0,0,.35); overflow: hidden; }
.tut-bar div { height: 100%; background: linear-gradient(90deg, #3fe08a, #b7ff6b); animation: tutFill 3s ease-out infinite; }
@keyframes tutFill { 0% { width: 10%; } 50%, 100% { width: 100%; } }
.tut-coins { display: flex; gap: 10px; }
.tut-coins span { color: #ffd25e; font-weight: 700; font-size: 20px; animation: tutCoin 3s infinite; opacity: 0; }
.tut-coins span:nth-child(2) { animation-delay: .2s; } .tut-coins span:nth-child(3) { animation-delay: .4s; }
@keyframes tutCoin { 0%, 45% { opacity: 0; transform: translateY(10px); } 55%, 90% { opacity: 1; transform: none; } 100% { opacity: 0; } }
.tut-dots { display: flex; gap: 8px; margin-top: 4px; }
.tut-dot { width: 12px; height: 12px; border-radius: 50%; background: rgba(255,255,255,.25); padding: 0; }
.tut-dot.on { background: #7cc4ff; }
@media (prefers-reduced-motion: reduce) {
  .tut-drop .tut-cell, .tut-path .tut-cell.p .tile, .tut-bar div, .tut-coins span { animation: none; opacity: 1; }
  .tut-bar div { width: 100%; }
  .tut-path .tut-cell.p .tile { box-shadow: 0 3px 0 #149a5f, 0 0 0 3px #4dff9c; }
}

/* ---------- mode tabs / casual ---------- */
.mode-tabs { display: flex; gap: 4px; width: min(340px, 100%); margin: 6px auto 0; padding: 4px; border-radius: 999px; background: rgba(0,0,0,.3); }
.mode-tab { flex: 1; padding: 9px 12px; border-radius: 999px; font-weight: 700; font-size: 16px; letter-spacing: .04em; color: #b8c4d4; }
.mode-tab.on { background: #2f6fe0; color: #fff; box-shadow: 0 3px 0 #173d85; }
.mode-tab:focus-visible, .diff:focus-visible { outline: 3px solid #ffd25e; outline-offset: 2px; }
.mode-desc { text-align: center; margin: 10px 0 0; opacity: .8; }
.final-score { text-align: center; font-size: 64px; font-weight: 700; color: #ffd25e; line-height: 1.1; font-variant-numeric: tabular-nums; }

/* ---------- lifetime stats ---------- */
.stats.stats-4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); width: 100%; }
.stats b { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.table-wrap { overflow-x: auto; }
.stats-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.stats-table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; opacity: .65; font-weight: 600; padding: 6px 10px; }
.stats-table td { padding: 8px 10px; background: rgba(0,0,0,.2); border-top: 2px solid transparent; }
.stats-table tr td:first-child { border-radius: 8px 0 0 8px; font-weight: 600; }
.stats-table tr td:last-child { border-radius: 0 8px 8px 0; }
.stats-table tbody tr { border-bottom: 4px solid transparent; }
.stats-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 24px; }
.stats-cols > div { min-width: 0; }
.rank { margin: 0; padding: 0; list-style: none; counter-reset: r; display: flex; flex-direction: column; gap: 6px; }
.rank li { counter-increment: r; display: flex; align-items: center; gap: 10px; background: rgba(0,0,0,.2); border-radius: 8px; padding: 6px 12px; }
.rank li::before { content: counter(r); width: 18px; opacity: .5; font-weight: 700; }
.rank li span { flex: 1; font-weight: 600; letter-spacing: .04em; }
.rank li b { color: #ffd25e; font-variant-numeric: tabular-nums; }
.fav-letters { display: flex; flex-wrap: wrap; gap: 10px; }
.fav-letters > div { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.fav-letters .tile { --cell: 46px; }
.fav-letters small { font-variant-numeric: tabular-nums; opacity: .75; }
.stats-empty { opacity: .6; margin: 0; }
.confirm-text { align-self: center; font-weight: 600; }

/* ---------- multi-letter tiles (ING, ED) ---------- */
.tile.ml-2 .L { font-size: calc(var(--cell) * .44); letter-spacing: -.01em; }
.tile.ml-3 .L { font-size: calc(var(--cell) * .34); letter-spacing: -.02em; }

/* ---------- phones & app shell: notches, home indicator, touch ---------- */
body { touch-action: manipulation; -webkit-touch-callout: none; overscroll-behavior: none; }
.topbar {
  padding-top: max(8px, env(safe-area-inset-top, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.stage {
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.bottombar {
  padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.modal-back {
  padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px))
           max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
@media (max-width: 820px) {
  .topbar { padding-top: max(6px, env(safe-area-inset-top, 0px)); padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px)); }
}

/* ---------- start screen actions ---------- */
.intro-actions { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 18px; }
.intro-start { font-size: 22px; padding: 14px 48px; min-width: min(300px, 100%); }
.intro-secondary { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.intro-secondary .btn { font-size: 16px; padding: 10px 22px; }
@media (max-width: 820px) {
  .diffs { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .diff { padding: 10px 12px; }
  .diff b { font-size: 16px; }
  .diff span { font-size: 12px; }
  .modal { padding: 18px 16px; }
  .modal h2 { font-size: 24px; }
}

/* ---------- full game unlock ---------- */
.diff.locked { opacity: .72; }
.diff.locked:hover { opacity: .9; }
.lock-tag { display: inline-flex; align-items: center; gap: 5px; font-style: normal; font-size: 12px; font-weight: 700; color: #ffd25e; margin-top: 2px; }
.lock { width: 13px; height: 13px; flex: none; }
.paywall { display: flex; flex-direction: column; align-items: center; text-align: center; }
.pw-tiles { display: flex; gap: 0; margin: 4px 0 12px; }
.pw-tiles .tile { --cell: 64px; }
.pw-tiles .tile:first-child { transform: translate(6px, -14px) rotate(-6deg); }
.pw-tiles .tile:last-child { transform: translate(-6px, 14px) rotate(4deg); }
.pw-list { list-style: none; padding: 0; margin: 4px 0 8px; display: flex; flex-direction: column; gap: 8px; text-align: left; }
.pw-list li { position: relative; padding-left: 26px; font-size: 16px; }
.pw-list li::before { content: ''; position: absolute; left: 4px; top: .35em; width: 12px; height: 7px; border-left: 3px solid #4dff9c; border-bottom: 3px solid #4dff9c; transform: rotate(-45deg); }
.pw-list small { opacity: .6; }
.pw-msg { min-height: 1.4em; font-size: 14px; opacity: .85; margin-top: 4px; }
.pw-msg.bad { color: #ffb3bd; opacity: 1; }
.pw-buy { font-size: 20px; padding: 13px 36px; min-width: min(280px, 100%); }
.btn .lock { width: 14px; height: 14px; vertical-align: -2px; color: #ffd25e; }

/* store badges (web edition) */
.store-row { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 12px; padding-top: 4px; }
.store-badge { display: block; line-height: 0; border-radius: 9px; }
.store-badge img { display: block; height: 46px; width: auto; }
.store-badge:active { transform: translateY(1px); }
.store-badge.soon { opacity: .45; filter: grayscale(1); }
.store-soon { margin: 6px 0 0; font-size: 13px; opacity: .7; text-align: center; }
.intro-badges { margin-top: 14px; }
.intro-badges .store-badge img { height: 40px; }
.support-link { display: block; width: fit-content; margin: 12px auto 0; padding: 8px 12px; border-radius: 10px; font-size: 14px; color: rgba(255,255,255,.62); text-decoration: none; text-align: center; }
.support-link:hover, .support-link:focus-visible { color: #fff; text-decoration: underline; }

/* phones: three cards across in the shop and upgrade picks instead of one per row */
@media (max-width: 560px) {
  .cards { gap: 8px; }
  .card { width: calc((100% - 16px) / 3); padding: 10px 6px; gap: 7px; border-radius: 13px; }
  .card .tile { --cell: 58px; }
  .card .name { font-size: 14px; line-height: 1.15; }
  .card .desc { font-size: 12px; line-height: 1.25; min-height: 0; }
  .card .rar { font-size: 10px; padding: 2px 6px; letter-spacing: .05em; }
  .card .btn { font-size: 14px; padding: 8px 10px; width: 100%; }
  .card .charm { flex-direction: column; min-height: 96px; }
  .card .charm .txt { font-size: 11.5px; padding: 6px 5px; }
  .card .charm .tab { width: 100%; height: 22px; font-size: 13px; }
  .card .up-pair { gap: 2px; }
  .card .up-pair .tile { --cell: 40px; }
  .card .up-arrow { font-size: 16px; }
  .services { gap: 8px; }
  .service { width: calc((100% - 8px) / 2); padding: 10px 8px; }
  .service .desc { font-size: 12px; }
  .service .btn { font-size: 14px; padding: 8px 12px; }
}
@media (max-width: 560px) { .card.mine { width: calc((100% - 16px) / 3); } }
