/* You're It! - menus. The game itself is drawn on the canvas; everything here
   is the HTML chrome around it, re-skinned per art style via body[data-theme]. */

@font-face { font-family: 'Orbitron'; src: url('/fonts/orbitron-800.woff2') format('woff2'); font-weight: 400 900; font-display: swap; }
@font-face { font-family: 'Rajdhani'; src: url('/fonts/rajdhani-600.woff2') format('woff2'); font-weight: 400 700; font-display: swap; }
@font-face { font-family: 'Creepster'; src: url('/fonts/creepster-400.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Special Elite'; src: url('/fonts/special-elite-400.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Permanent Marker'; src: url('/fonts/permanent-marker-400.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Patrick Hand'; src: url('/fonts/patrick-hand-400.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Press Start 2P'; src: url('/fonts/press-start-2p-400.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Kaushan Script'; src: url('/fonts/kaushan-script-400.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Cormorant Garamond'; src: url('/fonts/cormorant-garamond-600.woff2') format('woff2'); font-weight: 400 700; font-display: swap; }

/* ---------- theme tokens ---------- */
:root,
body[data-theme='neon'] {
  --page: #05030f;
  --panel: rgba(10, 7, 32, 0.8);
  --panel-line: rgba(34, 230, 255, 0.45);
  --panel-shadow: 0 0 0 1px rgba(255, 43, 214, 0.25), 0 0 40px rgba(34, 230, 255, 0.18), 0 24px 60px rgba(0, 0, 0, 0.6);
  --text: #e9faff;
  --muted: #9fb6d6;
  --accent: #22e6ff;
  --accent-2: #ff2bd6;
  --on-accent: #06021a;
  --field: rgba(255, 255, 255, 0.06);
  --display: 'Orbitron', 'Trebuchet MS', sans-serif;
  --body: 'Rajdhani', 'Segoe UI', system-ui, sans-serif;
  --radius: 4px;
  --body-size: 17px;
  --logo-size: clamp(34px, 7vw, 54px);
  --logo-shadow: 0 0 18px rgba(34, 230, 255, 0.8), 3px 3px 0 rgba(255, 43, 214, 0.9);
  --logo-space: 0.04em;
  --btn-shadow: 0 0 18px rgba(34, 230, 255, 0.45);
  --blur: 10px;
}

body[data-theme='nightmare'] {
  --page: #020303;
  --panel: rgba(9, 11, 12, 0.86);
  --panel-line: rgba(150, 20, 20, 0.6);
  --panel-shadow: 0 0 0 1px rgba(0, 0, 0, 0.9), 0 0 60px rgba(120, 0, 0, 0.35), 0 30px 70px rgba(0, 0, 0, 0.85);
  --text: #d9d4c4;
  --muted: #8c8a80;
  --accent: #b3121d;
  --accent-2: #e9e2cf;
  --on-accent: #f5efe0;
  --field: rgba(255, 255, 255, 0.04);
  --display: 'Creepster', 'Impact', fantasy;
  --body: 'Special Elite', 'Courier New', monospace;
  --radius: 2px;
  --body-size: 15px;
  --logo-size: clamp(44px, 9vw, 72px);
  --logo-shadow: 0 0 22px rgba(190, 10, 20, 0.9), 0 4px 0 #000;
  --logo-space: 0.06em;
  --btn-shadow: 0 0 22px rgba(170, 10, 20, 0.5);
  --blur: 4px;
}

body[data-theme='sketch'] {
  --page: #efe9d6;
  --panel: rgba(255, 253, 244, 0.93);
  --panel-line: #2b2b2b;
  --panel-shadow: 5px 6px 0 rgba(43, 43, 43, 0.85);
  --text: #26262b;
  --muted: #6c6c75;
  --accent: #2f6fde;
  --accent-2: #e23b3b;
  --on-accent: #ffffff;
  --field: rgba(47, 111, 222, 0.07);
  --display: 'Permanent Marker', 'Comic Sans MS', cursive;
  --body: 'Patrick Hand', 'Comic Sans MS', cursive;
  --radius: 12px 4px 14px 5px / 5px 14px 4px 12px;
  --body-size: 18px;
  --logo-size: clamp(38px, 8vw, 62px);
  --logo-shadow: 3px 3px 0 rgba(47, 111, 222, 0.35);
  --logo-space: 0.02em;
  --btn-shadow: 3px 3px 0 #2b2b2b;
  --blur: 0px;
}

body[data-theme='arcade'] {
  --page: #0b1030;
  --panel: rgba(16, 14, 48, 0.94);
  --panel-line: #ffffff;
  --panel-shadow: 0 0 0 4px #0b1030, 0 0 0 8px #ffd27a, 8px 8px 0 8px rgba(0, 0, 0, 0.55);
  --text: #ffffff;
  --muted: #b7b3e6;
  --accent: #ffd27a;
  --accent-2: #ff6b9a;
  --on-accent: #1a1040;
  --field: rgba(255, 255, 255, 0.08);
  --display: 'Press Start 2P', 'Courier New', monospace;
  --body: 'Press Start 2P', 'Courier New', monospace;
  --radius: 0px;
  --body-size: 10px;
  --logo-size: clamp(22px, 5.2vw, 38px);
  --logo-shadow: 4px 4px 0 #ff6b9a, 8px 8px 0 #3a1d6e;
  --logo-space: 0;
  --btn-shadow: 4px 4px 0 rgba(0, 0, 0, 0.6);
  --blur: 0px;
}

body[data-theme='ink'] {
  --page: #e9dfc8;
  --panel: rgba(246, 239, 223, 0.94);
  --panel-line: rgba(26, 26, 30, 0.75);
  --panel-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 18px 50px rgba(60, 40, 20, 0.28);
  --text: #1c1b1f;
  --muted: #6b6257;
  --accent: #c8372d;
  --accent-2: #1c1b1f;
  --on-accent: #fff6e8;
  --field: rgba(28, 27, 31, 0.05);
  --display: 'Kaushan Script', 'Brush Script MT', cursive;
  --body: 'Cormorant Garamond', Georgia, serif;
  --radius: 3px;
  --body-size: 18px;
  --logo-size: clamp(40px, 8vw, 66px);
  --logo-shadow: none;
  --logo-space: 0;
  --btn-shadow: none;
  --blur: 2px;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: var(--page);
  color: var(--text);
  font-family: var(--body);
  font-size: var(--body-size);
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: manipulation;
}
#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, p { margin: 0; }

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
  background: radial-gradient(ellipse at center, transparent 30%, color-mix(in srgb, var(--page) 55%, transparent) 100%);
}
.screen.overlay { background: color-mix(in srgb, var(--page) 45%, transparent); }

.panel {
  width: min(430px, 100%);
  margin: auto;
  padding: 26px 26px 20px;
  background: var(--panel);
  border: 2px solid var(--panel-line);
  border-radius: var(--radius);
  box-shadow: var(--panel-shadow);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  text-align: center;
  animation: pop 0.28s cubic-bezier(0.2, 1.3, 0.4, 1);
}
@keyframes pop { from { transform: translateY(10px) scale(0.97); opacity: 0; } }

.logo {
  font-family: var(--display);
  font-size: var(--logo-size);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: var(--logo-space);
  text-shadow: var(--logo-shadow);
}
.logo .it { color: var(--accent-2); display: inline-block; animation: wiggle 2.2s ease-in-out infinite; }
@keyframes wiggle { 0%, 86%, 100% { transform: rotate(0); } 90% { transform: rotate(-7deg) scale(1.08); } 95% { transform: rotate(6deg) scale(1.08); } }
.tagline { color: var(--muted); margin: 8px 0 18px; }

.field { display: block; text-align: left; margin-bottom: 12px; }
.field span { display: block; font-size: 0.8em; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.08em; }
input {
  width: 100%;
  padding: 11px 12px;
  background: var(--field);
  border: 2px solid color-mix(in srgb, var(--panel-line) 70%, transparent);
  border-radius: var(--radius);
  outline: none;
  user-select: text;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent); }
input::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }

.row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.row > .btn { flex: 1 1 120px; }

.btn {
  padding: 12px 14px;
  font-family: var(--display);
  font-size: 0.86em;
  letter-spacing: 0.04em;
  background: transparent;
  border: 2px solid var(--panel-line);
  border-radius: var(--radius);
  transition: transform 0.08s, filter 0.15s, background 0.15s;
}
.btn:hover { filter: brightness(1.15); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.btn:active { transform: translateY(2px) scale(0.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: var(--btn-shadow); }
.btn.primary:hover { background: var(--accent); filter: brightness(1.12); }
.btn.ghost { border-style: dashed; color: var(--muted); width: 100%; margin-top: 12px; }
.btn.small { padding: 7px 10px; font-size: 0.68em; }
.btn.big { font-size: 1.05em; padding: 15px 30px; min-width: 240px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; filter: grayscale(0.8); box-shadow: none; transform: none; }
.link { background: none; border: 0; padding: 6px 2px; color: var(--muted); }
.link:hover { color: var(--text); }

.join { display: flex; gap: 10px; margin-top: 10px; }
.join input { flex: 1; text-align: center; font-family: var(--display); font-size: 1.25em; letter-spacing: 0.35em; text-transform: uppercase; padding-left: 0.5em; }
.error { color: var(--accent-2); min-height: 1.4em; margin-top: 8px; font-size: 0.92em; }
body[data-theme='nightmare'] .error { color: #ff5a5a; }

.style-picker { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 14px; padding: 8px; border-top: 1px solid color-mix(in srgb, var(--panel-line) 45%, transparent); }
.style-picker button { background: none; border: 0; font-size: 1.1em; padding: 8px 12px; color: var(--accent); }
.style-picker button:hover { transform: scale(1.25); }
.style-picker small { display: block; color: var(--muted); font-size: 0.72em; text-transform: uppercase; letter-spacing: 0.1em; }
.style-picker strong { font-family: var(--display); font-weight: 400; font-size: 0.95em; }
.hint { color: var(--muted); font-size: 0.82em; margin-top: 4px; }
.hint b { color: var(--text); font-weight: 600; }
.conn { font-size: 0.74em; margin-top: 8px; color: var(--muted); }
.conn::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: #e0a100; vertical-align: baseline; animation: blink 1s infinite; }
.conn.ok::before { background: #2ecc71; animation: none; }
.conn.bad::before { background: #e74c3c; }
@keyframes blink { 50% { opacity: 0.25; } }

/* ---------- lobby ---------- */
.lobby-panel { width: min(760px, 100%); padding: 18px 24px 20px; }
.lobby-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; }
.lobby-head .link { justify-self: start; }
.lobby-head .btn { justify-self: end; }
.code-box small { color: var(--muted); text-transform: uppercase; letter-spacing: 0.16em; font-size: 0.7em; }
.code { font-family: var(--display); font-size: clamp(34px, 8vw, 58px); line-height: 1.1; letter-spacing: 0.22em; padding-left: 0.22em; color: var(--accent); text-shadow: var(--logo-shadow); user-select: text; }
.lobby-grid { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: 22px; margin: 16px 0; text-align: left; }
.lobby-grid h2 { font-family: var(--display); font-size: 0.82em; font-weight: 400; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.lobby-grid h2 small { text-transform: none; letter-spacing: 0; font-family: var(--body); opacity: 0.8; }

.players { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.players li { display: flex; align-items: center; gap: 10px; padding: 9px 10px; background: var(--field); border: 1px solid color-mix(in srgb, var(--panel-line) 40%, transparent); border-radius: var(--radius); min-height: 44px; }
.players li.empty { opacity: 0.45; border-style: dashed; }
.players .swatch { width: 20px; height: 24px; border-radius: 4px; flex: none; box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35); }
.players .pname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.players .tag { font-size: 0.68em; padding: 2px 6px; border: 1px solid currentColor; border-radius: 99px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.players .tag.host { color: var(--accent); }

.setting { display: grid; grid-template-columns: 74px 1fr; gap: 8px; align-items: start; margin-bottom: 10px; }
.setting > span { color: var(--muted); font-size: 0.82em; padding-top: 7px; }
.opts { display: flex; flex-wrap: wrap; gap: 6px; }
.opt { padding: 6px 9px; font-size: 0.8em; background: var(--field); border: 2px solid transparent; border-radius: var(--radius); color: var(--text); display: flex; align-items: center; gap: 6px; }
.opt:hover:not(:disabled) { border-color: color-mix(in srgb, var(--accent) 55%, transparent); }
.opt.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, transparent); }
.opt:disabled { cursor: default; opacity: 0.55; }
.opt.on:disabled { opacity: 1; }
.opt .chip { width: 14px; height: 14px; border-radius: 3px; flex: none; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4); }
.opt canvas { width: 40px; height: 25px; border-radius: 2px; background: rgba(0, 0, 0, 0.35); }
.arenas .opt { flex-direction: column; gap: 3px; padding: 5px 6px; font-size: 0.72em; }

.lobby-foot { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.wait { color: var(--muted); min-height: 1.3em; margin-top: 10px; }
.wait:not(:empty)::after { content: ''; animation: dots 1.4s steps(4) infinite; }

/* ---------- results ---------- */
.results-panel { width: min(470px, 100%); }
.results-panel h2 { font-family: var(--display); font-size: clamp(24px, 6vw, 38px); font-weight: 400; line-height: 1.1; text-shadow: var(--logo-shadow); color: var(--accent); overflow-wrap: anywhere; }
.results-list { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 7px; text-align: left; }
.results-list li { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: var(--field); border: 2px solid transparent; border-radius: var(--radius); }
.results-list li.win { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 20%, transparent); }
.results-list .rank { width: 1.6em; color: var(--muted); font-family: var(--display); font-size: 0.8em; }
.results-list .swatch { width: 16px; height: 20px; border-radius: 3px; flex: none; }
.results-list .pname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results-list .time { font-family: var(--display); font-size: 0.86em; font-variant-numeric: tabular-nums; }
.results-list .crown { color: var(--accent); }

/* ---------- in-game chrome ---------- */
#topbar { position: fixed; top: 8px; right: 8px; display: flex; gap: 6px; z-index: 5; }
.icon { width: 34px; height: 34px; border-radius: 50%; border: 1px solid color-mix(in srgb, var(--panel-line) 60%, transparent); background: color-mix(in srgb, var(--panel) 80%, transparent); color: var(--text); font-size: 15px; line-height: 1; opacity: 0.6; }
.icon:hover { opacity: 1; }
.icon.off { text-decoration: line-through; opacity: 0.35; }

#touch { position: fixed; inset: auto 0 0 0; padding: 0 14px calc(14px + env(safe-area-inset-bottom)); display: flex; justify-content: space-between; align-items: flex-end; pointer-events: none; z-index: 4; }
#touch button { pointer-events: auto; width: 74px; height: 74px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.55); background: rgba(20, 20, 30, 0.28); color: #fff; font-size: 24px; touch-action: none; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); }
#touch button.down { background: rgba(255, 255, 255, 0.35); }
#touch .pad { display: flex; gap: 12px; }
#touch .jump { width: 92px; height: 92px; font-size: 15px; font-weight: 700; letter-spacing: 0.06em; }

#toasts { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 9; pointer-events: none; }
.toast { padding: 8px 14px; background: var(--panel); border: 1px solid var(--panel-line); border-radius: 99px; font-size: 0.86em; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35); animation: toast 3s forwards; white-space: nowrap; }
@keyframes toast { 0% { opacity: 0; transform: translateY(8px); } 8%, 82% { opacity: 1; transform: none; } 100% { opacity: 0; } }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

/* ---------- per-style flourishes ---------- */
body[data-theme='neon'] .panel { clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 18px, 100% 100%, 18px 100%, 0 calc(100% - 18px)); }
body[data-theme='neon'] .btn { text-transform: uppercase; }

body[data-theme='nightmare'] .panel { border-style: double; border-width: 4px; }
body[data-theme='nightmare'] .logo { color: #e9e2cf; animation: flicker 5s infinite; }
body[data-theme='nightmare'] .logo .it { color: #c4121f; }
body[data-theme='nightmare'] .code { color: #c4121f; }
body[data-theme='nightmare'] .btn { letter-spacing: 0.1em; font-size: 1.05em; }
@keyframes flicker { 0%, 91%, 94%, 97%, 100% { opacity: 1; } 92%, 96% { opacity: 0.45; } }

body[data-theme='sketch'] .panel { transform: rotate(-0.6deg); background-image: repeating-linear-gradient(transparent 0 25px, rgba(90, 140, 220, 0.22) 25px 26px); }
body[data-theme='sketch'] .btn, body[data-theme='sketch'] input, body[data-theme='sketch'] .players li, body[data-theme='sketch'] .opt, body[data-theme='sketch'] .results-list li { border-color: #2b2b2b; border-width: 2px; border-style: solid; }
body[data-theme='sketch'] .opt { border-color: rgba(43, 43, 43, 0.25); }
body[data-theme='sketch'] .opt.on { border-color: #2f6fde; }
body[data-theme='sketch'] .players li.empty { border-style: dashed; }
body[data-theme='sketch'] .btn.ghost { border-style: dashed; }
body[data-theme='sketch'] .logo .it { text-decoration: underline wavy #e23b3b 3px; text-underline-offset: 6px; }

body[data-theme='arcade'] .panel { padding: 28px 22px 22px; }
body[data-theme='arcade'] .btn { text-transform: uppercase; padding: 14px 10px; }
body[data-theme='arcade'] .btn:not(.primary):not(.ghost) { border-color: #fff; box-shadow: var(--btn-shadow); }
body[data-theme='arcade'] .tagline, body[data-theme='arcade'] .hint { line-height: 1.8; }
body[data-theme='arcade'] .code { letter-spacing: 0.12em; }
body[data-theme='arcade'] .logo .it { animation: blink 0.9s steps(2) infinite; }
body[data-theme='arcade'] input { font-size: 12px; }
body[data-theme='arcade'] .join input { font-size: 14px; }

body[data-theme='ink'] .panel { border-width: 1px; border-top-width: 7px; border-bottom-width: 3px; }
body[data-theme='ink'] .logo .it { color: #c8372d; }
body[data-theme='ink'] .btn { font-size: 1.15em; letter-spacing: 0; padding: 9px 14px; }
body[data-theme='ink'] .btn.small { font-size: 0.85em; }
body[data-theme='ink'] .code { color: #1c1b1f; }
body[data-theme='ink'] .tagline, body[data-theme='ink'] .hint { font-style: italic; }

/* ---------- small screens ---------- */
@media (max-width: 640px) {
  .lobby-grid { grid-template-columns: 1fr; gap: 14px; }
  .lobby-head { grid-template-columns: 1fr; justify-items: center; }
  .lobby-head .link, .lobby-head .btn { justify-self: center; }
  .panel { padding: 20px 16px 16px; }
}
@media (max-height: 480px) {
  /* phones held sideways: keep the buttons out of the arena as much as possible */
  #touch { padding: 0 8px calc(8px + env(safe-area-inset-bottom)); }
  #touch button { width: 60px; height: 60px; font-size: 20px; }
  #touch .pad { gap: 6px; }
  #touch .jump { width: 78px; height: 78px; font-size: 13px; }
}
@media (max-height: 560px) {
  .tagline { margin-bottom: 10px; }
  .panel { padding-top: 14px; padding-bottom: 12px; }
  .hint { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; }
}
