:root {
  color-scheme: dark;
  --bg: #171716;
  --panel: #242321;
  --panel-strong: #302d2a;
  --line: #514b43;
  --text: #f5f1e8;
  --muted: #b9b0a2;
  --accent: #5de3bd;
  --accent-strong: #2dbd9f;
  --amber: #f2c96d;
  --rose: #ee6677;
  --violet: #9d95ff;
  --shadow: rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(93, 227, 189, 0.08), transparent 42%),
    radial-gradient(circle at 82% 18%, rgba(242, 201, 109, 0.12), transparent 26%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

.shell {
  width: min(1460px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: stretch;
}

.play-area {
  position: relative;
  min-height: 560px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111110;
  box-shadow: 0 18px 48px var(--shadow);
  overflow: hidden;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 560px;
  cursor: crosshair;
}

.canvas-status {
  position: absolute;
  left: 18px;
  bottom: 16px;
  max-width: min(520px, calc(100% - 36px));
  padding: 9px 12px;
  border: 1px solid rgba(245, 241, 232, 0.16);
  border-radius: 8px;
  background: rgba(23, 23, 22, 0.78);
  color: var(--text);
  font-size: 15px;
  line-height: 1.35;
  backdrop-filter: blur(8px);
}

.controls {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(36, 35, 33, 0.94);
  box-shadow: 0 18px 48px var(--shadow);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.title-block {
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(245, 241, 232, 0.12);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(34px, 4vw, 52px);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.objective,
.run-log {
  padding: 14px;
  border: 1px solid rgba(245, 241, 232, 0.12);
  border-radius: 8px;
  background: rgba(48, 45, 42, 0.72);
}

.objective p,
.run-log p {
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}

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

.stat-grid div {
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(245, 241, 232, 0.12);
  border-radius: 8px;
  background: var(--panel-strong);
}

.stat-grid span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stat-grid strong {
  display: block;
  color: var(--text);
  font-size: 24px;
  line-height: 1;
  letter-spacing: 0;
}

.action-group {
  display: grid;
  gap: 9px;
}

.action-button,
.restart-button {
  width: 100%;
  min-height: 46px;
  border: 1px solid rgba(245, 241, 232, 0.16);
  border-radius: 8px;
  background: #38342f;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.action-button span,
.restart-button {
  font-weight: 800;
}

.action-button b {
  min-width: 56px;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(93, 227, 189, 0.14);
  color: var(--accent);
  font-size: 13px;
  text-align: center;
}

.action-button:hover,
.restart-button:hover {
  transform: translateY(-1px);
  border-color: rgba(93, 227, 189, 0.68);
  background: #403b35;
}

.action-button:disabled {
  transform: none;
  cursor: not-allowed;
  color: rgba(245, 241, 232, 0.45);
  background: #292724;
}

.action-button:disabled b {
  color: rgba(245, 241, 232, 0.45);
  background: rgba(245, 241, 232, 0.08);
}

.action-button.secondary b {
  color: var(--amber);
  background: rgba(242, 201, 109, 0.14);
}

.restart-button {
  margin-top: auto;
  justify-content: center;
  border-color: rgba(238, 102, 119, 0.42);
  background: #422d31;
}

.restart-button:hover {
  border-color: rgba(238, 102, 119, 0.84);
  background: #52343a;
}

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

  .play-area,
  #gameCanvas {
    min-height: 480px;
  }

  .controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .title-block,
  .objective,
  .run-log,
  .restart-button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .shell {
    padding: 10px;
    gap: 10px;
  }

  .play-area,
  #gameCanvas {
    min-height: 390px;
  }

  .controls {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  h1 {
    font-size: 38px;
  }
}
