:root {
  color-scheme: light;
  --ink: #17324a;
  --muted: #6c7f91;
  --line: #dce8ef;
  --paper: #ffffff;
  --soft: #f5fafc;
  --coral: #ff6f61;
  --blue: #2baee8;
  --gold: #f5b928;
  --mint: #59cdb3;
  font-family: Inter, Pretendard, "Noto Sans KR", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
button, a { font: inherit; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: #fff;
}

.product-bar {
  position: sticky;
  z-index: 50;
  top: 0;
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px max(22px, calc((100vw - 1380px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(12px);
}

.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand span { display: grid; width: 40px; height: 40px; place-items: center; border-radius: 12px; color: #fff; background: var(--coral); font-weight: 900; }
.brand strong { letter-spacing: -.025em; }
.product-bar nav { display: flex; gap: 8px; }

.utility-button, .primary-button, .secondary-button {
  min-height: 44px;
  border-radius: 13px;
  font-weight: 850;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.utility-button { padding: 0 15px; border: 1px solid var(--line); color: var(--ink); background: #fff; }
.utility-button:hover, .utility-button:focus-visible { border-color: #8db9ce; box-shadow: 0 5px 16px rgba(33,89,116,.12); }
.utility-button:disabled { opacity: .42; cursor: not-allowed; }
.primary-button { min-width: 190px; padding: 0 24px; border: 0; color: #fff; background: linear-gradient(135deg, #ff796b, #f4585a); box-shadow: 0 10px 24px rgba(244,88,90,.23); }
.secondary-button { display: inline-grid; min-width: 190px; place-items: center; padding: 0 22px; border: 1px solid var(--line); color: var(--ink); background: #fff; text-decoration: none; }
.primary-button:hover, .secondary-button:hover { transform: translateY(-2px); }
.utility-button:focus-visible, .primary-button:focus-visible, .secondary-button:focus-visible, .word-drum:focus-visible { outline: 4px solid rgba(43,174,232,.28); outline-offset: 3px; }

.game-page { width: min(1380px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 48px; }
.game-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; margin-bottom: 18px; }
.game-heading span { color: var(--coral); font-size: 12px; font-weight: 900; letter-spacing: .12em; }
.game-heading h1 { margin: 7px 0 5px; font-size: clamp(28px, 4vw, 48px); line-height: 1; letter-spacing: -.055em; }
.game-heading p { margin: 0; color: var(--muted); }
.word-pack { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.word-pack span { padding: 8px 10px; border: 1px solid var(--line); border-radius: 999px; color: #496476; background: var(--soft); font-size: 10px; letter-spacing: .04em; }

.scoreboard {
  display: grid;
  grid-template-columns: 140px 120px 140px 1fr;
  gap: 1px;
  overflow: hidden;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--line);
}
.scoreboard > div { min-height: 68px; display: grid; align-content: center; padding: 10px 18px; background: #fff; }
.scoreboard span { color: var(--muted); font-size: 11px; font-weight: 800; }
.scoreboard strong { margin-top: 4px; font-size: 22px; }
.progress-block { grid-template-columns: auto auto; align-items: center; }
.progress-block strong { justify-self: end; }
.progress-block i { grid-column: 1 / -1; height: 7px; overflow: hidden; margin-top: 8px; border-radius: 999px; background: #e8f1f5; }
.progress-block b { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--coral), var(--gold), var(--blue)); transition: width .25s ease; }

.game-stage {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid #d7e4e9;
  border-radius: 26px;
  background: #fff url("./assets/word-beat-drum-commercial/runtime/empty-studio-background.webp") center / cover no-repeat;
  box-shadow: 0 24px 70px rgba(31,74,97,.14);
  cursor: none;
  user-select: none;
  touch-action: manipulation;
}

.target-card {
  position: absolute;
  z-index: 10;
  top: 3.5%;
  left: 50%;
  width: min(350px, 38%);
  min-height: 82px;
  transform: translateX(-50%);
  display: grid;
  place-items: center;
  padding: 10px 18px;
  border: 1px solid rgba(205,222,231,.95);
  border-radius: 18px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 11px 30px rgba(58,91,106,.12);
  text-align: center;
  backdrop-filter: blur(8px);
}
.target-card span { color: var(--muted); font-size: 10px; font-weight: 850; }
.target-card strong { font-size: clamp(22px, 2.6vw, 36px); letter-spacing: .03em; }
.target-card em { color: var(--coral); font-size: 11px; font-style: normal; font-weight: 750; }

.lane-label { position: absolute; z-index: 4; top: 16%; transform: translateX(-50%); padding: 6px 13px; border-radius: 999px; color: #fff; font-size: 10px; font-weight: 900; box-shadow: 0 5px 12px rgba(50,85,101,.13); }
.lane-label-english { left: 28%; background: var(--coral); }
.lane-label-pair { left: 50%; color: #6a4c00; background: #ffe182; }
.lane-label-korean { left: 72%; background: var(--blue); }

.hit-line { position: absolute; z-index: 3; top: 61.5%; left: 12%; right: 12%; height: 3px; border-radius: 999px; background: repeating-linear-gradient(90deg, rgba(37,106,134,.25) 0 13px, transparent 13px 23px); }
.hit-line span { position: absolute; top: -14px; left: 50%; transform: translateX(-50%); padding: 3px 8px; border-radius: 999px; color: #668191; background: rgba(255,255,255,.82); font-size: 8px; font-weight: 900; }
.note-layer { position: absolute; z-index: 8; inset: 0; pointer-events: none; }

.falling-token {
  position: absolute;
  z-index: 1;
  width: clamp(78px, 8.2vw, 118px);
  aspect-ratio: 3 / 4;
  transform: translate(-50%, -50%);
  will-change: top, transform;
}
.falling-token .token-image { position: relative; z-index: 2; display: block; width: 100%; height: 100%; object-fit: contain; }
.falling-token .miss-trail { position: absolute; z-index: 1; left: 50%; top: 28%; width: 76%; height: 118%; object-fit: contain; opacity: 0; transform: translateX(-50%); transition: opacity .14s ease; }
.falling-token.missed-flowing { filter: saturate(.78); }
.falling-token.missed-flowing .miss-trail { opacity: .9; }
.token-copy { position: absolute; z-index: 3; left: 20%; top: 35%; width: 60%; height: 38%; display: grid; place-items: center; color: #17324a; font-weight: 950; font-size: clamp(11px, 1.25vw, 17px); line-height: 1.05; text-align: center; }
.falling-token.pair .token-copy:first-of-type { top: 35%; height: 18%; }
.falling-token.pair .token-copy:last-of-type { top: 55%; height: 18%; color: #7a5700; }

.word-drum {
  position: absolute;
  z-index: 12;
  bottom: -6%;
  width: clamp(180px, 22vw, 310px);
  aspect-ratio: 3 / 4;
  transform: translateX(-50%);
  padding: 0;
  border: 0;
  background: transparent;
  cursor: none;
  transition: filter .15s ease, transform .15s ease;
}
.word-drum:hover { filter: brightness(1.04) saturate(1.08); }
.word-drum.active { animation: drumHit .22s ease; }
@keyframes drumHit { 50% { transform: translateX(-50%) translateY(10px) scale(.97); } }
.word-drum img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.drum-english { left: 28%; }
.drum-pair { left: 50%; }
.drum-korean { left: 72%; }
.drum-label { position: absolute; z-index: 2; display: grid; place-items: center; color: #183549; font-size: clamp(16px, 2.05vw, 30px); font-weight: 950; line-height: 1; letter-spacing: -.03em; pointer-events: none; mix-blend-mode: normal; }
.drum-label-single { left: 11%; top: 45%; width: 78%; height: 28%; }
.drum-label-pair-left { left: 9%; top: 45%; width: 35%; height: 28%; font-size: clamp(13px, 1.55vw, 22px); }
.drum-label-pair-right { left: 47%; top: 45%; width: 35%; height: 28%; color: #755300; font-size: clamp(13px, 1.55vw, 22px); }

.mouse-hand {
  position: absolute;
  z-index: 30;
  left: 50%;
  top: 55%;
  width: clamp(120px, 13vw, 205px);
  aspect-ratio: 3 / 4;
  object-fit: contain;
  transform: translate(-17%, -10%);
  transform-origin: 82% 82%;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s ease, transform .08s linear;
  will-change: left, top, transform;
}
.game-stage.pointer-active .mouse-hand { opacity: 1; }
.mouse-hand[data-pose="downstroke"] { transform: translate(-14%, -28%) rotate(-2deg); }
.mouse-hand[data-pose="contact"] { transform: translate(-5%, -70%); }
.mouse-hand[data-pose="rebound"] { transform: translate(-17%, -14%) rotate(-3deg); }
.impact-effect { position: absolute; z-index: 28; width: clamp(110px, 12vw, 175px); opacity: 0; transform: translate(-50%, -50%) scale(.45); pointer-events: none; }
.impact-effect.show { animation: impactPop .36s ease forwards; }
@keyframes impactPop { 40% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(1.2); } }

.feedback { position: absolute; z-index: 26; left: 50%; bottom: 31%; transform: translateX(-50%); padding: 8px 16px; border-radius: 999px; color: var(--ink); background: rgba(255,255,255,.9); box-shadow: 0 8px 20px rgba(35,84,105,.13); font-size: 12px; font-weight: 900; opacity: .8; pointer-events: none; }
.feedback.good { color: #107960; }
.feedback.bad { color: #c63e49; }

.game-overlay { position: absolute; z-index: 45; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(250,253,254,.86); backdrop-filter: blur(8px); cursor: default; }
.overlay-panel { width: min(560px, 94%); padding: clamp(25px, 4vw, 44px); border: 1px solid var(--line); border-radius: 26px; background: #fff; box-shadow: 0 22px 70px rgba(34,81,103,.16); text-align: center; }
.overlay-panel > span { color: var(--coral); font-size: 11px; font-weight: 950; letter-spacing: .13em; }
.overlay-panel h2 { margin: 10px 0 12px; font-size: clamp(24px, 3vw, 38px); letter-spacing: -.045em; }
.overlay-panel p { margin: 0 auto 24px; max-width: 430px; color: var(--muted); line-height: 1.65; }
.result-panel > strong { display: block; margin: 9px 0 18px; color: var(--coral); font-size: 42px; }
.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 22px; }
.result-grid div { padding: 13px 8px; border-radius: 14px; background: var(--soft); }
.result-grid span { display: block; color: var(--muted); font-size: 10px; font-weight: 800; }
.result-grid b { display: block; margin-top: 4px; font-size: 20px; }
.result-panel .primary-button, .result-panel .secondary-button { margin: 4px; }

@media (max-width: 850px) {
  .product-bar { padding-inline: 14px; }
  .brand strong { display: none; }
  .product-bar nav { gap: 5px; }
  .utility-button { padding-inline: 10px; font-size: 12px; }
  .game-page { width: min(100% - 14px, 1380px); padding-top: 18px; }
  .game-heading { display: block; }
  .word-pack { justify-content: flex-start; margin-top: 12px; }
  .scoreboard { grid-template-columns: repeat(3, 1fr); }
  .progress-block { grid-column: 1 / -1; min-height: 54px !important; }
  .target-card { width: 48%; min-height: 66px; }
  .target-card em { display: none; }
  .word-drum { width: 25%; bottom: -12%; }
  .falling-token { width: 9.5%; }
}

@media (max-width: 560px) {
  .game-heading p, .word-pack { display: none; }
  .scoreboard > div { min-height: 55px; padding: 8px 10px; }
  .scoreboard strong { font-size: 17px; }
  .game-stage { aspect-ratio: 4 / 3; border-radius: 18px; }
  .lane-label { top: 18%; padding: 4px 8px; font-size: 8px; }
  .hit-line { top: 60%; }
  .word-drum { width: 31%; bottom: -7%; }
  .drum-label { font-size: 14px; }
  .drum-label-pair-left, .drum-label-pair-right { font-size: 11px; }
  .mouse-hand { width: 34%; }
  .feedback { bottom: 30%; font-size: 10px; }
  .game-overlay { padding: 9px; }
  .overlay-panel { width: 96%; padding: 16px 13px; border-radius: 18px; }
  .overlay-panel > span { font-size: 9px; }
  .overlay-panel h2 { margin: 6px 0 8px; font-size: 21px; line-height: 1.2; }
  .overlay-panel p { margin-bottom: 13px; font-size: 12px; line-height: 1.42; }
  .overlay-panel .primary-button, .overlay-panel .secondary-button { min-width: 0; min-height: 40px; padding-inline: 12px; font-size: 12px; }
  .result-panel > strong { margin: 5px 0 9px; font-size: 30px; }
  .result-grid { grid-template-columns: repeat(3, 1fr); gap: 4px; margin-bottom: 9px; }
  .result-grid div { padding: 7px 3px; }
  .result-grid span { font-size: 8px; }
  .result-grid b { margin-top: 2px; font-size: 15px; }
  .result-panel .primary-button, .result-panel .secondary-button { width: 45%; margin: 2px; }
}

@media (pointer: coarse) {
  .game-stage, .word-drum { cursor: default; }
}
