:root {
  color-scheme: dark;
  --bg: #151816;
  --panel: #222821;
  --panel-2: #30382e;
  --text: #f5f2e8;
  --muted: #b8c0ad;
  --accent: #ffb238;
  --accent-2: #5fd4ff;
  --danger: #ff5d47;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  touch-action: manipulation;
}

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(95, 212, 255, 0.12), transparent 34%),
    linear-gradient(180deg, rgba(255, 178, 56, 0.1), transparent 42%),
    var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  display: grid;
  place-items: center;
  padding: 24px;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

body {
  align-content: center;
  gap: 18px;
}

button {
  font: inherit;
}

input {
  font: inherit;
  -webkit-user-select: text;
  user-select: text;
  touch-action: auto;
}

.game-shell {
  width: min(100%, 860px);
  display: grid;
  gap: 14px;
  touch-action: manipulation;
}

.top-bar {
  display: grid;
  grid-template-columns: repeat(5, minmax(72px, 1fr));
  gap: 10px;
  align-items: stretch;
}

.top-bar > div {
  background: rgba(34, 40, 33, 0.92);
  border: 1px solid rgba(245, 242, 232, 0.12);
  border-radius: 8px;
  min-height: 64px;
}

.top-bar > div {
  padding: 10px 14px;
}

.label {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
  margin: 0 0 4px;
}

.value {
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
  margin: 0;
}

.board-wrap {
  background: rgba(18, 22, 18, 0.72);
  border: 1px solid rgba(245, 242, 232, 0.12);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
}

#gameCanvas {
  width: 100%;
  aspect-ratio: 1;
  display: block;
  background: #10130f;
  border-radius: 6px;
  touch-action: none;
}

.hidden {
  display: none !important;
}

.score-entry {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}

.score-entry label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.score-entry input,
.score-entry button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid rgba(245, 242, 232, 0.16);
}

.score-entry input {
  width: 100%;
  background: #10130f;
  color: var(--text);
  padding: 0 12px;
}

.score-entry button {
  background: var(--accent);
  color: #1e1608;
  cursor: pointer;
  font-weight: 900;
  padding: 0 14px;
}

.high-scores {
  margin-top: 12px;
  color: var(--text);
}

.high-scores h2 {
  font-size: 14px;
  margin: 0 0 6px;
}

.high-scores ol {
  list-style-position: inside;
  margin: 0;
  padding: 0;
}

.high-scores li {
  display: grid;
  grid-template-columns: 7ch 1fr;
  gap: 12px;
  line-height: 1.6;
}

.score-number {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.score-name {
  text-align: left;
}

.seo-copy {
  width: min(100%, 860px);
  color: rgba(245, 242, 232, 0.78);
  font-size: 13px;
  line-height: 1.7;
}

.seo-copy h1 {
  color: rgba(245, 242, 232, 0.92);
  font-size: 18px;
  line-height: 1.35;
  margin: 0 0 8px;
}

.seo-copy p {
  margin: 0 0 6px;
}

.joystick-wrap {
  width: min(100%, 220px);
  justify-self: center;
  display: flex;
  justify-content: center;
  touch-action: none;
}

.joystick {
  position: relative;
  width: 132px;
  aspect-ratio: 1;
  border: 1px solid rgba(245, 242, 232, 0.12);
  border-radius: 50%;
  background: radial-gradient(circle, #30382e 0 34%, #222821 35% 100%);
  box-shadow: inset 0 0 0 12px rgba(16, 19, 15, 0.35);
  color: var(--text);
  cursor: pointer;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.joystick-arrows {
  position: absolute;
  inset: 20px 0 0;
  color: rgba(245, 242, 232, 0.48);
  font-size: 18px;
  font-weight: 900;
  line-height: 1.75;
  text-align: center;
  pointer-events: none;
}

.joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: linear-gradient(180deg, #5fd4ff, #2384a8);
  border: 3px solid rgba(245, 242, 232, 0.72);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.38);
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: transform 80ms ease;
}

@media (max-width: 620px) {
  body {
    padding: 8px;
    place-items: start center;
  }

  .top-bar {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
  }

  .top-bar > div {
    min-height: 48px;
    padding: 7px 6px;
  }

  .label {
    font-size: 10px;
    margin-bottom: 3px;
  }

  .value {
    font-size: 18px;
  }

  .board-wrap {
    padding: 8px;
  }

  .joystick {
    width: 120px;
  }

  .score-entry {
    grid-template-columns: 1fr;
  }
}
