/* Tenpop — overlays and HUD chrome. The board itself is canvas (js/render.js). */
:root {
  --font: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ink: #4b1d63;
  --ink-soft: rgba(75, 29, 99, .66);
  --pink: #ff4f9a;
  --card: rgba(255, 255, 255, .95);
  --scrim-a: rgba(255, 240, 248, .9);
  --scrim-b: rgba(255, 226, 242, .62);
}
body[data-theme="fruit"] { --pink: #f0532e; --scrim-a: rgba(255, 248, 225, .9); --scrim-b: rgba(255, 236, 200, .6); }
body[data-theme="gems"], body[data-theme="ocean"], body[data-theme="space"] {
  --scrim-a: rgba(20, 12, 50, .84); --scrim-b: rgba(14, 10, 40, .55);
}
body[data-theme="ocean"] { --scrim-a: rgba(8, 40, 90, .82); --scrim-b: rgba(6, 50, 110, .5); }

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #ffd6ea;
  overscroll-behavior: none;
}
body {
  position: fixed; inset: 0;
  font-family: var(--font); color: var(--ink);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}
[hidden] { display: none !important; }
button { font-family: inherit; color: inherit; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:focus { outline: none; }
button:focus-visible { outline: 3px solid #36a9f5; outline-offset: 3px; }

#game {
  position: fixed; left: 0; top: 0; width: 100vw; height: 100vh; height: 100dvh;
  display: block; touch-action: none;
}
#safe {
  position: fixed; left: 0; top: 0; width: 0; height: 0; visibility: hidden; pointer-events: none;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

/* ---------------------------------------------------------------- in-game chrome */
.hud-btn {
  position: fixed; z-index: 5; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .78); color: var(--ink);
  box-shadow: 0 3px 0 rgba(120, 50, 140, .18), 0 6px 14px rgba(80, 20, 100, .15);
  display: grid; place-items: center; cursor: pointer;
}
.hud-btn svg { width: 20px; height: 20px; fill: currentColor; }
.hud-btn:active { transform: translateY(2px); }
body[data-theme="gems"] .hud-btn, body[data-theme="ocean"] .hud-btn, body[data-theme="space"] .hud-btn {
  background: rgba(255, 255, 255, .16); color: #fff; box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .3);
}

#footer {
  position: fixed; z-index: 4; display: flex; align-items: center; gap: 8px; height: 40px;
  pointer-events: none;
}
#footer.stack { flex-direction: column; align-items: flex-start; height: auto; gap: 6px; }
.chip {
  font: 800 12px var(--font); letter-spacing: .02em; padding: 6px 11px; border-radius: 99px;
  background: rgba(255, 255, 255, .72); color: var(--ink); white-space: nowrap;
}
.chip.soft { background: rgba(255, 255, 255, .42); color: var(--ink-soft); }
body[data-theme="gems"] .chip, body[data-theme="ocean"] .chip, body[data-theme="space"] .chip {
  background: rgba(255, 255, 255, .16); color: #fff;
}
body[data-theme="gems"] .chip.soft, body[data-theme="ocean"] .chip.soft, body[data-theme="space"] .chip.soft {
  background: rgba(255, 255, 255, .08); color: rgba(255, 255, 255, .72);
}
.chip-btn {
  position: fixed; z-index: 5; display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 0 16px 0 12px; border: 0; border-radius: 99px; cursor: pointer;
  font: 900 16px var(--font); color: #7a4a00;
  background: linear-gradient(180deg, #fff3a3, #ffd23f); box-shadow: 0 4px 0 #d49a00, 0 8px 16px rgba(160, 100, 0, .25);
}
.chip-btn svg { width: 20px; height: 20px; fill: currentColor; }
.chip-btn { justify-content: center; }
.chip-btn.icon-only { padding: 0; }
.chip-btn.icon-only .hint-label { display: none; }
#footer.no-room { display: none; }
.chip-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #d49a00; }

/* ---------------------------------------------------------------- screens */
.screen {
  position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) calc(env(safe-area-inset-right, 0px) + 14px)
           calc(env(safe-area-inset-bottom, 0px) + 12px) calc(env(safe-area-inset-left, 0px) + 14px);
}
#title {
  background: radial-gradient(ellipse 80% 65% at 50% 45%, var(--scrim-a) 0%, var(--scrim-a) 38%, var(--scrim-b) 100%);
  overflow-y: auto; touch-action: pan-y; -webkit-overflow-scrolling: touch;
}
.title-inner {
  width: min(420px, 100%); margin: auto; display: flex; flex-direction: column; align-items: stretch; gap: 14px;
  text-align: center;
}
#logo { width: 100%; aspect-ratio: 6.3 / 1.55; display: block; }
.tagline { margin: -4px 0 6px; font: 800 17px/1.3 var(--font); color: var(--ink-soft); }
.tagline b { color: var(--pink); font-size: 20px; }
body[data-theme="gems"] .tagline, body[data-theme="ocean"] .tagline, body[data-theme="space"] .tagline { color: rgba(255, 255, 255, .78); }

.back {
  position: absolute; left: calc(env(safe-area-inset-left, 0px) + 12px); top: calc(env(safe-area-inset-top, 0px) + 10px);
  font: 800 15px var(--font); color: var(--ink-soft); text-decoration: none;
  min-height: 44px; display: inline-flex; align-items: center;
  padding: 0 14px; border-radius: 99px; background: rgba(255, 255, 255, .45);
}
.icon-btn {
  position: absolute; right: calc(env(safe-area-inset-right, 0px) + 12px); top: calc(env(safe-area-inset-top, 0px) + 8px);
  width: 46px; height: 46px; border: 0; border-radius: 50%; padding: 0; display: grid; place-items: center;
  background: rgba(255, 255, 255, .55); color: var(--ink); cursor: pointer;
}
.icon-btn svg { width: 24px; height: 24px; fill: currentColor; }
.ico-off { display: none; }
body.muted .ico-on { display: none; }
body.muted .ico-off { display: block; }
body[data-theme="gems"] .back, body[data-theme="ocean"] .back, body[data-theme="space"] .back,
body[data-theme="gems"] .icon-btn, body[data-theme="ocean"] .icon-btn, body[data-theme="space"] .icon-btn {
  background: rgba(255, 255, 255, .14); color: #fff;
}

.btn {
  border: 0; border-radius: 22px; min-height: 52px; padding: 10px 18px; cursor: pointer;
  font: 900 19px var(--font); color: #fff; letter-spacing: .01em;
  transition: transform .08s ease, box-shadow .08s ease;
}
.btn:active { transform: translateY(4px); }
.btn-play {
  width: 100%; min-height: 76px; border-radius: 26px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #ff8cc4 0%, #ff4f9a 55%, #ec3585 100%);
  box-shadow: 0 7px 0 #b91f67, 0 14px 28px rgba(210, 40, 120, .38), inset 0 2px 0 rgba(255, 255, 255, .45);
  text-shadow: 0 2px 0 rgba(150, 10, 70, .35);
}
.btn-play:active { box-shadow: 0 3px 0 #b91f67, 0 6px 14px rgba(210, 40, 120, .3), inset 0 2px 0 rgba(255, 255, 255, .45); }
.play-word { font: 900 34px/1 var(--font); letter-spacing: .02em; }
.btn-play .sub { font: 800 14px var(--font); opacity: .92; margin-top: 3px; }
.btn-play.small { min-height: 56px; font-size: 22px; margin-top: 12px; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.btn-mode {
  display: flex; flex-direction: column; align-items: center; min-height: 64px; border-radius: 22px; padding: 8px 10px;
}
.btn-mode { position: relative; }
.streak-badge {
  position: absolute; top: -10px; right: -6px; padding: 3px 9px 4px; border-radius: 99px;
  font: 900 13px/1.2 var(--font); color: #fff; text-shadow: none;
  background: linear-gradient(180deg, #ff8a4c, #ff3b3b); box-shadow: 0 3px 0 #b8251f, 0 4px 10px rgba(180, 30, 20, .3);
}
.btn-mode .m-title { font: 900 21px/1.1 var(--font); }
.btn-mode .m-sub { font: 800 12.5px/1.3 var(--font); opacity: .95; white-space: nowrap; }
.btn-mode.daily {
  background: linear-gradient(180deg, #ffc15a, #ff9024 60%, #f77a12);
  box-shadow: 0 6px 0 #c85a00, 0 10px 20px rgba(230, 110, 0, .3), inset 0 2px 0 rgba(255, 255, 255, .45);
  text-shadow: 0 2px 0 rgba(150, 60, 0, .3);
}
.btn-mode.daily.done { background: linear-gradient(180deg, #ffd796, #ffb258 60%, #f5a040); }
.btn-mode.zen {
  background: linear-gradient(180deg, #5fe3cf, #1fc7b0 60%, #12ad99);
  box-shadow: 0 6px 0 #0a8575, 0 10px 20px rgba(0, 150, 130, .28), inset 0 2px 0 rgba(255, 255, 255, .45);
  text-shadow: 0 2px 0 rgba(0, 90, 80, .3);
}
.btn-mode:active { box-shadow: 0 2px 0 rgba(0, 0, 0, .2); }
.links { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 2px; }
.over-lb { margin: 10px 0 0; } /* the family-board line (web/shared/leaderboard.js showResult) */
#over-board { white-space: nowrap; padding-left: 6px; padding-right: 6px; }
.link-btn {
  border: 0; background: rgba(255, 255, 255, .6); border-radius: 99px; min-height: 44px; padding: 0 18px;
  font: 800 15px var(--font); color: var(--ink); cursor: pointer;
}
body[data-theme="gems"] .link-btn, body[data-theme="ocean"] .link-btn, body[data-theme="space"] .link-btn { background: rgba(255, 255, 255, .15); color: #fff; }
.link-btn.pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.07); background: #fff; } }

/* ---------------------------------------------------------------- modal cards */
.modal { background: rgba(40, 10, 60, .42); z-index: 20; overflow-y: auto; touch-action: pan-y; }
.card {
  width: min(380px, 100%); margin: auto; background: var(--card); border-radius: 30px; padding: 22px 20px 20px;
  text-align: center; box-shadow: 0 20px 60px rgba(60, 10, 80, .38), inset 0 -5px 0 rgba(120, 60, 140, .1);
  animation: cardIn .32s cubic-bezier(.2, 1.4, .4, 1);
}
@keyframes cardIn { from { transform: translateY(24px) scale(.94); opacity: 0; } }
.card h2 { margin: 0 0 12px; font: 900 26px var(--font); }
.muted { margin: -6px 0 12px; font: 700 14px var(--font); color: var(--ink-soft); }
.row { display: flex; gap: 10px; margin-top: 12px; }
.row > * { flex: 1; }
.btn-ghost {
  background: #f3e6f7; color: var(--ink); box-shadow: 0 4px 0 #dcc3e6; min-height: 52px; font-size: 18px;
}
.btn-ghost:active { box-shadow: 0 1px 0 #dcc3e6; }
.btn-ghost.small { min-height: 44px; font-size: 15px; padding: 6px 14px; }
.toggles .toggle {
  min-height: 46px; border: 0; border-radius: 16px; font: 800 16px var(--font); cursor: pointer;
  background: #eee; color: #777;
}
.toggles .toggle[aria-pressed="true"] { background: #dff7ef; color: #0a8575; }
.toggles .toggle[aria-pressed="true"]::before { content: "✓ "; }
.toggles .toggle[aria-pressed="false"]::before { content: "✕ "; }

#howto-demo { width: 100%; height: 190px; display: block; }
.demo-cap { margin: 4px 0 10px; font: 900 18px var(--font); color: var(--pink); min-height: 24px; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; text-align: left; }
.legend li { display: flex; align-items: center; gap: 8px; font: 700 13.5px/1.25 var(--font); background: #fbf2fd; border-radius: 14px; padding: 8px; }
.ico { flex: 0 0 26px; width: 26px; height: 26px; border-radius: 50%; display: block; position: relative; }
.ico.clock { background: radial-gradient(circle, #fff 0 45%, #1aa7ea 47%); }
.ico.clock::after { content: ""; position: absolute; left: 12px; top: 6px; width: 2.5px; height: 8px; background: #0a5f9e; border-radius: 2px; }
.ico.star { background: linear-gradient(180deg, #fff3a0, #ffb300); clip-path: polygon(50% 2%, 62% 36%, 98% 38%, 69% 60%, 80% 96%, 50% 75%, 20% 96%, 31% 60%, 2% 38%, 38% 36%); }
.ico.wild { background: conic-gradient(#ff4d6d, #ff9e3d, #ffe14d, #6ee06e, #3dd6f5, #6f7dff, #c86bff, #ff4d6d); border-radius: 8px; }
.ico.combo { background: linear-gradient(180deg, #d58bff, #a53dff); border-radius: 50%; }
.ico.combo::after { content: "×5"; position: absolute; inset: 0; display: grid; place-items: center; font: 900 11px var(--font); color: #fff; }

#theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.theme-card {
  border: 0; border-radius: 18px; padding: 8px 8px 10px; background: #f7eefa; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 44px;
  box-shadow: inset 0 0 0 2px transparent;
}
.theme-card canvas { width: 100%; max-width: 132px; height: auto; aspect-ratio: 132 / 50; }
.theme-card.on { box-shadow: inset 0 0 0 3px var(--pink); background: #fff0f7; }
.theme-card.locked { cursor: default; }
.theme-card.locked canvas { opacity: .72; }
.theme-name { font: 900 16px var(--font); }
.theme-sub { font: 700 11.5px var(--font); color: var(--ink-soft); }
.theme-bar, .bar { display: block; width: 90%; height: 7px; border-radius: 9px; background: #ead9f0; overflow: hidden; }
.theme-bar span, .bar span { display: block; height: 100%; border-radius: 9px; background: linear-gradient(90deg, #ff8cc4, #ff4f9a); }

.modal.confirm { z-index: 30; background: rgba(40, 10, 60, .5); }
.confirm-text { margin: 0 0 4px; font: 700 16px/1.4 var(--font); color: var(--ink-soft); }
.btn-ghost.wide { width: 100%; margin-top: 10px; }
.title-toast {
  margin: 4px auto 0; padding: 10px 16px; border-radius: 16px; font: 800 14px var(--font);
  color: #0a6e5f; background: rgba(223, 247, 239, .95); box-shadow: 0 4px 12px rgba(0, 90, 80, .15);
}

/* ---------------------------------------------------------------- game over */
.modal.over { background: rgba(40, 10, 60, .35); }
.over-card { padding-top: 16px; }
.over-mode { margin: 0; font: 800 13px var(--font); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); }
.over-kicker { margin: 2px 0 0; font: 900 24px var(--font); color: var(--pink); }
.over-score {
  font: 900 64px/1.05 var(--font); letter-spacing: -.01em; margin: 2px 0 0;
  background: linear-gradient(180deg, #ff6fb0, #b53dff); -webkit-background-clip: text; background-clip: text; color: transparent;
  font-variant-numeric: tabular-nums;
}
.newbest {
  display: inline-block; margin: 2px 0 4px; padding: 5px 14px; border-radius: 99px;
  font: 900 16px var(--font); color: #7a4a00; background: linear-gradient(180deg, #fff3a3, #ffc21f);
  box-shadow: 0 3px 0 #d49a00; animation: bestIn .5s cubic-bezier(.2, 1.6, .4, 1);
}
@keyframes bestIn { from { transform: scale(.3) rotate(-8deg); opacity: 0; } }
.over-best { margin: 2px 0 0; font: 800 15px var(--font); color: var(--ink-soft); }
.over-note { margin: 6px 0 0; font: 800 14px var(--font); color: #d6336c; }
.stats { display: flex; justify-content: center; gap: 6px; margin: 14px 0 4px; }
.stats div { flex: 1 1 0; max-width: 25%; background: #fbf2fd; border-radius: 14px; padding: 8px 2px 7px; }
.stats b { display: block; font: 900 19px var(--font); }
.stats span { display: block; font: 700 10.5px var(--font); color: var(--ink-soft); }
.profile { display: flex; justify-content: center; align-items: center; gap: 4px; margin: 8px 0 0; flex-wrap: wrap; }
.profile::before { content: "combo per 20 s"; font: 800 10.5px var(--font); color: var(--ink-soft); margin-right: 4px; }
.profile span {
  min-width: 30px; height: 24px; padding: 0 4px; border-radius: 8px; display: grid; place-items: center;
  font: 900 12px var(--font); color: #fff; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .15);
}
.profile .m1 { background: #b9bfd0; }
.profile .m2 { background: #ffb400; }
.profile .m3 { background: #ff7a00; }
.profile .m4 { background: #ff2e63; }
.profile .m5 { background: #a53dff; }
.unlock { margin: 8px 0 12px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.unlock p { margin: 0; font: 800 13px var(--font); color: var(--ink-soft); }
.unlock .unlocked { font-size: 16px; color: #0a8575; }
.toast { margin: 10px 0 0; min-height: 18px; font: 800 13px var(--font); color: #0a8575; white-space: pre-wrap; word-break: break-word; }

#debug {
  position: fixed; left: 4px; bottom: 4px; z-index: 99; font: 700 11px ui-monospace, monospace; color: #fff;
  background: rgba(0, 0, 0, .55); padding: 3px 6px; border-radius: 6px; pointer-events: none; max-width: 96vw;
}

#resume { font-size: 26px; min-height: 64px; }
@media (min-width: 900px) and (min-height: 700px) {
  .title-inner { width: 500px; gap: 18px; }
  .tagline { font-size: 20px; }
  .tagline b { font-size: 24px; }
  .btn-play { min-height: 88px; }
  .play-word { font-size: 42px; }
  .btn-play .sub { font-size: 16px; }
  .btn-mode { min-height: 74px; }
  .btn-mode .m-title { font-size: 24px; }
  .btn-mode .m-sub { font-size: 14px; }
  .card { width: 420px; }
}
@media (max-height: 640px) {
  .title-inner { gap: 10px; }
  .btn-play { min-height: 64px; }
  .play-word { font-size: 28px; }
  .over-score { font-size: 50px; }
  .card { padding: 16px 16px 14px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .title-inner { width: min(640px, 100%); display: grid; grid-template-columns: 1.1fr 1fr; align-items: center; column-gap: 18px; row-gap: 10px; }
  #logo { grid-column: 1; grid-row: 1; }
  .tagline { grid-column: 1; grid-row: 2; margin: 0; }
  .btn-play { grid-column: 2; grid-row: 1; }
  .modes { grid-column: 2; grid-row: 2; }
  .links { grid-column: 1 / 3; }
  /* short landscape phones: every card becomes two columns so nothing needs scrolling */
  .card { padding: 14px 18px; }
  .card h2 { margin-bottom: 6px; font-size: 22px; }
  .over-card { width: min(760px, 100%); display: grid; grid-template-columns: 1fr 1.25fr; column-gap: 18px; align-items: center; }
  .over-score { font-size: 52px; }
  .stats { margin-top: 0; }
  .stats b { font-size: 17px; }
  .unlock { margin: 6px 0 8px; }
  .over-side .btn-play { min-height: 56px; }
  .over-side .row { margin-top: 8px; }
  .over-side .row .btn { min-height: 46px; }
  #howto .card { width: min(720px, 100%); display: grid; grid-template-columns: 1fr 1fr; column-gap: 16px; align-items: center; }
  #howto h2 { grid-column: 1 / 3; }
  #howto-demo { grid-column: 1; grid-row: 2 / 4; height: 190px; }
  #howto .demo-cap { grid-column: 1; grid-row: 4; margin: 0; }
  #howto .legend { grid-column: 2; grid-row: 2; }
  #howto #howto-ok { grid-column: 2; grid-row: 3 / 5; }
  #themes .card { width: min(760px, 100%); }
  #theme-grid { grid-template-columns: repeat(5, 1fr); gap: 8px; }
  .theme-card { padding: 6px 4px 8px; }
  .theme-sub { font-size: 10.5px; }
}
@media (prefers-reduced-motion: reduce) {
  .card, .newbest { animation: none; }
  .link-btn.pulse { animation: none; }
}
