:root {
  color-scheme: dark;
  --bg-0: #08101a;
  --bg-1: #0f2233;
  --bg-2: #123c4d;
  --ink: #eef4f6;
  --muted: #b7c6cd;
  --accent: #ffb454;
  --accent-strong: #ff7a1a;
  --panel: rgba(7, 12, 18, 0.78);
  --border: rgba(255, 255, 255, 0.12);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top, rgba(255, 180, 84, 0.2), transparent 28%),
    radial-gradient(circle at 20% 20%, rgba(86, 221, 184, 0.16), transparent 30%),
    linear-gradient(180deg, var(--bg-2), var(--bg-0) 56%);
}

.shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
}

.frame {
  width: min(1100px, 100%);
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 24%),
    var(--panel);
  backdrop-filter: blur(18px);
  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.masthead {
  display: grid;
  gap: 10px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--accent);
}

.masthead h1 {
  margin: 0;
  font-size: clamp(2.2rem, 4vw, 4.4rem);
  line-height: 0.95;
  letter-spacing: -0.04em;
}

.lede {
  margin: 0;
  max-width: 48rem;
  color: var(--muted);
  font-size: 1rem;
}

.canvas-wrap {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 18px;
  padding: 12px;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.01)),
    rgba(8, 12, 18, 0.82);
  overflow: hidden;
}

canvas {
  display: block;
  width: min(100%, 960px);
  height: auto;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow:
    0 20px 45px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.04);
}

.control-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 18px;
  justify-content: space-between;
  margin-bottom: 18px;
}

#start-btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 14px 22px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #071017;
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
  box-shadow: 0 14px 30px rgba(255, 122, 26, 0.24);
}

#start-btn:hover,
#start-btn:focus-visible {
  transform: translateY(-1px);
  filter: brightness(1.05);
  box-shadow: 0 18px 36px rgba(255, 122, 26, 0.3);
}

#start-btn:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.7);
  outline-offset: 2px;
}

#status-text {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.touch-panel {
  display: none;
  gap: 18px;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr);
  padding: 18px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.01)),
    rgba(4, 10, 16, 0.74);
}

.touch-group {
  display: grid;
  gap: 12px;
}

.touch-label {
  margin: 0;
  font-size: 0.74rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
}

.dpad {
  display: grid;
  justify-items: center;
  gap: 12px;
}

.dpad-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dpad-core {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.touch-actions {
  align-content: start;
}

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

.touch-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 22px;
  min-height: 72px;
  padding: 14px 16px;
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03)),
    rgba(8, 17, 25, 0.96);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 12px 28px rgba(0, 0, 0, 0.24);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: transform 100ms ease, background 100ms ease, border-color 100ms ease, box-shadow 100ms ease;
}

.touch-btn-dir {
  min-width: 72px;
}

.touch-btn-action {
  min-width: 96px;
}

.touch-btn.is-active,
.touch-btn:active,
.touch-btn:focus-visible {
  transform: translateY(1px) scale(0.98);
  border-color: rgba(255, 180, 84, 0.62);
  background:
    linear-gradient(180deg, rgba(255, 180, 84, 0.22), rgba(255, 255, 255, 0.05)),
    rgba(10, 18, 26, 0.98);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 10px 18px rgba(0, 0, 0, 0.18);
}

.touch-btn:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.7);
  outline-offset: 2px;
}

.frame:fullscreen {
  width: 100%;
  height: 100%;
  max-width: none;
  border-radius: 0;
  padding: 18px;
}

.frame:fullscreen .masthead {
  display: none;
}

.frame:fullscreen .canvas-wrap {
  height: calc(100vh - 96px);
  margin-bottom: 12px;
}

.frame:fullscreen .touch-panel {
  grid-template-columns: 1fr auto;
}

.frame:fullscreen canvas {
  width: auto;
  max-width: 100%;
  max-height: 100%;
}

@media (pointer: coarse), (max-width: 1100px) {
  .touch-panel {
    display: grid;
  }
}

@media (max-width: 720px) {
  .shell {
    padding: 14px;
  }

  .frame {
    padding: 18px;
    border-radius: 22px;
  }

  .control-strip {
    align-items: stretch;
  }

  .touch-panel {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .touch-actions-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }

  #start-btn {
    width: 100%;
    justify-content: center;
  }
}
