:root {
  --ink: #111827;
  --muted: #667085;
  --paper: #f7f5ef;
  --card: rgba(255,255,255,.92);
  --line: #d8d5cb;
  --acid: #d8ff3e;
  --acid-dark: #b7dc22;
  --blue: #3b82f6;
  --radius: 22px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #dce8ef;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  min-height: 100dvh;
  background:
    radial-gradient(circle at 10% 0%, rgba(216,255,62,.55), transparent 26rem),
    linear-gradient(135deg, #edf2f4, #cbdde7);
}
button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100dvh; overflow: hidden; }
.screen { display: none; min-height: 100dvh; }
.screen.active { display: flex; }

.register-screen {
  padding: clamp(24px, 4vw, 64px);
  align-items: center;
  justify-content: center;
  gap: clamp(32px, 7vw, 110px);
  position: relative;
}
.register-screen::before {
  content: ""; position: absolute; inset: 0; opacity: .18; pointer-events: none;
  background-image: linear-gradient(#111 1px, transparent 1px), linear-gradient(90deg, #111 1px, transparent 1px);
  background-size: 32px 32px; mask-image: linear-gradient(to right, #000, transparent 60%);
}
.brand-chip { position: absolute; top: 24px; left: clamp(24px, 4vw, 64px); font-weight: 900; letter-spacing: .08em; }
.welcome-copy { width: min(550px, 44vw); position: relative; z-index: 1; }
.company-logo {
  display: block;
  width: min(360px, 82%);
  height: auto;
  margin: 0 0 18px;
  filter: drop-shadow(0 10px 20px rgba(27,71,143,.13));
}
.game-title-logo {
  display: block;
  width: min(420px, 90%);
  height: auto;
  margin: 0 0 clamp(26px, 4vh, 44px);
  image-rendering: pixelated;
  filter: drop-shadow(0 12px 0 rgba(17,24,39,.08));
}
.eyebrow { margin: 0 0 10px; text-transform: uppercase; font-size: 12px; letter-spacing: .18em; font-weight: 900; color: #53606b; }
h1 { margin: 0; font-size: clamp(48px, 6vw, 92px); letter-spacing: -.065em; line-height: .92; }
h1 span { color: transparent; -webkit-text-stroke: 2px var(--ink); }
.intro { max-width: 470px; font-size: clamp(17px, 2vw, 22px); line-height: 1.5; color: #485461; }

.registration-card { width: min(540px, 48vw); position: relative; z-index: 1; padding: clamp(22px, 3vw, 38px); background: var(--card); border: 1px solid rgba(255,255,255,.8); border-radius: 30px; box-shadow: 0 30px 80px rgba(34,55,70,.18); backdrop-filter: blur(18px); }
.form-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.form-heading div { display: grid; gap: 2px; }
.form-heading strong { font-size: 21px; }
.form-heading small, .selection-footer small { color: var(--muted); }
.auth-mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: -6px 0 20px; padding: 4px; border-radius: 13px; background: #e9ecec; }
.auth-mode-switch button { min-height: 38px; border: 0; border-radius: 10px; background: transparent; color: #667085; font-size: 12px; font-weight: 850; }
.auth-mode-switch button.active { background: white; color: var(--ink); box-shadow: 0 3px 10px rgba(17,24,39,.1); }
.registration-card .login-only { display: none; }
.registration-card.login-mode .register-only { display: none; }
.registration-card.login-mode .login-only { display: grid; }
.registration-card .login-only[hidden] { display: none !important; }
.registration-card.login-mode .field-row { grid-template-columns: 1fr; }
.step-pill { display: inline-grid; place-items: center; min-width: 42px; height: 28px; padding: 0 10px; border-radius: 999px; background: var(--ink); color: white; font-size: 12px; font-weight: 800; }
label { display: grid; gap: 7px; margin-bottom: 15px; font-size: 13px; font-weight: 750; }
input:not([type="checkbox"]), select { width: 100%; border: 1px solid var(--line); border-radius: 13px; background: #fbfbf9; padding: 13px 14px; outline: none; transition: .2s; }
.iti { width: 100%; }
.iti input { width: 100%; min-height: 46px; }
.iti__dropdown-content { z-index: 50; max-width: min(360px, calc(100vw - 36px)); }
.iti__search-input { padding: 10px 12px !important; border-radius: 10px !important; }
input:focus, select:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(17,24,39,.08); }
.field-row { display: grid; grid-template-columns: 1.15fr .85fr; gap: 12px; }
.optional { margin-left: 4px; color: var(--muted); font-weight: 500; }
.check-row { display: flex; align-items: flex-start; gap: 10px; line-height: 1.4; font-weight: 500; }
.check-row input { width: 18px; height: 18px; accent-color: var(--ink); flex: 0 0 auto; }
.optional-check { color: #46525f; }
.optional-check em { color: var(--muted); font-style: normal; font-size: 11px; text-transform: uppercase; }
.parental-consent-row {
  padding: 11px 12px;
  border: 1px solid rgba(17,24,39,.12);
  border-radius: 14px;
  background: rgba(216,255,62,.20);
}
.text-button { border: 0; padding: 0; color: inherit; background: transparent; font-weight: 800; text-decoration: underline; }
.form-error { min-height: 20px; margin: 0 0 4px; color: #c1292e; font-size: 13px; font-weight: 700; }
.primary-button { width: 100%; min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 8px 0 22px; border: 0; border-radius: 15px; background: var(--acid); color: var(--ink); font-weight: 900; box-shadow: 0 7px 0 var(--acid-dark); transition: transform .15s, box-shadow .15s; }
.primary-button:hover { transform: translateY(-2px); box-shadow: 0 9px 0 var(--acid-dark); }
.primary-button:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--acid-dark); }
.primary-button b { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 11px; background: var(--ink); color: white; }
.primary-button:disabled { opacity: .55; pointer-events: none; }

.character-screen { flex-direction: column; padding: clamp(24px, 5vw, 60px); max-width: 1180px; margin: auto; }
.screen-header { display: grid; grid-template-columns: 50px 1fr auto; align-items: center; gap: 18px; margin-bottom: 26px; }
.screen-header h2 { margin: 0; font-size: clamp(38px, 5vw, 64px); letter-spacing: -.05em; }
.screen-header .eyebrow { margin-bottom: 3px; }
.back-button, .icon-button { border: 1px solid rgba(17,24,39,.15); border-radius: 14px; background: rgba(255,255,255,.7); color: var(--ink); font-size: 24px; width: 48px; height: 48px; }
.character-grid { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.character-card { min-height: 230px; position: relative; overflow: hidden; border: 2px solid transparent; border-radius: 22px; background: rgba(255,255,255,.72); box-shadow: 0 12px 35px rgba(38,58,73,.09); transition: transform .2s, border-color .2s; }
.character-card:hover { transform: translateY(-4px); }
.character-card.selected { border-color: var(--ink); background: var(--acid); }
.character-card img { width: 100%; height: 190px; object-fit: contain; object-position: center bottom; filter: drop-shadow(0 10px 8px rgba(0,0,0,.16)); transform-origin: center bottom; }
.character-card.exclusive-character img { transform: scale(1.08); transform-origin: center bottom; }
.character-card:hover img { animation: runner-bob .48s ease-in-out infinite alternate; }
.character-card.exclusive-character:hover img { animation: runner-bob-exclusive .48s ease-in-out infinite alternate; }
.character-card span { position: absolute; left: 13px; bottom: 12px; padding: 7px 10px; border-radius: 999px; background: var(--ink); color: white; font-size: 12px; font-weight: 800; }
.character-card.locked {
  cursor: not-allowed;
  background: rgba(229,231,235,.72);
  border-color: rgba(17,24,39,.08);
}
.character-card.locked:hover { transform: none; }
.character-card.locked img {
  filter: grayscale(1) saturate(.25) opacity(.42);
  animation: none;
}
.character-card.locked::after {
  content: "🔒";
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(17,24,39,.88);
  color: white;
  box-shadow: 0 8px 18px rgba(17,24,39,.18);
}
.character-card .lock-badge {
  left: 50%;
  bottom: 50px;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 24px);
  background: rgba(17,24,39,.86);
  color: white;
  text-align: center;
  white-space: normal;
}
@keyframes runner-bob { to { transform: translateY(-7px) rotate(-1.5deg); } }
@keyframes runner-bob-exclusive {
  from { transform: scale(1.08); }
  to { transform: scale(1.08) translateY(-7px) rotate(-1.5deg); }
}
.selection-footer { margin-top: 24px; display: grid; grid-template-columns: 1fr minmax(260px, 360px); align-items: center; gap: 24px; }
.selection-footer div { display: grid; }
.selection-footer strong { font-size: 24px; }

.game-screen { position: relative; flex-direction: column; background: #8dd4ff; }
.game-topbar { position: absolute; z-index: 10; top: max(14px, env(safe-area-inset-top)); left: 14px; right: 14px; display: grid; grid-template-columns: 48px 1fr 1fr 48px; gap: 10px; align-items: stretch; pointer-events: none; }
.game-topbar > * { pointer-events: auto; }
.score-box { justify-self: center; min-width: 150px; display: grid; text-align: center; padding: 8px 16px; border-radius: 15px; background: rgba(17,24,39,.88); color: white; box-shadow: 0 8px 22px rgba(0,0,0,.16); }
.score-box small { color: #cbd5e1; text-transform: uppercase; font-size: 9px; letter-spacing: .15em; }
.score-box strong { font-variant-numeric: tabular-nums; font-size: 20px; }
.score-box.best { background: var(--acid); color: var(--ink); }
.score-box.best small { color: #51611c; }
.canvas-wrap, #game-canvas { width: 100%; height: 100dvh; }
.canvas-wrap { position: relative; overflow: hidden; }
#game-canvas { display: block; touch-action: none; }
.game-floating-logo {
  position: absolute;
  z-index: 6;
  top: max(72px, calc(env(safe-area-inset-top) + 72px));
  left: 50%;
  width: clamp(230px, 26vw, 430px);
  height: auto;
  transform: translateX(-50%);
  pointer-events: none;
  user-select: none;
  opacity: 1;
  filter: drop-shadow(0 10px 16px rgba(3, 54, 112, .24));
  animation: floating-brand 3.4s ease-in-out infinite alternate;
}
@keyframes floating-brand {
  from { transform: translateX(-50%) translateY(0) rotate(-.35deg); }
  to { transform: translateX(-50%) translateY(8px) rotate(.35deg); }
}
.countdown { position: absolute; inset: 0; display: none; place-items: center; z-index: 8; color: white; font-size: min(24vw, 180px); font-weight: 950; text-shadow: 0 10px 0 rgba(17,24,39,.25); pointer-events: none; }
.countdown.visible { display: grid; }
.jump-hint { position: absolute; z-index: 5; left: 50%; bottom: 5vh; transform: translateX(-50%); padding: 10px 16px; border-radius: 999px; background: rgba(17,24,39,.84); color: white; font-size: 13px; font-weight: 800; animation: hint-pulse 1s infinite alternate; pointer-events: none; }
.jump-hint span { color: var(--acid); }
.jump-hint i { margin: 0 5px; color: #94a3b8; font-style: normal; }
@keyframes hint-pulse { to { transform: translateX(-50%) translateY(-6px); } }
.game-over-panel { position: absolute; z-index: 20; top: 50%; left: 50%; transform: translate(-50%,-50%); width: min(420px, calc(100% - 32px)); padding: 30px; text-align: center; border-radius: 28px; background: rgba(255,255,255,.95); box-shadow: 0 30px 90px rgba(0,0,0,.25); backdrop-filter: blur(16px); }
.game-over-panel h2 { margin: 0; font-size: 64px; letter-spacing: -.06em; }
.game-over-panel p:not(.eyebrow) { color: var(--muted); }
.game-over-panel .primary-button { margin-top: 20px; }
.secondary-button { margin-top: 18px; border: 0; background: transparent; color: var(--ink); font-weight: 800; text-decoration: underline; }

.privacy-dialog { width: min(860px, calc(100% - 28px)); max-height: min(86dvh, 860px); border: 0; border-radius: 24px; padding: 32px; box-shadow: 0 30px 100px rgba(0,0,0,.35); }
.privacy-dialog::backdrop { background: rgba(13,22,30,.7); backdrop-filter: blur(5px); }
.privacy-dialog h2 { margin: 0; font-size: 32px; }
.privacy-dialog p { line-height: 1.55; color: #46525f; }
.privacy-text {
  max-height: min(56dvh, 540px);
  margin: 18px 0 22px;
  padding: 18px;
  overflow: auto;
  border: 1px solid rgba(17,24,39,.10);
  border-radius: 16px;
  background: #f8fafc;
  color: #334155;
  font-size: 14px;
  line-height: 1.58;
  white-space: pre-wrap;
}
.dialog-close { position: absolute; top: 12px; right: 12px; width: 38px; height: 38px; border: 0; border-radius: 50%; background: #edf0f2; font-size: 24px; }

@media (max-width: 760px) {
  .register-screen { padding: 72px 16px 28px; flex-direction: column; gap: 24px; justify-content: flex-start; }
  .brand-chip { top: 22px; left: 18px; }
  .welcome-copy, .registration-card { width: 100%; }
  .welcome-copy h1 { font-size: clamp(46px, 15vw, 68px); }
  .company-logo { width: min(300px, 76vw); margin-bottom: 14px; }
  .game-title-logo { width: min(330px, 82vw); margin-top: -12px; }
  .intro { margin-bottom: 0; font-size: 16px; }
  .registration-card { padding: 22px 18px 26px; border-radius: 24px; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .character-screen { padding: 22px 14px; }
  .screen-header { grid-template-columns: 44px 1fr auto; gap: 10px; }
  .back-button { width: 42px; height: 42px; }
  .character-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .character-card { min-height: 190px; }
  .character-card img { height: 160px; }
  .character-card.exclusive-character img { transform: scale(1.06); }
  .selection-footer { position: sticky; bottom: 0; z-index: 5; grid-template-columns: 1fr 2fr; margin: 16px -14px -22px; padding: 14px; background: rgba(240,246,248,.94); backdrop-filter: blur(12px); }
  .selection-footer strong { font-size: 17px; }
  .selection-footer .primary-button { min-height: 50px; padding-left: 14px; font-size: 13px; }
  .game-topbar { grid-template-columns: 42px 1fr 1fr 42px; gap: 6px; }
  .icon-button { width: 42px; height: 42px; }
  .score-box { min-width: 0; padding: 7px 8px; }
  .score-box strong { font-size: 15px; }
  .game-floating-logo {
    top: max(64px, calc(env(safe-area-inset-top) + 64px));
    width: clamp(190px, 54vw, 285px);
  }
}

@media (max-height: 620px) and (orientation: landscape) {
  .game-topbar { top: 8px; }
  .score-box { padding: 4px 12px; }
  .game-floating-logo { top: 50px; width: clamp(170px, 22vw, 260px); }
  .game-over-panel { padding: 20px; }
  .game-over-panel h2 { font-size: 48px; }
}
