:root {
  color-scheme: dark;
  --bg: #10141a;
  --panel: #181f27;
  --panel-2: #202934;
  --line: #344252;
  --line-soft: rgba(255, 255, 255, 0.1);
  --text: #eef6f2;
  --muted: #a9b8bb;
  --accent: #35d0aa;
  --gold: #f5bd48;
  --warn: #ff6f67;
  --blue: #6ea8fe;
  --shadow: rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    radial-gradient(circle at 12% 10%, rgba(53, 208, 170, 0.12), transparent 30rem),
    linear-gradient(135deg, #10141a 0%, #151b21 54%, #0f1319 100%);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
}

button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

button:hover:not(:disabled),
button:focus-visible {
  border-color: var(--accent);
  background: #263342;
  outline: none;
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.game-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  width: min(1280px, calc(100vw - 28px));
  min-height: calc(100vh - 28px);
  margin: 14px auto;
}

.play-area,
.control-panel {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(24, 31, 39, 0.88);
  box-shadow: 0 18px 48px var(--shadow);
}

.play-area {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.top-strip {
  display: grid;
  grid-template-columns: minmax(160px, 0.55fr) minmax(240px, 1fr);
  gap: 18px;
  align-items: center;
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.4rem, 2.4vw, 2.15rem);
  line-height: 1.05;
}

h2 {
  margin-bottom: 10px;
  font-size: 0.84rem;
  color: var(--muted);
  text-transform: uppercase;
}

.objective {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.45;
}

.canvas-wrap {
  position: relative;
  min-height: 420px;
  background: #11171e;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 18px;
  max-width: min(520px, calc(100% - 32px));
  padding: 9px 12px;
  border: 1px solid rgba(53, 208, 170, 0.4);
  border-radius: 8px;
  background: rgba(15, 19, 25, 0.9);
  color: var(--text);
  font-size: 0.92rem;
  opacity: 0;
  transform: translate(-50%, 8px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
}

.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.status-grid div {
  min-height: 72px;
  padding: 11px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(32, 41, 52, 0.78);
}

.status-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
}

.status-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 1.24rem;
}

.panel-section {
  padding-top: 2px;
}

.button-stack {
  display: grid;
  gap: 8px;
}

.button-stack button {
  position: relative;
  width: 100%;
  padding: 10px 12px;
}

.button-stack button.selected {
  border-color: var(--accent);
  background: rgba(53, 208, 170, 0.14);
}

.button-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.button-sub {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.25;
}

.secondary {
  border-color: rgba(255, 255, 255, 0.16);
}

.hint {
  margin: auto 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

@media (max-width: 980px) {
  .game-shell {
    grid-template-columns: 1fr;
  }

  .control-panel {
    order: -1;
  }

  .canvas-wrap {
    min-height: 58vh;
  }
}

@media (max-width: 640px) {
  .game-shell {
    width: min(100vw - 16px, 1280px);
    min-height: calc(100vh - 16px);
    margin: 8px auto;
    gap: 10px;
  }

  .top-strip {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 14px;
  }

  .control-panel {
    padding: 12px;
  }

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

  .status-grid div {
    min-height: 62px;
    padding: 8px;
  }

  .status-grid span {
    font-size: 0.66rem;
  }

  .status-grid strong {
    font-size: 0.95rem;
  }
}
