@font-face { font-family: Caption; src: url(/fonts/caption.woff2) format('woff2'); font-weight: 100 900; font-display: swap; }

:root {
  --ink: #14214d; --ink2: #51608f; --paper: rgba(255, 255, 255, 0.96); --glass: rgba(12, 30, 90, 0.5);
  --gold: #f6b93b; --gold2: #ffd36b; --goldink: #3b2600; --sky: #2b73cc; --line: #dde6f6;
  --shadow: 0 12px 34px rgba(8, 20, 70, 0.3);
  --dock-h: 100px;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #2b73cc; }
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: #fff;
  -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; }

#sky { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; cursor: grab; user-select: none; -webkit-user-select: none; }
#sky:focus-visible { box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.85); }

:focus-visible { outline: 3px solid #fff; outline-offset: 2px; box-shadow: 0 0 0 6px var(--ink); }
dialog :focus-visible { outline-color: var(--sky); box-shadow: none; }

/* ---- header ---- */
.top { position: fixed; z-index: 10; inset: 0 0 auto 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: calc(var(--sat) + 12px) 16px 0; pointer-events: none; }
.top > * { pointer-events: auto; }
.brand { margin: 0; font: 400 clamp(26px, 6.4vw, 40px) / 1.16 Caption, cursive; letter-spacing: 0.01em; text-shadow: 0 2px 0 rgba(14, 40, 110, 0.5), 0 5px 22px rgba(14, 40, 110, 0.55); }
.sub { margin: 6px 0 0; font-size: 11px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: rgba(255, 255, 255, 0.92); text-shadow: 0 1px 8px rgba(14, 40, 110, 0.6); display: flex; align-items: center; gap: 8px; }
.sub::before { content: ""; width: 22px; height: 10px; border-radius: 2px; background: linear-gradient(90deg, #111 0 33.3%, #fdda24 33.3% 66.6%, #ef3340 66.6%); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); }
.tools { display: flex; align-items: center; gap: 8px; }
.langs { display: flex; padding: 3px; border-radius: 999px; background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid rgba(255, 255, 255, 0.22); }
.langs button { min-width: 40px; min-height: 36px; border: 0; border-radius: 999px; background: transparent; font-size: 12px; font-weight: 800; letter-spacing: 0.06em; cursor: pointer; color: #fff; }
.langs button[aria-pressed="true"] { background: #fff; color: var(--ink); }
.tvlink { display: none; padding: 9px 14px; border-radius: 999px; background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid rgba(255, 255, 255, 0.22); color: #fff; font-size: 12px; font-weight: 800; letter-spacing: 0.06em; text-decoration: none; text-transform: uppercase; }
@media (min-width: 1100px) { .tvlink { display: inline-block; } }

/* ---- live numbers ---- */
.hud { position: fixed; z-index: 9; left: 16px; top: calc(var(--sat) + 84px); display: flex; flex-direction: column; align-items: flex-start; gap: 6px; pointer-events: none; }
.stats, .meter { margin: 0; display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid rgba(255, 255, 255, 0.2); font-size: 12.5px; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.stats i { width: 3px; height: 3px; border-radius: 50%; background: rgba(255, 255, 255, 0.6); }
.meter { font-weight: 600; font-size: 12px; gap: 9px; }
.pips { display: inline-flex; gap: 4px; }
.pips b { width: 10px; height: 10px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, #9fb3d8 55%, #5f739e); opacity: 0.8; transition: all 0.6s; }
.pips b.on { background: radial-gradient(circle at 35% 30%, #fff8e0, #ffd36b 50%, #f0a020); box-shadow: 0 0 10px 2px rgba(255, 200, 90, 0.85); opacity: 1; }
.ticker { margin: 0; min-height: 22px; padding: 0 4px; font-size: 13px; font-weight: 600; text-shadow: 0 1px 10px rgba(14, 40, 110, 0.8), 0 0 2px rgba(14, 40, 110, 0.8); opacity: 0; transform: translateY(-4px); transition: opacity 0.4s, transform 0.4s; }
.ticker.on { opacity: 1; transform: none; }
.proof { position: fixed; z-index: 5; left: 16px; bottom: calc(var(--sab) + 14px); margin: 0; font-size: 12px; font-weight: 600; color: rgba(255, 255, 255, 0.88); text-shadow: 0 1px 8px rgba(8, 20, 70, 0.9); display: none; pointer-events: none; }
@media (min-width: 1000px) { .proof { display: block; } }

.coach { position: fixed; z-index: 12; left: 50%; bottom: calc(var(--dock-h) + var(--sab) + 6px); transform: translateX(-50%); padding: 10px 16px; border-radius: 14px; background: var(--paper); color: var(--ink); font-size: 14px; font-weight: 600; box-shadow: var(--shadow); text-align: center; max-width: 92vw; animation: coachIn 0.6s cubic-bezier(0.2, 0.9, 0.3, 1.2) both, bob 3.2s ease-in-out 0.7s infinite; }
.coach::after { content: ""; position: absolute; left: 50%; bottom: -7px; width: 14px; height: 14px; background: inherit; transform: translateX(-50%) rotate(45deg); border-radius: 3px; }

/* ---- buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px; border: 0; border-radius: 999px; font-size: 15px; font-weight: 700; cursor: pointer; transition: transform 0.12s, box-shadow 0.12s, background 0.2s; -webkit-user-select: none; user-select: none; }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn.big { min-height: 58px; padding: 0 32px; font-size: 17px; }
.btn.gold { background: linear-gradient(#ffd877, #f6b93b); color: var(--goldink); box-shadow: 0 5px 0 #c58a12, 0 14px 26px rgba(8, 20, 70, 0.35); }
.btn.gold:active { transform: translateY(4px); box-shadow: 0 1px 0 #c58a12, 0 6px 14px rgba(8, 20, 70, 0.3); }
.btn.gold:disabled { filter: grayscale(0.7); opacity: 0.7; cursor: default; }
.btn.glass { background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); color: #fff; border: 1px solid rgba(255, 255, 255, 0.25); box-shadow: 0 8px 22px rgba(8, 20, 70, 0.25); }
.btn.glass:active { transform: scale(0.96); }
.btn.glass.dark { background: var(--ink); border-color: var(--ink); }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px var(--line); }
@media (hover: hover) {
  .btn.gold:hover { transform: translateY(-2px); box-shadow: 0 7px 0 #c58a12, 0 18px 30px rgba(8, 20, 70, 0.38); }
  .btn.glass:hover { background: rgba(12, 30, 90, 0.68); }
  .langs button:hover:not([aria-pressed="true"]) { background: rgba(255, 255, 255, 0.18); }
}

.dock { position: fixed; z-index: 11; left: 0; right: 0; bottom: 0; padding: 0 12px calc(var(--sab) + 14px); display: flex; justify-content: center; align-items: center; gap: 8px; pointer-events: none; }
.dock > *, .mine > * { pointer-events: auto; }
.mine { display: flex; gap: 8px; }
@media (max-width: 560px) {
  .dock { gap: 6px; padding-inline: 8px; }
  .mine { gap: 6px; }
  .btn.glass { flex-direction: column; gap: 3px; min-height: 58px; min-width: 70px; padding: 0 8px; border-radius: 18px; font-size: 11.5px; font-weight: 700; }
}
.x { position: absolute; top: 10px; right: 10px; width: 40px; height: 40px; border: 0; border-radius: 50%; background: rgba(20, 33, 77, 0.07); color: var(--ink); font-size: 26px; line-height: 1; cursor: pointer; }
.x:hover { background: rgba(20, 33, 77, 0.14); }

/* ---- card for a tapped dev ---- */
.card { position: fixed; z-index: 14; left: 50%; bottom: calc(var(--dock-h) + var(--sab) + 12px); transform: translateX(-50%); width: min(94vw, 460px); padding: 16px 18px 16px; border-radius: 22px; background: var(--paper); color: var(--ink); box-shadow: var(--shadow); animation: cardIn 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.1) both; }
.card .x { top: 8px; right: 8px; }
.card .cap { margin: 0 34px 2px 0; font: 400 25px / 1.2 Caption, cursive; }
.card .trans { margin: 0; color: var(--ink2); font-size: 13px; font-style: italic; }
.card .who { margin: 10px 0 12px; font-weight: 700; font-size: 15px; }
.card .who small { font-weight: 600; color: var(--ink2); font-size: 13px; }
.card .row { display: flex; gap: 8px; flex-wrap: wrap; }
.card .btn { min-height: 46px; padding: 0 18px; }
.card .btn.gold { box-shadow: 0 4px 0 #c58a12, 0 10px 18px rgba(8, 20, 70, 0.2); }
body.card-on .toast { bottom: calc(var(--dock-h) + var(--sab) + 200px); }

/* ---- toast ---- */
.toast { position: fixed; z-index: 30; left: 50%; bottom: calc(var(--dock-h) + var(--sab) + 12px); transform: translateX(-50%); width: max-content; max-width: min(92vw, 440px); padding: 12px 16px; border-radius: 16px; background: rgba(14, 33, 77, 0.96); color: #fff; font-size: 14.5px; font-weight: 600; box-shadow: var(--shadow); display: flex; align-items: center; gap: 12px; animation: toastIn 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.1) both; pointer-events: auto; }
.toast button { flex: none; border: 0; border-radius: 999px; padding: 8px 14px; background: var(--gold); color: var(--goldink); font-weight: 800; font-size: 13px; cursor: pointer; }

/* ---- sheets (native <dialog>) ---- */
dialog.sheet { border: 0; padding: 0; margin: auto auto 0; width: min(100vw, 560px); max-width: 100vw; max-height: 94dvh; background: var(--paper); color: var(--ink); border-radius: 26px 26px 0 0; box-shadow: var(--shadow); overflow: hidden; }
dialog.sheet[open] { display: flex; flex-direction: column; animation: sheetIn 0.34s cubic-bezier(0.2, 0.9, 0.25, 1) both; }
dialog.sheet::backdrop { background: rgba(8, 24, 80, 0.4); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
dialog.sheet form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.sheethead { position: relative; padding: 18px 64px 6px 20px; flex: none; }
.caption { margin: 0; font: 400 28px / 1.3 Caption, cursive; }
.lead { margin: 6px 0 0; font-size: 14px; color: var(--ink2); }
.sheetfoot { flex: none; padding: 12px 16px calc(var(--sab) + 14px); border-top: 1px solid var(--line); background: #fff; }
.sheetfoot .btn { width: 100%; }
.sheetfoot.two { display: flex; gap: 10px; }
.sheetfoot.two .btn { flex: 1; }

.stage { overflow: auto; overscroll-behavior: contain; padding: 0 18px 14px; flex: 1; min-height: 0; }
.preview { position: sticky; top: 0; z-index: 2; display: flex; justify-content: center; margin: 4px -18px 10px; padding: 8px 0 4px; background: linear-gradient(#cfe6f7 0%, #eef6fd 70%, rgba(255, 255, 255, 0)); }
.preview canvas { width: 126px; height: 189px; cursor: pointer; touch-action: manipulation; }
fieldset { border: 0; margin: 0 0 12px; padding: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 7px; font-size: 12px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink2); }
.faces { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.faces button { aspect-ratio: 1; padding: 3px; border: 2px solid transparent; border-radius: 14px; background: #eaf2fc; cursor: pointer; transition: transform 0.15s, border-color 0.15s, background 0.15s, box-shadow 0.15s; }
.faces button canvas { width: 100%; height: 100%; display: block; pointer-events: none; }
.faces button[aria-checked="true"] { border-color: var(--sky); background: #fff; transform: translateY(-2px) scale(1.06); box-shadow: 0 8px 16px rgba(43, 115, 204, 0.3); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatches button { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1.5px rgba(20, 33, 77, 0.28), 0 3px 6px rgba(20, 33, 77, 0.18); cursor: pointer; transition: transform 0.15s; }
.swatches button[aria-checked="true"] { box-shadow: 0 0 0 3px var(--ink), 0 4px 10px rgba(20, 33, 77, 0.3); transform: scale(1.12); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 14px; }
.chip { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 2px solid var(--line); background: #fff; color: var(--ink); font-size: 14px; font-weight: 700; cursor: pointer; transition: all 0.15s; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip[aria-pressed="true"]::before { content: "\2713\00a0"; }
.chip.soft { border-style: dashed; margin-left: auto; }
.field { display: block; font-size: 12px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink2); }
.inp { display: flex; gap: 8px; margin-top: 7px; text-transform: none; letter-spacing: 0; }
.inp input { flex: 1; min-width: 0; height: 48px; padding: 0 14px; border: 2px solid #c9d6ee; border-radius: 14px; background: #fff; color: var(--ink); font: 600 17px system-ui, sans-serif; }
.inp input:focus { outline: none; border-color: var(--sky); box-shadow: 0 0 0 4px rgba(43, 115, 204, 0.2); }
.inp button { width: 48px; height: 48px; border: 2px solid #c9d6ee; border-radius: 14px; background: #fff; color: var(--ink); cursor: pointer; display: grid; place-items: center; }
.inp button svg { width: 24px; height: 24px; }
.inp button:active { transform: rotate(40deg) scale(0.92); }
.err { margin: 8px 0 0; color: #b3261e; font-weight: 700; font-size: 13.5px; }

dialog.slim { width: min(100vw, 520px); }
.rolllist { list-style: none; margin: 0; padding: 4px 6px calc(var(--sab) + 14px); overflow: auto; overscroll-behavior: contain; flex: 1; }
.rolllist li { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 16px; }
.rolllist li:nth-child(odd) { background: #f1f6fd; }
.rolllist canvas { width: 40px; height: 62px; flex: none; }
.rolllist .t { flex: 1; min-width: 0; }
.rolllist .t b { display: block; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rolllist .t small { display: block; color: var(--ink2); font: 400 14px Caption, cursive; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rolllist .n { font-size: 12px; font-weight: 800; color: var(--ink2); min-width: 22px; text-align: right; }
.rolllist .btn { min-height: 38px; padding: 0 14px; font-size: 13px; background: var(--ink); color: #fff; }
.rolllist .btn:disabled { background: #cfd8ec; color: #fff; cursor: default; }
.pcwrap { padding: 4px 20px 14px; overflow: auto; flex: 1; min-height: 0; display: flex; justify-content: center; }
.pcwrap img { max-width: 100%; max-height: 56dvh; width: auto; height: auto; border-radius: 12px; box-shadow: 0 10px 30px rgba(8, 20, 70, 0.3); background: #cfe6f7; }

@media (min-width: 900px) {
  dialog.sheet { margin: auto; border-radius: 28px; max-height: 90dvh; }
  dialog#atelier { width: min(900px, 94vw); }
  #atelier .stage { display: grid; grid-template-columns: 250px 1fr; gap: 26px; padding: 6px 26px 18px; align-items: start; }
  #atelier .preview { position: static; margin: 0; padding: 14px 0; border-radius: 22px; background: linear-gradient(#5aa1e6, #cfe6f7); }
  #atelier .preview canvas { width: 220px; height: 330px; }
  #atelier .sheethead { padding: 22px 70px 8px 26px; }
  .faces { gap: 8px; }
  .sheetfoot { padding: 14px 26px 18px; }
  .sheetfoot .btn { width: auto; min-width: 280px; margin-left: auto; display: flex; }
  .sheetfoot.two .btn { min-width: 0; margin: 0; }
}

/* ---- TV mode: a projector in a hall, no controls ---- */
body.tv .dock, body.tv .coach, body.tv .card, body.tv .langs, body.tv .tvlink, body.tv .proof, body.tv .toast { display: none !important; }
body.tv #sky { cursor: none; }
body.tv .brand { font-size: clamp(40px, 4.4vw, 84px); }
body.tv .sub { font-size: clamp(13px, 1.1vw, 20px); }
body.tv .hud { top: calc(var(--sat) + clamp(90px, 8vw, 150px)); left: 24px; gap: 10px; }
body.tv .stats, body.tv .meter { font-size: clamp(16px, 1.5vw, 28px); padding: 8px 18px; }
body.tv .pips b { width: clamp(12px, 1.1vw, 20px); height: clamp(12px, 1.1vw, 20px); }
body.tv .ticker { font-size: clamp(16px, 1.5vw, 28px); }
.tvbar { position: fixed; z-index: 12; right: 24px; bottom: 24px; display: none; align-items: center; gap: 18px; padding: 14px 22px 14px 14px; border-radius: 26px; background: var(--paper); color: var(--ink); box-shadow: var(--shadow); }
body.tv .tvbar { display: flex; }
.tvbar img { width: clamp(120px, 10vw, 200px); height: auto; border-radius: 14px; background: #fff; }
.tvjoin { margin: 0; font: 400 clamp(26px, 2.6vw, 48px) / 1.3 Caption, cursive; }
.tvurl { margin: 6px 0 0; font-weight: 800; font-size: clamp(16px, 1.5vw, 28px); letter-spacing: 0.01em; }

.noscript { position: fixed; z-index: 99; inset: 30% 10% auto; margin: 0; padding: 22px; border-radius: 20px; background: #fff; color: var(--ink); font-weight: 600; text-align: center; box-shadow: var(--shadow); }

@keyframes sheetIn { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes cardIn { from { transform: translate(-50%, 22px) scale(0.96); opacity: 0; } to { transform: translateX(-50%); opacity: 1; } }
@keyframes toastIn { from { transform: translate(-50%, 16px) scale(0.96); opacity: 0; } to { transform: translateX(-50%); opacity: 1; } }
@keyframes coachIn { from { transform: translate(-50%, 18px); opacity: 0; } to { transform: translateX(-50%); opacity: 1; } }
@keyframes bob { 0%, 100% { margin-bottom: 0; } 50% { margin-bottom: 6px; } }
@media (min-width: 900px) { @keyframes sheetIn { from { transform: translateY(24px) scale(0.98); opacity: 0; } to { transform: none; opacity: 1; } } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

@media (max-width: 560px) {
  .brand { font-size: 25px; }
  .hud { top: calc(var(--sat) + 96px); }
  .card { padding: 12px 14px 13px; border-radius: 20px; }
  .card .cap { font-size: 21px; margin-right: 38px; }
  .card .trans { font-size: 12px; }
  .card .who { margin: 6px 0 9px; font-size: 14px; }
  .card .btn { min-height: 42px; font-size: 14px; }
}
