/* Stone Age Toss — prehistoric stone & wood palette. No external assets. */
:root {
  --wood-900: #17100a;
  --wood-800: #241812;
  --wood-700: #332416;
  --wood-600: #4a3320;
  --amber: #e8a33d;
  --amber-light: #f5c15c;
  --amber-soft: #f8d68a;
  --bone: #f5ead2;
  --muted: #c4a06e;
  --gold: #ffc93c;
  --ember: #ff8c2e;
  --red: #ff6b4a;
  --leaf: #7da05c;
  --panel: rgba(43, 28, 16, 0.95);
  --border: rgba(232, 179, 75, 0.28);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: radial-gradient(1200px 700px at 50% -10%, #4a2413 0%, var(--wood-900) 60%);
  color: var(--bone);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

#app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 1080px;
  margin: 0 auto;
  padding: 10px 14px 14px;
}

/* ---------- Top bar / HUD ---------- */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 2px 12px;
  flex-wrap: wrap;
}

#brand { display: flex; align-items: center; gap: 10px; }

#wordmark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--amber-light), #c77f2a);
  color: #241812;
  font-weight: 900;
  font-size: 20px;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 14px rgba(232, 163, 61, 0.45);
}

#game-title {
  font-weight: 900;
  font-size: 22px;
  letter-spacing: 3px;
}

#hud {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 5px 10px;
  min-width: 62px;
}

.hud-label {
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--muted);
  font-weight: 700;
}

.hud-item > span:last-child {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.2;
}

#hud-throws { letter-spacing: 2px; font-size: 14px; }
#hud-throws .orb-dot { color: var(--amber-light); }
#hud-throws .orb-dot.spent { color: #5a4632; }

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--bone);
  font-size: 19px;
  cursor: pointer;
  line-height: 1;
}
.icon-btn:hover { background: var(--wood-600); }
.icon-btn:active { transform: scale(0.94); }

/* ---------- Stage / canvas ---------- */
#stage {
  position: relative;
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  background: var(--wood-800);
  aspect-ratio: 8 / 5;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

/* ---------- Overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 12, 6, 0.62);
  backdrop-filter: blur(2px);
  padding: 16px;
  z-index: 5;
}
.overlay.hidden { display: none; }

.panel {
  background: linear-gradient(180deg, rgba(74, 51, 32, 0.97), rgba(43, 28, 16, 0.97));
  border: 1px solid #6b4a26;
  border-radius: 18px;
  padding: 26px 30px;
  text-align: center;
  max-width: 560px;
  width: 100%;
  box-shadow: inset 0 0 0 1px rgba(232, 179, 75, 0.12), 0 20px 60px rgba(0, 0, 0, 0.55);
  animation: pop 0.25s ease-out;
}
.panel.small { max-width: 440px; }

@keyframes pop {
  from { transform: scale(0.94); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.logo-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 18px;
  background: linear-gradient(145deg, var(--amber-light), #c77f2a);
  color: #241812;
  font-weight: 900;
  font-size: 34px;
  box-shadow: 0 8px 26px rgba(232, 163, 61, 0.5);
  margin-bottom: 12px;
}

h1 {
  font-size: 40px;
  font-weight: 900;
  letter-spacing: 4px;
  line-height: 1.05;
}
h2 {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 2px;
  margin: 4px 0 8px;
}

.tagline { color: var(--muted); font-size: 15px; line-height: 1.5; margin: 8px 0 4px; }
.muted { color: var(--muted); font-size: 13px; letter-spacing: 2px; font-weight: 700; }
.level-facts { color: var(--amber-soft); font-weight: 700; font-size: 14px; margin: 8px 0 2px; }

.howto {
  text-align: left;
  margin: 18px auto 6px;
  max-width: 430px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  font-size: 14.5px;
  line-height: 1.45;
  color: #e8dcc0;
}
.howto-key {
  display: inline-block;
  background: var(--amber);
  color: #241812;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 2px 8px;
  border-radius: 6px;
  margin-right: 8px;
}

.menu-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 20px;
  flex-wrap: wrap;
}

.btn {
  font: inherit;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.5px;
  color: var(--bone);
  background: var(--wood-600);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 22px;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover { background: #5d4128; }
.btn:active { transform: scale(0.96); }
.btn.primary {
  background: linear-gradient(145deg, var(--amber-light), #c77f2a);
  color: #241812;
  border-color: transparent;
  box-shadow: 0 6px 20px rgba(232, 163, 61, 0.4);
}
.btn.primary:hover { filter: brightness(1.1); }
.btn:disabled { opacity: 0.45; cursor: default; }

/* Level select grid */
#level-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin: 16px 0 4px;
}
.level-btn {
  font: inherit;
  background: var(--wood-700);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--bone);
  padding: 12px 4px 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.level-btn:hover:not(:disabled) { background: var(--wood-600); border-color: var(--amber); }
.level-btn:disabled { opacity: 0.4; cursor: default; }
.level-btn .lvl-num { font-size: 20px; font-weight: 900; }
.level-btn .lvl-stars { font-size: 11px; letter-spacing: 1px; color: var(--gold); min-height: 13px; }
.level-btn .lvl-stars:empty::after { content: "—"; color: #5a4632; }

/* Stars + score lines */
.stars {
  font-size: 38px;
  letter-spacing: 6px;
  color: var(--gold);
  text-shadow: 0 0 18px rgba(255, 201, 60, 0.55);
  margin: 6px 0 2px;
}
.stars .dim { color: #5a4632; text-shadow: none; }

.score-lines {
  text-align: left;
  max-width: 320px;
  margin: 14px auto 4px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 15px;
}
.score-lines > div {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px dashed rgba(196, 160, 110, 0.25);
  padding-bottom: 5px;
}
.score-lines .total { font-weight: 800; font-size: 16px; border-bottom: none; }
.score-lines b { color: var(--amber-soft); }

.newbest {
  color: var(--gold);
  font-weight: 900;
  letter-spacing: 1px;
  margin-top: 12px;
  animation: pop 0.3s ease-out;
}

/* Toast */
#toast {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 18px;
  font-weight: 800;
  font-size: 14px;
  z-index: 6;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
#toast.hidden { display: none; }

/* ---------- Footer hint bar ---------- */
#hintbar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 4px 0;
  color: var(--muted);
  font-size: 13px;
}
#hintbar .keys { letter-spacing: 0.5px; }

/* ---------- Small screens ---------- */
@media (max-width: 640px) {
  #game-title { font-size: 17px; letter-spacing: 2px; }
  #wordmark { width: 36px; height: 36px; font-size: 17px; }
  h1 { font-size: 30px; }
  h2 { font-size: 21px; }
  .panel { padding: 20px 16px; }
  .hud-item { min-width: 52px; padding: 4px 7px; }
  .hud-item > span:last-child { font-size: 14px; }
  #level-grid { grid-template-columns: repeat(5, 1fr); gap: 7px; }
  .btn { padding: 11px 16px; font-size: 15px; }
  #hintbar .keys { display: none; }
}
