@import url("https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:FILL,wght,GRAD,opsz@0..1,300..700,0,20..48");

:root {
  --bg: #0d0a1a;
  --bg2: #160e2c;
  --ink: #f0ebff;
  --muted: #9887bc;
  --panel: #1c1235;
  --panel2: #261948;
  --line: rgba(255,255,255,.1);
  --cyan: #58f0ff;
  --pink: #ff5fd2;
  --lime: #a8ff5d;
  --yellow: #ffd84f;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { min-height: 100svh; color: var(--ink); font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans KR", sans-serif; background: #0d0a1a; }
body::before { content: ""; position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse 110% 55% at 50% -5%, #2a1560 0%, transparent 68%); }
body::after { content: ""; position: fixed; inset: 0; pointer-events: none; background-image: linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px); background-size: 28px 28px; }
h1, h2, h3 { font-family: "Courier New", Consolas, monospace; }
.eyebrow, .pill { font-family: "Courier New", Consolas, monospace; }
.wrap { width: min(100%, 860px); margin: 0 auto; padding: calc(16px + env(safe-area-inset-top)) 14px calc(22px + env(safe-area-inset-bottom)); }
.card { margin-top: 12px; padding: 16px; border: 1px solid rgba(255,255,255,.1); border-radius: 14px; background: linear-gradient(160deg, var(--panel2), var(--panel)); box-shadow: 0 0 0 1px rgba(255,255,255,.05) inset, 0 8px 24px rgba(0,0,0,.4); }
.card.compact { padding: 12px; }
.hero { margin-top: 0; background: linear-gradient(160deg, #3d2870, #1e1245); border-color: rgba(88,240,255,.14); box-shadow: 0 0 0 1px rgba(255,255,255,.07) inset, 0 8px 24px rgba(0,0,0,.4), 0 0 40px rgba(88,240,255,.07); }
.topline { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.pill { padding: 4px 10px; border-radius: 4px; background: rgba(88,240,255,.12); color: var(--cyan); font-size: 11px; font-weight: 700; letter-spacing: .08em; }
.header h1 { margin: 0; font-size: 30px; line-height: 1.1; letter-spacing: .02em; text-shadow: 0 0 30px rgba(88,240,255,.2); }
.sub { margin: 8px 0 0; color: var(--muted); line-height: 1.6; font-size: 14px; }
.section-title { margin: 0; font-size: 17px; letter-spacing: .02em; }
.small { font-size: 12px; color: var(--muted); }
.row { display: grid; grid-template-columns: 1fr; gap: 10px; }
.row.between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
input, select { width: 100%; min-height: 44px; font-size: 15px; padding: 10px 14px; border: 1px solid rgba(255,255,255,.12); border-radius: 8px; background: rgba(0,0,0,.3); color: var(--ink); font-family: inherit; outline: none; transition: border-color 150ms ease; }
input:focus, select:focus { border-color: var(--cyan); }
select option { background: #1c1235; }
.game { margin-top: 10px; }
.stats { display: grid; grid-template-columns: 1fr; gap: 10px; }
.stat { padding: 14px; border: 1px solid rgba(255,255,255,.08); border-radius: 10px; background: rgba(0,0,0,.25); }
.stat .k { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.stat .v { display: block; margin-top: 6px; font-size: 24px; font-weight: 700; font-family: "Courier New", Consolas, monospace; }
.status-box, .reaction-state { margin-top: 12px; padding: 14px; border: 1px solid rgba(255,255,255,.08); border-radius: 10px; background: rgba(0,0,0,.2); color: var(--ink); font-size: 14px; line-height: 1.5; }
.big { margin-top: 12px; width: 100%; min-height: 160px; border: none; border-radius: 14px; background: linear-gradient(180deg, #b8ff7c, #8eea4f); color: #11240c; font-size: clamp(24px, 8vw, 40px); font-weight: 800; text-transform: uppercase; letter-spacing: .05em; box-shadow: 0 4px 24px rgba(168,255,93,.3); transition: filter 100ms ease, transform 80ms ease; cursor: pointer; }
.big:hover { filter: brightness(1.06); }
.big:active { transform: translateY(2px); }
.big:disabled { opacity: .4; box-shadow: none; filter: none; }
.canvas-shell { margin-top: 12px; border: 1px solid rgba(255,255,255,.1); border-radius: 12px; background: #0f1730; overflow: hidden; }
.game-canvas { display: block; width: 100%; height: auto; aspect-ratio: 12 / 7; background: #0b1226; touch-action: pan-y; }
.tile-grid { margin-top: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { height: 112px; border: none; border-radius: 10px; cursor: pointer; transition: filter 100ms ease, transform 80ms ease; }
.tile:hover { filter: brightness(1.1); }
.tile:active { transform: scale(.97); }
.tile.active { outline: 3px solid rgba(255,255,255,.85); outline-offset: 2px; }
.t0 { background: var(--pink); }
.t1 { background: var(--cyan); }
.t2 { background: var(--lime); }
.t3 { background: var(--yellow); }
.control-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.bar-wrap { margin-top: 12px; position: relative; height: 92px; border: 1px solid rgba(255,255,255,.1); border-radius: 10px; background: rgba(0,0,0,.3); overflow: hidden; }
.target-zone { position: absolute; top: 0; bottom: 0; background: rgba(168,255,93,.18); border-left: 2px solid var(--lime); border-right: 2px solid var(--lime); }
.moving-bar { position: absolute; top: 8px; bottom: 8px; width: 6px; border-radius: 3px; background: var(--yellow); box-shadow: 0 0 10px rgba(255,216,79,.6); }
.number-grid { margin-top: 12px; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.nbtn { min-height: 56px; border: 1px solid rgba(255,255,255,.1); border-radius: 8px; background: rgba(255,255,255,.05); color: var(--ink); font-size: 18px; font-weight: 700; font-family: "Courier New", Consolas, monospace; transition: filter 80ms ease, transform 60ms ease; cursor: pointer; }
.nbtn:active { transform: scale(.95); }
.nbtn.ok { background: rgba(168,255,93,.18); border-color: var(--lime); color: var(--lime); }
.nbtn.wrong { background: rgba(255,110,110,.18); border-color: #ff6e6e; color: #ff9090; }
.lane-buttons { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.lane-btn { font-size: 18px; font-weight: 700; border-radius: 8px; }
.actions { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 14px; }
.btn { min-height: 48px; border: none; border-radius: 8px; background: linear-gradient(180deg, #7ef5ff, var(--cyan) 60%, #00c8dd); color: #00232a; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; font-family: inherit; font-size: 14px; font-weight: 700; letter-spacing: .05em; cursor: pointer; box-shadow: 0 4px 16px rgba(88,240,255,.3); transition: filter 120ms ease, transform 80ms ease, box-shadow 80ms ease; }
.btn:hover { filter: brightness(1.1); box-shadow: 0 4px 24px rgba(88,240,255,.5); }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 8px rgba(88,240,255,.2); }
.btn.secondary { background: rgba(255,255,255,.08); color: var(--ink); box-shadow: none; border: 1px solid rgba(255,255,255,.14); }
.btn.secondary:hover { background: rgba(255,255,255,.13); }
.btn.warning { background: var(--yellow); color: #2b2200; box-shadow: 0 4px 16px rgba(255,216,79,.3); }
.btn.slim { min-height: 36px; padding: 6px 14px; font-size: 12px; }
.rank { margin: 12px 0 0; padding: 0; list-style: none; }
.rank li { padding: 10px 4px; border-bottom: 1px solid rgba(255,255,255,.07); font-size: 14px; }
.rank li:last-child { border-bottom: none; }
.rank-mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.07);
}
.rank-mode-btn {
  min-height: 26px;
  border: none;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,255,255,.72);
  background: transparent;
  cursor: pointer;
}
.rank-mode-btn.is-active {
  background: rgba(88,240,255,.22);
  color: #d9feff;
}
.reaction-pad { border-radius: 12px; }
.reaction-pad.waiting { background: #e8a030; color: #1a0e00; }
.reaction-pad.ready { background: #79ffa8; color: #0a2412; }
.reaction-pad.too-early { background: #e85050; color: #fff0f0; }
@media (min-width: 700px) { .row { grid-template-columns: 1fr 180px; } .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } .actions { grid-template-columns: 1fr 1fr; } }
@media (max-width: 700px) { .game-canvas { aspect-ratio: 3 / 4; } }

.result-banner { margin-top: 12px; padding: 20px 16px 16px; border: 1px solid rgba(168,255,93,.25); border-radius: 12px; background: rgba(168,255,93,.08); text-align: center; position: relative; overflow: hidden; }
.result-banner.rank-1 { border-color: rgba(255,216,79,.5); background: rgba(255,216,79,.08); box-shadow: 0 0 32px rgba(255,216,79,.15); }
.result-banner.rank-2 { border-color: rgba(192,200,220,.5); background: rgba(192,200,220,.07); box-shadow: 0 0 32px rgba(192,200,220,.1); }
.result-banner.rank-3 { border-color: rgba(200,130,60,.5); background: rgba(200,130,60,.07); box-shadow: 0 0 32px rgba(200,130,60,.1); }
.result-pb { font-size: 13px; font-weight: 700; letter-spacing: .06em; color: var(--muted); margin-bottom: 6px; min-height: 18px; }
.result-pb.new-record { color: var(--lime); animation: pb-pop .5s cubic-bezier(.34,1.56,.64,1) both; }
@keyframes pb-pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.result-score { font-size: 28px; font-weight: 700; font-family: "Courier New", Consolas, monospace; color: var(--lime); margin-bottom: 8px; }
.result-rank { font-size: 22px; font-weight: 800; margin-bottom: 14px; min-height: 28px; animation: rank-in .4s cubic-bezier(.34,1.56,.64,1) both; }
.result-rank.top1 { color: var(--yellow); text-shadow: 0 0 20px rgba(255,216,79,.6); }
.result-rank.top2 { color: #c8d4e8; text-shadow: 0 0 20px rgba(192,200,220,.4); }
.result-rank.top3 { color: #e0a060; text-shadow: 0 0 20px rgba(200,130,60,.4); }
@keyframes rank-in { from { transform: scale(.5) translateY(10px); opacity: 0; } to { transform: scale(1) translateY(0); opacity: 1; } }
.result-restart { width: 100%; }
.result-actions { display: flex; gap: 8px; margin-top: 0; flex-wrap: wrap; }
.result-actions .result-restart { flex: 1; min-width: 100px; }
.btn.share { background: rgba(255,255,255,.1); color: var(--ink); box-shadow: none; border: 1px solid rgba(255,255,255,.2); flex: 1; min-width: 80px; font-size: 13px; }
.btn.share:hover { background: rgba(255,255,255,.18); }.challenge-notice { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; padding: 12px 14px; border: 1px solid rgba(255,95,210,.35); border-radius: 10px; background: rgba(255,95,210,.08); font-size: 14px; line-height: 1.4; }
.challenge-notice-icon { font-size: 20px; flex-shrink: 0; }
.challenge-notice-text em { font-style: normal; color: var(--pink); font-weight: 700; }
.challenge-result { margin-bottom: 10px; font-size: 16px; font-weight: 700; }
.challenge-win { color: var(--lime); }
.challenge-lose { color: var(--pink); }
.challenge-tie { color: var(--yellow); }
.result-next { margin: 4px 0 10px; text-align: left; }
.result-next-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: .03em;
}
.result-next-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.result-next-btn {
  min-height: 34px;
  padding: 4px 12px;
}

/* 컨페티 */
.confetti-piece { position: fixed; width: 8px; height: 8px; border-radius: 2px; top: -10px; pointer-events: none; z-index: 999; animation: confetti-fall linear forwards; }
@keyframes confetti-fall {
  0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
  80%  { opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* 모바일 헤더 압축 */
@media (max-width: 600px) {
  .hero .sub { display: none; }
  .hero h1 { font-size: 22px; }
  .hero { padding: 14px; }
  .wrap { padding-top: calc(10px + env(safe-area-inset-top)); }
}

/* 시작 버튼 하단 고정 */
.sticky-actions {
  position: sticky;
  bottom: env(safe-area-inset-bottom, 0);
  z-index: 20;
  background: var(--bg);
  padding: 10px 0 6px;
  margin-top: 12px;
  border-top: 1px solid rgba(255,255,255,.07);
}

/* 모바일 게임 UI 추가 압축 */
@media (max-width: 600px) {
  .card { margin-top: 8px; padding: 12px; }
  .stats { gap: 6px; }
  .stat { padding: 10px; }
  .stat .k { font-size: 11px; }
  .stat .v { font-size: 18px; }
  .status-box { padding: 10px 12px; font-size: 13px; margin-top: 8px; }
  .rank li { padding: 8px 4px; font-size: 13px; }
}
.result-banner:not([hidden]) ~ .sticky-actions { display: none; }
.how-to-list { margin: 10px 0 0; padding-left: 20px; color: var(--muted); font-size: 14px; line-height: 1.9; }
.how-to-list li + li { margin-top: 2px; }

/* ── 게임 페이지 하단 탭바 ── */
.game-tab-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  background: rgba(11,10,20,0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid rgba(255,255,255,.1);
  padding-bottom: env(safe-area-inset-bottom);
}
.game-tab-btn {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; padding: 9px 0 7px;
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,.35);
  font-size: 10px; font-weight: 700; letter-spacing: .05em; font-family: inherit;
  text-decoration: none;
  transition: color 150ms;
}
.game-tab-btn .tab-icon {
  font-family: "Material Symbols Outlined";
  font-size: 22px;
  line-height: 1;
  font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 24;
}
.game-tab-btn.active .tab-icon {
  font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24;
}
.game-tab-btn.active { color: var(--cyan, #58f0ff); }
.wrap.with-tab-bar { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
