:root {
  color-scheme: light;
  --ink: #16181f;
  --muted: #657080;
  --line: #d9dee7;
  --paper: #f6f3ea;
  --panel: #ffffff;
  --dark: #171b24;
  --accent: #0f8b8d;
  --accent-strong: #0b6266;
  --gold: #f0b429;
  --red: #d64545;
  --green: #2f9e62;
  --blue: #3454d1;
  --shadow: 0 18px 55px rgba(27, 32, 43, 0.15);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: "Segoe UI", "Noto Sans KR", Arial, sans-serif;
}

button, input { font: inherit; }
button { border: 0; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.5; }

.app-shell {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 30px 0;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 900;
}

h1, h2 { margin: 0; }
h1 { font-size: clamp(2.4rem, 7vw, 5.2rem); line-height: 0.95; }
h2 { font-size: 1.12rem; }

.room-status {
  min-width: 164px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: rgba(255,255,255,0.82);
  text-align: right;
  font-weight: 900;
}

.room-status span, .room-status strong { display: block; }
.room-status span { color: var(--accent-strong); font-size: 0.84rem; }

.rule-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.rule-strip article {
  min-height: 86px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255,255,255,0.76);
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
}

.rule-strip strong {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--dark);
  color: #fff;
  display: grid;
  place-items: center;
}

.rule-strip span {
  color: #3b4250;
  line-height: 1.45;
  font-weight: 800;
}

.join-panel, .game-panel, .scoreboard {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,0.86);
  box-shadow: var(--shadow);
}

.join-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
  margin-bottom: 16px;
}

.room-form { display: grid; gap: 10px; }
label, .room-list-head { color: var(--muted); font-weight: 800; }

input {
  min-width: 0;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--panel);
}

.room-form button, .controls button {
  min-height: 48px;
  border-radius: 8px;
  padding: 0 18px;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
}

.room-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.mini-button {
  min-height: 32px;
  border-radius: 8px;
  padding: 0 10px;
  background: #eceff3;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 900;
}

.room-list { display: grid; gap: 8px; }

.room-card-button {
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  display: grid;
  gap: 4px;
}

.room-card-button:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(15,139,141,0.12);
}

.room-card-button strong, .room-card-button span, .room-card-button small { display: block; }
.room-card-button small, .empty-room { color: var(--muted); }
.empty-room {
  margin: 0;
  min-height: 48px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 13px;
  font-weight: 800;
}

.error-text {
  grid-column: 1 / -1;
  min-height: 22px;
  margin: 0;
  color: var(--red);
  font-weight: 900;
}

.game-panel { padding: 18px; margin-bottom: 16px; }
.is-hidden { display: none; }

.stage {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(260px, 0.9fr);
  gap: 16px;
  align-items: stretch;
}

.clock-face {
  min-height: 290px;
  border-radius: 8px;
  padding: 24px;
  background: var(--dark);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.clock-face span {
  color: #95e0dc;
  font-size: 1rem;
  font-weight: 900;
}

.clock-face strong {
  display: block;
  min-height: 120px;
  margin: 10px 0;
  font-size: clamp(4.8rem, 17vw, 9.2rem);
  line-height: 0.9;
  font-variant-numeric: tabular-nums;
}

.clock-face small {
  color: #eef2f7;
  font-size: clamp(1.08rem, 3vw, 1.45rem);
  line-height: 1.45;
  font-weight: 900;
}

.action-zone {
  min-height: 290px;
  display: grid;
  grid-template-rows: minmax(180px, 1fr) auto;
  gap: 12px;
}

.now-button {
  width: 100%;
  min-height: 180px;
  border-radius: 8px;
  background: var(--gold);
  color: #19130a;
  font-size: clamp(2.4rem, 8vw, 5rem);
  font-weight: 1000;
  box-shadow: inset 0 -12px 0 rgba(0,0,0,0.14);
  touch-action: manipulation;
}

.now-button.danger-ready { background: #f2dddd; color: var(--red); }
.now-button:active { transform: translateY(3px); box-shadow: inset 0 -6px 0 rgba(0,0,0,0.18); }

.action-zone p {
  min-height: 82px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
  color: #303846;
  line-height: 1.45;
  font-weight: 800;
}

.slot-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(54px, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.slot-cell {
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  display: grid;
  place-items: center;
  padding: 6px;
}

.slot-cell span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.slot-cell strong {
  min-height: 22px;
  color: var(--ink);
  font-weight: 1000;
}

.slot-cell.occupied {
  border-color: var(--green);
  background: #edf8f1;
}

.slot-cell.collision {
  border-color: var(--red);
  background: #f9eeee;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.controls .secondary { background: #eceff3; color: var(--ink); }
.controls .danger { background: #f2dddd; color: var(--red); }

.scoreboard { padding: 18px; }
.scoreboard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.scoreboard-head span { color: var(--muted); font-weight: 900; }

.players {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
}

.player-card {
  min-height: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel);
  display: grid;
  gap: 10px;
}

.player-card.me {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(15,139,141,0.13);
}

.player-card.winner {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(240,180,41,0.24);
}

.player-card.eliminated { opacity: 0.68; }

.player-name {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-weight: 1000;
}

.tag {
  min-width: 44px;
  border-radius: 999px;
  padding: 2px 8px;
  background: #eff8f7;
  color: var(--accent-strong);
  text-align: center;
  font-size: 0.78rem;
  font-weight: 1000;
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.stat {
  border-radius: 8px;
  background: #f4f6f8;
  padding: 8px;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.stat strong { font-variant-numeric: tabular-nums; }

@media (max-width: 780px) {
  .app-shell {
    width: min(100vw - 20px, 560px);
    padding: 20px 0;
  }
  .topbar, .stage, .join-panel, .rule-strip { grid-template-columns: 1fr; }
  .topbar { align-items: stretch; }
  .room-status { text-align: left; }
  .clock-face, .action-zone { min-height: 230px; }
  .clock-face strong { min-height: 92px; }
  .controls { flex-direction: column; }
}
