/* 닮은말: 원고지 칸과 빨간 도장
 * 화면 전체는 고정하고, 넘치는 영역만 안에서 스크롤한다. */

:root {
  --desk: #e3e9e4;
  --paper: #fbfcf8;
  --paper-2: #f1f6f2;
  --grid: #2f8a67;
  --grid-text: #24704f;
  --grid-soft: #bdd9ca;
  --line: #c9d8cf;
  --track: #e1ebe5;
  --ink: #1f2b4d;
  --ink-hover: #2b3a63;
  --ink-soft: #545f7e;
  --stamp: #cf3b2f;
  --stamp-text: #b42f27;
  --mark: #fff1a8;
  --turn: #eaf3ee;
  --heat-cold: #6f8db4;
  --heat-warm: #c77a1e;
  --heat-hot: #e0662a;
  --font-cell: 'Gowun Batang', 'Nanum Myeongjo', 'AppleMyungjo', 'Batang', serif;
  --font-ui: 'IBM Plex Sans KR', 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', system-ui, sans-serif;
  --pad: 20px;
  --gap: 16px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  overflow: auto;
  background: var(--desk);
  color: var(--ink);
  font: 15px/1.55 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

#app {
  height: 100vh;
  height: 100dvh;
  min-height: 460px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.screen {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

button,
input {
  font: inherit;
  color: inherit;
}

p,
h1,
h2,
h3,
ol,
ul,
dl,
dd {
  margin: 0;
}

ol,
ul {
  padding: 0;
  list-style: none;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  padding: 0;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* 화면 읽기 프로그램용 알림 줄이 페이지 높이를 늘리지 않게 */
#live {
  position: fixed;
  top: 0;
  left: 0;
}

.boot {
  margin: auto;
  font-family: var(--font-cell);
  font-size: 22px;
  color: var(--ink-soft);
}

.scroll {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--grid-soft) transparent;
}

/* ---------------------------------------------------------------- 원고지 칸 */

.cells {
  --cell: 44px;
  display: inline-flex;
  flex: 0 0 auto;
  vertical-align: middle;
}

.cell {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: var(--cell);
  height: var(--cell);
  margin-left: -1.5px;
  border: 1.5px solid var(--grid);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-cell);
  font-size: calc(var(--cell) * 0.57);
  line-height: 1;
}

.cell:first-child {
  margin-left: 0;
}

/* 영어 단어는 글자를 칸으로 나누지 않고 한 칸에 이어 쓴다 */
.wordbox {
  --cell: 44px;
  flex: 0 1 auto;
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  height: var(--cell);
  padding: 0 calc(var(--cell) * 0.28);
  overflow: hidden;
  border: 1.5px solid var(--grid);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-cell);
  font-size: calc(var(--cell) * 0.5);
  line-height: 1;
  white-space: nowrap;
  text-overflow: ellipsis;
  vertical-align: middle;
}

.cells[data-fit='1'] {
  --cell: 36px;
}

.cells[data-fit='2'] {
  --cell: 30px;
}

.cells[data-fit='3'] {
  --cell: 26px;
}

.cells-sm {
  --cell: 34px;
}

.cells-md {
  --cell: 48px;
}

.cells-xl {
  --cell: clamp(64px, 9vw, 104px);
}

.cell-q {
  --cell: 48px;
  color: var(--ink-soft);
  font-family: var(--font-ui);
  font-size: 24px;
}

.brand {
  flex: 0 0 auto;
  display: inline-flex;
  margin: 0;
}

.brand .cell {
  --cell: 28px;
  font-size: 16px;
}

.brand-lg .cell {
  --cell: 40px;
  font-size: 23px;
  font-weight: 700;
}

/* ---------------------------------------------------------------- 도장 */

.stamp {
  display: inline-grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 3px solid var(--stamp);
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px var(--paper), inset 0 0 0 4px var(--stamp);
  background: rgba(251, 252, 248, 0.6);
  color: var(--stamp);
  font-family: var(--font-cell);
  font-size: 15px;
  font-weight: 700;
  transform: rotate(-14deg);
}

html[lang='en'] .stamp {
  font-size: 13px;
}

.stamp.fresh {
  animation: stamp-in 0.38s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

@keyframes stamp-in {
  from {
    transform: rotate(-14deg) scale(1.9);
    opacity: 0;
  }
  to {
    transform: rotate(-14deg) scale(1);
    opacity: 1;
  }
}

.stamp-xl {
  position: absolute;
  top: 0;
  right: 0;
  width: 92px;
  height: 92px;
  font-size: 26px;
}

html[lang='en'] .stamp-xl {
  font-size: 22px;
}

.stamp-mini {
  display: inline-block;
  padding: 0 6px;
  border: 1.5px solid var(--stamp);
  color: var(--stamp-text);
  font-size: 12px;
  font-weight: 600;
  line-height: 20px;
}

/* ---------------------------------------------------------------- 버튼과 입력 */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1.5px solid transparent;
  border-radius: 0;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.btn-primary:hover:not(:disabled) {
  border-color: var(--ink-hover);
  background: var(--ink-hover);
}

.btn-outline {
  border-color: var(--grid);
  background: var(--paper);
  color: var(--grid-text);
}

.btn-outline:hover:not(:disabled) {
  background: var(--paper-2);
}

.btn-outline-ink {
  border-color: var(--ink);
  background: var(--paper);
  color: var(--ink);
}

.btn-outline-ink:hover:not(:disabled) {
  background: var(--paper-2);
}

.btn-ghost {
  padding: 0 10px;
  color: var(--ink-soft);
  font-weight: 400;
}

.btn-ghost:hover {
  color: var(--ink);
}

.btn-lg {
  min-height: 52px;
  padding: 0 28px;
  font-size: 16px;
}

.btn-block {
  width: 100%;
}

.seg-group {
  flex: 0 0 auto;
  display: inline-flex;
  border: 1px solid var(--grid);
}

.seg {
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  background: var(--paper);
  font-size: 14px;
  cursor: pointer;
}

.seg[aria-pressed='true'] {
  background: var(--ink);
  color: var(--paper);
}

.radio-seg {
  display: inline-flex;
  margin-top: 6px;
  border: 1px solid var(--grid);
}

.radio-seg label {
  position: relative;
  display: flex;
}

.radio-seg input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.radio-seg span {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 22px;
  background: var(--paper);
  font-size: 14px;
}

.radio-seg input:checked + span {
  background: var(--ink);
  color: var(--paper);
}

.radio-seg input:focus-visible + span {
  position: relative;
  z-index: 1;
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

.field {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1.5px solid var(--grid);
  border-radius: 0;
  background: var(--paper);
  font-family: var(--font-cell);
  font-size: 20px;
}

.field-code {
  font-family: var(--font-ui);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.num {
  width: 84px;
  height: 44px;
  padding: 0 10px;
  border: 1.5px solid var(--grid);
  border-radius: 0;
  background: var(--paper);
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}

.label {
  display: block;
  font-size: 14px;
  font-weight: 600;
}

.help {
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 13px;
}

.range-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.range-row output {
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

input[type='range'] {
  width: 100%;
  margin: 6px 0 0;
  accent-color: var(--ink);
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-size: 14px;
  cursor: pointer;
}

.check input {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--ink);
}

.fields-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px 24px;
}

.num-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.unit {
  color: var(--ink-soft);
  font-size: 14px;
}

details.more {
  padding-top: 12px;
  border-top: 1px solid var(--grid-soft);
}

details.more summary {
  min-height: 32px;
  color: var(--grid-text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.more-grid {
  margin-top: 10px;
}

/* ---------------------------------------------------------------- 상단 바 */

.topbar {
  flex: 0 0 auto;
  min-height: 64px;
  padding: 10px var(--pad);
  display: flex;
  align-items: center;
  gap: 10px 16px;
  border-bottom: 1px solid var(--line);
}

.room-meta {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 14px;
  overflow: hidden;
  white-space: nowrap;
}

.room-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 16px;
  font-weight: 600;
}

.meta {
  color: var(--ink-soft);
  font-size: 13px;
}

.meta b {
  color: var(--ink);
  letter-spacing: 0.08em;
}

.tagline {
  flex: 1 1 200px;
  color: var(--ink-soft);
  font-size: 14px;
}

.nick {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.nick .field {
  width: 180px;
  height: 44px;
  font-size: 18px;
}

.show-mobile {
  display: none !important;
}

.banner {
  flex: 0 0 auto;
  padding: 6px var(--pad);
  border-bottom: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink-soft);
  font-size: 13px;
}

.banner-warn {
  background: var(--mark);
  color: var(--ink);
}

/* ---------------------------------------------------------------- 본문 틀 */

.room-body,
.home-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  gap: var(--gap);
  padding: var(--gap) var(--pad) var(--pad);
}

.sheet {
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--grid-soft);
  border-top: 3px solid var(--grid);
  background: var(--paper);
}

.stage {
  flex: 1 1 auto;
}

.side {
  flex: 0 0 300px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.panel {
  border: 1px solid var(--grid-soft);
  background: var(--paper);
  padding: 14px 16px 6px;
}

.players-panel {
  flex: 0 1 auto;
}

.log-panel {
  flex: 1 1 0;
  min-height: 120px;
  padding: 0 4px;
}

.panel-title {
  color: var(--grid-text);
  font-size: 14px;
  font-weight: 600;
}

.panel-sub {
  color: var(--ink-soft);
  font-size: 12px;
}

.log-panel .panel-title {
  position: sticky;
  top: 0;
  padding-bottom: 6px;
  background: var(--desk);
}

.players {
  margin-top: 6px;
}

.player {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin: 0 -8px;
  padding: 8px;
  border-top: 1px solid var(--track);
}

.player.is-turn {
  background: var(--turn);
}

.seat {
  color: var(--ink-soft);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.pname {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
}

.pname b {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.tag {
  flex: 0 0 auto;
  padding: 0 6px;
  border: 1px solid currentColor;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 20px;
}

.tag-me {
  color: var(--ink);
}

.tag-turn {
  color: var(--grid-text);
}

.tag-off {
  border-style: dashed;
}

.score {
  font-size: 19px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.score small,
.rank-score small {
  margin-left: 2px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 400;
}

.log-list li {
  padding: 6px 0;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 13px;
}

.chips {
  display: none;
}

/* ---------------------------------------------------------------- 상태 줄 */

.status {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 28px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--grid-soft);
}

.status-text {
  flex: 1 1 240px;
  min-width: 0;
}

.round-line {
  color: var(--ink-soft);
  font-size: 13px;
}

.phase {
  margin-top: 2px;
  font-family: var(--font-cell);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
}

.answer-slot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.slot-label {
  color: var(--grid-text);
  font-size: 13px;
  font-weight: 600;
}

.slot-note {
  color: var(--ink-soft);
  font-size: 13px;
}

.timer {
  flex: 0 0 132px;
  text-align: right;
}

.timer-num {
  font-size: 40px;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.timer-unit {
  margin-left: 3px;
  font-size: 15px;
  font-weight: 500;
}

.timer-bar {
  height: 5px;
  margin-top: 8px;
  background: var(--track);
}

.timer-bar i {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--ink);
  transition: width 0.2s linear;
}

.timer-sub {
  margin-top: 6px;
  color: var(--ink-soft);
  font-size: 13px;
}

.timer.urgent .timer-num {
  color: var(--stamp-text);
}

.timer.urgent .timer-bar i {
  background: var(--stamp);
}

.invite {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.code-cells .cell {
  --cell: 46px;
  font-family: var(--font-ui);
  font-size: 23px;
  font-weight: 600;
}

/* ---------------------------------------------------------------- 힌트 목록 */

.stage-main {
  flex: 1 1 auto;
  padding: 0 24px 12px;
}

.hints-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  padding: 12px 0 8px;
  border-bottom: 1px solid var(--grid-soft);
  background: var(--paper);
}

.hh-left {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
}

.hh-meta {
  color: var(--ink-soft);
  font-size: 13px;
}

.pass-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 13px;
}

.pass-legend i {
  display: inline-block;
  width: 2px;
  height: 14px;
  background: var(--ink);
}

.hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin: 0 -12px;
  padding: 9px 12px;
  border-bottom: 1px dashed var(--grid-soft);
}

.hint.is-new {
  background: var(--mark);
}

.hint-no {
  flex: 0 0 40px;
  display: flex;
  flex-direction: column;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}

.hint-new {
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
}

.hint-cells {
  flex: 0 0 184px;
  min-width: 0;
  display: flex;
}

.meter {
  flex: 1 1 160px;
  position: relative;
  height: 10px;
  background: var(--track);
}

.meter-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
}

.meter-mark {
  position: absolute;
  top: -6px;
  bottom: -6px;
  width: 2px;
  margin-left: -1px;
  background: var(--ink);
}

.meter-pending {
  animation: pulse 1.1s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    background: var(--grid-soft);
  }
}

.pct {
  flex: 0 0 56px;
  text-align: right;
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pct-pending {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 500;
}

.stamp-slot {
  flex: 0 0 56px;
  display: flex;
  justify-content: center;
}

.hint-timeout {
  flex: 1 1 200px;
  color: var(--ink-soft);
  font-size: 14px;
}

.empty,
.wait {
  padding: 24px 0;
  color: var(--ink-soft);
  font-size: 15px;
}

/* ---------------------------------------------------------------- 나온 답 */

.guesses {
  flex: 0 0 auto;
  max-height: 88px;
  overflow-y: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 22px;
  padding: 10px 24px;
  border-top: 1px solid var(--grid-soft);
}

.guess {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

.guess-name {
  color: var(--ink-soft);
  font-size: 13px;
}

.guess s,
.recap-guess s {
  font-family: var(--font-cell);
  font-size: 20px;
  text-decoration-color: var(--stamp);
  text-decoration-thickness: 2px;
}

/* ---------------------------------------------------------------- 입력 줄과 아래 줄 */

.stage-bottom {
  flex: 0 0 auto;
}

.inputbar,
.bottombar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  padding: 14px 24px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--grid-soft);
  background: var(--paper-2);
}

.ib-label {
  flex: 0 0 auto;
  font-size: 15px;
  font-weight: 600;
}

.word-input {
  flex: 1 1 240px;
  min-width: 0;
  height: 52px;
  padding: 0 16px;
  border: 1.5px solid var(--grid);
  border-radius: 0;
  background: var(--paper);
  font-family: var(--font-cell);
  font-size: 23px;
}

.word-input:disabled {
  background: var(--track);
}

.input-msg {
  flex: 1 0 100%;
  min-height: 1.55em;
  color: var(--ink-soft);
  font-size: 13px;
}

.input-msg.is-error {
  color: var(--stamp-text);
  font-weight: 600;
}

.bottom-note {
  flex: 1 1 260px;
  color: var(--ink-soft);
  font-size: 14px;
}

/* ---------------------------------------------------------------- 단어 후보 */

.cand-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  padding-top: 16px;
}

.candidates {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 12px;
  padding-bottom: 12px;
}

.pick {
  width: 100%;
  min-height: 124px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 1.5px solid var(--grid-soft);
  border-radius: 0;
  background: var(--paper);
  text-align: left;
  cursor: pointer;
}

.pick:hover:not(:disabled) {
  border-color: var(--ink);
  background: var(--paper-2);
}

.pick:disabled {
  opacity: 0.5;
  cursor: default;
}

.pick .cells {
  --cell: 48px;
}

.pick .cells[data-fit],
.pick .wordbox {
  --cell: 48px;
}

/* ---------------------------------------------------------------- 라운드 결과, 최종 순위 */

.reveal {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px 36px;
  padding-top: 24px;
}

.reveal-word {
  position: relative;
  display: inline-flex;
  padding: 22px 52px 0 0;
}

.reveal-text {
  flex: 1 1 240px;
  min-width: 0;
}

.reveal-head {
  font-size: 17px;
  font-weight: 600;
}

.reveal-sub {
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 14px;
}

.recap {
  display: flex;
  flex-wrap: wrap;
  gap: 20px 40px;
  margin-top: 28px;
  padding-bottom: 16px;
}

.recap > div {
  flex: 1 1 300px;
  min-width: 0;
}

.recap-list {
  margin-top: 8px;
}

.recap-list li,
.recap-guess {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--grid-soft);
}

.recap-guesses {
  margin-top: 8px;
}

.recap-guess {
  align-items: baseline;
  gap: 8px;
}

.recap-guess b {
  font-family: var(--font-cell);
  font-size: 20px;
}

.recap-no {
  flex: 0 0 36px;
  color: var(--ink-soft);
  font-size: 13px;
}

.recap-pct {
  margin-left: auto;
  font-size: 17px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.recap-pct.is-pass {
  color: var(--stamp-text);
}

.results {
  padding: 16px 0;
}

.ranking {
  margin-top: 8px;
}

.rank-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 64px auto;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px dashed var(--grid-soft);
}

.rank-row.is-me {
  background: var(--turn);
}

.rank-no {
  padding-left: 6px;
  font-family: var(--font-cell);
  font-size: 22px;
  font-weight: 700;
}

.rank-name {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 17px;
  font-weight: 600;
}

.rank-score {
  padding-right: 6px;
  font-size: 24px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.note {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--paper-2);
  font-size: 14px;
}

/* ---------------------------------------------------------------- 대기실 설정 */

.settings {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px 0;
}

.settings-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px 40px;
}

.settings-top .range-field {
  flex: 1 1 280px;
}

.settings .fields-grid {
  padding-top: 16px;
  border-top: 1px solid var(--track);
}

.settings-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px 24px;
  margin-top: 4px;
}

.settings-list dt {
  color: var(--ink-soft);
  font-size: 13px;
}

.settings-list dd {
  font-size: 17px;
  font-weight: 600;
}

/* ---------------------------------------------------------------- 첫 화면 */

.home-tabs {
  display: none;
}

.home-body > .sheet {
  flex: 1 1 0;
}

.sheet-title {
  flex: 0 0 auto;
  padding: 16px 24px 8px;
  font-family: var(--font-cell);
  font-size: 22px;
  line-height: 1.3;
}

.form-scroll {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 8px 24px 16px;
}

.join-form {
  flex: 0 0 auto;
  padding: 8px 24px 16px;
  border-bottom: 1px solid var(--grid-soft);
}

.join-row {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.join-row .field {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
}

.join-row .btn {
  min-height: 48px;
}

.sub-title {
  flex: 0 0 auto;
  padding: 14px 24px 4px;
  color: var(--grid-text);
  font-size: 14px;
  font-weight: 600;
}

.room-list {
  flex: 1 1 auto;
  padding: 0 24px 12px;
}

.room-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--track);
}

.ri-main {
  flex: 1 1 auto;
  min-width: 0;
}

.ri-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.ri-meta {
  color: var(--ink-soft);
  font-size: 13px;
}

.invite-note {
  margin: 0 24px 8px;
  padding: 10px 12px;
  background: var(--mark);
  font-size: 14px;
}

.rules {
  flex: 0 1 280px;
  min-width: 200px;
  padding: 4px 4px 0;
}

.rules ol {
  margin-top: 8px;
}

.rules li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
}

.rules .cell {
  --cell: 28px;
  font-size: 15px;
}

/* ---------------------------------------------------------------- 알림과 기록 창 */

.toasts {
  position: fixed;
  z-index: 50;
  top: 72px;
  left: 50%;
  width: min(92vw, 440px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  padding: 10px 14px;
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  box-shadow: 0 6px 20px rgba(31, 43, 77, 0.18);
  pointer-events: auto;
}

.toast.is-error {
  background: var(--stamp-text);
}

.log-dialog {
  width: min(92vw, 420px);
  max-height: 80dvh;
  padding: 0;
  border: 1px solid var(--grid-soft);
  border-top: 3px solid var(--grid);
  background: var(--paper);
  color: var(--ink);
}

.log-dialog::backdrop {
  background: rgba(31, 43, 77, 0.35);
}

.dialog-inner {
  max-height: 80dvh;
  display: flex;
  flex-direction: column;
}

.dialog-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 16px;
  border-bottom: 1px solid var(--grid-soft);
}

.dialog-head h2 {
  flex: 1 1 auto;
  color: var(--grid-text);
  font-size: 15px;
  font-weight: 600;
}

.dialog-body {
  padding: 0 16px 12px;
}

/* ---------------------------------------------------------------- 좁은 화면 */

@media (max-width: 1100px) {
  .side {
    flex-basis: 260px;
  }
}

@media (max-width: 760px) {
  :root {
    --pad: 12px;
    --gap: 10px;
  }

  .hide-mobile {
    display: none !important;
  }

  .show-mobile {
    display: inline-flex !important;
  }

  .topbar {
    min-height: 52px;
    padding: 4px 6px 4px 12px;
    gap: 4px;
  }

  .brand .cell,
  .brand-lg .cell {
    --cell: 22px;
    font-size: 13px;
    font-weight: 400;
  }

  .room-meta {
    margin-left: 6px;
  }

  .room-meta .meta,
  .tagline {
    display: none;
  }

  .room-name {
    font-size: 14px;
  }

  .nick {
    flex: 1 1 auto;
    justify-content: flex-end;
  }

  .nick label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .nick .field {
    width: 100%;
    max-width: 170px;
    height: 40px;
    font-size: 16px;
  }

  .room-body,
  .home-body {
    padding: 0;
    gap: 0;
  }

  .stage,
  .home-body > .sheet {
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
  }

  .side {
    display: none;
  }

  .status {
    gap: 6px 12px;
    padding: 10px 14px 8px;
  }

  .status-text {
    flex: 1 1 0;
    order: 0;
  }

  .timer {
    flex: 0 0 auto;
    order: 1;
  }

  .answer-slot {
    flex: 1 0 100%;
    order: 2;
    gap: 8px;
  }

  .answer-slot.is-secret {
    display: none;
  }

  .answer-slot .cells-md {
    --cell: 34px;
  }

  .phase {
    font-size: 19px;
  }

  .round-line {
    font-size: 12px;
  }

  .timer-num {
    font-size: 32px;
  }

  .timer-bar {
    width: 80px;
    margin-left: auto;
  }

  .invite {
    flex: 1 0 100%;
    order: 2;
  }

  .code-cells .cell {
    --cell: 38px;
    font-size: 19px;
  }

  .chips {
    flex: 0 0 auto;
    display: flex;
    gap: 6px;
    padding: 0 14px 8px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .chip {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border: 1.5px solid var(--grid-soft);
    background: var(--paper);
    font-size: 13px;
    white-space: nowrap;
  }

  .chip.is-me {
    border-color: var(--ink);
  }

  .chip.is-turn {
    border-color: var(--grid);
    background: var(--turn);
  }

  .chip.is-off {
    border-style: dashed;
  }

  .chip b {
    font-weight: 600;
  }

  .chip-score {
    font-size: 16px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
  }

  .chip-tag {
    color: var(--grid-text);
    font-size: 11px;
  }

  .stage-main {
    padding: 0 14px 8px;
    border-top: 1px solid var(--grid-soft);
  }

  .hints-head {
    padding: 8px 0 6px;
  }

  .hh-meta,
  .pass-legend {
    font-size: 12px;
  }

  .hint {
    gap: 6px 10px;
    margin: 0 -14px;
    padding: 8px 14px;
  }

  .hint-no {
    flex-basis: 32px;
    font-size: 12px;
  }

  .hint-new {
    font-size: 11px;
  }

  .hint-cells {
    flex: 1 1 auto;
  }

  .hint-cells .cells {
    --cell: 34px;
  }

  .hint-cells .cells[data-fit='1'] {
    --cell: 30px;
  }

  .hint-cells .cells[data-fit='2'] {
    --cell: 26px;
  }

  .hint-cells .cells[data-fit='3'] {
    --cell: 22px;
  }

  .hint-cells .wordbox,
  .pick .wordbox {
    --cell: 36px;
  }

  .answer-slot .wordbox {
    --cell: 34px;
  }

  .meter {
    flex: 0 0 calc(100% - 94px);
    order: 5;
    height: 6px;
    margin: 0 52px 0 42px;
  }

  .banner {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 12px;
  }

  .meter-mark {
    top: -4px;
    bottom: -4px;
  }

  .pct {
    flex: 0 0 auto;
    font-size: 18px;
  }

  .stamp-slot {
    flex: 0 0 42px;
  }

  .stamp {
    width: 42px;
    height: 42px;
    border-width: 2.5px;
    font-size: 13px;
  }

  html[lang='en'] .stamp {
    font-size: 11px;
  }

  .stamp-xl {
    width: 72px;
    height: 72px;
    font-size: 21px;
  }

  .guesses {
    flex-wrap: nowrap;
    gap: 14px;
    max-height: none;
    padding: 8px 14px;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    scrollbar-width: none;
  }

  .guess s {
    font-size: 17px;
  }

  .inputbar,
  .bottombar {
    gap: 6px 8px;
    padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
  }

  .ib-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .word-input {
    flex: 1 1 0;
    height: 50px;
    padding: 0 12px;
    font-size: 20px;
  }

  .inputbar .btn-lg {
    min-height: 50px;
    padding: 0 18px;
    font-size: 15px;
  }

  .input-msg {
    font-size: 12px;
  }

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

  .pick {
    min-height: 92px;
    padding: 12px;
  }

  .pick .cells,
  .pick .cells[data-fit] {
    --cell: 36px;
  }

  .reveal-word .cells-xl {
    --cell: 64px;
  }

  .reveal-word {
    padding: 18px 40px 0 0;
  }

  .rank-row {
    grid-template-columns: 48px minmax(0, 1fr) 48px auto;
  }

  .home-tabs {
    flex: 0 0 auto;
    display: flex;
    border-bottom: 1px solid var(--line);
  }

  .home-tabs button {
    flex: 1 1 0;
    min-height: 44px;
    border: 0;
    border-bottom: 3px solid transparent;
    background: transparent;
    color: var(--ink-soft);
    font-size: 14px;
    cursor: pointer;
  }

  .home-tabs button[aria-selected='true'] {
    border-bottom-color: var(--grid);
    color: var(--ink);
    font-weight: 600;
  }

  .home-body > * {
    display: none;
  }

  .home[data-tab='create'] .panel-create,
  .home[data-tab='join'] .panel-join {
    flex: 1 1 auto;
    display: flex;
  }

  .home[data-tab='rules'] .panel-rules {
    flex: 1 1 auto;
    display: block;
    min-width: 0;
    padding: 12px 14px;
  }

  .sheet-title {
    display: none;
  }

  .form-scroll {
    padding-top: 14px;
  }

  .join-form {
    padding-top: 14px;
  }

  .toasts {
    top: 58px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stamp.fresh,
  .meter-pending {
    animation: none;
  }

  .timer-bar i {
    transition: none;
  }
}
