:root {
  --bg: #0f1220; --panel: #1a1f36; --panel2: #232945; --text: #eef0fb; --muted: #8f96b8;
  --accent: #ffb020; --green: #3ddc84; --red: #ff4d5e; --line: #2d345a;
}
* { box-sizing: border-box; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 16px/1.3 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  touch-action: manipulation; overscroll-behavior: none; }
body { overflow: hidden; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
button, input { font: inherit; color: inherit; touch-action: manipulation; }
[hidden] { display: none !important; }
#app { height: 100vh; height: 100dvh; position: relative; }

.screen { height: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); overflow-y: auto; }
.screen.center { justify-content: center; }
.logo { margin: 8px 0 0; font-size: 40px; line-height: 1; text-align: center; color: var(--accent);
  text-transform: uppercase; letter-spacing: 1px; text-shadow: 0 3px 0 #7a4a00; }
.lead { margin: 0; color: var(--muted); text-align: center; }

.btn { border: 0; border-radius: 14px; background: var(--panel2); padding: 14px 20px; font-weight: 700; min-height: 52px; cursor: pointer; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: #2a1a00; width: 100%; max-width: 360px; font-size: 20px; min-height: 60px; }
.btn.primary:disabled { background: var(--panel2); color: var(--muted); }
.btn.small { min-height: 40px; padding: 6px 14px; font-size: 14px; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.input { width: 100%; max-width: 360px; background: var(--panel); border: 2px solid var(--line); border-radius: 14px;
  padding: 14px; font-size: 18px; text-align: center; user-select: text; -webkit-user-select: text; }
.input:focus { outline: none; border-color: var(--accent); }
.error { margin: 0; color: var(--red); text-align: center; font-weight: 600; }

.picker { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; width: 100%; max-width: 360px; }
.pick { aspect-ratio: 1; padding: 0; border: 3px solid transparent; border-radius: 12px; background: var(--panel);
  overflow: hidden; display: flex; align-items: center; justify-content: center; font-size: 22px; cursor: pointer; }
.pick-photo { grid-column: 1 / -1; aspect-ratio: auto; height: 46px; font-size: 16px; font-weight: 700; gap: 8px; }
.pick-photo .av-img { width: 36px; height: 36px; border-radius: 8px; }
.pick.sel { border-color: var(--accent); background: var(--panel2); }
.av-img, .av-fallback { width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; display: block; }
.av-fallback { display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.4em; color: #fff; }

/* Sala */
.screen.room { padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom)); gap: 4px; overflow: hidden; align-items: stretch; }
.bar { display: flex; align-items: center; gap: 6px; height: 44px; flex: none; }
.grow { flex: 1; }
.chip { background: var(--panel); border-radius: 999px; padding: 6px 12px; font-weight: 800; letter-spacing: 2px; font-size: 14px; }
.chip.warn { background: #5a3d00; color: var(--accent); letter-spacing: 0; font-weight: 600; }
.status { flex: none; height: 52px; text-align: center; display: flex; flex-direction: column; justify-content: center; }
.status-title { font-size: 20px; font-weight: 800; }
.status-sub { font-size: 13px; color: var(--muted); }
.grid { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 8px; }
.row { display: flex; justify-content: center; gap: 8px; }
.actions { flex: none; height: 76px; display: flex; align-items: center; justify-content: center; }

.tile { position: relative; flex: none; width: var(--tw); height: var(--th); background: var(--panel); border: 2px solid var(--line);
  border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: space-evenly; padding: 4px; overflow: hidden; }
.tile.me { border-color: var(--accent); }
.tile.hittable { cursor: pointer; border-color: #4b5594; }
.tile.hittable:active { background: var(--panel2); transform: scale(.96); }
.tile.winner { border-color: var(--green); box-shadow: 0 0 0 3px var(--green), 0 0 24px var(--green); }
.tile.offline { opacity: .45; }
.tile.eliminated .av, .tile.spectator .av { filter: grayscale(1); opacity: .55; }
.tile.eliminated .name, .tile.spectator .name { color: var(--muted); }
.tile.shake { animation: shake .45s; }
@keyframes shake { 0%,100% { transform: translateX(0); } 15% { transform: translateX(-9px) rotate(-3deg); background: #5a1a28; }
  35% { transform: translateX(9px) rotate(3deg); } 55% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.av { position: relative; width: calc(var(--tw) * .56); height: calc(var(--tw) * .56); border-radius: 10px; overflow: hidden; background: #0c0f1d; flex: none; }
.name { max-width: 100%; font-weight: 700; font-size: clamp(11px, calc(var(--tw) * .13), 16px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lives { display: flex; gap: 4px; }
.dot { width: calc(var(--tw) * .12); height: calc(var(--tw) * .12); min-width: 9px; min-height: 9px; border-radius: 50%; background: var(--green); transition: background .3s; }
.dot.lost { background: var(--red); }
.tag { position: absolute; top: 3px; left: 3px; background: var(--accent); color: #2a1a00; font-size: 11px; font-weight: 800; padding: 1px 6px; border-radius: 999px; z-index: 2; }
.tag.wait { background: var(--muted); color: #10131f; }
.cd { position: absolute; top: 2px; right: 2px; min-width: 22px; height: 22px; border-radius: 11px; background: var(--accent); color: #2a1a00;
  font-weight: 900; font-size: 13px; display: flex; align-items: center; justify-content: center; z-index: 2; }
.off { position: absolute; bottom: 2px; right: 2px; font-size: 14px; z-index: 2; }
.stamp { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%) rotate(-14deg); color: var(--red); border: 2px solid var(--red);
  border-radius: 4px; padding: 1px 3px; font-weight: 900; letter-spacing: 0; font-size: clamp(8px, calc(var(--tw) * .125), 14px);
  background: rgba(15,18,32,.55); z-index: 3; pointer-events: none; white-space: nowrap; }

/* Overlays */
.overlay { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 50; }
.count { background-color: rgba(8,10,20,.7); }
.count-n { font-size: 52vmin; font-weight: 900; line-height: 1; color: #ffb020; will-change: transform, opacity;
  -webkit-text-stroke: 0.04em rgba(0,0,0,.85); paint-order: stroke fill;
  text-shadow: 0 0.04em 0 rgba(0,0,0,.9), 0 0 0.25em rgba(0,0,0,.8); }
.count-sub { font-size: 20px; font-weight: 700; color: var(--text); margin-top: 8px; }
.elim { background: #c3101f; z-index: 60; }
.elim-t { font-size: 13vmin; font-weight: 900; text-align: center; animation: pop .4s; }
@keyframes pop { from { transform: scale(.4); } to { transform: scale(1); } }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); max-width: 90%; background: #000c; border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 12px; z-index: 70; text-align: center; font-weight: 600; pointer-events: none; }

input { -webkit-user-select: text; user-select: text; }
