:root {
  color-scheme: dark;
  --ink: #10111f;
  --paper: #fff8ef;
  --lime: #c8ff3d;
  --pink: #ff4f9a;
  --cyan: #31d7ff;
  --orange: #ffb72c;
  --violet: #8f6bff;
  --green: #33e18f;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 79, 154, 0.34), transparent 28%),
    radial-gradient(circle at 86% 18%, rgba(49, 215, 255, 0.34), transparent 28%),
    linear-gradient(135deg, #171126 0%, #122633 45%, #1b3a22 100%);
  color: var(--paper);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

.game-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  width: min(1180px, 100vw);
  height: 100%;
  margin: 0 auto;
  padding: 14px;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 72px;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
}

.brand-mark {
  display: grid;
  flex: 0 0 52px;
  width: 52px;
  height: 52px;
  place-items: center;
  border: 3px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: linear-gradient(135deg, var(--pink), var(--orange) 48%, var(--lime));
  color: #111;
  font-weight: 950;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.25rem, 3vw, 2rem);
  line-height: 1;
}

.brand p {
  margin-top: 4px;
  color: rgba(255, 248, 239, 0.74);
  font-size: 0.88rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(76px, 1fr));
  gap: 8px;
  min-width: min(45vw, 340px);
}

.stats div {
  display: grid;
  min-height: 52px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(10, 12, 22, 0.48);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.stats span {
  color: rgba(255, 248, 239, 0.72);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.stats strong {
  font-size: 1.25rem;
  line-height: 1;
}

.icon-button,
.primary-button,
.mobile-controls button {
  cursor: pointer;
  touch-action: manipulation;
}

.toolbar-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 10px;
}

.icon-button {
  display: grid;
  flex: 0 0 52px;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 8px;
  background: var(--cyan);
  color: #09101c;
  font-size: 1.55rem;
  font-weight: 950;
  box-shadow: 0 8px 0 #0c6f87;
}

.help-button {
  background: var(--pink);
  box-shadow: 0 8px 0 #8e2452;
}

.icon-button.is-on {
  background: var(--lime);
  box-shadow: 0 8px 0 #6c9219;
}

.stage-wrap {
  position: relative;
  display: grid;
  min-height: 0;
  overflow: hidden;
  border: 3px solid rgba(255, 255, 255, 0.38);
  border-radius: 8px;
  background: #0d281c;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.4);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.overlay-panel {
  position: absolute;
  inset: 50% auto auto 50%;
  display: grid;
  width: min(520px, calc(100% - 28px));
  gap: 16px;
  transform: translate(-50%, -50%);
  border: 3px solid rgba(255, 255, 255, 0.62);
  border-radius: 8px;
  padding: 22px;
  background: rgba(13, 17, 30, 0.88);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.48);
  text-align: center;
  backdrop-filter: blur(12px);
}

.overlay-panel.hidden {
  display: none;
}

.overlay-panel h2 {
  font-size: clamp(1.55rem, 5vw, 2.6rem);
  line-height: 1.02;
}

.overlay-panel p {
  color: rgba(255, 248, 239, 0.82);
  line-height: 1.5;
}

.help-panel {
  width: min(680px, calc(100% - 28px));
}

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

.tip-grid div {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 2px 10px;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.08);
  text-align: left;
}

.tip-grid strong {
  color: var(--lime);
  font-size: 0.96rem;
}

.tip-grid p {
  grid-column: 2;
  font-size: 0.86rem;
  line-height: 1.35;
}

.tip-icon {
  display: grid;
  grid-row: span 2;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 2px solid rgba(16, 17, 31, 0.92);
  border-radius: 8px;
  color: var(--ink);
  font-size: 1.25rem;
  font-weight: 950;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
}

.note-icon {
  background: var(--cyan);
}

.math-icon {
  background: var(--lime);
}

.ball-icon {
  background: var(--orange);
}

.shield-icon {
  background: var(--pink);
}

.control-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.control-strip span {
  min-width: 74px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--lime);
  font-size: 0.86rem;
  font-weight: 900;
}

.primary-button {
  justify-self: center;
  min-width: 180px;
  border-radius: 8px;
  padding: 13px 18px;
  background: linear-gradient(135deg, var(--lime), var(--green));
  color: #0a1320;
  font-weight: 950;
  box-shadow: 0 9px 0 #267b41;
}

.primary-button:active,
.icon-button:active,
.mobile-controls button:active {
  transform: translateY(4px);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
}

.mobile-controls {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  min-height: 58px;
}

.mobile-controls button {
  border: 2px solid rgba(255, 255, 255, 0.34);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--paper);
  font-size: 1.35rem;
  font-weight: 950;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.35);
}

#kickButton {
  background: var(--orange);
  color: #16120a;
}

@media (max-width: 720px) {
  body {
    overflow: auto;
  }

  .game-shell {
    min-height: 100%;
    padding: 10px;
  }

  .top-bar {
    align-items: stretch;
    min-height: 0;
  }

  .brand-mark {
    flex-basis: 44px;
    width: 44px;
    height: 44px;
  }

  .brand p {
    display: none;
  }

  .stats {
    grid-template-columns: repeat(3, minmax(54px, 1fr));
    min-width: 0;
    flex: 1 1 auto;
  }

  .stats div {
    min-height: 44px;
  }

  .stats span {
    font-size: 0.62rem;
  }

  .stats strong {
    font-size: 1rem;
  }

  .icon-button {
    flex-basis: 44px;
    width: 44px;
    height: 44px;
  }

  .stage-wrap {
    min-height: 56vh;
  }

  .overlay-panel {
    padding: 18px;
  }

  .tip-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 470px) {
  .top-bar {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .stats {
    grid-column: 1 / -1;
    order: 3;
  }
}
