:root {
  --bg: #ffffff;
  --ink: #101216;
  --muted: #6b7280;
  --line: #e4e7ee;
  --stage: #f4f6fa;
  --grid: 24, 34, 64; /* 격자 선 색 (r, g, b) */
  --accent: #2f5bff;
  --accent-soft: #eaf0ff;
  --ok: #00a36f;
  --warn: #e5484d; /* 시간이 얼마 안 남았을 때, 타임어택 미달 */
  --radius: 22px;
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
    "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  word-break: keep-all;
}

button { font-family: inherit; }

.app {
  max-width: 560px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 16px 16px 28px;
  display: flex;
  flex-direction: column;
}

/* ───── 상단 ───── */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px; /* 진행 표시가 있든 없든 높이가 같게 */
  position: relative; /* 로비에서 아주 크게 키운 그림이 제목과 로그인 버튼을 덮지 않게 */
  z-index: 2;
  padding: 2px 2px 16px;
}
.brand {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.4px;
}

/* 게임 중에만 보이는 진행 표시: 몇 번째 문제인지 + 지금까지 쌓인 점수 */
.status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  line-height: 1;
  letter-spacing: -0.3px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.stage-no {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--stage);
  font-weight: 800;
}
.running { font-weight: 800; }
.time { min-width: 2.6em; text-align: right; font-weight: 800; color: var(--accent); }
.time.low { color: var(--warn); }

/* 계정 버튼: 로그인 전에는 "로그인", 로그인하면 포인트와 이름. 게임 중에는 진행 표시에 자리를 내준다 */
.account {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: -0.2px;
  white-space: nowrap;
  cursor: pointer;
}
.account b { color: var(--accent); font-weight: 800; font-variant-numeric: tabular-nums; }
body[data-screen="play"] .account { display: none; }

.screen { display: flex; flex-direction: column; flex: 1; }

.question {
  margin: 0 2px 16px;
  font-size: 23px;
  line-height: 1.34;
  font-weight: 500;
  letter-spacing: -0.7px;
  min-height: 2.68em;
}
.question b { font-weight: 800; }
.question .t { color: var(--accent); }

/* ───── 무대 ─────
 * 격자는 3단계가 겹쳐 있고, 확대·축소에 따라 game.js가 칸 크기(--g1~3)와
 * 진하기(--a1~2), 기준점(--gx, --gy)을 바꾼다.
 */
.stage {
  --g1: 20px; --g2: 100px; --g3: 500px;
  --a1: 0.05; --a2: 0.09; --a3: 0.14;
  --gx: 0px; --gy: 0px;
  position: relative;
  height: clamp(280px, 46dvh, 440px);
  background-color: var(--stage);
  background-image:
    linear-gradient(rgba(var(--grid), var(--a3)) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--grid), var(--a3)) 1px, transparent 1px),
    linear-gradient(rgba(var(--grid), var(--a2)) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--grid), var(--a2)) 1px, transparent 1px),
    linear-gradient(rgba(var(--grid), var(--a1)) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--grid), var(--a1)) 1px, transparent 1px);
  background-size:
    var(--g3) var(--g3), var(--g3) var(--g3),
    var(--g2) var(--g2), var(--g2) var(--g2),
    var(--g1) var(--g1), var(--g1) var(--g1);
  background-position: var(--gx) var(--gy);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}
.layer { position: absolute; inset: 0; }

/* 바닥선 아래는 이름표 자리 */
.ground {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  border-top: 2px solid var(--ink);
  background: var(--bg);
}

.obj { position: absolute; }
.obj svg { display: block; width: 100%; height: 100%; overflow: visible; }
.obj svg * {
  vector-effect: non-scaling-stroke;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
  fill: var(--fill, none);
}
.obj svg .l { fill: none; }

.obj.ref { color: var(--ink); --fill: #ffffff; }
.obj.target { color: var(--accent); --fill: var(--accent-soft); cursor: nesw-resize; }
.obj.target svg * { stroke-width: 2.25; }
.obj.target.locked { cursor: inherit; opacity: 0.5; }

.obj.ghost { color: var(--ok); pointer-events: none; }
.obj.ghost svg * { fill: none; stroke-width: 2.25; stroke-dasharray: 7 5; }

.handle {
  position: absolute;
  top: -19px;
  right: -19px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 17 17 7M11 7h6v6M13 17H7v-6'/%3E%3C/svg%3E")
    center / 18px no-repeat;
  border: 3px solid #fff;
  box-shadow: 0 3px 10px rgba(16, 24, 64, 0.28);
  cursor: nesw-resize;
}
.handle::after {
  content: "";
  position: absolute;
  inset: -10px; /* 손가락으로 잡기 쉽게 */
}

.tag {
  position: absolute;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  letter-spacing: -0.3px;
}
.tag.ref { color: var(--ink); }
.tag.target { color: var(--accent); }
.tag .ans { color: var(--ok); margin-left: 6px; }

/* 확대·축소 버튼: 위쪽 여백(54px) 안에 가로로 둔다. 왼쪽에 붙은 검은 물체를 가리지 않게. */
.zoom {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  gap: 6px;
}
.zoom button {
  width: 38px;
  height: 38px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(16, 24, 64, 0.08);
  cursor: pointer;
  touch-action: manipulation;
}
.zoom button:active { background: var(--stage); }
.zoom svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hint {
  position: absolute;
  top: 12px;
  left: 148px;
  right: 14px;
  display: flex;
  justify-content: center;
  pointer-events: none;
}
.hint span {
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
}

/* 타임어택: 무대 위쪽 가장자리의 남은 시간 막대 */
.timebar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: rgba(var(--grid), 0.08);
  pointer-events: none;
}
.timebar i { display: block; height: 100%; background: var(--accent); }
.timebar.low i { background: var(--warn); }

/* ───── 버튼 ───── */
.controls { padding-top: 14px; }

.primary, .ghost-btn {
  width: 100%;
  height: 58px;
  border-radius: 17px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  cursor: pointer;
  touch-action: manipulation;
}
.primary { border: 0; background: var(--ink); color: #fff; }
.primary:active { transform: scale(0.985); }
.ghost-btn {
  margin-top: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

/* ───── 로비: 모드 카드 ─────
 * 카드는 모두 크기가 같다. 이름과 한 줄 상태만 있고, 들어갈 수 있는 카드에는 오른쪽에 화살표가 붙는다.
 */
.modes { display: grid; gap: 10px; margin-top: 20px; }
.mode {
  display: block;
  width: 100%;
  padding: 13px 14px 13px 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}
.mode.main { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); } /* 테두리가 두꺼워 보여도 크기는 그대로 */
.mode:not(:disabled):active { transform: scale(0.99); }
.mode:disabled { cursor: default; }
.mode-in {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
}
.mode-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  flex: 1;
  min-width: 0;
}
.mode-title { font-size: 17px; line-height: 1.25; font-weight: 800; letter-spacing: -0.5px; }
.mode-sub {
  margin-top: 3px;
  font-size: 13.5px;
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.mode-go { /* 들어가는 화살표 */
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--ink)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M13 6l6 6-6 6'/%3E%3C/svg%3E")
    center / 16px no-repeat;
}

/* ───── 로비 배경과 배치 ─────
 * 로비에서는 화면 전체가 격자 무대다 (body[data-screen]은 game.js가 화면을 바꿀 때 적는다).
 * 바닥선과 그 아래 흰 바닥(.lobby::before)은 화면 양끝까지 이어지고, 큰 그림이 그 바닥선 위에 선다.
 * 기본(좁은 화면): 큰 그림 → 바닥선 → 모드 카드 → 내 기록. 넓은 화면 배치는 파일 맨 아래.
 */
body { overflow-x: clip; } /* 양끝까지 뻗는 바닥이 가로 스크롤을 만들지 않게 */
body { /* 로비 격자의 기본값. 확대·축소하면 game.js가 칸 크기(--g1~3), 진하기(--a1~2), 기준점(--gx, --gy)을 바꾼다 */
  --g1: 24px; --g2: 120px; --g3: 600px;
  --a1: 0.05; --a2: 0.085; --a3: 0.085;
  --gx: 50%; --gy: 0px;
}
body[data-screen="intro"] {
  background-color: var(--stage);
  background-image:
    linear-gradient(rgba(var(--grid), var(--a3)) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--grid), var(--a3)) 1px, transparent 1px),
    linear-gradient(rgba(var(--grid), var(--a2)) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--grid), var(--a2)) 1px, transparent 1px),
    linear-gradient(rgba(var(--grid), var(--a1)) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--grid), var(--a1)) 1px, transparent 1px);
  background-size:
    var(--g3) var(--g3), var(--g3) var(--g3),
    var(--g2) var(--g2), var(--g2) var(--g2),
    var(--g1) var(--g1), var(--g1) var(--g1);
  background-position: var(--gx) var(--gy);
}
body[data-screen="intro"] .app { padding-bottom: 0; }

.lobby {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto 1fr;
}
.lobby::before { /* 바닥선 + 그 아래 흰 바닥 */
  content: "";
  grid-area: 2 / 1 / -1 / -1;
  margin: 0 calc(50% - 50vw);
  border-top: 2px solid var(--ink);
  background: var(--bg);
}
.lobby > * { position: relative; } /* 흰 바닥보다 위에 그려지게 */
.lobby-art { grid-area: 1 / 1; height: 190px; touch-action: none; } /* 여기서 두 손가락으로 벌리면 배경이 확대·축소된다 */
.toy-layer { position: absolute; inset: 0; }
.lobby-art .zoom { top: 0; left: 0; } /* 확대·축소 버튼: 게임 무대와 같은 모양 */

/* ───── 화면이 바뀔 때의 움직임 ─────
 * 로비에서 나갈 때(.lobby.leaving): 모드 카드는 하나씩 왼쪽으로, 내 기록은 오른쪽으로 빠져나가고 큰 그림은 흐려진다.
 * 그 다음 화면(.screen.pop): 살짝 작았다가 튀어나오듯 나타난다.
 * 로비로 돌아올 때(.lobby.arriving): 카드들이 양옆에서 들어온다.
 * 클래스는 game.js의 show()가 붙였다 뗀다. 나가는 움직임의 전체 길이는 game.js의 LEAVE_MS와 맞춘다.
 */
@keyframes out-left { to { opacity: 0; transform: translateX(calc(-100% - 48px)); } }
@keyframes out-right { to { opacity: 0; transform: translateX(calc(100% + 48px)); } }
@keyframes in-left { from { opacity: 0; transform: translateX(calc(-100% - 48px)); } }
@keyframes in-right { from { opacity: 0; transform: translateX(calc(100% + 48px)); } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes screen-pop {
  0% { opacity: 0; transform: scale(0.92) translateY(16px); }
  60% { opacity: 1; transform: scale(1.015) translateY(0); }
  100% { opacity: 1; transform: none; }
}
.lobby.leaving .mode { animation: out-left 0.26s cubic-bezier(0.5, 0, 0.9, 0.5) both; }
.lobby.leaving .mode:nth-child(2) { animation-delay: 0.03s; }
.lobby.leaving .mode:nth-child(3) { animation-delay: 0.06s; }
.lobby.leaving .mode:nth-child(4) { animation-delay: 0.09s; }
.lobby.leaving .records { animation: out-right 0.3s cubic-bezier(0.5, 0, 0.9, 0.5) both; }
.lobby.leaving .lobby-art { animation: fade-out 0.3s ease both; }
.lobby.arriving .mode { animation: in-left 0.42s cubic-bezier(0.2, 0.8, 0.3, 1) both; }
.lobby.arriving .mode:nth-child(2) { animation-delay: 0.05s; }
.lobby.arriving .mode:nth-child(3) { animation-delay: 0.1s; }
.lobby.arriving .mode:nth-child(4) { animation-delay: 0.15s; }
.lobby.arriving .records { animation: in-right 0.46s cubic-bezier(0.2, 0.8, 0.3, 1) 0.05s both; }
.screen.pop { transform-origin: 50% 25%; animation: screen-pop 0.4s cubic-bezier(0.2, 0.7, 0.3, 1) both; }
@media (prefers-reduced-motion: reduce) {
  .lobby.leaving .mode, .lobby.leaving .records, .lobby.leaving .lobby-art,
  .lobby.arriving .mode, .lobby.arriving .records, .screen.pop { animation: none; }
}

/* 코끼리가 오른쪽 화면 밖에서 걸어 들어온다.
 * 거리(--from), 전체 시간(--walk), 한 걸음 주기(--cycle), 걸음 수(--steps)는 game.js가 정한다.
 * 다리는 대각선끼리 짝을 지어(leg-a, leg-b) 반대로 흔들리고, 몸통은 한 주기에 두 번 살짝 들썩인다.
 * 주기의 처음과 끝에서 다리 각도가 0이라, 도착하면 선 자세로 자연스럽게 멈춘다.
 */
@keyframes walk-in {
  from { transform: translateX(var(--from)); }
  to { transform: translateX(0); }
}
@keyframes leg-a {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(17deg); }
  75% { transform: rotate(-17deg); }
}
@keyframes leg-b {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-17deg); }
  75% { transform: rotate(17deg); }
}
@keyframes body-bob {
  0%, 50%, 100% { transform: translateY(0); }
  25%, 75% { transform: translateY(-1.2%); }
}
@keyframes waddle { /* 다리를 따로 그리지 않은 캐릭터: 몸 전체가 좌우로 뒤뚱거린다 */
  0%, 50%, 100% { transform: rotate(0deg) translateY(0); }
  25% { transform: rotate(-7deg) translateY(-3%); }
  75% { transform: rotate(7deg) translateY(-3%); }
}
.lobby-art .obj.target.walking { animation: walk-in var(--walk) linear both; }
.lobby-art .walking .leg-a { animation: leg-a var(--cycle) ease-in-out var(--steps); }
.lobby-art .walking .leg-b { animation: leg-b var(--cycle) ease-in-out var(--steps); }
.lobby-art .walking .body { animation: body-bob var(--cycle) ease-in-out var(--steps); }
.lobby-art .walking.waddle svg {
  transform-origin: 50% 100%;
  animation: waddle var(--cycle) ease-in-out var(--steps);
}
.lobby-art .handle { transition: opacity 0.3s; }
.lobby-art .obj.target.walking .handle { opacity: 0; }
@media (prefers-reduced-motion: reduce) {
  .lobby-art .obj.target.walking,
  .lobby-art .walking .leg,
  .lobby-art .walking .body,
  .lobby-art .walking.waddle svg { animation: none; }
}
.lobby-art .handle { top: -15px; right: -15px; width: 30px; height: 30px; background-size: 15px; }
.lobby .modes { grid-area: 2 / 1; margin-top: 18px; }

.records {
  grid-area: 3 / 1;
  align-self: start;
  margin: 12px 0 28px;
  padding: 14px 18px 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}
.records h2 {
  margin: 0 0 6px;
  font-size: 13px;
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--muted);
}
.records dl { margin: 0; }
.rec-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  font-size: 14.5px;
  line-height: 1.35;
  letter-spacing: -0.3px;
}
.rec-row dt { font-weight: 600; }
.rec-row dd { margin: 0; font-weight: 800; font-variant-numeric: tabular-nums; }
.rec-row dd.none { font-weight: 600; color: var(--muted); }

/* 들어가기 전 화면의 그림이 놓이는 작은 무대: 격자, 바닥선, 검은 선 하나와 파란 선 하나 */
.thumb {
  --floor: 14px;
  position: relative;
  display: block;
  border-radius: 15px;
  overflow: hidden;
  background-color: var(--stage);
  background-image:
    linear-gradient(rgba(var(--grid), 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--grid), 0.07) 1px, transparent 1px);
  background-size: 14px 14px;
  background-position: 7px 10px;
  pointer-events: none;
}
.thumb::after { /* 바닥선과 그 아래 흰 띠 */
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--floor);
  border-top: 2px solid var(--ink);
  background: #fff;
}
/* ───── 들어가기 전 화면 ───── */
.back {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 36px;
  margin: -6px 0 6px -8px;
  padding: 0 12px 0 6px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--muted);
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.3px;
  cursor: pointer;
  touch-action: manipulation;
}
.back svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ready-title {
  margin: 0 2px 16px;
  font-size: 30px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -1.1px;
}
/* 선 굵기와 손잡이는 게임 화면과 같다. */
.thumb.hero {
  height: 200px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background-size: 20px 20px;
  background-position: 9px 6px;
}

.facts3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}
.facts3 li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px 8px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  text-align: center;
}
.facts3 .big {
  display: grid;
  place-items: center;
  height: 34px;
  font-size: 28px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -1.2px;
  font-variant-numeric: tabular-nums;
}
.facts3 .grip { /* 게임 화면의 파란 손잡이와 같은 모양 */
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 17 17 7M11 7h6v6M13 17H7v-6'/%3E%3C/svg%3E")
    center / 16px no-repeat;
}
.facts3 span {
  font-size: 12.5px;
  line-height: 1.4;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: var(--muted);
}

.ready-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding: 8px 8px 8px 18px;
  border-radius: var(--radius);
  background: var(--stage);
}
.ready-best {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  line-height: 1.35;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: var(--muted);
}
.ready-best b { color: var(--ink); font-weight: 800; font-variant-numeric: tabular-nums; }
.ready-bar .primary { flex: none; width: auto; height: 52px; padding: 0 30px; border-radius: 16px; }

.text-btn {
  margin-top: 4px;
  height: 46px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

/* ───── 친구랑 같이 하기: 방 ───── */
.field { display: block; margin: 0 0 14px; }
.field span {
  display: block;
  margin: 0 2px 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}
.field input, .join-row input {
  width: 100%;
  height: 54px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  outline: none;
}
.field input:focus, .join-row input:focus { border-color: var(--ink); }
.or { margin: 22px 0 10px; text-align: center; font-size: 13px; font-weight: 600; color: var(--muted); }
.join-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.join-row input {
  text-align: center;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: 6px;
  font-variant-numeric: tabular-nums;
}
.join-row input::placeholder { font-size: 15px; font-weight: 600; letter-spacing: 0; }
.join-row .ghost-btn { width: auto; height: 54px; margin: 0; padding: 0 22px; border-radius: 15px; }
.room-msg { margin: 14px 2px 0; text-align: center; font-size: 14px; font-weight: 600; color: var(--muted); }
.room-note { margin: 18px 2px 0; text-align: center; font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.code-label { margin: 4px 0 6px; text-align: center; font-size: 13px; font-weight: 700; color: var(--muted); }
.code {
  margin: 0 0 22px;
  padding-left: 10px; /* 글자 사이 간격만큼 오른쪽이 비어 보이는 것을 맞춘다 */
  text-align: center;
  font-size: 64px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: 10px;
  font-variant-numeric: tabular-nums;
}
.players { display: grid; gap: 8px; margin: 0 0 18px; padding: 0; list-style: none; }
.players li {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 50px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  font-size: 16px;
}
.players li.empty { border-style: dashed; color: var(--muted); font-size: 14px; font-weight: 600; }
.players b { font-weight: 700; }
.players i {
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--stage);
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
}
.players i.paid { background: var(--accent-soft); color: var(--accent); }

/* 내 포인트와 충전 버튼 */
.wallet {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: -6px 2px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}
.wallet b { color: var(--ink); font-weight: 800; font-variant-numeric: tabular-nums; }
.chip-btn {
  height: 32px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

/* 충전 화면: 아래에서 올라오는 판 */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: end center;
  padding: 16px;
  background: rgba(16, 18, 22, 0.45);
}
.sheet-card {
  width: min(100%, 440px);
  padding: 22px 20px 10px;
  border-radius: 24px;
  background: #fff;
}
.sheet-card h2 { margin: 0 0 6px; font-size: 21px; font-weight: 800; letter-spacing: -0.6px; }
.sheet-sub { margin: 0 0 16px; font-size: 13.5px; line-height: 1.5; color: var(--muted); }
.sheet-sub b { color: var(--ink); font-weight: 800; word-break: break-all; }
.sheet-msg { margin: 12px 2px 0; text-align: center; font-size: 13px; font-weight: 600; line-height: 1.45; color: var(--warn); } /* 로그인이 안 됐을 때 이유 */.tiers { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tier {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.tier:active { background: var(--stage); }
.tier.on { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); } /* 고른 금액 */
.tier em { margin-top: 5px; font-size: 12px; font-style: normal; font-weight: 600; color: var(--muted); }
.tier i { /* 수수료 없음 딱지 */
  align-self: flex-start;
  margin-top: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
}
.sheet .primary { margin-top: 12px; }

/* 계정 화면 */
.acc-wallet {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 10px 0 14px;
  padding: 16px 16px 16px 18px;
  border-radius: 18px;
  background: var(--stage);
}
.acc-wallet span { display: block; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.acc-wallet b { display: block; margin-top: 2px; font-size: 26px; font-weight: 800; letter-spacing: -0.8px; font-variant-numeric: tabular-nums; }
.acc-wallet b span { display: inline; font: inherit; color: inherit; }
.acc-wallet .primary { width: auto; height: 46px; margin: 0; padding: 0 24px; border-radius: 14px; }
.acc-records { margin: 0 0 6px; padding: 4px 2px; }

/* 잠깐 떴다 사라지는 알림 */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 30;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border-radius: 14px;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.4;
  text-align: center;
  width: max-content; /* 짧으면 한 줄, 화면보다 길면 줄을 바꾼다 */
}
.tier b { font-size: 18px; font-weight: 800; letter-spacing: -0.4px; font-variant-numeric: tabular-nums; }
.tier span { font-size: 13.5px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.room-plan { /* 이 방이 오늘 어떤 상태인지: 이용권 있음 / 무료 한 판 남음 / 결제할 사람을 정해야 함 */
  margin: 0 0 14px;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--stage);
  font-size: 13.5px;
  line-height: 1.45;
  font-weight: 600;
  letter-spacing: -0.3px;
}
.room .text-btn { display: block; width: 100%; margin-top: 2px; font-size: 12.5px; }
.primary:disabled { opacity: 0.35; cursor: default; }

/* 온라인 대결: 랭크 카드 */
.rank-card {
  margin: 0 0 18px;
  padding: 18px 20px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--stage);
}
.rank-name { margin: 0; font-size: 30px; line-height: 1.15; font-weight: 800; letter-spacing: -1px; color: var(--accent); }
.rank-points { margin: 4px 0 14px; font-size: 14.5px; font-weight: 600; color: var(--muted); }
.rank-points b { color: var(--ink); font-weight: 800; font-variant-numeric: tabular-nums; }
.rank-card .bar { height: 6px; border-radius: 3px; background: #fff; overflow: hidden; }
.rank-card .bar i { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.rank-next { margin: 8px 0 0; font-size: 12.5px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }

/* 친구랑 같이 하기: 게임 중 */
.peers { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 12px; }
.peers span {
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--stage);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.peers span.done { background: #e2f6ee; color: var(--ok); }
.peers span.done::after { content: " ✓"; }
.waiting { margin: 0; padding: 22px 0 6px; text-align: center; font-size: 16px; font-weight: 700; }
.rush { /* 친구가 먼저 결정해서 시간이 줄었을 때 잠깐 뜨는 알림 */
  position: absolute;
  left: 0;
  right: 0;
  top: 62px;
  display: flex;
  justify-content: center;
  pointer-events: none;
}
.rush span {
  padding: 9px 14px;
  border-radius: 12px;
  background: var(--warn);
  color: #fff;
  font-size: 13.5px;
  font-weight: 800;
}
.rush.calm span { background: var(--ink); } /* 시간과 상관없는 안내 (방값을 냈다 등) */
.rank { margin: 0 0 16px; padding: 0; list-style: none; text-align: left; }
.rank li {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: baseline;
  padding: 10px 4px;
  border-top: 1px solid var(--line);
  font-size: 15px;
  letter-spacing: -0.3px;
}
.rank li:last-child { border-bottom: 1px solid var(--line); }
.rank .no { font-weight: 800; color: var(--muted); }
.rank .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.rank .pts { font-weight: 800; font-variant-numeric: tabular-nums; }
.rank .sum { font-size: 12.5px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.rank li.me .who { color: var(--accent); }

/* ───── 점수 ───── */
.result { padding-top: 16px; text-align: center; }
.score {
  font-size: 66px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -3px;
  font-variant-numeric: tabular-nums;
}
.score small {
  margin-left: 3px;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.score.big { font-size: 88px; letter-spacing: -4.5px; text-align: center; }
.pass { /* 타임어택: 이번 문제를 넘겼는지 */
  display: inline-block;
  margin: 0 0 12px;
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 13.5px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.3px;
}
.pass.ok { background: #e2f6ee; color: var(--ok); }
.pass.no { background: #fdeaea; color: var(--warn); }
.verdict { margin: 10px 0 4px; font-size: 17px; font-weight: 600; letter-spacing: -0.3px; }
.verdict b { font-weight: 800; }
.verdict .ok { color: var(--ok); font-weight: 800; }
.facts { margin: 0 0 18px; font-size: 13.5px; color: var(--muted); line-height: 1.5; }

/* ───── 최종 결과 ───── */
.sum-label {
  margin: 22px 0 6px;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--muted);
}
.sum-max {
  margin: 10px 0 0;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.grade { margin: 14px 0 26px; text-align: center; }
.grade span {
  display: inline-block;
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.4px;
}
.rounds { margin: 0 0 24px; padding: 0; list-style: none; }
.rounds li { padding: 11px 2px 12px; border-top: 1px solid var(--line); }
.rounds li:last-child { border-bottom: 1px solid var(--line); }
.rounds .row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14.5px;
  letter-spacing: -0.3px;
}
.rounds .n { font-weight: 700; font-variant-numeric: tabular-nums; }
.rounds .bar {
  margin-top: 8px;
  height: 4px;
  border-radius: 2px;
  background: var(--stage);
  overflow: hidden;
}
.rounds .bar i { display: block; height: 100%; border-radius: 2px; background: var(--accent); }

/* ───── 휴대폰 ───── */
@media (max-width: 480px) {
  .app { padding: 14px 12px 24px; }
  .question { font-size: 21px; }
}

/* ───── 넓은 화면(노트북)의 로비 ─────
 * 왼쪽에 모드 카드, 나머지 폭 전체에 큰 그림, 그 오른쪽 위에 내 기록. 바닥선은 화면 아래쪽을 가로지른다.
 */
@media (min-width: 900px) {
  body[data-screen="intro"] .app { max-width: 1160px; padding: 20px 36px 0; }
  .lobby {
    grid-template-columns: 400px minmax(0, 1fr) 240px;
    grid-template-rows: 1fr auto 1.5fr 64px;
    column-gap: 44px;
  }
  .lobby::before { grid-area: 4 / 1 / 5 / -1; }
  .lobby .modes { grid-area: 2 / 1; margin-top: 0; }
  .lobby-art { grid-area: 1 / 2 / 4 / 4; align-self: end; height: clamp(260px, 56vh, 520px); }
  .lobby-art .handle { top: -19px; right: -19px; width: 38px; height: 38px; background-size: 18px; }
  .lobby-art .zoom { top: auto; bottom: 18px; } /* 넓은 화면에서는 바닥선 바로 위 왼쪽 구석에 */
  .records { grid-area: 2 / 3; margin: 0; }
}
