@import url(/static/fonts/fonts.css);

/* BOGONDO!: a deep blue evening sky with a warm glow, glossy coloured
   pieces on a slate board, cut gems. */
:root {
  --night: #13233f;
  --night-2: #1c3157;
  --slate: #24365a;
  --slate-2: #2d4470;
  --gold: #f39c1f;
  --gold-dk: #a65f00;
  --teal: #2fc6e0;
  --ink: #1b2440;
  --ink-shadow: #0b1326;
  --red: #e8443a;
  --red-dark: #8f1f19;
  --orange: #f39c1f;
  --yellow: #f5d33b;
  --green: #3fb34f;
  --blue: #3a8fe0;
  --paper: #ffffff;
  --muted: #66708a;
  --line: #e3e7f0;
  --good: #3fb34f;
  --bad: #e8443a;
  --radius: 16px;
  --stencil: Anton, Impact, Haettenschweiler, 'Arial Narrow', sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
html { background: var(--night); }
body {
  min-height: 100vh;
  background:
    radial-gradient(ellipse 70% 50% at 50% 105%, rgba(243, 156, 31, .35), transparent 70%),
    radial-gradient(ellipse 60% 40% at 15% 0%, rgba(47, 198, 224, .18), transparent 70%),
    linear-gradient(180deg, #101d36, var(--night) 60%, #2a2346);
  background-attachment: fixed;
  color: var(--ink); font-family: Montserrat, system-ui, sans-serif; font-size: 15px; line-height: 1.45;
}
main { max-width: 1100px; margin: 0 auto; padding: 16px; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h2 { font-weight: 800; color: var(--ink); }
p { margin: 0 0 .5rem; }
a { color: var(--blue); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center-text { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------------------------------------------------------------- logo */
.logo { display: inline-flex; font-family: var(--stencil); font-weight: 400; letter-spacing: .02em; line-height: 1; white-space: nowrap; user-select: none; }
.logo span {
  color: var(--lc); -webkit-text-stroke: .045em var(--ink-shadow); paint-order: stroke fill;
  text-shadow: .03em .06em 0 var(--ink-shadow); display: inline-block;
  transform: rotate(calc((var(--i) - 3.5) * 2deg)) translateY(calc(sin(var(--i) * 80deg) * .05em));
  animation: hop 2.4s ease-in-out infinite; animation-delay: calc(var(--i) * .12s);
}
@keyframes hop { 0%, 70%, 100% { translate: 0 0; } 80% { translate: 0 -.08em; } 90% { translate: 0 .02em; } }
.hero-logo { font-size: clamp(3.4rem, 15vw, 6.4rem); }
.brand-logo { font-size: 1.5rem; }
.brand-logo span, .mini-logo span { animation: none; }
.mini-logo { font-size: 1.1rem; }

/* ---------------------------------------------------------------- topbar */
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); background: rgba(11, 19, 38, .78); color: #fff; flex-wrap: wrap; backdrop-filter: blur(6px); }
.topbar a, .topbar .linkbtn { color: #fff; text-decoration: none; font-weight: 600; }
.brand { display: flex; align-items: center; padding: 4px 8px; }
.topbar nav { margin-left: auto; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }

/* ---------------------------------------------------------------- forms */
label { display: block; font-weight: 700; font-size: .85rem; margin-bottom: 4px; color: var(--ink); }
input, select { width: 100%; padding: 11px 12px; border: 2px solid var(--line); border-radius: 10px; font: inherit; background: #fff; color: var(--ink); }
input:focus, select:focus { outline: none; border-color: var(--yellow); box-shadow: 0 0 0 3px rgba(243, 156, 31, .35); }
button, .btn { font: inherit; font-weight: 800; border: 0; border-radius: 12px; padding: 11px 18px; cursor: pointer; background: #2d4470; color: #fff; text-decoration: none; display: inline-block; box-shadow: 0 3px 0 #101b33; transition: transform .08s, filter .15s; }
button:hover { filter: brightness(1.08); }
button:active { transform: translateY(2px); box-shadow: 0 1px 0 #101b33; }
button:disabled { opacity: .45; cursor: default; }
.btn-accent { background: var(--gold); color: #2a1500; box-shadow: 0 3px 0 var(--gold-dk); }
.btn-accent:active { box-shadow: 0 1px 0 var(--gold-dk); }
.btn-ghost { background: #fff; color: var(--ink); box-shadow: inset 0 0 0 2px var(--line); }
.btn-small { padding: 6px 12px; font-size: .85rem; }
.btn-block { width: 100%; }
.sso-btn::before { content: '🔑 '; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.check input { width: auto; }
.code-input { text-transform: uppercase; letter-spacing: .3em; font-weight: 900; font-size: 1.4rem; text-align: center; }

/* ---------------------------------------------------------------- layout */
.panel { background: var(--paper); border-radius: var(--radius); padding: 18px; box-shadow: 0 10px 30px rgba(5, 2, 20, .45), inset 0 -4px 0 rgba(28, 23, 51, .07); }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 8px; align-items: center; }
.grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 16px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.notice { padding: 12px 14px; border-radius: 10px; background: #fff; border-left: 5px solid var(--blue); }
.notice.err { border-left-color: var(--bad); }
.notice.ok { border-left-color: var(--good); background: #f1faf2; }
.pill { display: inline-block; font-size: .72rem; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: #e9f1f4; color: var(--ink); margin-right: 4px; }
.pill.off { background: #f3f3f3; color: #888; }
.pill.gold { background: var(--yellow); color: var(--ink); }
.dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; flex: none; box-shadow: 0 0 0 2px #fff, 0 0 0 3px rgba(0,0,0,.15); }
.copybox { display: flex; gap: 6px; }
.copybox input { font-size: .85rem; }
.toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; border-left: 5px solid var(--yellow); z-index: 2000; max-width: calc(100vw - 32px); font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.35); animation: toast-in .25s ease-out; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } }
.spinner { width: 14px; height: 14px; border: 3px solid rgba(255,255,255,.35); border-top-color: var(--yellow); border-radius: 50%; display: inline-block; vertical-align: -2px; margin-right: 8px; animation: spin 0.9s linear infinite; }
.panel .spinner { border-color: var(--line); border-top-color: var(--gold-dk); }
@keyframes spin { to { transform: rotate(360deg); } }
.wait { color: var(--muted); font-weight: 600; }

/* confetti (ui.js) */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 3000; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { top: 110vh; transform: rotate(720deg) translateX(40px); } }

/* ---------------------------------------------------------------- home */
.hero { text-align: center; margin: 10px 0 26px; color: #fff; }
.hero-pieces { display: flex; justify-content: center; align-items: flex-end; gap: 12px; margin: 16px 0 14px; min-height: 90px; }
.hero-pieces .piece { position: relative; transform: rotate(var(--r)); animation: drop .8s cubic-bezier(.2,.8,.3,1.3) backwards; animation-delay: calc(var(--i) * 110ms); }
@keyframes drop { from { opacity: 0; transform: translateY(-120px) rotate(calc(var(--r) * -4)); } }
.subtitle { font-size: 1.1rem; font-weight: 600; color: #e7ecf8; margin: 16px auto 0; max-width: 680px; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.rules { padding-left: 1.3rem; margin: 0 0 1rem; }
.rules li { margin-bottom: .55rem; }
.rules li::marker { color: var(--gold-dk); font-weight: 900; }
.gem-table { list-style: none; margin: 0 0 1rem; padding: 0; }
.gem-table li { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.gem-row { display: inline-flex; gap: 3px; }

/* ---------------------------------------------------------------- lobby */
.lobby { margin-top: 8px; }
.code-text { font-size: clamp(2.4rem, 10vw, 3.4rem); font-weight: 900; font-style: italic; letter-spacing: .18em; color: var(--yellow); -webkit-text-stroke: 3px var(--ink-shadow); paint-order: stroke fill; text-shadow: 3px 4px 0 var(--red); }
.qr { width: 180px; height: 180px; display: block; margin: 0 auto; border-radius: 12px; border: 6px solid #fff; box-shadow: 0 0 0 3px var(--gold); }
.players .tags { margin-top: 2px; }
.lobby-wrap main { padding-bottom: 40px; }

/* ---------------------------------------------------------------- pieces + gems */
.piece { position: relative; flex: none; touch-action: none; }
.piece .blk {
  position: absolute; width: var(--cell); height: var(--cell); border-radius: calc(var(--cell) * .14);
  background: linear-gradient(145deg, color-mix(in srgb, var(--pc) 70%, #fff), var(--pc) 45%, color-mix(in srgb, var(--pc) 78%, #000));
  box-shadow: inset 0 calc(var(--cell) * .06) 0 rgba(255,255,255,.35), inset 0 calc(var(--cell) * -.08) 0 rgba(0,0,0,.25), 0 1px 0 rgba(0,0,0,.3);
  outline: 1px solid rgba(0,0,0,.25); outline-offset: -1px; cursor: grab;
}
.piece.ghost { position: fixed; z-index: 1800; pointer-events: none; filter: drop-shadow(0 10px 14px rgba(0,0,0,.55)); opacity: .92; transform: scale(1.04); }
.piece.ghost.fit { opacity: 1; filter: drop-shadow(0 4px 6px rgba(0,0,0,.5)); transform: none; }
.piece.ghost:not(.fit) .blk { outline: 2px dashed rgba(255,255,255,.7); }
.piece.sel .blk { outline: 2px solid #fff; outline-offset: -2px; }
.gem { display: inline-block; width: 22px; height: 20px; flex: none; filter: drop-shadow(0 1px 1px rgba(0,0,0,.45)); }
.gem svg { width: 100%; height: 100%; display: block; }
.gem.big { width: 34px; height: 31px; }
.gem.flying { position: fixed; width: 28px; height: 26px; z-index: 1700; }
.gem.pop { animation: gem-pop .45s cubic-bezier(.2,.8,.3,1.4) backwards; }
.gem-row .gem.pop:nth-child(2) { animation-delay: .12s; } .gem-row .gem.pop:nth-child(3) { animation-delay: .24s; } .gem-row .gem.pop:nth-child(4) { animation-delay: .36s; }
@keyframes gem-pop { from { transform: scale(0) rotate(-40deg); } }
.gem-counts { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.gem-counts .gc { display: inline-flex; align-items: center; gap: 2px; font-weight: 800; }
.gem-counts .gc.zero { opacity: .35; }
.gem-counts.small .gem { width: 16px; height: 15px; }
.gem-counts.small { gap: 5px; font-size: .8rem; }

/* ---------------------------------------------------------------- table */
body.in-game { overflow: hidden; overscroll-behavior: none; }
.game {
  height: 100svh; display: flex; flex-direction: column; gap: 8px; color: #fff; max-width: 900px; margin: 0 auto;
  padding: max(6px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  user-select: none; -webkit-user-select: none;
}
.tinfo { display: flex; align-items: center; gap: 12px; flex: none; height: 38px; font-weight: 800; font-size: .9rem; white-space: nowrap; }
.tinfo .muted { color: #a9b6d6; font-weight: 600; }
.tlogo { display: flex; }
.clock { flex: 1; height: 10px; border-radius: 6px; background: rgba(255,255,255,.12); overflow: hidden; --left: 1; min-width: 40px; }
.clock i { display: block; height: 100%; width: calc(var(--left) * 100%); background: linear-gradient(90deg, var(--red), var(--gold) 30%, #7be08f); border-radius: 6px; transition: width .1s linear; }
.clock.hurry i { animation: hurry .5s ease-in-out infinite alternate; }
@keyframes hurry { to { filter: brightness(1.6); } }
.clock-num { font-family: var(--stencil); font-weight: 400; font-size: 1.3rem; min-width: 2.2ch; text-align: right; color: var(--yellow); }
.menu-btn { background: rgba(255,255,255,.1); box-shadow: none; padding: 6px 12px; font-size: 1.1rem; line-height: 1; }
.strip { display: flex; gap: 8px; overflow-x: auto; flex: none; padding-bottom: 2px; scrollbar-width: none; }
.chip { flex: none; min-width: 108px; background: rgba(11, 19, 38, .6); border: 2px solid color-mix(in srgb, var(--pc) 60%, transparent); border-radius: 12px; padding: 5px 8px; transition: background .3s; }
.chip.me { background: rgba(255,255,255,.12); }
.chip.solved { border-color: #7be08f; box-shadow: 0 0 14px rgba(123, 224, 143, .4); }
.chip-top { display: flex; align-items: center; gap: 6px; font-weight: 800; font-size: .82rem; }
.chip-name { max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-place { margin-left: auto; background: #7be08f; color: #0b2a14; border-radius: 6px; padding: 0 6px; font-size: .75rem; }
.pips { display: flex; gap: 3px; margin: 4px 0 2px; }
.pips i { flex: 1; height: 5px; border-radius: 3px; background: rgba(255,255,255,.15); }
.pips i.on { background: var(--pc); }
.chip-gems { display: flex; align-items: center; gap: 3px; font-size: .8rem; }
.chip-gems .gem { width: 15px; height: 14px; }
.chip-gems small { color: #a9b6d6; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; box-shadow: 0 0 0 2px rgba(255,255,255,.8); }
.arena { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.status { margin: 0; color: #cdd6ee; font-weight: 700; text-align: center; min-height: 1.4em; }
.board { position: relative; flex: none; }
.board::before { content: ''; position: absolute; inset: -10px; border-radius: 16px; background: rgba(11, 19, 38, .55); box-shadow: inset 0 0 0 2px rgba(255,255,255,.08); }
.bcell { position: absolute; width: var(--cell); height: var(--cell); background: var(--slate); box-shadow: inset 0 0 0 1px rgba(255,255,255,.12), inset 0 0 0 calc(var(--cell) * .12) rgba(0,0,0,.08); }
.board .placed { position: absolute; z-index: 1; animation: settle .18s ease-out; }
@keyframes settle { from { transform: scale(1.06); } }
.board.done .placed .blk { animation: shine 1s ease-out; }
@keyframes shine { 40% { filter: brightness(1.6); } }
.count-box { text-align: center; }
.count { font-family: var(--stencil); font-size: clamp(5rem, 30vw, 10rem); color: var(--yellow); -webkit-text-stroke: 4px var(--ink-shadow); paint-order: stroke fill; text-shadow: 6px 6px 0 var(--ink-shadow); line-height: 1; }
.count.beat { animation: beat .5s ease-out; }
@keyframes beat { from { transform: scale(1.5); opacity: .4; } }
.tray-box { flex: none; background: rgba(11, 19, 38, .55); border-radius: 16px; padding: 10px; }
.tray-box.empty { height: 120px; }
.tray { display: flex; justify-content: space-around; align-items: center; gap: 10px; min-height: var(--tray-h); }
.slot { display: grid; place-items: center; flex: none; border-radius: 10px; }
.slot.sel { background: rgba(255,255,255,.08); box-shadow: inset 0 0 0 2px rgba(255,255,255,.3); }
.controls { display: flex; gap: 8px; margin-top: 10px; }
.ctl { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 11px 6px; background: var(--slate-2); box-shadow: 0 3px 0 #101b33; font-size: .92rem; }
.ctl.ghosty { background: rgba(255,255,255,.08); box-shadow: none; }
.my-gems { flex: none; display: flex; align-items: center; gap: 10px; padding: 0 4px; }
.my-gems .muted { color: #a9b6d6; }
.result-card { position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(460px, calc(100vw - 24px)); z-index: 1100; background: #fff; color: var(--ink); border-radius: 18px; padding: 14px 16px; box-shadow: 0 16px 40px rgba(0,0,0,.5); animation: rise .35s cubic-bezier(.2,.8,.3,1.2); }
@keyframes rise { from { transform: translate(-50%, 40px); opacity: 0; } }
.gains { list-style: none; margin: 4px 0 8px; padding: 0; }
.gains li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.g-place { width: 1.6em; color: var(--gold-dk); }
@media (min-width: 760px) {
  .chip { min-width: 140px; }
}

/* bubbles */
.fly-layer { position: fixed; inset: 0; pointer-events: none; z-index: 1500; }
.bubble { position: fixed; z-index: 1700; transform: translate(-50%, -50%); font-family: var(--stencil); font-weight: 400; font-size: 2rem; color: #fff; white-space: nowrap;
  -webkit-text-stroke: 3px var(--ink-shadow); paint-order: stroke fill; text-shadow: 3px 3px 0 var(--ink-shadow); animation: bubble 1.8s ease-out forwards; letter-spacing: .03em; }
.bubble.b-solved { font-size: clamp(3rem, 14vw, 5rem); color: var(--yellow); text-shadow: 4px 4px 0 var(--ink-shadow), 0 0 30px rgba(245, 211, 59, .8); }
.bubble.b-go { font-size: 4rem; color: #7be08f; }
.bubble.b-place { color: #7be08f; font-size: 1.8rem; }
.bubble.b-timeup { color: #ff7b6b; font-size: 3rem; }
@keyframes bubble { 0% { opacity: 0; scale: .3; } 15% { opacity: 1; scale: 1.15; } 25% { scale: 1; } 75% { opacity: 1; translate: 0 -12px; } 100% { opacity: 0; translate: 0 -34px; } }
@keyframes pop { 0% { scale: 1.18; } 100% { scale: 1; } }
@keyframes fade-in { from { opacity: 0; } }

/* menu + overlays */
.menu { position: fixed; right: 12px; top: calc(max(8px, env(safe-area-inset-top)) + 44px); z-index: 1200; background: #fff; border-radius: 14px; padding: 6px; display: flex; flex-direction: column; min-width: 220px; box-shadow: 0 12px 30px rgba(0,0,0,.4); animation: pop .2s; }
.menu button { background: none; box-shadow: none; color: var(--ink); text-align: left; padding: 10px 12px; font-weight: 700; }
.menu button:hover { background: #eef5f7; }
.overlay { position: fixed; inset: 0; z-index: 1300; background: rgba(8, 14, 30, .66); display: grid; place-items: center; padding: 16px; animation: fade-in .3s; backdrop-filter: blur(3px); }
.modal { width: min(480px, 100%); max-height: calc(100svh - 32px); overflow: auto; color: var(--ink); animation: pop .35s; }
.overlay.clear { background: transparent; backdrop-filter: none; }
.over { text-align: center; }
.over h2 { font-size: 2rem; font-weight: 400; font-family: var(--stencil); letter-spacing: .02em; color: var(--ink); }
.scores li { text-align: left; }
.scores li.win { background: #fff4d8; border-radius: 10px; padding-left: 8px; padding-right: 8px; }
.score { color: var(--ink); white-space: nowrap; }
.grid-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.over-gems { display: flex; justify-content: center; gap: 6px; margin: 4px 0 12px; }
.over-gems .gem { animation: gem-pop .5s cubic-bezier(.2,.8,.3,1.4) backwards; }
.over-gems .gem:nth-child(2) { animation-delay: .1s; } .over-gems .gem:nth-child(3) { animation-delay: .2s; } .over-gems .gem:nth-child(4) { animation-delay: .3s; } .over-gems .gem:nth-child(5) { animation-delay: .4s; } .over-gems .gem:nth-child(6) { animation-delay: .5s; }
.place { width: 2em; color: var(--gold-dk); }
.scores li { flex-wrap: wrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
