@import url('https://fonts.googleapis.com/css2?family=Oxanium:wght@400;500;600;700;800;900&display=swap');

:root {
  --panel-bg: rgba(10, 3, 28, 0.64);
  --panel-border: rgba(0, 255, 236, 0.32);
  --text: #f9fbff;
  --muted: #9ff9ff;
  --accent: #00ffec;
  --danger: #ff2bd6;
  --gold: #ffe45e;
  --black: #000000;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #000000;
  color: var(--text);
  font-family: "Oxanium", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  touch-action: none;
  user-select: none;
  overscroll-behavior: none;
}

body {
  display: grid;
  place-items: center;
}

button,
input {
  font: inherit;
}

.app-shell {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(320px, min(100vw, calc(100dvh * 9 / 16))) minmax(240px, 1fr);
  gap: clamp(10px, 1.2vw, 20px);
  align-items: stretch;
  justify-items: center;
  overflow: hidden;
  padding: 0 max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  background:
    radial-gradient(circle at 24% 12%, rgba(0, 255, 236, 0.10), transparent 28%),
    radial-gradient(circle at 77% 74%, rgba(255, 43, 214, 0.10), transparent 32%),
    #000000;
}

.viewport-frame {
  position: relative;
  display: flex;
  align-items: stretch;
  justify-content: center;
  width: min(100vw, calc(100dvh * 9 / 16));
  height: 100dvh;
  max-width: 100vw;
  max-height: 100dvh;
}

.game-stage {
  --stage-width: 100vw;
  --stage-height: 100vh;
  --play-width: 100vw;
  --play-height: 100vh;
  --play-x: 0px;
  --play-y: 0px;
  position: relative;
  width: min(100vw, calc(100dvh * 9 / 16));
  height: 100dvh;
  max-width: 100vw;
  max-height: 100dvh;
  overflow: hidden;
  background: #080012;
  box-shadow: 0 0 0 1px rgba(0, 255, 236, 0.16), 0 0 80px rgba(0, 255, 236, 0.10), 0 0 120px rgba(255, 43, 214, 0.08);
  isolation: isolate;
}

.game-stage.playfield-locked {
  background:
    radial-gradient(circle at 50% var(--play-y), rgba(0, 255, 236, 0.11), transparent 34%),
    radial-gradient(circle at 50% calc(var(--play-y) + var(--play-height)), rgba(255, 43, 214, 0.10), transparent 38%),
    #080012;
}

canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.panel,
.center-message,
.desktop-board {
  border: 1px solid var(--panel-border);
  background: linear-gradient(135deg, rgba(18, 5, 45, 0.74), rgba(3, 13, 35, 0.60));
  box-shadow: 0 0 0 1px rgba(255, 43, 214, 0.10), 0 14px 36px rgba(0, 0, 0, 0.30), 0 0 26px rgba(0, 255, 236, 0.08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.panel {
  position: absolute;
  padding: 10px 14px;
  border-radius: 10px;
}

.score-panel {
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  min-width: 188px;
}

.run-panel {
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  text-align: right;
  min-width: 164px;
  display: none;
}

.big-number {
  display: block;
  font-size: clamp(24px, calc(var(--stage-width) * 0.08), 42px);
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1;
}

.label {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.jump-panel {
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
}

.pip {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  border: 2px solid rgba(255, 255, 255, 0.92);
  box-shadow: inset 0 0 10px rgba(0, 255, 236, 0.62), 0 0 16px rgba(255, 43, 214, 0.28);
  opacity: 0.28;
  transform: rotate(45deg) scale(0.78);
  transition: opacity 120ms ease, transform 120ms ease, background 120ms ease;
}

.pip.ready {
  background: linear-gradient(135deg, #ffffff, #00ffec 42%, #ff2bd6 100%);
  opacity: 1;
  transform: rotate(45deg) scale(1);
}

.hint {
  font-size: 13px;
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
}

.kbd {
  display: inline-block;
  padding: 3px 8px 4px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 5px;
  background: rgba(0, 255, 236, 0.10);
  color: #ffffff;
  font-weight: 900;
}

.sound-toggle {
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  pointer-events: auto;
  z-index: 5;
  transition: opacity 120ms ease, transform 120ms ease, border-color 120ms ease;
}

.sound-toggle:hover,
.sound-toggle:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(125, 252, 255, 0.52);
  outline: none;
}

.sound-toggle.muted {
  opacity: 0.68;
}

.center-message {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 8;
  width: min(640px, calc(100% - 28px));
  max-height: calc(100% - 36px);
  overflow: auto;
  transform: translate(-50%, -50%);
  text-align: center;
  padding: 24px 24px 22px;
  border-radius: 18px;
  pointer-events: auto;
  transition: opacity 140ms ease, transform 140ms ease;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 255, 236, 0.5) rgba(0, 0, 0, 0.18);
}

.center-message.hidden {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.96);
  pointer-events: none;
}

.center-message h1,
.center-message h2,
.desktop-board h2,
.home-leaderboards h2,
.howto h2 {
  margin: 0;
  line-height: 1;
  font-weight: 900;
  letter-spacing: -0.045em;
  text-shadow: 0 0 22px rgba(0, 255, 236, 0.46), 0 0 36px rgba(255, 43, 214, 0.26);
}

.brand-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 0 auto 10px;
  max-width: 100%;
  min-width: 0;
}

.brand-logo {
  width: clamp(108px, calc(var(--stage-width) * 0.26), 168px);
  height: clamp(108px, calc(var(--stage-width) * 0.26), 168px);
  object-fit: contain;
  border-radius: 0;
  filter: drop-shadow(0 0 26px rgba(0, 255, 236, 0.50));
}

.brand-row h1 {
  font-size: clamp(42px, calc(var(--stage-width) * 0.13), 78px);
  min-width: 0;
  white-space: nowrap;
}

@media (hover: hover) and (pointer: fine) {
  .game-stage:not(.playfield-locked) .center-message .brand-row {
    width: 100%;
    gap: clamp(8px, calc(var(--stage-width) * 0.018), 12px);
  }

  .game-stage:not(.playfield-locked) .center-message .brand-logo {
    width: clamp(86px, calc(var(--stage-width) * 0.205), 132px);
    height: clamp(86px, calc(var(--stage-width) * 0.205), 132px);
  }

  .game-stage:not(.playfield-locked) .center-message .brand-row h1 {
    font-size: clamp(34px, calc(var(--stage-width) * 0.102), 62px);
    letter-spacing: -0.055em;
  }
}

.tagline,
.center-message p {
  margin: 8px auto 0;
  max-width: 520px;
  color: rgba(210, 247, 255, 0.82);
  font-size: clamp(14px, calc(var(--stage-width) * 0.032), 17px);
  line-height: 1.45;
  font-weight: 650;
}

.start-form {
  display: grid;
  gap: 10px;
  margin: 18px auto 0;
  max-width: 390px;
}

.start-form label {
  color: #ffffff;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 12px;
}

.start-form input {
  width: 100%;
  border: 1px solid rgba(0, 255, 236, 0.32);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.34);
  color: #ffffff;
  outline: none;
  padding: 13px 14px;
  text-align: center;
  font-weight: 900;
  letter-spacing: 0.02em;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06), 0 0 22px rgba(0, 255, 236, 0.06);
}

.start-form input:focus {
  border-color: rgba(0, 255, 236, 0.74);
  box-shadow: 0 0 0 3px rgba(0, 255, 236, 0.12), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.start-form input[aria-invalid="true"] {
  border-color: rgba(255, 43, 214, 0.82);
}

.field-note {
  min-height: 18px;
  color: rgba(210, 247, 255, 0.78);
  font-size: 12px;
  font-weight: 700;
}

.primary-action {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 14px;
  padding: 13px 18px;
  color: #050014;
  background: linear-gradient(135deg, #ffffff, #00ffec 52%, #ff2bd6 120%);
  box-shadow: 0 0 30px rgba(0, 255, 236, 0.28), 0 14px 36px rgba(0, 0, 0, 0.28);
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease, filter 120ms ease;
}

.primary-action:hover:not(:disabled),
.primary-action:focus-visible:not(:disabled) {
  transform: translateY(-1px);
  outline: none;
}

.primary-action:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  filter: grayscale(0.5);
}

.play-again {
  max-width: 360px;
  margin: 14px auto 0;
}

.howto,
.home-leaderboards {
  margin: 18px auto 0;
  max-width: 540px;
  text-align: left;
}

.howto h2,
.home-leaderboards h2 {
  font-size: 16px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #ffffff;
  text-shadow: none;
}

.howto p {
  text-align: left;
  font-size: 13px;
  margin-top: 8px;
}

.summary-title {
  margin-top: 6px !important;
  font-size: clamp(34px, calc(var(--stage-width) * 0.095), 64px);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 14px auto 8px;
  max-width: 540px;
}

.summary-grid div {
  border: 1px solid rgba(0, 255, 236, 0.20);
  border-radius: 12px;
  padding: 11px 8px;
  background: rgba(0, 0, 0, 0.22);
}

.summary-grid strong {
  display: block;
  font-size: clamp(18px, calc(var(--stage-width) * 0.044), 28px);
  line-height: 1;
}

.summary-grid span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.rank-line {
  color: #ffffff !important;
}

.shard-line {
  font-size: 12px !important;
}

.leaderboard-widget {
  margin-top: 10px;
  border: 1px solid rgba(0, 255, 236, 0.22);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.24);
}

.lb-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 6px;
  gap: 6px;
  background: rgba(0, 0, 0, 0.22);
}

.lb-tab {
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 10px;
  padding: 8px 10px;
  color: rgba(210, 247, 255, 0.76);
  background: rgba(255, 255, 255, 0.04);
  font-weight: 900;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 12px;
}

.lb-tab.active {
  color: #050014;
  background: linear-gradient(135deg, #ffffff, #00ffec 60%, #ff2bd6 130%);
}

.lb-head,
.lb-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 88px 62px;
  align-items: center;
  gap: 8px;
}

.lb-head {
  padding: 8px 12px;
  color: rgba(210, 247, 255, 0.66);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.lb-scroll {
  max-height: calc(10 * 35px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 255, 236, 0.5) rgba(0, 0, 0, 0.18);
}

.lb-row {
  min-height: 35px;
  padding: 7px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.055);
  font-size: 12px;
  font-weight: 800;
}

.lb-row:nth-child(1) .lb-rank,
.lb-row:nth-child(2) .lb-rank,
.lb-row:nth-child(3) .lb-rank {
  color: var(--gold);
}

.lb-rank {
  color: var(--muted);
}

.lb-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #ffffff;
}

.lb-score,
.lb-time {
  text-align: right;
  color: rgba(255, 255, 255, 0.90);
}

.lb-empty {
  padding: 18px 12px;
  color: rgba(210, 247, 255, 0.70);
  text-align: center;
  font-size: 12px;
  font-weight: 750;
}

.desktop-board {
  align-self: stretch;
  width: 100%;
  height: 100dvh;
  max-height: 100dvh;
  max-width: 360px;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  border-radius: 0;
  padding: 12px 14px;
  pointer-events: auto;
  overflow: hidden;
}

.desktop-board h2 {
  font-size: clamp(18px, 1.6vw, 26px);
  letter-spacing: 0.02em;
  color: #ffffff;
}

.side-subtitle {
  margin: 5px 0 12px;
  color: rgba(210, 247, 255, 0.70);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.lb-side-scroll {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(0, 255, 236, 0.18);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.18);
}

.desktop-board .lb-row {
  grid-template-columns: 44px minmax(0, 1fr) 76px 52px;
  min-height: 34px;
  padding: 6px 9px;
  font-size: 11px;
}

.desktop-board .lb-head {
  grid-template-columns: 44px minmax(0, 1fr) 76px 52px;
  padding: 7px 9px;
}

.orientation-lock {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: max(22px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(22px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  overflow: hidden;
  color: var(--text);
  text-align: center;
  background:
    radial-gradient(circle at 18% 18%, rgba(0, 255, 236, 0.22), transparent 34%),
    radial-gradient(circle at 82% 72%, rgba(255, 43, 214, 0.22), transparent 36%),
    linear-gradient(135deg, rgba(8, 0, 18, 0.94), rgba(3, 13, 35, 0.96));
  backdrop-filter: blur(12px) saturate(1.12);
  -webkit-backdrop-filter: blur(12px) saturate(1.12);
  pointer-events: auto;
}

.orientation-lock::before,
.orientation-lock::after {
  content: "";
  position: absolute;
  inset: -18%;
  pointer-events: none;
}

.orientation-lock::before {
  opacity: 0.18;
  background:
    repeating-linear-gradient(90deg, transparent 0 34px, rgba(0, 255, 236, 0.34) 35px 36px),
    repeating-linear-gradient(0deg, transparent 0 34px, rgba(255, 43, 214, 0.24) 35px 36px);
  transform: perspective(520px) rotateX(58deg) translateY(15%);
  transform-origin: center bottom;
}

.orientation-lock::after {
  opacity: 0.18;
  background: repeating-linear-gradient(115deg, transparent 0 72px, rgba(255, 255, 255, 0.72) 73px 75px, transparent 76px 148px);
  animation: orientationSweep 3.8s linear infinite;
}

.orientation-card {
  position: relative;
  z-index: 1;
  width: min(500px, calc(100vw - 32px));
  padding: 28px 24px 24px;
  border: 1px solid rgba(0, 255, 236, 0.36);
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(21, 5, 56, 0.88), rgba(7, 0, 20, 0.78));
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.52), 0 0 64px rgba(255, 43, 214, 0.24), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.orientation-card h2 {
  margin: 14px 0 10px;
  font-size: clamp(30px, 8vw, 52px);
  line-height: 0.92;
  letter-spacing: -0.06em;
  text-shadow: 0 0 22px rgba(0, 255, 236, 0.42), 0 0 32px rgba(255, 43, 214, 0.24);
}

.orientation-card p {
  margin: 0 auto;
  max-width: 390px;
  color: var(--muted);
  font-size: clamp(15px, 3.8vw, 18px);
  font-weight: 800;
  line-height: 1.42;
}

.rotate-device-icon {
  position: relative;
  width: 82px;
  height: 82px;
  margin: 0 auto;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: radial-gradient(circle, rgba(0, 255, 236, 0.18), rgba(255, 43, 214, 0.12) 58%, rgba(0, 0, 0, 0.08));
  box-shadow: 0 0 34px rgba(0, 255, 236, 0.25);
}

.rotate-device-icon::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 30px;
  height: 48px;
  border: 3px solid #ffffff;
  border-radius: 8px;
  transform: translate(-50%, -50%) rotate(90deg);
  box-shadow: 0 0 18px rgba(0, 255, 236, 0.42);
  animation: phoneRotate 1.75s ease-in-out infinite;
}

.rotate-device-icon::after {
  content: "↻";
  position: absolute;
  right: -8px;
  bottom: -4px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: #080012;
  background: linear-gradient(135deg, #ffffff, #00ffec 54%, #ff2bd6);
  font-size: 22px;
  font-weight: 900;
  line-height: 32px;
  box-shadow: 0 0 22px rgba(255, 43, 214, 0.34);
}

body.mobile-landscape-locked .orientation-lock {
  display: flex;
}

body.mobile-landscape-locked .game-stage {
  filter: blur(4px) brightness(0.62) saturate(0.9);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 120;
  transform: translate(-50%, 18px);
  opacity: 0;
  pointer-events: none;
  max-width: min(520px, calc(100vw - 28px));
  padding: 12px 16px;
  border: 1px solid rgba(0, 255, 236, 0.36);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(21, 5, 56, 0.92), rgba(7, 0, 20, 0.82));
  color: #ffffff;
  font-size: 13px;
  font-weight: 900;
  text-align: center;
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.44), 0 0 32px rgba(0, 255, 236, 0.18);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast[data-mode="error"] {
  border-color: rgba(255, 43, 214, 0.58);
}

@keyframes phoneRotate {
  0%, 22% { transform: translate(-50%, -50%) rotate(90deg); }
  55%, 100% { transform: translate(-50%, -50%) rotate(0deg); }
}

@keyframes orientationSweep {
  from { transform: translateX(-7%); }
  to { transform: translateX(7%); }
}

@media (max-width: 1100px) {
  .app-shell {
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: 0;
  }
  .desktop-board {
    display: none;
  }
}

@media (max-width: 700px) {
  .run-panel {
    display: none;
  }
  .sound-toggle {
    top: max(14px, env(safe-area-inset-top));
  }
  .score-panel {
    min-width: 146px;
  }
  .jump-panel {
    width: calc(100% - 28px);
    justify-content: center;
  }
  .hint {
    font-size: 12px;
  }
  .center-message {
    padding: 20px 18px 18px;
  }
  .brand-row {
    gap: 10px;
  }
  .summary-grid {
    grid-template-columns: 1fr;
  }
  .lb-head,
  .lb-row {
    grid-template-columns: 46px minmax(0, 1fr) 74px 54px;
    gap: 6px;
    padding-left: 8px;
    padding-right: 8px;
  }
}

.perf-panel {
  position: fixed;
  left: 10px;
  bottom: 10px;
  z-index: 200;
  max-width: calc(100vw - 20px);
  padding: 7px 9px;
  border: 1px solid rgba(0, 255, 236, 0.36);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.72);
  color: #cfffff;
  font: 700 11px/1.35 "Oxanium", monospace;
  pointer-events: none;
  white-space: pre-wrap;
  box-shadow: 0 0 22px rgba(0, 255, 236, 0.12);
}
