@font-face { font-family: 'GmarketSans'; font-weight: 300; src: url('fonts/GmarketSansLight.otf') format('opentype'); font-display: swap; }
@font-face { font-family: 'GmarketSans'; font-weight: 500; src: url('fonts/GmarketSansMedium.otf') format('opentype'); font-display: swap; }
@font-face { font-family: 'GmarketSans'; font-weight: 700; src: url('fonts/GmarketSansBold.otf') format('opentype'); font-display: swap; }

:root {
  color-scheme: light dark;
  --bg: #f3f5f9;
  --surface: #fafbfd;
  --line: #dde2ec;
  --text: #1b1e26;
  --muted: #6b7384;
  --accent: #3b5fd9;
  --accent-text: #f7f8fd;
  --accent-soft: #e3e9fb;
  --ok: #17724a;
  --ok-soft: #dff2e8;
  --miss: #b0372f;
  --miss-soft: #f9e4e1;
  --radius: 16px;
  --gap: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #13151a;
    --surface: #1b1e25;
    --line: #2b303b;
    --text: #e6e9f1;
    --muted: #8d95a8;
    --accent: #6f8cf5;
    --accent-text: #11141c;
    --accent-soft: #212842;
    --ok: #4cc58a;
    --ok-soft: #1b2e26;
    --miss: #ef7f76;
    --miss-soft: #33211f;
  }
}

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

html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: 'GmarketSans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-weight: 500;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

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

.app {
  max-width: 520px;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px var(--gap); }
h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }

.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; }
.tab { white-space: nowrap; border: 0; background: none; padding: 6px 14px; border-radius: 999px; color: var(--muted); font-size: 14px; }
.tab.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }

.view { display: flex; flex-direction: column; gap: var(--gap); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap); }
.stats > div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; }
.stat-label { font-size: 12px; font-weight: 300; color: var(--muted); }
.stats strong { font-size: 24px; font-weight: 700; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: var(--gap); }

.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--bg); border-radius: 12px; }
.seg-btn { border: 0; background: none; padding: 8px 6px; border-radius: 9px; font-size: 13px; color: var(--muted); }
.seg-btn.is-active { background: var(--surface); color: var(--text); font-weight: 700; box-shadow: 0 0 0 1px var(--line); }

.play {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  width: 100%; padding: 28px 16px; border: 0; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-text); font-size: 18px; font-weight: 700;
  transition: transform 0.08s;
}
.play:active { transform: scale(0.985); }
.play-icon { width: 0; height: 0; border-left: 14px solid currentColor; border-top: 9px solid transparent; border-bottom: 9px solid transparent; }
.play.is-playing .play-icon { width: 14px; height: 18px; border: 0; background: linear-gradient(90deg, currentColor 0 36%, transparent 36% 64%, currentColor 64%); }

.play-area { display: flex; flex-direction: column; gap: var(--gap); }
.hint-text { margin: 0; padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); font-size: 14px; }
.hint-text:empty { display: none; }
.hint-text.is-error { background: none; padding: 0 2px; color: var(--miss); }

.answer { display: flex; gap: 10px; }
.field { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 0 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; }
.field:focus-within { border-color: var(--accent); }
.field input { flex: 1; min-width: 0; padding: 13px 0; border: 0; background: none; outline: none; font-size: 16px; }
.field input::placeholder { color: var(--muted); font-weight: 300; }
.unit { color: var(--muted); font-size: 14px; }

.btn { border: 0; border-radius: 12px; padding: 12px 18px; font-size: 15px; font-weight: 700; }
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.ghost { flex: 1; background: var(--bg); border: 1px solid var(--line); color: var(--text); font-weight: 500; font-size: 14px; }
.btn:disabled { color: var(--muted); cursor: default; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.actions .btn { flex: 1 1 auto; }
.play-row { display: flex; gap: 10px; }
.play-row .play { flex: 1; width: auto; }
.play-row .btn { flex: none; align-self: stretch; padding: 0 20px; }
.play:disabled { opacity: 0.45; cursor: default; }
.cal-block { display: flex; flex-direction: column; gap: var(--gap); }
.cal-status { margin: 0; padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); font-size: 14px; }
.cal-label { margin: 0; font-size: 18px; font-weight: 700; }

.result { display: flex; flex-direction: column; gap: var(--gap); }
/* 답을 낸 뒤에는 큰 소리 버튼 자리에 결과가 들어간다. */
.result p { margin: 0; padding: 28px 16px; border-radius: var(--radius); background: var(--accent-soft); color: var(--accent); text-align: center; font-size: 18px; font-weight: 700; }
.result .ok { background: var(--ok-soft); color: var(--ok); }
.result .miss { background: var(--miss-soft); color: var(--miss); }
.kbtn { flex: none; min-width: 40px; min-height: 36px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--muted); font-weight: 700; }
.kbtn.is-on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.unit { min-width: 2.4em; }

.note { margin: 0; font-size: 14px; font-weight: 300; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 10px; }
.cell { padding: 14px 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); font-size: 14px; }
.cell.is-playing { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 700; }

.foot { display: flex; flex-direction: column; gap: 10px; color: var(--muted); font-size: 12px; font-weight: 300; }
.foot p { margin: 0; }
.vol { display: flex; align-items: center; gap: 12px; font-size: 13px; font-weight: 500; }
.vol input { flex: 1; min-height: 28px; accent-color: var(--accent); }

button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
