/* Mini Games — shared styles */
:root {
  --bg: #f4f5f9;
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --border: #e4e6ee;
  --line-strong: #d3d6e2;
  --text: #171923;
  --text-2: #3f4354;
  --muted: #606579;
  --accent: #4f46e5;
  --accent-strong: #4338ca;
  --accent-soft: #eef0ff;
  --accent-text: #ffffff;
  --accent-ink: #3730a3;
  --accent-glow: rgba(79, 70, 229, .16);
  --seg-bg: #e9ebf2;
  --focus: #4338ca;
  --tile-ink: #30251c;
  --good: #18794e;
  --bad: #b91c1c;
  --warn: #d9a400;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 10px 30px -10px rgba(16, 24, 40, .14);
  --radius: 22px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  /* Use installed fonts only; no remote font requests. */
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #14151f;
    --surface: #1e202e;
    --surface-2: #252838;
    --border: #383c50;
    --line-strong: #555b74;
    --text: #f1f2f8;
    --text-2: #d3d6e5;
    --muted: #adb2c8;
    --accent-soft: #2e2b52;
    --accent-ink: #c4bfff;
    --accent-glow: rgba(129, 120, 255, .14);
    --seg-bg: #252838;
    --focus: #c4bfff;
    --good: #4ade80;
    --bad: #fb7185;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .2);
    --shadow: 0 1px 2px rgba(0, 0, 0, .15), 0 10px 30px -10px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--bg);
  background-image: radial-gradient(1000px 520px at 50% -160px, var(--accent-glow), transparent 72%);
  background-repeat: no-repeat;
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  letter-spacing: -.01em;
  word-break: keep-all;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}
body.hub-page { scrollbar-gutter: stable; overflow-x: clip; }
button { font: inherit; color: inherit; cursor: pointer; }
button:not(.cell):not(.tile) { min-height: 44px; min-width: 44px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* header */
.site-header {
  position: sticky; top: 0; z-index: 20;
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 6px; align-items: center;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.site-header .back {
  justify-self: start;
  color: var(--muted); text-decoration: none; font-size: .9rem; font-weight: 600;
  display: inline-flex; align-items: center; min-height: 44px;
  padding: 8px 4px; margin: 0; border-radius: 10px; white-space: nowrap;
}
.site-header .back:hover { color: var(--accent-ink); }
.site-header h1 { margin: 0; font-size: 1.15rem; font-weight: 800; letter-spacing: -.03em; text-align: center; white-space: nowrap; }
.site-header .spacer { justify-self: end; }

main.game { width: 100%; max-width: 560px; margin: 0 auto; padding: 24px 16px 48px; }

/* stats bar */
.statbar { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 12px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 8px 16px; text-align: center; min-width: 76px; box-shadow: var(--shadow-sm);
}
.stat .label { display: block; font-size: .7rem; color: var(--muted); font-weight: 600; }
.stat .value { display: block; font-size: 1.15rem; font-weight: 800; font-variant-numeric: tabular-nums; }

/* buttons */
.btn {
  min-height: 44px; min-width: 44px;
  border: 1px solid var(--border); background: var(--surface); border-radius: 14px;
  padding: 11px 16px; font-weight: 700; box-shadow: var(--shadow-sm);
  transition: transform .15s var(--ease), background .2s ease, border-color .2s ease, box-shadow .2s ease;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.btn:hover { border-color: var(--line-strong); background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; box-shadow: 0 1px 2px rgba(16,24,40,.1), 0 8px 20px -6px var(--accent); }
.btn.primary:hover { background: var(--accent-strong); transform: translateY(-1px); }
.btn[aria-pressed="true"], .btn.on { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.toolbar { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 12px 0; }

/* segmented control (difficulty) */
.seg { display: inline-flex; flex-wrap: wrap; max-width: 100%; background: var(--seg-bg); border: 1px solid var(--border); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button {
  min-height: 44px;
  border: 0; background: transparent; padding: 8px 14px; border-radius: 10px; font-weight: 700; color: var(--muted);
  touch-action: manipulation;
}
.seg button[aria-pressed="true"], .seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg-wrap { display: flex; justify-content: center; margin-bottom: 12px; }

/* toast */
#toast {
  position: fixed; left: 50%; top: 70px; transform: translate(-50%, -10px);
  background: #1f2333; color: #fff; padding: 10px 18px; border-radius: 12px;
  font-weight: 700; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  z-index: 100; max-width: 90vw; text-align: center; box-shadow: 0 4px 16px rgba(0,0,0,.3);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* modal / result message */
.overlay {
  position: fixed; inset: 0; background: rgba(10, 12, 25, .55); display: none;
  align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.overlay.show { display: flex; }
.dialog {
  background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--accent); border-radius: var(--radius); padding: 28px 24px; max-width: 360px; width: 100%;
  max-height: calc(100dvh - 40px); overflow-y: auto;
  text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.35); animation: pop .38s var(--ease);
}
.dialog h2 { margin: 0 0 6px; font-size: 1.4rem; }
.dialog p { margin: 6px 0; color: var(--muted); white-space: pre-line; }
.dialog .row { display: flex; gap: 8px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.hint { text-align: center; color: var(--muted); font-size: .85rem; margin: 10px 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}

/* ---------- hub ---------- */
.hub { max-width: 860px; margin: 0 auto; padding: 48px 24px; }
.hub header { text-align: center; margin-bottom: 24px; }
.hub h1 { margin: 0; font-size: 2rem; font-weight: 800; letter-spacing: -.03em; }
.hub header p { margin: 10px 0 0; color: var(--muted); font-size: .95rem; line-height: 1.65; }
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.hub .card {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  text-decoration: none; text-align: center; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px 22px; min-height: 176px; box-shadow: var(--shadow);
  transition: transform .18s var(--ease), box-shadow .2s ease, border-color .2s ease;
}
.hub .card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--accent); }
.hub .card:hover { transform: translateY(-2px); border-color: var(--line-strong); box-shadow: 0 12px 30px -10px var(--accent-glow); }
.hub .card .emoji {
  font-size: 2rem; width: 3.4rem; height: 3.4rem; flex: none; display: grid; place-items: center;
  background: var(--accent-soft); border-radius: 18px;
}
.hub .card h2 { margin: 0 0 6px; font-size: 1.1rem; font-weight: 700; letter-spacing: -.025em; }
.hub .card p { margin: 0; color: var(--muted); font-size: .88rem; line-height: 1.65; }
.hub footer { text-align: center; color: var(--muted); font-size: .8rem; margin-top: 28px; }

/* hub sections */
.hub-section { margin-top: 26px; }
.hub-section:first-of-type { margin-top: 0; }
.section-title { display: flex; align-items: baseline; gap: 10px; margin: 0 0 12px; font-size: 1.2rem; }
.section-title small { color: var(--muted); font-size: .8rem; font-weight: 500; }
.hub .card .tag {
  display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; vertical-align: middle;
  font-size: .68rem; font-weight: 700; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border);
}
.hub .card.external .tag { color: var(--accent-ink); background: var(--accent-soft); }

/* Icebreaker segmented tabs. Hash is applied before paint. */
.hub-switch { display: none; margin: 2px auto 16px; }
html[data-hub] .hub-switch { display: block; }
.hub-modes {
  display: flex;
  gap: 4px;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 4px;
  background: var(--seg-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.hub-mode {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .2em;
  text-decoration: none;
  min-height: 44px;
  flex: 1 1 0;
  min-width: 0;
  border: 0;
  background: var(--seg-bg);
  color: var(--text-2);
  border-radius: 10px;
  padding: 11px 4px;
  /* Apply readable foreground/background pairs together, including on tab switches. */
  transition: box-shadow .2s ease;
  font-weight: 700;
  font-size: clamp(.84rem, 3.4vw, 1.02rem);
  line-height: 1.2;
  white-space: nowrap;
  font-family: inherit;
  touch-action: manipulation;
}
.hub-mode[aria-current="page"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(16,24,40,.08), 0 2px 8px rgba(16,24,40,.06);
}
html[data-hub] .hub-section { margin-top: 0; }
html[data-hub] .hub-kicker {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
html[data-hub] .section-title {
  font-size: .95rem;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 12px;
}
html[data-hub] .section-title small { font-size: 1em; font-weight: 600; color: inherit; }

/* ---------- shared form-ish widgets (party games / tools) ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.panel > h2 { margin: 0 0 8px; font-size: 1rem; }
.field { margin: 12px 0; }
.field > .label { display: block; font-size: .8rem; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.center { text-align: center; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips.center { justify-content: center; }
.chip {
  min-height: 44px;
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 7px 13px;
  color: var(--text-2); font-weight: 600; font-size: .85rem; touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.chip:hover { border-color: var(--line-strong); background: var(--surface-2); }
.chip[aria-pressed="true"] { background: var(--text); color: var(--surface); border-color: var(--text); }
.input {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 2px solid var(--border);
  border-radius: 12px; padding: 10px 12px; min-width: 0;
}
.input:focus { outline: none; border-color: var(--accent-ink); }
textarea.input { resize: vertical; min-height: 96px; }
.btn.big { padding: 16px 20px; font-size: 1.15rem; border-radius: 16px; }
.btn.wide { width: 100%; }
.btn.good { background: var(--good); color: #fff; border-color: transparent; }
.btn.bad { background: var(--bad); color: #fff; border-color: transparent; }
.btn.small { padding: 6px 10px; font-size: .85rem; border-radius: 10px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row.center { justify-content: center; }
.row > .grow { flex: 1 1 0; min-width: 0; }
.team-inputs { display: grid; gap: 8px; }
.team-inputs .input { font-weight: 700; }
.team-dot { display: inline-block; width: .8em; height: .8em; border-radius: 50%; vertical-align: -.05em; margin-right: .35em; }
.muted { color: var(--muted); }
details.panel > summary { cursor: pointer; font-weight: 700; list-style: none; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::after { content: "▾"; float: right; color: var(--muted); }
details.panel[open] > summary::after { content: "▴"; }
details.panel[open] > summary { margin-bottom: 10px; }
.scoreboard { display: grid; gap: 6px; }
.scoreboard .srow { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border-radius: 12px; padding: 8px 12px; font-weight: 700; }
.scoreboard .srow .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scoreboard .srow .pts { font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.scoreboard .srow.first { background: color-mix(in srgb, var(--warn) 25%, var(--surface)); }
.bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 100%; background: var(--accent); transition: width .25s linear; }
.bar.low > i { background: var(--bad); }

/* ---------- team round engine (몸으로 말해요 / 스피드 퀴즈 / 금지어) ---------- */
.tr-screen { text-align: center; }
.tr-turn { font-size: 1.1rem; font-weight: 800; margin: 6px 0 2px; }
.tr-emoji { font-size: 3.4rem; margin: 10px 0 4px; }
.tr-note { color: var(--muted); font-size: .92rem; margin: 6px 0 16px; white-space: pre-line; }
.tr-count { font-size: 7rem; font-weight: 900; line-height: 1.1; color: var(--accent-ink); margin: 24px 0; }
.tr-timer { font-size: 2.4rem; font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1; }
.tr-timer.low { color: var(--bad); }
.tr-word {
  background: var(--surface); border: 3px solid var(--accent); border-radius: 22px; padding: 22px 12px;
  margin: 12px 0; min-height: 150px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  box-shadow: var(--shadow);
}
.tr-word { position: relative; }
.tr-word .tr-face { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; width: 100%; }
.tr-word.is-covered .tr-face { visibility: hidden; }
.tr-mask {
  display: none; position: absolute; inset: 8px; z-index: 1;
  flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  margin: 0; padding: 12px; border: 0; border-radius: 16px; cursor: pointer;
  font: inherit; font-weight: 800; color: var(--text); touch-action: manipulation;
  background:
    repeating-linear-gradient(-45deg, color-mix(in srgb, var(--accent) 18%, transparent) 0 12px, transparent 12px 22px),
    var(--surface-2);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 50%, var(--border));
}
.tr-word.is-covered .tr-mask { display: flex; }
.tr-mask-title { font-size: 1.15rem; }
.tr-mask-hint { color: var(--accent-ink); font-size: 1rem; }
.tr-ghost { display: flex; gap: 7px; align-items: center; margin-bottom: 2px; }
.tr-ghost i {
  display: block; height: 16px; border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 62%, var(--surface));
}
.tr-ghost i:nth-child(1) { width: 42px; }
.tr-ghost i:nth-child(2) { width: 86px; }
.tr-ghost i:nth-child(3) { width: 28px; }
.tr-word .cat { font-size: .8rem; font-weight: 700; color: var(--muted); }
.tr-word .w { font-size: clamp(2.2rem, 11vw, 3.6rem); font-weight: 900; line-height: 1.2; word-break: keep-all; overflow-wrap: anywhere; }
.tr-word .w.long { font-size: clamp(1.6rem, 8vw, 2.4rem); }
.tr-forbid { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.tr-forbid span { background: color-mix(in srgb, var(--bad) 14%, var(--surface)); color: var(--bad); border: 1px solid var(--bad); border-radius: 10px; padding: 4px 10px; font-weight: 800; font-size: 1.05rem; text-decoration: line-through; text-decoration-thickness: 2px; }
.tr-forbid-title { font-size: .75rem; font-weight: 800; color: var(--bad); }
.tr-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.tr-actions.three { grid-template-columns: 1fr 1fr 1fr; }
.tr-actions .btn { min-height: 76px; font-size: 1.25rem; }
.tr-actions.three .btn { font-size: 1.05rem; padding: 10px 6px; }
.tr-list { list-style: none; padding: 0; margin: 8px 0; text-align: left; display: grid; gap: 6px; }
.tr-list li { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); font-weight: 700; }
.tr-list li.ok { background: color-mix(in srgb, var(--good) 18%, var(--surface)); }
.tr-list li.bad { background: color-mix(in srgb, var(--bad) 14%, var(--surface)); }
.tr-list li button { margin-left: auto; }
.tr-podium { font-size: 1.6rem; }

/* Shared responsive spacing and readable theme inks. */
main, .panel, .row > *, .card > div { min-width: 0; }
.panel, .dialog, .card, .tr-list li, .scoreboard { overflow-wrap: anywhere; }
details.panel > summary { min-height: 44px; padding-block: 10px; }
.input:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
@media (max-width: 400px) {
  .site-header { padding: 8px 10px; }
  .site-header h1 { font-size: 1rem; }
  .site-header .back { font-size: .8rem; }
}
@media (max-width: 560px) {
  .hub .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .hub { padding: 28px 16px 40px; }
  .hub h1 { font-size: 1.65rem; }
  .hub header p { font-size: .88rem; }
  .hub .card {
    min-width: 44px; min-height: 120px; padding: 14px 12px; gap: 8px;
    align-items: flex-start; justify-content: flex-start; text-align: left;
  }
  .hub .card .emoji { width: 30px; height: 30px; font-size: 1.25rem; border-radius: 10px; }
  .hub .card > div { width: 100%; }
  .hub .card h2 { margin-bottom: 4px; font-size: .9rem; line-height: 1.4; }
  .hub .card p { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: .76rem; }
  .hub .card .tag { display: block; width: fit-content; margin: 4px 0 0; padding: 1px 5px; font-size: .6rem; }
}
@media (prefers-color-scheme: dark) {
  .btn.good { background: #18794e; }
  .btn.bad { background: #b91c1c; }
}
@media (prefers-reduced-motion: reduce) {
  .btn:hover, .btn:active, .hub .card:hover { transform: none; }
}

/* Tabs share the same labels on phones; only their decorative icons hide. */
#tab-ads { flex-grow: 1.2; }
@media (max-width: 600px) {
  .hub-mode .tab-icon { display: none; }
  #tab-ads { flex-grow: 1; }
  .hub-mode { font-size: .8rem; }
}

/* Optional PWA action, pinned clear of the hub heading and safe areas. */
.install-button {
  position: fixed; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); z-index: 100;
  min-width: 0; min-height: 0; padding: 7px 11px; border-radius: 999px; font-size: 13px;
  box-shadow: var(--shadow-sm);
}
.hub-page .hub { padding-top: 78px; }
.install-button[hidden] { display: none; }
