.screen[hidden], .arena[hidden] { display: none; }
.logo { font-size: clamp(42px, 13vw, 60px); }
.bot-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.lobby-text { margin: 0; text-align: center; color: var(--muted); }
.board li.out { opacity: .5; }

.setup { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.setup select {
  width: 100%;
  padding: 10px;
  font: inherit;
  color: var(--ink);
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 6px;
}
.story-title { font-size: clamp(30px, 9vw, 44px); }
.chapter h2 { margin: 14px 0 6px; font-size: 16px; color: var(--sun); }
.level {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 6px;
  padding: 10px 12px;
  font: inherit;
  text-align: left;
  color: var(--ink);
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}
.level small { color: var(--muted); }
.level.done b::after { content: ' ✓'; color: var(--sun); }
.level:disabled { opacity: .45; cursor: default; }
.talk-card { text-align: center; }
.talk-art svg { width: 150px; height: 150px; }
.talk-card.narrator .talk-art { display: none; }
.talk-name { display: block; min-height: 1.2em; font-size: 20px; color: var(--sun); }
.talk-text { min-height: 5.5em; margin: 8px 0 14px; font-size: 17px; line-height: 1.45; }
.talk-card.narrator .talk-text { font-style: italic; }
.talk-row { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; }
.chips .score { margin-top: 2px; font-size: 11px; font-weight: 800; color: var(--sun); }

.legend {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}
.legend li { display: flex; align-items: center; gap: 6px; }
.legend i { font-style: normal; font-size: 18px; }

.arena {
  position: fixed;
  inset: 0;
  display: grid;
  gap: 4px;
  padding: max(6px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
  background: #0e0c15;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  grid-template-areas:
    "top top"
    "stat stat"
    "board board"
    "pad bomb";
  user-select: none;
  -webkit-user-select: none;
}

.topbar { grid-area: top; display: flex; align-items: center; gap: 5px; width: 100%; max-width: 640px; justify-self: center; }
.round-btn {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  font: inherit;
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
  background: var(--panel);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}
.round-btn.off { opacity: .4; text-decoration: line-through; }

.chips { flex: 1; min-width: 0; list-style: none; margin: 0; padding: 0; display: flex; gap: 4px; }
.chips li {
  flex: 1 1 0;
  min-width: 0;
  padding: 3px 6px;
  background: var(--panel);
  border: 2px solid transparent;
  border-radius: 6px;
}
.chips li.me { border-color: var(--ink); }
.chips li.out { opacity: .4; }
.chips .who-row { display: flex; align-items: center; gap: 4px; }
.chips .dot { flex: none; width: 9px; height: 9px; border-radius: 50%; }
.chips .nick { font-size: 11px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chips .wins { display: flex; gap: 3px; margin-top: 3px; }
.chips .wins i { width: 12px; height: 4px; border-radius: 2px; background: var(--line); }
.chips .wins i.on { background: var(--sun); }

.statline {
  grid-area: stat;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  max-width: 640px;
  justify-self: center;
  padding: 0 4px;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.statline b { color: var(--ink); }
.statline b.danger { color: var(--hot); }

.board-wrap { grid-area: board; position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; overflow: hidden; }
#canvas { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 6px; }
.banner {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  text-align: center;
  font-size: clamp(30px, 9vw, 58px);
  font-weight: 900;
  font-style: italic;
  line-height: 1.05;
  color: var(--ink);
  text-shadow: 0 3px 0 #231a2c, 0 0 18px rgba(0, 0, 0, .7);
  pointer-events: none;
}

.pad, .bomb-btn { touch-action: none; }
.pad {
  grid-area: pad;
  position: relative;
  justify-self: center;
  align-self: center;
  width: 148px;
  height: 148px;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 50%;
}
.arrow { position: absolute; width: 0; height: 0; border: 13px solid transparent; opacity: .75; }
.arrow.up { left: 59px; top: 6px; border-bottom: 18px solid var(--ink); border-top-width: 0; }
.arrow.down { left: 59px; bottom: 6px; border-top: 18px solid var(--ink); border-bottom-width: 0; }
.arrow.left { top: 59px; left: 6px; border-right: 18px solid var(--ink); border-left-width: 0; }
.arrow.right { top: 59px; right: 6px; border-left: 18px solid var(--ink); border-right-width: 0; }
.pad[data-dir="1"] .arrow.up, .pad[data-dir="2"] .arrow.right, .pad[data-dir="3"] .arrow.down, .pad[data-dir="4"] .arrow.left { opacity: 1; filter: drop-shadow(0 0 6px var(--sun)); }

.bomb-btn {
  grid-area: bomb;
  justify-self: center;
  align-self: center;
  width: 112px;
  height: 112px;
  font-size: 48px;
  background: var(--hot);
  border: 4px solid #ffb199;
  border-radius: 50%;
  cursor: pointer;
}
.bomb-btn:active { transform: scale(.94); }

@media (orientation: landscape) and (any-pointer: coarse) {
  .arena {
    grid-template-columns: 164px minmax(0, 1fr) 164px;
    grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas:
      "top top top"
      "stat stat stat"
      "pad board bomb";
  }
}
@media not all and (any-pointer: coarse) {
  .pad, .bomb-btn { display: none; }
}

.reconnect {
  position: fixed;
  top: 40%;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 8px 14px;
  background: rgba(14, 11, 22, .88);
  border-radius: 6px;
  font-weight: 800;
}
