/* 오늘도 빙고 — 빙고장 테이블(코발트) 위의 빙고 카드, 마젠타 도장, 노란 공 */
:root {
  --table: #2440c4;
  --table-deep: #1a2f97;
  --table-line: #3a56d6;
  --card: #ffffff;
  --card-soft: #f2f4fb;
  --ink: #161b46;
  --ink-soft: #6c7299;
  --rule: #d8dcef;
  --dauber: #e8287f;
  --ball: #ffd23f;
  --ball-deep: #e6ac00;
  --go: #19b394;

  --num: 'Black Han Sans', 'Gothic A1', system-ui, sans-serif;
  --body: 'Gothic A1', system-ui, -apple-system, 'Apple SD Gothic Neo', sans-serif;

  --bar-h: 76px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--table);
  background-image: radial-gradient(var(--table-line) 1px, transparent 1.4px);
  background-size: 18px 18px;
  color: #fff;
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--ball); outline-offset: 2px; }

.screen {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) 16px calc(24px + env(safe-area-inset-bottom));
}

/* ------------------------------------------------ 버튼 */
.btn {
  border: 0;
  border-radius: 999px;
  padding: 12px 22px;
  font-weight: 800;
  font-size: 16px;
  cursor: pointer;
  background: var(--card-soft);
  color: var(--ink);
  transition: transform .08s ease;
}
.btn:active:not(:disabled) { transform: translateY(1px) scale(.98); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--ball); color: var(--ink); box-shadow: 0 4px 0 var(--ball-deep); }
.btn-ink { background: var(--ink); color: #fff; }
.btn-go { background: var(--go); color: #fff; box-shadow: 0 4px 0 #0f8a71; }
.btn-ghost { background: transparent; color: var(--ink); border: 2px solid var(--rule); }
.btn-ghost-light { background: rgba(255,255,255,.12); color: #fff; }
.btn-big { width: 100%; padding: 16px; font-size: 18px; }
.btn-small { padding: 7px 14px; font-size: 14px; }
.link { background: none; border: 0; color: var(--ink-soft); text-decoration: underline; cursor: pointer; padding: 8px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255,255,255,.12); display: grid; place-items: center;
}
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* ------------------------------------------------ 홈 */
.hero { text-align: center; padding: 48px 0 28px; }
.hero-balls { display: flex; justify-content: center; gap: 6px; margin-bottom: 18px; }
.hero-balls span {
  width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--num); font-size: 20px; color: var(--ink);
  background: radial-gradient(circle at 35% 30%, #fff 0 22%, var(--ball) 23%);
  box-shadow: inset 0 -4px 0 var(--ball-deep);
}
.hero-balls span:nth-child(2n) { transform: translateY(6px); }
.logo {
  margin: 0; font-family: var(--num); font-weight: 400;
  font-size: 76px; line-height: 1; letter-spacing: -1px;
  text-shadow: 0 5px 0 var(--table-deep);
}
.logo small { display: block; font-size: 22px; letter-spacing: 2px; margin-bottom: 6px; opacity: .85; }
.hero-lead { margin: 16px auto 0; max-width: 22em; opacity: .9; }

.sheet {
  background: var(--card);
  color: var(--ink);
  border-radius: 22px;
  padding: 22px 18px;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 10px 0 var(--table-deep);
}
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 800; }
.field input, .join input {
  font: inherit; font-weight: 600; font-size: 18px;
  border: 2px solid var(--rule); border-radius: 14px;
  padding: 12px 14px; color: var(--ink); background: var(--card-soft);
  width: 100%;
}
.field input:focus, .join input:focus { outline: none; border-color: var(--table); background: #fff; }
.field-error { margin: -8px 0 0; min-height: 1.2em; color: var(--dauber); font-size: 14px; font-weight: 600; }
.join { display: flex; gap: 8px; }
.join input { text-transform: uppercase; letter-spacing: 6px; font-family: var(--num); font-weight: 400; text-align: center; }
.join .btn { flex: none; }
.resume {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: #fff6d4; border-radius: 14px; padding: 10px 12px; font-size: 15px;
}

/* 방 만들기 선택지 */
.choice-group { border: 0; padding: 0; margin: 0 0 6px; }
.choice-group legend { font-weight: 800; margin-bottom: 8px; padding: 0; }
.choices { display: grid; gap: 8px; }
.choices.sizes { grid-template-columns: repeat(4, 1fr); }
.choices.two { grid-template-columns: 1fr 1fr; }
.choice {
  border: 2px solid var(--rule); border-radius: 14px; background: #fff;
  padding: 12px 10px; cursor: pointer; text-align: left; color: var(--ink);
  display: flex; flex-direction: column; gap: 2px;
}
.choice b { font-size: 16px; }
.choice small { color: var(--ink-soft); font-size: 13px; line-height: 1.4; }
.sizes .choice { text-align: center; align-items: center; }
.sizes .choice b { font-family: var(--num); font-weight: 400; font-size: 22px; }
.choice[aria-checked="true"] { border-color: var(--table); background: #eef1ff; box-shadow: inset 0 0 0 1px var(--table); }
.choice:disabled { opacity: .5; cursor: default; }
.choice .soon { color: var(--dauber); font-weight: 800; }

/* ------------------------------------------------ 방 */
.topbar { display: flex; align-items: center; gap: 10px; padding: 12px 0; }
.topbar h2 { margin: 0; flex: 1; font-size: 18px; }
.room-code b { font-family: var(--num); font-weight: 400; font-size: 24px; letter-spacing: 3px; margin-left: 4px; }
.room-rule { margin: 0 0 10px; font-size: 14px; opacity: .85; }
.room { padding-bottom: calc(var(--bar-h) + 24px + env(safe-area-inset-bottom)); }
.conn { background: var(--dauber); border-radius: 10px; padding: 6px 12px; font-weight: 600; font-size: 14px; margin: 0 0 10px; }

/* 부르는 숫자 */
.caller {
  display: flex; align-items: center; gap: 14px;
  background: var(--table-deep); border-radius: 20px; padding: 12px 14px; margin-bottom: 12px;
}
.ball {
  flex: none; width: 76px; height: 76px; border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 34% 28%, #fff 0 14%, var(--ball) 15%);
  box-shadow: inset 0 -6px 0 var(--ball-deep), 0 4px 10px rgba(0,0,0,.25);
  color: var(--ink);
}
.ball span {
  width: 46px; height: 46px; border-radius: 50%; background: #fff;
  display: grid; place-items: center;
  font-family: var(--num); font-size: 26px; line-height: 1;
}
.ball.drop { animation: drop .55s cubic-bezier(.3,1.6,.5,1); }
.ball.cannon { animation: blast .6s ease-out; }
@keyframes drop { from { transform: translateY(-40px) rotate(-90deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes blast { 0% { transform: scale(.2); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }
.caller-text { flex: 1; min-width: 0; }
.caller-who { margin: 0; font-size: 14px; opacity: .85; }
.caller-where { display: inline-block; margin: 2px 0 4px; padding: 1px 10px; border-radius: 999px; font-size: 13px; font-weight: 800; }
.caller-where.yes { background: var(--ball); color: var(--ink); }
.caller-where.no { background: rgba(255,255,255,.14); color: #fff; }
.caller-turn { margin: 0 0 6px; font-weight: 800; font-size: 16px; }
.caller-turn.mine { color: var(--ball); }
.timer { height: 6px; border-radius: 3px; background: rgba(255,255,255,.18); overflow: hidden; }
.timer i { display: block; height: 100%; width: 100%; background: var(--ball); transform-origin: left; }
.btn-cannon { flex: none; background: var(--dauber); color: #fff; box-shadow: 0 4px 0 #a5155a; padding: 14px 16px; }

/* 참가자 */
.players { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.player {
  flex: none; display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.12); border-radius: 999px; padding: 6px 12px;
  font-size: 14px; white-space: nowrap; border: 2px solid transparent;
}
.player:has(.dot) { padding-left: 6px; }
.player .dot {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255,255,255,.2); font-family: var(--num); font-size: 13px;
}
.player.ready .dot { background: var(--go); }
.player.turn { border-color: var(--ball); background: rgba(255,210,63,.18); }
.player.me { font-weight: 800; }
.player.off { opacity: .5; }
.player .tag { opacity: .75; font-size: 12px; }
.player.ranked .dot { background: var(--ball); color: var(--ink); }

/* 빙고 카드 */
.card {
  background: var(--card); color: var(--ink); border-radius: 20px;
  padding: 12px; box-shadow: 0 8px 0 var(--table-deep);
}
.card-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 4px 8px; font-weight: 800; }
.card-head .lines { font-family: var(--num); font-weight: 400; font-size: 20px; color: var(--dauber); }
.card-head .lines.done { color: var(--go); }
.board { display: grid; gap: 4px; }
.cell {
  position: relative; aspect-ratio: 1; border: 0; border-radius: 8px;
  background: var(--card-soft); color: var(--ink);
  font-family: var(--num); font-size: var(--cell-fs, 26px); line-height: 1;
  display: grid; place-items: center; cursor: pointer; padding: 0;
  overflow: hidden;
}
.cell.empty { color: var(--ink-soft); font-family: var(--body); font-size: 12px; }
.cell.selected { box-shadow: inset 0 0 0 3px var(--table); background: #eef1ff; }
.cell.callable { box-shadow: inset 0 0 0 2px rgba(36,64,196,.4); }
.cell.in-line { background: #ffe1ee; }
/* 방금 나온 숫자: 노란 테두리가 깜빡여서 어디 있는지 바로 보인다 */
.cell.hot { background: var(--ball); box-shadow: inset 0 0 0 3px var(--ball-deep); z-index: 3; animation: hot 1s ease-in-out infinite; }
@keyframes hot { 50% { box-shadow: inset 0 0 0 3px var(--ball-deep), 0 0 0 4px rgba(255,210,63,.75); } }
.cell span { position: relative; z-index: 1; }
/* 도장: 반투명 마젠타 잉크가 숫자 위에 */
.cell.marked::after {
  content: ''; position: absolute; inset: 9%; border-radius: 50%;
  background: radial-gradient(circle at 40% 38%, rgba(232,40,127,.55), rgba(232,40,127,.78) 70%, rgba(200,20,100,.85));
  z-index: 2; mix-blend-mode: multiply;
}
.cell.marked.stamp::after { animation: stamp .22s ease-out; }
@keyframes stamp { from { transform: scale(1.5); opacity: 0; } to { transform: none; opacity: 1; } }
.board.size-3 { --cell-fs: 40px; }
.board.size-5 { --cell-fs: 28px; }
.board.size-7 { --cell-fs: 20px; gap: 3px; }
.board.size-9 { --cell-fs: 16px; gap: 2px; }
.board.size-9 .cell, .board.size-7 .cell { border-radius: 5px; }
.hint { margin: 12px 4px 0; font-size: 14px; opacity: .9; min-height: 1.4em; }

/* 숫자 고르기 */
#picker-wrap { margin-top: 14px; }
.picker-tools { display: flex; gap: 6px; margin-bottom: 10px; }
.picker-tools .btn { flex: 1; padding-inline: 8px; }
.picker { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.pick {
  aspect-ratio: 1; border: 0; border-radius: 50%; cursor: pointer;
  background: #fff; color: var(--ink); font-family: var(--num); font-size: 15px; padding: 0;
}
.pick:disabled { background: transparent; color: rgba(255,255,255,.35); box-shadow: inset 0 0 0 1px rgba(255,255,255,.2); cursor: default; }

/* 나온 숫자 */
#history-wrap { margin-top: 16px; }
.history-title { margin: 0 0 8px; font-size: 15px; }
.history-title span { opacity: .7; font-weight: 600; }
.history { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 5px; }
.history li {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255,255,255,.14); font-family: var(--num); font-size: 15px;
}
.history li.last { background: var(--ball); color: var(--ink); }

/* 하단 버튼 자리 (준비 완료 ↔ 빙고) */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  background: var(--table-deep);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}
.actionbar-inner { max-width: 488px; margin: 0 auto; display: flex; gap: 8px; }
.actionbar-inner .btn { flex: 1; padding: 15px; font-size: 18px; }
.actionbar-inner .btn-side { flex: 0 0 auto; }
.btn-bingo {
  background: var(--dauber); color: #fff; font-family: var(--num); font-weight: 400;
  font-size: 24px !important; letter-spacing: 2px; box-shadow: 0 4px 0 #a5155a;
}
.btn-bingo:not(:disabled) { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.03); } }

/* 대화상자 */
.dialog {
  border: 0; border-radius: 22px; padding: 0; width: min(92vw, 440px);
  color: var(--ink); background: var(--card);
}
.dialog::backdrop { background: rgba(16, 22, 70, .6); }
.dialog-body { padding: 22px 20px 18px; display: flex; flex-direction: column; gap: 14px; }
.dialog h2 { margin: 0; font-size: 20px; }
.dialog-note { margin: 0; font-size: 13px; color: var(--ink-soft); }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; }
.dialog-actions .btn { flex: 1; }
.rules ol { margin: 0; padding-left: 1.3em; display: flex; flex-direction: column; gap: 8px; font-size: 15px; }
.result { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.result li {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  background: var(--card-soft); border-radius: 14px; font-weight: 600;
}
.result li.me { box-shadow: inset 0 0 0 2px var(--table); }
.result .rank { font-family: var(--num); font-size: 22px; width: 2.6em; color: var(--ink-soft); }
.result li:first-child .rank { color: var(--dauber); }
.result .sub { margin-left: auto; font-size: 13px; color: var(--ink-soft); }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--bar-h) + 22px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-weight: 600; font-size: 15px; transition: opacity .2s, transform .2s; z-index: 20;
  max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.big { background: var(--dauber); font-size: 18px; }

@media (min-width: 560px) {
  .board.size-3 { --cell-fs: 52px; }
  .board.size-5 { --cell-fs: 34px; }
  .board.size-7 { --cell-fs: 24px; }
  .board.size-9 { --cell-fs: 19px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
