/* «33»: ванильная палитра поверх 3D-сцены. */
:root {
  --cream: #f4ecd8;
  --cream2: #ebe1c7;
  --ink: #3b3328;
  --muted: #7a6f5d;
  --line: #d9cdae;
  --orange: #e8662c;
  --green: #5f8f55;
  --gold: #d9a23a;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #efe6d2; color: var(--ink); font: 16px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; user-select: none; }
[hidden] { display: none !important; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(244, 236, 216, 0.35); backdrop-filter: blur(2px); z-index: 5; }
.card { width: min(720px, 100%); max-height: 100%; overflow: auto; background: rgba(244, 236, 216, 0.96); border: 2px solid var(--line); border-radius: 22px; padding: 22px 26px; box-shadow: 0 18px 50px rgba(59, 51, 40, 0.18); }
h1 { margin: 2px 0 12px; font-size: 28px; }
.step, .kicker { font-size: 13px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); }
.row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 16px; }
.hint { margin-top: 10px; text-align: center; font-size: 13px; color: var(--muted); }
.btn { font: inherit; font-weight: 650; color: #fbf6e8; background: var(--ink); border: 2px solid var(--ink); border-radius: 12px; padding: 10px 18px; cursor: pointer; text-decoration: none; display: inline-block; }
.btn.ghost { background: transparent; color: var(--ink); border-color: #b9ab88; }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn:hover:not(:disabled) { filter: brightness(1.15); }

/* правила */
#ruleArt { width: 100%; aspect-ratio: 560 / 220; border-radius: 16px; background: #e9dfc4; display: block; }
.rule-text { margin-top: 14px; min-height: 110px; }
.rule-text p { margin: 6px 0; }
.rule-text b { color: var(--ink); }
.rule-text table { width: 100%; border-collapse: collapse; font-size: 15px; }
.rule-text td { padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.rule-text td:first-child { font-weight: 700; white-space: nowrap; padding-right: 14px; }
.dots { display: flex; gap: 8px; justify-content: center; margin-top: 8px; }
.dots i { width: 9px; height: 9px; border-radius: 50%; background: #d4c7a6; }
.dots i.on { background: var(--orange); }

/* лобби */
.lobby { width: min(860px, 100%); }
.lobby-head { display: flex; justify-content: space-between; gap: 18px; align-items: flex-end; flex-wrap: wrap; }
.code { font-size: 64px; font-weight: 900; letter-spacing: 10px; line-height: 1; }
.join-hint { color: var(--muted); max-width: 380px; font-size: 15px; }
.join-hint b { color: var(--ink); font-size: 18px; }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 18px 0 10px; }
.slot { background: var(--cream2); border: 2px solid var(--line); border-radius: 14px; padding: 10px 12px; min-height: 64px; position: relative; }
.slot.empty { border-style: dashed; color: var(--muted); display: flex; align-items: center; justify-content: center; font-size: 14px; }
.slot .nm { font-weight: 750; display: flex; align-items: center; gap: 7px; }
.slot .dev { font-size: 13px; color: var(--muted); }
.slot .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.slot .x { position: absolute; top: 6px; right: 8px; background: none; border: 0; font-size: 18px; color: var(--muted); cursor: pointer; }
.slot.off { opacity: 0.55; }
.local-hint { font-size: 14px; color: var(--muted); }
.split-note { margin-top: 8px; font-weight: 650; color: var(--orange); }

/* HUD поверх 3D */
#huds { position: fixed; inset: 0; pointer-events: none; z-index: 2; }
.hud { position: absolute; top: 0; bottom: 0; overflow: hidden; }
.hud + .hud { border-left: 3px solid rgba(244, 236, 216, 0.9); }
.chips { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: rgba(244, 236, 216, 0.9); border: 2px solid transparent; border-radius: 12px; padding: 5px 10px; font-size: 14px; display: flex; align-items: center; gap: 7px; }
.chip.cur { border-color: var(--ink); }
.chip .dot { width: 10px; height: 10px; border-radius: 50%; }
.chip .sc { font-weight: 800; }
.chip .lv { display: flex; gap: 2px; }
.chip .lv i { width: 6px; height: 6px; border-radius: 50%; background: #cfc3a4; }
.chip .lv i.on { background: var(--green); }
.chip.off { opacity: 0.55; }
.turn { position: absolute; left: 50%; top: 64px; transform: translateX(-50%); background: rgba(59, 51, 40, 0.82); color: #fbf6e8; border-radius: 14px; padding: 8px 18px; text-align: center; white-space: nowrap; }
.turn .who { font-size: 20px; font-weight: 800; }
.turn .sub { font-size: 13px; opacity: 0.85; }
.wind { position: absolute; right: 14px; top: 64px; background: rgba(244, 236, 216, 0.9); border-radius: 14px; padding: 6px 10px; display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; }
.wind .arrow { width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; font-size: 22px; transition: transform 0.15s linear; }
.toast { position: absolute; left: 50%; top: var(--toast-top, 68%); transform: translate(-50%, -50%) scale(0.9); font-size: clamp(28px, 6vw, 72px); font-weight: 900; color: #fbf6e8; text-shadow: 0 4px 0 rgba(59, 51, 40, 0.6), 0 0 30px rgba(59, 51, 40, 0.35); opacity: 0; transition: opacity 0.2s, transform 0.2s; text-align: center; white-space: nowrap; }
.toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.toast.good { color: #fff3c4; }
.toast.bad { color: #ffd9c9; }
.toast small { display: block; font-size: 0.4em; font-weight: 700; }
.winner { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.winner .box { background: rgba(244, 236, 216, 0.95); border-radius: 22px; padding: 18px 28px; text-align: center; border: 2px solid var(--line); }
.winner .big { font-size: 34px; font-weight: 900; }

/* итоги */
.results table { width: 100%; border-collapse: collapse; margin: 6px 0 14px; }
.results th, .results td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); }
.results tr.win td { font-weight: 800; background: #f7edcf; }
.results h2 { margin: 12px 0 2px; font-size: 18px; }

/* всплывающие надписи «СВИШ!», «ДЗЫНЬ!» у кольца */
#pops { position: fixed; inset: 0; pointer-events: none; z-index: 3; overflow: hidden; }
.pop { position: absolute; left: 0; top: 0; will-change: transform; white-space: nowrap; }
.pop { font: 900 calc(30px * var(--big, 1)) / 1 'Arial Black', 'Segoe UI Black', system-ui, sans-serif; letter-spacing: 0.5px; color: #fff4c9;
  -webkit-text-stroke: calc(2px * var(--big, 1)) #3b2414; paint-order: stroke fill; text-shadow: 0 4px 0 rgba(59, 36, 20, 0.55), 0 0 18px rgba(255, 200, 80, 0.35); }
.pop { animation: popIn 1.1s cubic-bezier(0.2, 0.9, 0.3, 1.2) forwards; }
.pop.hit { color: #ffe066; }
.pop.faint { color: #ff9b8a; }
.pop.gold { color: #ffd34d; }
.pop.dodge { color: #b8f0ff; font-size: calc(24px * var(--big, 1)); }
.pop.combo { color: #ffffff; background: linear-gradient(90deg, #ffde59, #ff7a59); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
@keyframes popIn {
  0% { scale: 0.2; rotate: calc(var(--rot) * 3); opacity: 0; translate: -50% -50%; }
  14% { scale: 1.35; rotate: var(--rot); opacity: 1; translate: -50% -50%; }
  28% { scale: 0.95; translate: -50% -50%; }
  40% { scale: 1.05; translate: -50% -50%; }
  75% { opacity: 1; translate: -50% -50%; }
  100% { scale: 0.85; opacity: 0; translate: -50% -70%; }
}

/* рекорд */
.record { margin-top: 8px; text-align: center; font-size: 14px; color: var(--muted); }
.record b { color: var(--ink); }
.record.lg { font-size: 17px; margin: 0 0 8px; }
.record.new { color: var(--gold); font-weight: 900; animation: recPop 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.3); }
@keyframes recPop { 0% { scale: 0.6; opacity: 0; } 100% { scale: 1; opacity: 1; } }

/* настройки */
#screen-settings { z-index: 8; }
.settings { width: min(560px, 100%); }
.set-row { display: flex; align-items: center; gap: 12px; margin: 12px 0; flex-wrap: wrap; }
.set-row > b { min-width: 150px; }
.set-row input[type=range] { flex: 1; min-width: 140px; accent-color: var(--orange); }
.set-row.check { gap: 8px; }
.set-note { font-size: 13px; color: var(--muted); }
.seg { display: inline-flex; border: 2px solid var(--line); border-radius: 12px; overflow: hidden; flex-wrap: wrap; }
.seg button { font: inherit; font-weight: 650; background: transparent; border: 0; padding: 8px 12px; cursor: pointer; color: var(--ink); }
.seg button.on { background: var(--ink); color: #fbf6e8; }
.link { background: none; border: 0; color: var(--orange); text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }

/* FPS */
#fps { position: fixed; left: 50%; bottom: 6px; transform: translateX(-50%); z-index: 9; font: 700 12px/1 ui-monospace, monospace; background: rgba(59, 51, 40, 0.75); color: #fbf6e8; padding: 4px 8px; border-radius: 8px; pointer-events: none; }

@media (max-width: 700px) {
  .pop { font-size: calc(22px * var(--big, 1)); }
  .card { padding: 14px 14px; border-radius: 16px; }
  .slots { grid-template-columns: repeat(2, 1fr); }
  .code { font-size: 46px; letter-spacing: 6px; }
  .turn { top: auto; bottom: 14px; }
}
