/* 참가자 휴대폰 (기준 360×640, 스크롤 없이 핵심 버튼이 보이게) */
#app { max-width: 480px; margin: 0 auto; padding: 16px; }
.stack { display: flex; flex-direction: column; gap: var(--gap); }
.row { display: flex; gap: 8px; align-items: center; }
.event-title { font-size: 1rem; color: var(--muted); font-weight: 700; margin-bottom: 4px; }

.code-input { font-size: 1.6rem; letter-spacing: 0.3em; text-transform: uppercase; text-align: center; }

.survey-q { border: 0; padding: 0; margin: 0; }
.survey-q legend { font-weight: 700; margin-bottom: 8px; }
.survey-q .choices { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; }
.survey-q .choices button { padding: 0 8px; }
.survey-q .skip { font-weight: 500; border-style: dashed; }

.team-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.team-grid button {
  display: flex; align-items: center; justify-content: flex-start;
  padding: 8px 12px; text-align: left;
  border-color: var(--line);
  border-left: 8px solid var(--team, var(--ink));
}
.team-grid button[aria-pressed='true'] { background: var(--surface); color: var(--ink); border-color: var(--ink); border-left-color: var(--team); box-shadow: 0 0 0 3px var(--accent); }

.status-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.status-bar .event-title { flex: 1; min-width: 0; margin-bottom: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-bar .pill, .status-bar .contrast-toggle { flex: none; white-space: nowrap; }
.status-bar .contrast-toggle { min-width: 44px; min-height: 44px; padding: 0 8px; font-size: 0.85rem; }
.my-team {
  border-left: 12px solid var(--team, var(--ink));
  display: flex; flex-direction: column; gap: 8px;
}
.my-team .team-badge .team-name { font-size: 1.6rem; }
.leader-tag { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: var(--ink); color: var(--surface); font-size: 0.8rem; font-weight: 800; vertical-align: middle; }
.rename-team input { font-size: 1.2rem; }
.teammates { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.waiting { text-align: center; padding: 28px 8px; font-size: 1.1rem; }
.notice { background: var(--warn-bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-weight: 700; }
.link-button { background: none; border: 0; min-height: 44px; padding: 0; color: var(--accent); text-decoration: underline; font-weight: 700; }

/* ---------- 경기 ---------- */
.team-strip { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-left: 6px solid var(--team); padding: 4px 10px; margin-bottom: 8px; background: var(--surface); border-radius: 10px; }
.game-card { display: flex; flex-direction: column; gap: 10px; }
.game-kind { color: var(--accent); font-weight: 800; margin: 0; font-size: 0.9rem; }
.game-title { font-size: 1.6rem; margin: 0; }
.rules { margin: 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: 6px; }
.big-msg { font-size: 1.4rem; font-weight: 900; margin: 4px 0; }
.my-result { border-left: 10px solid var(--team); padding-left: 12px; }

.game-live { position: relative; display: flex; flex-direction: column; gap: 10px; }
.game-top { display: flex; justify-content: space-between; align-items: center; }
.timer { font-size: 1.6rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stats > div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; display: flex; flex-direction: column; }
.stat-num { font-size: 1.8rem; font-variant-numeric: tabular-nums; }
.net-warn { background: var(--warn-bg); border-radius: 10px; padding: 8px; margin: 0; font-weight: 700; }

/* 조작 버튼: 이 영역에서만 터치 기본 동작(확대·스크롤)을 끈다 (사양 7장) */
.controls { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.controls.disabled { opacity: 0.4; pointer-events: none; }
.tap-btn {
  width: 100%; height: min(46vh, 340px); border-radius: 28px;
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
  font-size: 3rem; font-weight: 900; letter-spacing: 0.08em;
}
.tap-btn.pulse { animation: pulse 120ms ease-out; }
@keyframes pulse { from { transform: scale(0.96); } to { transform: scale(1); } }
.feet { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.foot-btn { height: min(42vh, 320px); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; font-size: 1.4rem; border-width: 3px; }
.foot-btn.next { background: var(--ink); color: var(--surface); }
.foot-arrow { font-size: 2.4rem; }
.foot-btn.wrong { animation: wrong 260ms; }
@keyframes wrong { 0%, 100% { transform: translateX(0); } 30% { transform: translateX(-6px); } 70% { transform: translateX(6px); } }

.countdown-overlay {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 7rem; font-weight: 900; color: var(--ink);
  background: rgba(250, 246, 236, 0.88);
  border-radius: 20px; pointer-events: none;
}

/* ---------- 선택형 게임 ---------- */
.choice { display: flex; flex-direction: column; gap: 10px; }
.save { margin: 0; padding: 8px 12px; border-radius: 10px; font-weight: 800; border: 2px solid var(--line); background: var(--surface); }
.save.ok { border-color: var(--ok); color: var(--ok); }
.save.pending { border-style: dashed; }
.save.fail { border-color: var(--danger); color: var(--danger); }
.save.idle { color: var(--muted); }
.hint { margin: 0; background: var(--warn-bg); border-radius: 10px; padding: 8px 12px; font-weight: 800; }

.target-line { font-size: 1.2rem; margin: 0; }
.target { font-size: 2.6rem; color: var(--accent); }
.card-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.brain-controls { max-width: 440px; width: 100%; align-self: center; touch-action: manipulation; }
.brain-message, .switch-rule { text-align: center; }
.brain-message { min-height: 1.5em; font-weight: 700; }
.brain-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.brain-actions button { min-height: 48px; }
.route-controls.controls.disabled { opacity: 1; }
.route-board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: min(100%, 280px); margin-inline: auto; }
.route-cell { aspect-ratio: 1; min-height: 44px; padding: 0; font-size: 1.6rem; font-weight: 800; border-width: 2px; }
.route-cell.marked { opacity: 1; color: var(--ink); background: var(--surface); border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.switch-rule { margin-block: 0.2rem; font-size: clamp(1.3rem, 5vw, 2rem); }
.switch-mark { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 88px; color: var(--ink); background: var(--surface); border: 2px solid var(--line); border-radius: 12px; }
.switch-digit { font-size: 2.15rem; font-weight: 800; }
.crowd-title { margin: 0; font-size: clamp(1.35rem, 6vw, 2.1rem); }
.crowd-detail { white-space: pre-line; }
.crowd-options, .crowd-map { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.crowd-options.three-columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.crowd-options button { min-height: 54px; padding-inline: 4px; overflow-wrap: anywhere; }
.crowd-options button[hidden] { display: none; }
.crowd-options .crowd-tap { grid-column: 1 / -1; min-height: min(35vh, 230px); font-size: 2rem; }
.crowd-map { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.crowd-map span { display: grid; min-height: 32px; place-items: center; border: 1px solid var(--line); border-radius: 7px; }
.crowd-map .marked { outline: 2px solid var(--accent); outline-offset: -2px; font-weight: 850; }
.card-btn { min-height: 120px; font-size: 3rem; border-width: 3px; border-radius: 18px; }
.card-btn.default { border-style: dashed; }

.clue { font-size: 1.3rem; font-weight: 900; background: var(--surface); border: 2px solid var(--ink); border-radius: 14px; padding: 12px; margin: 0; }
.slots { display: flex; gap: 6px; flex-wrap: wrap; }
.slot { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; min-width: 56px; padding: 6px; border: 2px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 0.8rem; font-weight: 700; }
.slot.mine { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.slot.dup { background: var(--warn-bg); }
.shape-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.shape-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 6px; font-size: 0.95rem; }

.zone-row { display: grid; grid-template-columns: 1fr auto 56px 44px 56px; gap: 8px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 6px 10px; }
.zone-name { font-weight: 900; }
.reward { color: var(--accent); font-weight: 800; }
.zone-val { font-size: 1.6rem; text-align: center; font-variant-numeric: tabular-nums; }

.board-box { display: flex; justify-content: center; }
.pipe-board { width: min(100%, 320px); height: auto; }
.pipe-board .cell { fill: var(--surface); stroke: var(--line); stroke-width: 2; }
.pipe-board .cell.turn { stroke: var(--muted); stroke-dasharray: 6 4; }
.pipe-board .cell.mine { stroke: var(--accent); stroke-width: 6; stroke-dasharray: none; }
.pipe-board .cell.wet { fill: #e0f4f3; }
.pipe-board .pipe { stroke: var(--ink); stroke-width: 16; stroke-linecap: round; }
.pipe-board .pipe.wet { stroke: var(--accent); }
.pipe-board .cp { fill: #fff; stroke: var(--ink); stroke-width: 4; }
.pipe-board .cp.hit { fill: var(--accent); }
.pipe-board .gate { fill: var(--danger); }
.deg-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }

.question { font-size: 1.3rem; margin: 0; }
.guess-row { display: grid; grid-template-columns: 56px 56px 1fr 56px 56px; gap: 6px; align-items: center; }
.guess-num { text-align: center; font-size: 2.6rem; font-variant-numeric: tabular-nums; }
.preset-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.preset-row button { padding: 0; }

/* 고대비에서는 채움·테두리 모양으로도 상태를 구별한다. */
:root[data-contrast='high'] .save.ok { background: var(--ok); color: var(--surface); }
:root[data-contrast='high'] .save.fail { background: var(--danger); color: var(--surface); border-style: double; border-width: 4px; }
:root[data-contrast='high'] .save.pending { border-color: var(--ink); color: var(--ink); }
:root[data-contrast='high'] .foot-btn.next,
:root[data-contrast='high'] button[aria-pressed='true'] { background: var(--ink); color: var(--surface); border-color: var(--ink); box-shadow: 0 0 0 3px var(--accent); }
:root[data-contrast='high'] .countdown-overlay { background: var(--bg); }

/* ---------- 작은 화면 경기 배치 (360×640에서 핵심 버튼·저장 상태가 스크롤 없이, 사양 7장) ---------- */
.game-live { gap: 8px; }
.game-live .stack { gap: 8px; }
.game-live p { margin: 0; }
.team-strip { padding: 2px 10px; margin-bottom: 6px; }
.pipe-board { width: min(100%, 300px, 40vh); }
@media (max-height: 760px) {
  #app { padding: 8px 12px; }
  .status-bar { margin-bottom: 4px; }
  .event-title { font-size: 0.9rem; }
  .timer { font-size: 1.3rem; }
  .card-btn { min-height: 88px; font-size: 2.4rem; }
  .target { font-size: 2rem; }
  .zone-row { padding: 2px 8px; }
  .zone-row button { min-height: 56px; }
  .clue { font-size: 1.1rem; padding: 8px 10px; }
  .choice .muted, .choice p { font-size: 0.9rem; }
  .save, .hint { padding: 6px 10px; }
  .deg-row button { min-height: 56px; }
}
