:root {
  --sky-top: #6eb6ff;
  --sky-mid: #9fd0ff;
  --sky-bottom: #c8e6ff;
  --ground: #c4a35a;
  --ground-dark: #a8843f;
  --net: #2a2a2a;
  --slime-left: #e85d4c;
  --slime-right: #3d8bfd;
  --ball: #f4f0e6;
  --ink: #1a1f2e;
  --panel: rgba(15, 22, 36, 0.82);
  --accent: #ffe566;
  --white: #f7f9fc;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  touch-action: none;
}

::selection {
  background: transparent;
}

::-moz-selection {
  background: transparent;
}

html,
body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none !important;
  user-select: none !important;
  -webkit-touch-callout: none !important;
  background:
    radial-gradient(ellipse 120% 80% at 50% -10%, #8ec8ff 0%, transparent 55%),
    linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 45%, var(--sky-bottom) 100%);
  color: var(--ink);
  font-family: "Space Grotesk", sans-serif;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 12px env(safe-area-inset-bottom);
}

.top-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 10px 4px 8px;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

.brand {
  font-family: "Press Start 2P", monospace;
  font-size: clamp(0.55rem, 2.2vw, 0.85rem);
  letter-spacing: -0.02em;
  color: var(--ink);
  text-shadow: 2px 2px 0 rgba(255, 255, 255, 0.45);
  justify-self: start;
}

.scoreboard {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: "Press Start 2P", monospace;
  font-size: clamp(1.1rem, 4vw, 1.6rem);
}

.score-left {
  color: var(--slime-left);
}

.score-right {
  color: var(--slime-right);
}

.score-sep {
  color: var(--ink);
  opacity: 0.55;
}

.mode-label {
  justify-self: end;
  font-family: "Press Start 2P", monospace;
  font-size: 0.55rem;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.35);
  border: 2px solid rgba(26, 31, 46, 0.2);
  color: var(--ink);
}

.stage {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

#game {
  display: block;
  width: 100%;
  height: auto;
  max-height: 100%;
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 55%, #b8dcff 78%, var(--ground) 78%, var(--ground-dark) 100%);
  border: 3px solid rgba(26, 31, 46, 0.35);
  box-shadow:
    0 12px 40px rgba(20, 40, 80, 0.25),
    inset 0 0 0 1px rgba(255, 255, 255, 0.25);
  image-rendering: pixelated;
  -webkit-user-drag: none;
  user-drag: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12, 24, 48, 0.35);
  backdrop-filter: blur(2px);
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.overlay-panel {
  text-align: center;
  background: var(--panel);
  color: var(--white);
  padding: 24px 20px;
  border: 3px solid rgba(255, 255, 255, 0.18);
  max-width: min(92vw, 420px);
  max-height: min(88vh, 640px);
  overflow-y: auto;
  animation: panel-in 0.35s ease-out;
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.overlay-title {
  font-family: "Press Start 2P", monospace;
  font-size: clamp(0.7rem, 3vw, 1rem);
  line-height: 1.5;
  margin-bottom: 12px;
  color: var(--accent);
}

.overlay-sub {
  font-size: 0.95rem;
  opacity: 0.9;
  margin-bottom: 16px;
  line-height: 1.4;
}

.mode-select {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}

.mode-select[hidden] {
  display: none;
}

.mode-btn[hidden] {
  display: none;
}

.mode-btn {
  appearance: none;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: var(--white);
  font-family: "Space Grotesk", sans-serif;
  text-align: left;
  padding: 14px 16px;
  cursor: pointer;
  border-radius: 10px;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.mode-btn-title {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.mode-btn-desc {
  display: block;
  font-size: 0.78rem;
  opacity: 0.72;
  line-height: 1.35;
}

.mode-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.mode-btn.active {
  background: rgba(255, 229, 102, 0.18);
  border-color: var(--accent);
}

.mode-btn.active .mode-btn-title {
  color: var(--accent);
}

.mode-btn:active {
  transform: scale(0.98);
}

.btn-primary {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: "Press Start 2P", monospace;
  font-size: 0.7rem;
  padding: 14px 28px;
  background: var(--accent);
  color: var(--ink);
  border-bottom: 4px solid #c9b040;
  transition: transform 0.1s ease, filter 0.15s ease;
}

.btn-primary:hover {
  filter: brightness(1.05);
}

.btn-primary:active {
  transform: translateY(2px);
  border-bottom-width: 2px;
}

.controls-hint {
  margin-top: 18px;
  font-size: 0.8rem;
  line-height: 1.45;
  opacity: 0.75;
  white-space: pre-line;
}

.touch-controls {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  padding: 10px 4px 14px;
  flex-shrink: 0;
}

.touch-controls[hidden] {
  display: none;
}

.touch-player {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.touch-player[hidden] {
  display: none;
}

.touch-p1 {
  align-items: flex-start;
}

.touch-p2 {
  align-items: flex-end;
}

.touch-label {
  font-family: "Press Start 2P", monospace;
  font-size: 0.45rem;
  opacity: 0.7;
}

.touch-p1 .touch-label {
  color: var(--slime-left);
}

.touch-p2 .touch-label {
  color: var(--slime-right);
}

.touch-cluster {
  display: flex;
  gap: 8px;
}

.touch-btn {
  width: 72px;
  height: 72px;
  border: 3px solid rgba(26, 31, 46, 0.35);
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink);
  font-size: 1.4rem;
  font-weight: 700;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.1s ease, transform 0.1s ease;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

.touch-btn.jump {
  width: 88px;
  background: rgba(255, 229, 102, 0.75);
}

.touch-btn:active,
.touch-btn.active {
  background: rgba(255, 255, 255, 0.9);
  transform: scale(0.96);
}

.touch-btn.jump:active,
.touch-btn.jump.active {
  background: rgba(255, 229, 102, 0.95);
}

@media (max-width: 640px) {
  .brand {
    font-size: 0.5rem;
  }

  .overlay-panel {
    padding: 20px 16px;
  }

  .overlay-title {
    font-size: 0.65rem;
  }

  .mode-btn {
    padding: 16px;
  }

  .touch-btn {
    width: 64px;
    height: 64px;
  }

  .touch-btn.jump {
    width: 64px;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .top-bar {
    padding: 4px;
  }

  .brand {
    font-size: 0.45rem;
  }

  .touch-controls {
    padding: 4px 0 8px;
  }

  .touch-btn {
    width: 56px;
    height: 52px;
    font-size: 1.1rem;
  }

  .touch-btn.jump {
    width: 68px;
  }
}
