/* 낮의 콘크리트 주차장 팔레트 */
:root {
  --font-body: 'IBM Plex Sans KR', 'Noto Sans SC', 'Noto Sans Devanagari', 'Noto Sans Bengali', 'Noto Sans Arabic', system-ui,
    -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --page: #e7e3d9;
  --page-2: #f2efe8;
  --ink: #1c1f22;
  --ink-soft: #5c605f;
  --ink-faint: #8c8f8b;
  --rule: #cfcabd;
  --asphalt: #5e656b;
  --asphalt-2: #535a60;
  --paint: #efede4;
  --paint-soft: rgba(239, 237, 228, 0.34);
  --hero: #f2b705;
  --hero-deep: #c98f00;
  --hero-glow: rgba(242, 183, 5, 0.3);
  --curb: #3c4247;
  --panel: #fbf9f4;
  --panel-line: #dfd9cb;
  --shadow: rgba(28, 31, 34, 0.18);
  --ok: #4a7c59;
  --alert: #b4553f;
}
/* 같은 주차장의 밤 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --page: #131619;
    --page-2: #1a1e22;
    --ink: #e7e9e4;
    --ink-soft: #a0a5a3;
    --ink-faint: #6e7472;
    --rule: #2a2f34;
    --asphalt: #2c3238;
    --asphalt-2: #252a30;
    --paint: #d8d6cc;
    --paint-soft: rgba(216, 214, 204, 0.22);
    --hero: #f7c324;
    --hero-deep: #b98a05;
    --hero-glow: rgba(247, 195, 36, 0.26);
    --curb: #171b1f;
    --panel: #1c2126;
    --panel-line: #2e343a;
    --shadow: rgba(0, 0, 0, 0.45);
    --ok: #69a97c;
    --alert: #e0907a;
  }
}
:root[data-theme='dark'] {
  --page: #131619;
  --page-2: #1a1e22;
  --ink: #e7e9e4;
  --ink-soft: #a0a5a3;
  --ink-faint: #6e7472;
  --rule: #2a2f34;
  --asphalt: #2c3238;
  --asphalt-2: #252a30;
  --paint: #d8d6cc;
  --paint-soft: rgba(216, 214, 204, 0.22);
  --hero: #f7c324;
  --hero-deep: #b98a05;
  --hero-glow: rgba(247, 195, 36, 0.26);
  --curb: #171b1f;
  --panel: #1c2126;
  --panel-line: #2e343a;
  --shadow: rgba(0, 0, 0, 0.45);
  --ok: #69a97c;
  --alert: #e0907a;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  margin: 0;
  height: 100%;
  overscroll-behavior: none;
}
body {
  background: var(--page);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

#app {
  height: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}
.screen {
  display: none;
  flex-direction: column;
  height: 100%;
}
#app[data-screen='home'] .screen[data-name='home'],
#app[data-screen='solo'] .screen[data-name='solo'],
#app[data-screen='rank'] .screen[data-name='rank'],
#app[data-screen='select'] .screen[data-name='select'],
#app[data-screen='vs-menu'] .screen[data-name='vs-menu'],
#app[data-screen='vs-room'] .screen[data-name='vs-room'],
#app[data-screen='vs-watch'] .screen[data-name='vs-watch'],
#app[data-screen='play'] .screen[data-name='play'] {
  display: flex;
}

/* 표지판 서체: 숫자와 라벨 */
.sign-face,
.eyebrow,
.num,
.tier,
.meter .k,
.meter .v,
.chip,
.group h3,
.stamp {
  font-family: Archivo, var(--font-body);
  font-variant-numeric: tabular-nums;
}
.eyebrow {
  font-variation-settings: 'wdth' 78;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.sign-face {
  font-variation-settings: 'wdth' 82;
  font-weight: 700;
  letter-spacing: 0.06em;
}

/* ---------- 공통 버튼 ---------- */
button.ctl {
  flex: 1;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 4px;
  padding: 11px 6px;
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s, transform 0.06s;
}
button.ctl:hover {
  border-color: var(--ink-faint);
}
button.ctl:active {
  transform: translateY(1px);
}
button.ctl:disabled {
  opacity: 0.4;
  cursor: default;
  transform: none;
}
button.ctl:focus-visible {
  outline: 2.5px solid var(--hero);
  outline-offset: 2px;
}
button.ctl.primary {
  background: var(--hero);
  border-color: var(--hero-deep);
  color: #1c1f22;
  font-weight: 600;
}
.icon-btn {
  width: 34px;
  height: 34px;
  flex: none;
  border: 1px solid transparent;
  border-radius: 4px;
  background: none;
  color: var(--ink-soft);
  font-size: 18px;
  cursor: pointer;
}
.icon-btn:active {
  background: var(--panel);
}
.spacer {
  flex: 1;
}

/* ---------- 홈 ---------- */
.home-top {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  padding: 24px;
}
.home-mark {
  width: 132px;
  height: 66px;
  margin-bottom: 18px;
  filter: drop-shadow(0 6px 10px var(--shadow));
}
.home-mark svg {
  display: block;
  width: 100%;
  height: 100%;
}
h1 {
  margin: 2px 0 0;
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.tagline {
  margin: 4px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
}
.home-progress {
  padding: 26px 20px 0;
}
.progress-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 7px;
}
#home-count {
  font-size: 13px;
  color: var(--ink-soft);
}
.bar {
  height: 3px;
  background: var(--rule);
  overflow: hidden;
}
.bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--hero-deep);
  transition: width 0.4s ease;
}
.home-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 22px 20px calc(28px + env(safe-area-inset-bottom));
}

.home-modes {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 26px 20px calc(30px + env(safe-area-inset-bottom));
}
.home-foot {
  margin: 0;
  padding: 0 20px calc(18px + env(safe-area-inset-bottom));
  text-align: center;
  font-size: 12px;
}
.home-foot a {
  color: var(--ink-faint);
}
.mode-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
  padding: 18px 18px 16px;
  font-family: var(--font-body);
  text-align: start;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 5px;
  cursor: pointer;
}
.mode-card b {
  font-size: 19px;
  font-weight: 700;
}
.mode-card span {
  font-size: 12px;
  color: var(--ink-soft);
}
.mode-card.primary {
  background: var(--hero);
  border-color: var(--hero-deep);
}
.mode-card.primary span {
  color: var(--ink);
  opacity: 0.75;
}
.mode-card:active {
  transform: translateY(1px);
}
.mode-card:focus-visible {
  outline: 2.5px solid var(--ink);
  outline-offset: 2px;
}

.rank-mine {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.rank-mine strong {
  font-size: 30px;
  line-height: 1;
  color: var(--hero-deep);
}
.rank-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.rank-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--page-2);
}
.rank-list li.me {
  border-color: var(--hero-deep);
  background: color-mix(in srgb, var(--hero) 22%, var(--page-2));
}
.rank-list .n {
  flex: none;
  width: 1.6em;
  font-family: Archivo, var(--font-body);
  font-variation-settings: 'wdth' 80;
  font-weight: 800;
  font-size: 15px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.rank-list li:nth-child(-n + 3) .n {
  color: var(--hero-deep);
}
.rank-list b {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rank-list .time {
  flex: none;
  font-family: Archivo, var(--font-body);
  font-variation-settings: 'wdth' 85;
  font-weight: 700;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

/* ---------- 상단 바 ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px 6px;
}
.play-bar {
  align-items: flex-end;
}
.lot-id {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}
.lot-id .row {
  display: flex;
  align-items: baseline;
  gap: 7px;
}
.lot-id .num {
  font-variation-settings: 'wdth' 80;
  font-weight: 800;
  font-size: 26px;
  line-height: 0.95;
}
.tier {
  font-variation-settings: 'wdth' 80;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  padding: 3px 6px;
  border-radius: 3px;
  border: 1px solid currentColor;
}
.tier[data-t='easy'] {
  color: #6e8b6b;
}
.tier[data-t='medium'] {
  color: #4f7f9b;
}
.tier[data-t='hard'] {
  color: #b4763f;
}
.tier[data-t='expert'] {
  color: #9c5a4a;
}

.meters {
  display: flex;
  border: 1px solid var(--rule);
  border-radius: 4px;
  overflow: hidden;
  background: var(--panel);
}
.meter {
  padding: 5px 10px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 52px;
}
.meter + .meter {
  border-left: 1px solid var(--rule);
}
.meter .k {
  font-family: var(--font-body);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
}
.meter .v {
  font-variation-settings: 'wdth' 82;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}
.meter.live .v {
  color: var(--hero-deep);
}

/* ---------- 주차장 ---------- */
.lot-area {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 6px 16px;
}
.lot-wrap {
  position: relative;
  width: var(--board-w);
  flex: none;
  /* 판 밖으로 나가는 램프와 EXIT 표지까지 포함해 가운데로 보이도록 */
  margin-right: calc(var(--cell) * 0.62 + 21px);
}
.lot {
  position: relative;
  width: var(--board-w);
  height: var(--board-w);
  background: linear-gradient(180deg, var(--asphalt) 0%, var(--asphalt-2) 100%);
  border-radius: 5px;
  box-shadow: 0 10px 26px -12px var(--shadow), inset 0 0 0 1px rgba(0, 0, 0, 0.22);
  touch-action: none;
  overflow: visible;
}
.paint {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 5px;
  overflow: hidden;
}
.paint i {
  position: absolute;
  background: var(--paint-soft);
}
.paint i.v {
  width: 2px;
  top: 6%;
  bottom: 6%;
}
.paint i.h {
  height: 2px;
  left: 6%;
  right: 6%;
}

.exit-ramp {
  position: absolute;
  left: var(--board-w);
  top: calc(var(--cell) * 2);
  width: calc(var(--cell) * 0.62);
  height: var(--cell);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.exit-ramp .chev {
  width: 100%;
  height: 62%;
  background: repeating-linear-gradient(115deg, var(--hero) 0 6px, transparent 6px 12px);
  opacity: 0.85;
  border-radius: 2px;
}
.exit-label {
  position: absolute;
  left: calc(var(--board-w) + var(--cell) * 0.62 + 7px);
  top: calc(var(--cell) * 2);
  height: var(--cell);
  display: flex;
  align-items: center;
  font-family: Archivo, var(--font-body);
  font-variation-settings: 'wdth' 76;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--hero-deep);
  writing-mode: vertical-rl;
  pointer-events: none;
}

.car {
  position: absolute;
  cursor: grab;
  border: 0;
  padding: 0;
  background: none;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.35));
  transition: left 0.19s cubic-bezier(0.2, 0.9, 0.25, 1),
    top 0.19s cubic-bezier(0.2, 0.9, 0.25, 1);
  touch-action: none;
}
.car:active {
  cursor: grabbing;
}
.car.dragging {
  transition: none;
  z-index: 20;
  filter: drop-shadow(0 7px 11px rgba(0, 0, 0, 0.45));
}
.car svg {
  display: block;
  width: 100%;
  height: 100%;
}
.car:focus-visible {
  outline: 2.5px solid var(--hero);
  outline-offset: 3px;
  border-radius: 4px;
}
.car.hero {
  z-index: 10;
}
.car::after {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 9px;
  box-shadow: 0 0 0 2px var(--hero-glow);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.car.hint::after {
  opacity: 1;
}
.car.nudge {
  animation: nudge 0.5s ease-in-out 2;
}
@keyframes nudge {
  0%,
  100% {
    transform: translate(0, 0);
  }
  55% {
    transform: translate(var(--nx, 0px), var(--ny, 0px));
  }
}
.car.out {
  transition: left 0.62s cubic-bezier(0.55, 0, 0.85, 0.35), opacity 0.3s 0.34s;
  opacity: 0;
}
.car.stuck {
  animation: stuck 0.3s ease-in-out;
}
@keyframes stuck {
  0%,
  100% {
    transform: translate(0, 0);
  }
  25% {
    transform: translate(var(--sx, 0px), var(--sy, 0px));
  }
  75% {
    transform: translate(calc(var(--sx, 0px) * -1), calc(var(--sy, 0px) * -1));
  }
}

/* ---------- 클리어 ---------- */
.win {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--page) 78%, transparent);
  backdrop-filter: blur(2px);
  border-radius: 5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 30;
}
.win.on {
  opacity: 1;
  pointer-events: auto;
}
.win .card {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
}
.win .stamp {
  font-variation-settings: 'wdth' 78;
  font-size: clamp(28px, 7.5vw, 40px);
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--hero-deep);
  transform: rotate(-3deg);
  border: 3px solid var(--hero-deep);
  border-radius: 5px;
  padding: 5px 16px 7px;
}
.win .detail {
  font-size: 13px;
  color: var(--ink-soft);
}
.win .detail b {
  color: var(--ink);
  font-weight: 600;
}

/* ---------- 조작부 ---------- */
.controls {
  display: flex;
  gap: 8px;
  padding: 10px 16px 0;
}
.hintline {
  margin: 11px 16px 0;
  padding: 11px 0 calc(14px + env(safe-area-inset-bottom));
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--ink-faint);
  border-top: 1px solid var(--rule);
}
.hintline b {
  color: var(--ink-soft);
  font-weight: 600;
}

/* ---------- 레벨 목록 ---------- */
.sheet {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 15px;
  padding: 8px 16px calc(24px + env(safe-area-inset-bottom));
}
.group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.group h3 {
  margin: 0;
  font-variation-settings: 'wdth' 78;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.chips {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}
.chip {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  font-variation-settings: 'wdth' 82;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid var(--panel-line);
  border-radius: 4px;
  background: var(--page-2);
  color: var(--ink-soft);
  cursor: pointer;
  position: relative;
  transition: border-color 0.14s, background 0.14s;
}
.chip:hover {
  border-color: var(--ink-faint);
}
.chip:focus-visible {
  outline: 2.5px solid var(--hero);
  outline-offset: 2px;
}
.chip.done {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 45%, transparent);
}
.chip.done::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--ok);
}
.chip.cur {
  background: var(--hero);
  border-color: var(--hero-deep);
  color: #1c1f22;
}
.chip.cur::after {
  background: #1c1f22;
}
.chip.locked {
  color: var(--ink-faint);
  opacity: 0.45;
  cursor: default;
}

@media (prefers-reduced-motion: reduce) {
  .car,
  .car.out,
  .win,
  .bar span {
    transition-duration: 0.01ms;
  }
  .car.nudge,
  .car.stuck {
    animation: none;
  }
}

button.ctl.wide {
  flex: 1 1 100%;
}

/* ---------- 혼자 하기 / 대결 모드 전환 ---------- */
.vs-only {
  display: none;
}
#app[data-mode='versus'] .solo-only {
  display: none;
}
#app[data-mode='versus'] .vs-head {
  display: flex;
}
#app[data-mode='versus'] p.vs-only {
  display: block;
}
#app[data-mode='versus'] button.vs-only:not([hidden]) {
  display: block;
}

/* ---------- 대결: 메뉴 · 대기실 ---------- */
.vs-scroll {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 8px 16px calc(24px + env(safe-area-inset-bottom));
}
.vs-rule {
  margin: 0;
  font-size: 13px;
  line-height: 1.65;
  color: var(--ink-soft);
}
.vs-rule b {
  color: var(--ink);
  font-weight: 600;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field[hidden],
.vs-empty[hidden],
.vs-toast[hidden],
.vs-overlay[hidden],
#vs-wait[hidden] {
  display: none;
}
.field input,
.code-input {
  width: 100%;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 4px;
  padding: 11px 12px;
  -webkit-user-select: text;
  user-select: text;
}
.field input:focus-visible,
.code-input:focus-visible {
  outline: 2.5px solid var(--hero);
  outline-offset: 1px;
}
.vs-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 5px;
}
.vs-card h3 {
  margin: 0;
  font-family: Archivo, var(--font-body);
  font-variation-settings: 'wdth' 78;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--ink-faint);
}
.vs-card .field input,
.vs-card .code-input {
  background: var(--page-2);
}
.vs-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.icon-btn.small {
  width: 30px;
  height: 30px;
  font-size: 16px;
}
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-soft);
}
.check input {
  accent-color: var(--hero-deep);
  width: 16px;
  height: 16px;
}
.vs-card .row {
  display: flex;
  gap: 8px;
}
.code-input {
  flex: 1;
  min-width: 0;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.3em;
  font-family: Archivo, var(--font-body);
  font-variation-settings: 'wdth' 82;
  font-weight: 700;
}
.vs-card .row button.ctl {
  flex: none;
  padding-left: 22px;
  padding-right: 22px;
}
.vs-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.vs-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--page-2);
}
.vs-list .who {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.vs-list .who b {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vs-list .who span {
  font-size: 12px;
  color: var(--ink-faint);
}
.vs-list .actions {
  display: flex;
  flex: none;
  gap: 6px;
}
.room-switch {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.room-switch [hidden] {
  display: none;
}
.vs-list li button.ctl {
  flex: none;
  padding: 9px 16px;
}
.vs-empty {
  margin: 0;
  font-size: 13px;
  color: var(--ink-faint);
}
.vs-msg {
  margin: 0;
  min-height: 1.5em;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
}

.room-code {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 14px 14px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 5px;
}
.room-code strong {
  font-size: 44px;
  line-height: 1;
  letter-spacing: 0.2em;
  padding-left: 0.2em;
  color: var(--hero-deep);
}
.room-kind {
  font-size: 12px;
  color: var(--ink-faint);
  text-align: center;
}
.room-code button.ctl {
  flex: none;
  align-self: stretch;
}
.slots {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.slot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 5px;
}
.slot b {
  font-size: 16px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.slot .tag {
  flex: none;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--hero-deep);
}
.slot.empty {
  border-style: dashed;
  background: transparent;
}
.slot.empty b {
  font-weight: 400;
  color: var(--ink-faint);
}
.slot.away {
  opacity: 0.55;
}
#room-start {
  flex: none;
  padding: 14px 6px;
  font-size: 15px;
}

/* ---------- 대결: 플레이 ---------- */
.vs-head {
  flex: 1;
  min-width: 0;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
}
.vs-score {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.vs-score.opp {
  align-items: flex-end;
  text-align: end;
}
.vs-score .k,
.vs-timer .k {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-faint);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vs-score .v {
  font-family: Archivo, var(--font-body);
  font-variation-settings: 'wdth' 80;
  font-size: 30px;
  font-weight: 800;
  line-height: 0.95;
  font-variant-numeric: tabular-nums;
}
.vs-score.opp .v {
  color: var(--ink-soft);
}
.vs-timer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: none;
}
.vs-timer .v {
  font-size: 26px;
  line-height: 1;
  letter-spacing: 0.04em;
}
.vs-timer .v.low {
  color: var(--alert);
}

.vs-overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  border-radius: 5px;
  background: color-mix(in srgb, var(--page) 82%, transparent);
  backdrop-filter: blur(3px);
}
.vs-overlay.solid {
  background: var(--page);
  backdrop-filter: none;
}
.vs-overlay .card {
  width: 100%;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}
.vs-overlay .kicker {
  margin: 0;
  font-size: 13px;
  color: var(--ink-soft);
}
.vs-overlay .count {
  font-family: Archivo, var(--font-body);
  font-variation-settings: 'wdth' 80;
  font-size: 96px;
  font-weight: 800;
  line-height: 1;
  color: var(--hero-deep);
}
.vs-overlay .stamp {
  font-family: Archivo, var(--font-body);
  font-variation-settings: 'wdth' 78;
  font-size: clamp(26px, 7vw, 36px);
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  transform: rotate(-3deg);
  border: 3px solid currentColor;
  border-radius: 5px;
  padding: 5px 16px 7px;
}
.vs-overlay .stamp.win {
  color: var(--hero-deep);
}
.vs-overlay .detail {
  font-size: 14px;
  font-weight: 500;
}
.vs-overlay .small {
  margin: 0;
  font-size: 12px;
  color: var(--ink-soft);
}
.vs-overlay .btn-row {
  display: flex;
  gap: 8px;
  align-self: stretch;
  justify-content: center;
  margin-top: 4px;
}
.vs-overlay .btn-row button.ctl {
  flex: 1;
  max-width: 180px;
}

.vs-toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 60;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--page);
  background: var(--ink);
  box-shadow: 0 8px 24px -8px var(--shadow);
}

/* ---------- 관전 ---------- */
.screen[data-name='vs-watch'] .vs-head {
  display: flex;
}
.vs-timer .watchers {
  font-size: 11px;
  color: var(--ink-faint);
}
.vs-timer .watchers[hidden] {
  display: none;
}
.watch-area {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
  gap: 10px;
  padding: 6px 16px;
}
.watch-board {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.watch-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  height: 22px;
  font-size: 13px;
}
.watch-label b {
  max-width: 70%;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.watch-label .tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--hero-deep);
}
.watch-board .car {
  pointer-events: none;
  cursor: default;
  transition: left 0.25s cubic-bezier(0.2, 0.9, 0.25, 1), top 0.25s cubic-bezier(0.2, 0.9, 0.25, 1);
}

/* ---------- 언어 ---------- */
.lang-btn {
  display: none;
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  inset-inline-end: 12px;
  z-index: 20;
  padding: 7px 12px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-soft);
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 4px;
  cursor: pointer;
}
.lang-btn:focus-visible,
.lang-item:focus-visible {
  outline: 2.5px solid var(--hero);
  outline-offset: 2px;
}
#app[data-screen='home'] .lang-btn,
#app[data-screen='solo'] .lang-btn,
#app[data-screen='vs-menu'] .lang-btn {
  display: block;
}
.lang-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: color-mix(in srgb, var(--ink) 45%, transparent);
}
.lang-modal[hidden] {
  display: none;
}
.lang-sheet {
  width: 100%;
  max-width: 560px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 14px 16px calc(18px + env(safe-area-inset-bottom));
  background: var(--page);
  border-radius: 12px 12px 0 0;
}
.lang-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.lang-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}
.lang-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.lang-item {
  width: 100%;
  padding: 13px 12px;
  font-family: var(--font-body);
  font-size: 15px;
  text-align: start;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 4px;
  cursor: pointer;
}
.lang-item[aria-current='true'] {
  font-weight: 600;
  color: #1c1f22;
  background: var(--hero);
  border-color: var(--hero-deep);
}

/* ---------- 오른쪽에서 왼쪽으로 읽는 언어 (아랍어) ---------- */
/* 퍼즐 판은 출구가 항상 오른쪽이어야 해서 뒤집지 않는다 */
html[dir='rtl'] .lot-wrap {
  direction: ltr;
}
/* 뒤로 가는 화살표는 읽는 방향 반대쪽을 가리켜야 한다 */
html[dir='rtl'] [data-back],
html[dir='rtl'] #room-leave,
html[dir='rtl'] #watch-leave {
  transform: scaleX(-1);
}

/* 글자 사이 간격을 벌리거나 대문자로 바꾸면 이어 쓰는 글자(아랍어·인도계 문자)가 깨진다 */
html[lang='ar'] *,
html[lang='hi'] *,
html[lang='bn'] * {
  letter-spacing: normal !important;
  text-transform: none !important;
}

/* ---------- 팀 대결 ---------- */
.seg {
  display: flex;
  gap: 6px;
}
.seg-btn {
  flex: 1;
  min-width: 0;
  padding: 9px 4px;
  font-family: Archivo, var(--font-body);
  font-variation-settings: 'wdth' 82;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  background: var(--page-2);
  border: 1px solid var(--rule);
  border-radius: 4px;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.seg-btn[aria-checked='true'] {
  color: var(--ink);
  background: var(--hero);
  border-color: var(--hero-deep);
}
.seg-btn:focus-visible {
  outline: 2.5px solid var(--hero);
  outline-offset: 1px;
}
.vs-hint {
  margin: 0;
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink-faint);
}
.vs-hint[hidden],
.w-rows[hidden] {
  display: none;
}
.room-teams.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: start;
}
.team-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.team-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-faint);
}
.team-head b {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}
.team-b .team-head b {
  color: var(--ink-soft);
}
.team-col .slot {
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px;
  min-width: 0;
}
.team-col .slot b {
  max-width: 100%;
  font-size: 14px;
}
.team-col button.ctl {
  padding: 9px 6px;
  font-size: 12px;
}
.vs-score .k {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  line-height: 1.2;
  white-space: normal;
  overflow-wrap: anywhere;
}
.w-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 2px 16px 4px;
}
.w-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.w-team {
  flex: none;
  min-width: 3.2em;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-faint);
}
.w-chip {
  max-width: 100%;
  padding: 5px 10px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-soft);
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 999px;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.w-chip.on {
  color: var(--ink);
  background: var(--hero);
  border-color: var(--hero-deep);
}
.w-chip.away {
  opacity: 0.55;
}
.w-chip:focus-visible {
  outline: 2.5px solid var(--hero);
  outline-offset: 1px;
}
