:root {
  --bg: #1f2631;
  --panel: rgba(33, 42, 55, 0.92);
  --panel-strong: rgba(48, 56, 66, 0.95);
  --line: rgba(249, 242, 222, 0.2);
  --text: #fff8e7;
  --muted: #d9d2c3;
  --teal: #39b6a6;
  --red: #e85d5d;
  --amber: #f4b84f;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    linear-gradient(145deg, rgba(57, 182, 166, 0.18), transparent 34%),
    linear-gradient(235deg, rgba(244, 184, 79, 0.18), transparent 36%),
    linear-gradient(180deg, #384557 0%, #1f2631 58%, #171b22 100%);
  color: var(--text);
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
}

body { display: flex; justify-content: center; }

.wrap {
  width: min(980px, 100vw);
  padding: 12px;
}

.topbar,
.stat,
.controls {
  border: 1px solid var(--line);
  border-radius: 8px;
  backdrop-filter: blur(14px);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding: 13px 14px;
  background: linear-gradient(180deg, rgba(52, 63, 78, 0.96), rgba(28, 36, 47, 0.96));
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.35rem, 3vw, 2.1rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.topbar p {
  margin: 6px 0 0;
  max-width: 58ch;
  color: var(--muted);
  font-size: 0.95rem;
}

.topbar-actions,
.control-actions {
  display: flex;
  gap: 8px;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  color: #fffdf4;
  font: inherit;
  font-weight: 850;
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease, opacity 120ms ease;
}

button:hover { transform: translateY(-1px); filter: brightness(1.04); }
button:active { transform: translateY(0); }
button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

#shakeBtn { padding: 10px 14px; background: linear-gradient(135deg, #39b6a6, #1e8078); }
#restartBtn { padding: 10px 14px; background: linear-gradient(135deg, #e85d5d, #b9424d); }
#rewardBtn { padding: 10px 14px; background: linear-gradient(135deg, #f4b84f, #c97825); }
#rewardBtn span { color: #fff7cf; font-weight: 950; white-space: nowrap; }

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

.stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 9px 10px;
  background: var(--panel);
}

.stat span {
  color: var(--muted);
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.stat strong {
  font-size: 1.02rem;
  text-align: right;
}

.stage-shell {
  width: min(100%, 620px);
  margin: 0 auto;
  aspect-ratio: 9 / 14;
  border: 1px solid rgba(249, 242, 222, 0.28);
  border-radius: 8px;
  overflow: hidden;
  background: #283340;
  box-shadow: 0 24px 60px rgba(9, 12, 17, 0.42);
  touch-action: none;
}

#game-stage,
#game-stage canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  padding: 11px 12px;
  background: var(--panel-strong);
}

#message {
  margin: 0;
  font-weight: 750;
  color: var(--text);
}

@media (max-width: 720px) {
  .topbar,
  .controls {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-actions,
  .control-actions {
    width: 100%;
  }

  .topbar-actions button,
  .control-actions button {
    flex: 1 1 0;
  }

  .hud { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stage-shell { width: min(100%, 520px); }
}
