:root {
  --ink: #f4f6ff;
  --dim: rgba(244, 246, 255, 0.62);
  --glass: rgba(14, 16, 40, 0.62);
  --line: rgba(255, 255, 255, 0.12);
  --a1: #6f7dff;
  --a2: #d15bff;
  --a3: #3ff0e0;
  --font: ui-rounded, 'SF Pro Rounded', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0b1026;
  color: var(--ink);
  font-family: var(--font);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  overscroll-behavior: none;
}

canvas#game {
  position: fixed;
  inset: 0;
  display: block;
  touch-action: none;
}

[hidden] {
  display: none !important;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 0;
}

/* --- overlays --- */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: radial-gradient(ellipse at center, rgba(6, 8, 22, 0.35), rgba(4, 5, 14, 0.75));
  overflow-y: auto;
  z-index: 10;
  animation: fade 0.25s ease-out;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

@keyframes rise {
  from {
    transform: translateY(14px) scale(0.98);
    opacity: 0;
  }
}

.card {
  width: min(560px, 100%);
  margin: auto;
  padding: 26px 24px 22px;
  border-radius: 24px;
  background: linear-gradient(160deg, rgba(30, 34, 80, 0.72), rgba(12, 12, 34, 0.78));
  border: 1px solid var(--line);
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 0 60px rgba(111, 125, 255, 0.18);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: rise 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.small-card {
  width: min(400px, 100%);
}

h2 {
  margin: 0 0 6px;
  font-size: 28px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.logo {
  margin: 0;
  font-size: clamp(44px, 11vw, 76px);
  line-height: 0.95;
  font-weight: 900;
  letter-spacing: 0.04em;
  display: flex;
  justify-content: center;
  gap: 0.08em;
  filter: drop-shadow(0 0 18px rgba(160, 120, 255, 0.55));
}

.logo span {
  background: linear-gradient(180deg, #ffffff 0%, #a9f6ff 45%, #6f7dff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.logo span + span {
  background: linear-gradient(180deg, #ffffff 0%, #ffc0f3 45%, #c54dff 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

.tag {
  margin: 0 0 4px;
  color: var(--dim);
  font-size: 15px;
}

.modes {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.mode {
  position: relative;
  text-align: left;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  transition:
    transform 0.15s,
    background 0.15s,
    border-color 0.15s,
    box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-height: 86px;
}

.mode:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.08);
}

.mode[aria-checked='true'] {
  border-color: rgba(160, 170, 255, 0.85);
  background: linear-gradient(160deg, rgba(111, 125, 255, 0.3), rgba(209, 91, 255, 0.18));
  box-shadow: 0 0 24px rgba(111, 125, 255, 0.35);
}

.mode b {
  padding-right: 42px;
  font-size: 17px;
  letter-spacing: 0.02em;
}

.mode small {
  color: var(--dim);
  font-size: 12px;
  line-height: 1.3;
}

.mode .best {
  margin-top: auto;
  font-size: 12px;
  font-weight: 700;
  color: #a9f6ff;
}

.mode .medals {
  position: absolute;
  top: 10px;
  right: 12px;
  display: flex;
  gap: 3px;
}

.pip {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
}

.pip.on.b {
  background: radial-gradient(circle at 35% 35%, #ffd2a6, #c8773a);
  box-shadow: 0 0 6px #c8773a;
}
.pip.on.s {
  background: radial-gradient(circle at 35% 35%, #ffffff, #9aa6c0);
  box-shadow: 0 0 6px #c7d2ea;
}
.pip.on.g {
  background: radial-gradient(circle at 35% 35%, #fff6c2, #e5a91a);
  box-shadow: 0 0 8px #ffcc33;
}

.primary {
  padding: 15px 20px;
  border-radius: 16px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: linear-gradient(135deg, #6f7dff, #c54dff);
  box-shadow:
    0 10px 30px rgba(140, 90, 255, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition:
    transform 0.12s,
    filter 0.12s;
}

.primary:hover {
  transform: translateY(-1px);
  filter: brightness(1.12);
}

.primary:active,
.ghost:active,
.mode:active {
  transform: scale(0.97);
}

.ghost {
  padding: 11px 16px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
  transition: background 0.12s;
}

.ghost:hover {
  background: rgba(255, 255, 255, 0.13);
}

button:focus-visible {
  outline: 2px solid #a9f6ff;
  outline-offset: 2px;
}

.row {
  display: flex;
  gap: 10px;
}

.row > * {
  flex: 1;
}

.howto {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px 14px;
  text-align: left;
  font-size: 13px;
  color: var(--dim);
  padding: 10px 6px 0;
  border-top: 1px solid var(--line);
}

kbd {
  display: inline-block;
  min-width: 22px;
  padding: 1px 6px;
  margin-right: 3px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-bottom-width: 2px;
  font: 700 12px var(--font);
  color: var(--ink);
  text-align: center;
}

.touch-hint {
  display: none;
  margin: 0;
  font-size: 13px;
  color: var(--dim);
}

body.touchmode .touch-hint {
  display: block;
}

body.touchmode .howto {
  display: none;
}

/* --- game over --- */
.over-kicker {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #a9f6ff;
}

.over-big {
  font-size: clamp(44px, 12vw, 64px);
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 30px rgba(160, 140, 255, 0.7);
}

.over-best {
  color: var(--dim);
  font-size: 15px;
}

.over-best .new {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ffd36b, #ff7ac3);
  color: #24102a;
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 0.1em;
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    transform: scale(1.08);
  }
}

.medal-line {
  font-size: 14px;
  font-weight: 700;
  min-height: 1em;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 4px 0 6px;
}

.stats div {
  padding: 8px 4px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 18px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.stats small {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--dim);
  text-transform: uppercase;
}

/* --- settings --- */
.settings {
  text-align: left;
}

.settings h2 {
  text-align: center;
}

.slider {
  display: grid;
  grid-template-columns: 1fr 64px;
  align-items: center;
  gap: 2px 10px;
  font-weight: 700;
}

.slider span {
  grid-column: 1 / -1;
}

.slider em {
  font-style: normal;
  font-weight: 500;
  color: var(--dim);
  font-size: 12px;
  margin-left: 6px;
}

.slider output {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: #a9f6ff;
}

input[type='range'] {
  width: 100%;
  accent-color: #8f7dff;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.toggle input {
  width: 20px;
  height: 20px;
  accent-color: #8f7dff;
}

/* --- hud buttons --- */
.hud {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  right: 60px;
  z-index: 5;
}

.icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.icon svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.mute {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  right: 12px;
  z-index: 20;
}

.mute .off,
.mute.muted .on {
  display: none;
}

.mute.muted .off {
  display: block;
}

/* --- touch controls --- */
.touch {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 8px 12px max(10px, env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 10px;
  z-index: 4;
}

.cluster {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}

.cluster.right {
  align-items: flex-end;
}

.dpad,
.rot {
  display: flex;
  gap: 8px;
}

.tb {
  width: 60px;
  height: 60px;
  border-radius: 18px;
  font-size: 22px;
  font-weight: 800;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.05));
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
  touch-action: none;
}

.tb.small {
  height: 44px;
  width: 92px;
  font-size: 14px;
  letter-spacing: 0.12em;
}

.tb.drop {
  width: 128px;
  background: linear-gradient(135deg, rgba(111, 125, 255, 0.55), rgba(197, 77, 255, 0.45));
}

.tb.down {
  background: rgba(169, 246, 255, 0.35);
  transform: scale(0.95);
}

@media (max-width: 360px) {
  .tb {
    width: 52px;
    height: 54px;
  }
  .tb.drop {
    width: 112px;
  }
}

@media (max-height: 560px) {
  .card {
    padding: 16px 18px;
    gap: 8px;
  }
  .howto {
    display: none;
  }
  .mode {
    min-height: 70px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .screen,
  .card,
  .over-best .new {
    animation: none;
  }
}
