:root {
  --sky-top: #9fe7ff;
  --sky-bottom: #fef3c7;
  --ink: #1c2140;
  --muted: #55607d;
  --panel: rgba(255, 255, 255, 0.82);
  --stroke: rgba(28, 33, 64, 0.12);
  --shadow: 0 18px 42px rgba(31, 46, 83, 0.18);
  --orange: #ff8f4d;
  --yellow: #ffd75c;
  --blue: #4fc0ff;
  --green: #67d38f;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Trebuchet MS", "Arial Rounded MT Bold", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 14% 16%, rgba(255, 255, 255, 0.7), transparent 24%),
    radial-gradient(circle at 86% 12%, rgba(255, 227, 141, 0.8), transparent 22%),
    linear-gradient(180deg, var(--sky-top), var(--sky-bottom));
  padding: 16px;
}

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.hero-panel {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 18px 20px;
}

.hero-copy h1 {
  margin: 0;
  font-size: clamp(2.2rem, 5vw, 4rem);
  line-height: 1;
}

.eyebrow {
  margin: 0 0 6px;
  color: #ff6f61;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sub {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.hud {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(28, 33, 64, 0.1);
  font-weight: 900;
}

.game-panel {
  padding: 14px;
}

.canvas-wrap {
  overflow: hidden;
  border-radius: 20px;
  border: 1px solid rgba(28, 33, 64, 0.12);
  background: linear-gradient(180deg, #8fdcff 0%, #dff7ff 48%, #edf9ff 100%);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.main-btn,
.ghost-btn,
.touch-btn {
  appearance: none;
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease;
}

.main-btn {
  color: white;
  background: linear-gradient(135deg, var(--orange), #ff5c57);
}

.ghost-btn {
  color: var(--ink);
  background: linear-gradient(135deg, white, #e8f4ff);
  border: 1px solid rgba(28, 33, 64, 0.1);
}

.main-btn:active,
.ghost-btn:active,
.touch-btn:active {
  transform: translateY(1px);
}

.tip,
.small {
  color: var(--muted);
  font-weight: 700;
}

.controls-panel {
  padding: 18px 20px 20px;
}

.controls-panel h2 {
  margin: 0 0 12px;
  font-size: 1.3rem;
}

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

.touch-btn {
  min-height: 56px;
  color: white;
  background: linear-gradient(135deg, #63a9ff, #4378ff);
}

.touch-btn.go {
  background: linear-gradient(135deg, var(--green), #2abf73);
}

.touch-btn.back {
  background: linear-gradient(135deg, #ffc65d, #ff9d47);
  color: #422300;
}

@media (max-width: 760px) {
  body {
    padding: 10px;
  }

  .hero-panel {
    flex-direction: column;
    align-items: flex-start;
  }

  .touch-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
}
