@font-face { font-family: 'Baloo 2'; font-weight: 600; font-display: swap; src: url('fonts/baloo-2-latin-600-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: 'Baloo 2'; font-weight: 600; font-display: swap; src: url('fonts/baloo-2-latin-ext-600-normal.woff2') format('woff2'); unicode-range: U+0100-0130, U+0132-02BA; }
@font-face { font-family: 'Baloo 2'; font-weight: 800; font-display: swap; src: url('fonts/baloo-2-latin-800-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: 'Baloo 2'; font-weight: 800; font-display: swap; src: url('fonts/baloo-2-latin-ext-800-normal.woff2') format('woff2'); unicode-range: U+0100-0130, U+0132-02BA; }

:root {
  --ink: #151b33;
  --paper: #ffffff;
  --blue: #1f6dff;
  --red: #ff2740;
  --gold: #ffc21a;
  --green: #18c964;
  --panel: #fff;
  --muted: #5b6480;
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
  font-family: 'Baloo 2', ui-rounded, 'SF Pro Rounded', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1787ea; color: var(--ink); overscroll-behavior: none; }
body { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
canvas#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
[hidden] { display: none !important; }

button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; touch-action: manipulation; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---------- ortak düğmeler ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 54px; padding: 8px 18px;
  border-radius: 16px; border: 3px solid var(--ink);
  font-weight: 800; font-size: 19px; letter-spacing: .02em;
  background: var(--paper); color: var(--ink);
  box-shadow: 0 5px 0 var(--ink);
  transition: transform .08s ease, box-shadow .08s ease;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn.primary { background: var(--gold); font-size: 26px; min-height: 62px; }
.btn.ghost { background: rgba(255,255,255,.92); }
.btn.small { min-height: 48px; font-size: 18px; }
.btn.ghost span { font-weight: 600; }
.btn b { font-weight: 800; color: var(--blue); }

/* ---------- ana menü ---------- */
.screen { position: fixed; inset: 0; z-index: 20; }
.menu {
  display: flex; flex-direction: column;
  padding: calc(var(--top) + 14px) 16px calc(var(--bottom) + 16px);
  background: linear-gradient(180deg, rgba(10,30,90,.05) 0%, rgba(10,30,90,0) 22%, rgba(10,25,70,.42) 62%, rgba(10,25,70,.72) 100%);
  touch-action: pan-y;
}
.menu-head { text-align: center; margin-bottom: 6px; flex: 0 0 auto; }
.logo {
  margin: 0; font-weight: 800; font-size: clamp(50px, 17vw, 76px); line-height: .95; letter-spacing: .01em;
  color: var(--gold);
  -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill;
  text-shadow: 0 5px 0 var(--ink);
  transform: rotate(-2deg);
}
.menu-head p { margin: 6px 0 0; font-weight: 800; font-size: 16px; color: #fff; text-shadow: 0 2px 0 var(--ink); }
.menu-body {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; gap: 10px;
  padding: 6px 0 12px; touch-action: pan-y;
}
.menu-body::before { content: ''; flex: 1 1 auto; min-height: 0; }
.group h2 { margin: 0 0 4px; font-size: 14px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #fff; text-shadow: 0 2px 0 var(--ink); }

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.card {
  text-align: left; padding: 8px 12px; min-height: 66px; border-radius: 14px;
  background: rgba(255,255,255,.93); border: 3px solid var(--ink);
  line-height: 1.15;
}
.card strong { display: block; font-weight: 800; font-size: 17px; }
.card span { font-weight: 600; font-size: 13px; color: var(--muted); }
.card[aria-pressed='true'] { background: var(--gold); box-shadow: 0 4px 0 var(--ink); transform: translateY(-2px); }
.card[aria-pressed='true'] span { color: var(--ink); }

.chips { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.chip {
  grid-column: span 2; padding: 6px 4px; min-height: 58px; border-radius: 14px; line-height: 1.1;
  background: rgba(255,255,255,.93); border: 3px solid var(--ink); text-align: center;
}
.chip:nth-child(n+4) { grid-column: span 3; }
.chip strong { display: block; font-weight: 800; font-size: 15px; }
.chip span { font-weight: 600; font-size: 12px; color: var(--muted); }
.chip[aria-pressed='true'] { background: #38e0ff; box-shadow: 0 4px 0 var(--ink); transform: translateY(-2px); }
.chip[aria-pressed='true'] span { color: var(--ink); }

.segments { display: grid; grid-template-columns: repeat(3, 1fr); border: 3px solid var(--ink); border-radius: 14px; overflow: hidden; background: rgba(255,255,255,.93); }
.segment { min-height: 46px; font-weight: 800; font-size: 16px; }
.segment + .segment { border-left: 3px solid var(--ink); }
.segment[aria-pressed='true'] { background: var(--ink); color: var(--gold); }
.best { margin: 5px 0 0; min-height: 18px; font-size: 13px; font-weight: 800; color: #fff; text-align: center; text-shadow: 0 1px 0 var(--ink); }

.menu-foot { flex: 0 0 auto; display: grid; gap: 12px; }
.menu-foot .btn.ghost { min-height: 44px; font-size: 16px; box-shadow: 0 3px 0 var(--ink); }

@media (max-height: 700px) {
  .menu-head p { display: none; }
  .logo { font-size: 44px; }
  .card { min-height: 54px; padding: 5px 10px; }
  .chip { min-height: 50px; padding: 3px 4px; }
  .segment { min-height: 40px; }
  .btn.primary { min-height: 52px; font-size: 22px; }
  .menu-body { gap: 6px; }
}
@media (min-width: 720px) {
  .menu { align-items: center; }
  .menu-body, .menu-foot { width: 100%; max-width: 460px; }
}

/* ---------- panel ekranları ---------- */
.panel-screen {
  display: flex; align-items: center; justify-content: center;
  padding: calc(var(--top) + 16px) 16px calc(var(--bottom) + 16px);
  background: rgba(10, 18, 50, .55);
  touch-action: pan-y; overflow-y: auto;
}
.panel {
  width: 100%; max-width: 400px; margin: auto;
  background: var(--panel); border: 4px solid var(--ink); border-radius: 24px;
  box-shadow: 0 8px 0 var(--ink);
  padding: 18px 18px 22px;
  display: flex; flex-direction: column; gap: 12px;
}
.panel.center { text-align: center; }
.panel h2 { margin: 0; font-size: 28px; font-weight: 800; line-height: 1.1; }
.panel p { margin: 0; font-weight: 600; font-size: 16px; line-height: 1.3; color: #333b58; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.error { color: #c4122a !important; }

.load-bar { height: 18px; border: 3px solid var(--ink); border-radius: 10px; overflow: hidden; background: #e6edf9; }
.load-bar div { height: 100%; width: 0; background: var(--gold); transition: width .12s linear; }

/* ---------- kalibrasyon ---------- */
.calib-pad {
  position: relative; width: 100%; height: 190px; border-radius: 18px;
  background: #101a3f; color: #fff; border: 3px solid var(--ink); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.calib-count { position: relative; font-weight: 800; font-size: 32px; pointer-events: none; }
.calib-ring {
  position: absolute; left: 50%; top: 50%; width: 130px; height: 130px; margin: -65px 0 0 -65px;
  border-radius: 50%; border: 6px solid var(--gold); opacity: .25; pointer-events: none;
}
.calib-ring.hit { animation: ring .32s ease-out; }
@keyframes ring { from { transform: scale(1.25); opacity: 1; } to { transform: scale(1); opacity: .25; } }
.calib-result { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: baseline; }
.calib-result label { font-weight: 800; font-size: 16px; }
.calib-result output { font-weight: 800; font-size: 22px; color: var(--blue); }
.calib-result input { grid-column: 1 / -1; width: 100%; accent-color: var(--blue); height: 32px; touch-action: none; }
.calib-result small { grid-column: 1 / -1; font-weight: 600; font-size: 13px; color: var(--muted); line-height: 1.25; }

/* ---------- HUD ---------- */
.hud {
  position: fixed; inset: 0; z-index: 10; pointer-events: none;
  padding: calc(var(--top) + 8px) 12px calc(var(--bottom) + 10px);
}
.progress { height: 9px; border: 2px solid var(--ink); border-radius: 6px; background: rgba(255,255,255,.65); overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--gold); }
.hud-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; margin-top: 8px; }
.hud-score { line-height: 1; color: #fff; text-shadow: 0 2px 0 var(--ink), 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 -2px 0 var(--ink); }
.hud-score small { display: block; font-weight: 800; font-size: 12px; letter-spacing: .06em; }
.hud-score strong { font-weight: 800; font-size: 30px; font-variant-numeric: tabular-nums; }
.hud-lives { display: flex; gap: 3px; }
.hud-lives svg { width: 28px; height: 28px; stroke: var(--ink); stroke-width: 2.4; fill: #ff2f55; transition: transform .2s; }
.hud-lives svg.gone { fill: rgba(255,255,255,.35); transform: scale(.82); }
.icon-btn {
  pointer-events: auto; width: 46px; height: 46px; display: grid; place-items: center;
  background: rgba(255,255,255,.92); border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 3px 0 var(--ink);
}
.icon-btn svg { fill: var(--ink); }

.combo {
  position: absolute; left: 50%; top: calc(var(--top) + 84px); transform: translateX(-50%);
  display: flex; align-items: baseline; gap: 6px; color: #fff; white-space: nowrap;
  text-shadow: 0 2px 0 var(--ink), 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 -2px 0 var(--ink);
}
.combo strong { font-weight: 800; font-size: 38px; font-variant-numeric: tabular-nums; line-height: 1; }
.combo span { font-weight: 800; font-size: 15px; }
.combo em { font-style: normal; font-weight: 800; font-size: 20px; color: var(--gold); }
.combo.bump strong { animation: bump .18s ease-out; }
@keyframes bump { from { transform: scale(1.32); } to { transform: scale(1); } }

.judgement {
  position: absolute; left: 0; right: 0; top: 29%; text-align: center;
  font-weight: 800; font-size: clamp(34px, 11vw, 54px); line-height: 1; opacity: 0;
  -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill;
  text-shadow: 0 4px 0 var(--ink);
}
.judgement.show { animation: pop .52s cubic-bezier(.17,.89,.32,1.28) both; }
.judgement.perfect { color: #ffe14a; }
.judgement.good { color: #6bf0a2; }
.judgement.miss { color: #ff5a6f; }
.judgement.bonus { color: #fff; font-size: clamp(22px, 7vw, 32px); }
@keyframes pop {
  0% { opacity: 0; transform: scale(.5) rotate(-4deg); }
  30% { opacity: 1; transform: scale(1.12) rotate(1deg); }
  70% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: translateY(-16px) scale(.96); }
}

.hint {
  position: absolute; left: 50%; bottom: calc(var(--bottom) + 28px); transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 32px);
  padding: 6px 16px; border-radius: 14px; text-align: center;
  background: rgba(21,27,51,.86); color: #fff; font-weight: 800; font-size: 17px; line-height: 1.2;
}
.beat-dot {
  position: absolute; left: 50%; bottom: calc(var(--bottom) + 8px); width: 12px; height: 12px; margin-left: -6px;
  border-radius: 50%; background: #fff; border: 2px solid var(--ink); will-change: transform;
}

.countdown {
  position: fixed; inset: 0; z-index: 15; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: clamp(90px, 34vw, 170px); color: var(--gold);
  -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; text-shadow: 0 7px 0 var(--ink);
}
.countdown.go { font-size: clamp(56px, 20vw, 110px); color: #fff; }
.countdown span { display: block; animation: count .5s ease-out both; }
@keyframes count { from { transform: scale(1.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.flash { position: fixed; inset: 0; z-index: 5; pointer-events: none; opacity: 0; background: radial-gradient(circle at 50% 62%, rgba(255,255,255,0) 35%, #fff 100%); }
.flash.gold { background: radial-gradient(circle at 50% 62%, rgba(255,210,50,0) 30%, rgba(255,194,26,.95) 100%); }
.flash.red { background: radial-gradient(circle at 50% 55%, rgba(255,40,64,0) 25%, rgba(255,20,50,.9) 100%); }
.flash.on { animation: flash .3s ease-out; }
@keyframes flash { from { opacity: .85; } to { opacity: 0; } }
.vignette { position: fixed; inset: 0; z-index: 4; pointer-events: none; opacity: 0; background: radial-gradient(circle at 50% 58%, rgba(255,255,255,0) 52%, rgba(255,70,180,.42) 100%); }

/* ---------- sonuç ---------- */
.rank {
  width: 96px; height: 96px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center;
  background: var(--gold); border: 4px solid var(--ink); box-shadow: 0 5px 0 var(--ink);
  font-weight: 800; font-size: 58px; line-height: 1; padding-top: 6px;
}
.res-score { line-height: 1; }
.res-score strong { font-weight: 800; font-size: 42px; font-variant-numeric: tabular-nums; }
.record { display: block; margin-top: 2px; font-weight: 800; font-size: 16px; color: #e0156d; }
.res-accuracy { display: flex; align-items: baseline; justify-content: center; gap: 6px; }
.res-accuracy b { font-weight: 800; font-size: 26px; color: var(--blue); }
.res-accuracy span { font-weight: 600; font-size: 15px; color: var(--muted); }
.res-grid { margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.res-grid div { padding: 6px 2px; background: #eef3fc; border-radius: 12px; }
.res-grid dt { font-weight: 800; font-size: 12px; line-height: 1.1; color: var(--muted); min-height: 26px; display: flex; align-items: center; justify-content: center; }
.res-grid dt.p { color: #a06a00; }
.res-grid dt.g { color: #087f3e; }
.res-grid dt.m { color: #c4122a; }
.res-grid dd { margin: 0; font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums; }
.tip { font-size: 14px !important; background: #fff4cc; border-radius: 12px; padding: 8px 10px; }
.panel.center .btn { margin-top: 2px; }

@media (prefers-reduced-motion: reduce) {
  .flash.on { animation-duration: .1s; }
}
