/* ————— Facets: velvet case & gold engraving ————— */

:root {
  --velvet-950: #080512;
  --velvet-900: #0d0820;
  --velvet-800: #150e2b;
  --velvet-700: #1e1440;
  --velvet-600: #2a1d54;
  --gold: #e5c36a;
  --gold-bright: #f7e3a4;
  --gold-deep: #a9812f;
  --ivory: #f7f1e1;
  --muted: #9a8fbe;
  --font-display: 'Cinzel', 'Palatino Linotype', Palatino, Georgia, serif;
  --font-ui: 'Outfit', -apple-system, 'Segoe UI', system-ui, sans-serif;
}

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

html, body { height: 100%; }

body {
  font-family: var(--font-ui);
  color: var(--ivory);
  background:
    radial-gradient(120% 90% at 50% -10%, var(--velvet-700) 0%, var(--velvet-900) 52%, var(--velvet-950) 100%);
  background-attachment: fixed;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

#app {
  width: min(560px, 100vw);
  padding: calc(14px + env(safe-area-inset-top, 0px)) 12px calc(20px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

/* ————— masthead ————— */

.masthead { text-align: center; user-select: none; margin-top: 2px; }

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.brand h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(26px, 6vw, 34px);
  letter-spacing: 0.34em;
  text-indent: 0.34em; /* re-center letterspaced text */
  background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold) 46%, var(--gold-deep) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 1px 0 rgba(0,0,0,.55));
}

.brand-rule {
  flex: 0 0 clamp(28px, 9vw, 64px);
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-deep));
}
.brand-rule:last-of-type {
  background: linear-gradient(90deg, var(--gold-deep), transparent);
}

.brand-sub {
  margin-top: 2px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.52em;
  text-indent: 0.52em;
  color: var(--muted);
}

/* ————— HUD ————— */

.hud {
  border: 1px solid rgba(229, 195, 106, 0.28);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(42, 29, 84, .55), rgba(21, 14, 43, .55));
  box-shadow: inset 0 1px 0 rgba(247, 227, 164, .07), 0 6px 24px rgba(0,0,0,.35);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hud-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.level-badge, .moves-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.05;
  min-width: 54px;
}

.lb-label, .mv-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--muted);
}

.lb-num {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 24px;
  color: var(--gold);
}

.mv-num {
  font-weight: 800;
  font-size: 26px;
  color: var(--ivory);
  font-variant-numeric: tabular-nums;
  transition: color .2s;
}
.mv-num.low { color: #ff7d8e; }

.goals {
  flex: 1;
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.goal-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px 4px 5px;
  border-radius: 999px;
  border: 1px solid rgba(229, 195, 106, .22);
  background: rgba(13, 8, 32, .55);
  box-shadow: inset 0 1px 0 rgba(247,227,164,.06);
}

.goal-chip canvas { width: 24px; height: 24px; display: block; }

.goal-chip .gc-count {
  font-weight: 700;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--ivory);
}

.goal-chip.done { border-color: rgba(110, 231, 160, .55); }
.goal-chip.done .gc-count { color: #6ee7a0; }

.goal-chip.score-goal { padding-left: 9px; }
.goal-chip .gc-icon { font-size: 13px; color: var(--gold); }

/* score / progress */

.score-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-track {
  position: relative;
  flex: 1;
  height: 10px;
  border-radius: 999px;
  background: rgba(8, 5, 18, .8);
  border: 1px solid rgba(229, 195, 106, .18);
  overflow: visible;
}

.progress-fill {
  position: absolute;
  inset: 1px auto 1px 1px;
  width: 0%;
  max-width: calc(100% - 2px);
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold) 60%, var(--gold-bright));
  box-shadow: 0 0 10px rgba(229, 195, 106, .45);
  transition: width .45s cubic-bezier(.22,.9,.32,1);
}

.star-pip {
  position: absolute;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translate(-50%, -50%);
}
.star-pip svg { width: 100%; height: 100%; fill: #3a2f5e; stroke: rgba(229,195,106,.35); stroke-width: 1.2; transition: fill .25s, filter .25s; }
.star-pip.lit svg { fill: var(--gold); filter: drop-shadow(0 0 5px rgba(229,195,106,.8)); }

.score-num {
  font-weight: 800;
  font-size: 17px;
  min-width: 58px;
  text-align: right;
  color: var(--gold-bright);
  font-variant-numeric: tabular-nums;
}

.hud-btns { display: flex; gap: 6px; }

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(229, 195, 106, .28);
  background: rgba(13, 8, 32, .55);
  color: var(--gold);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background .15s, transform .1s;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { background: rgba(42, 29, 84, .8); }
.icon-btn:active { transform: scale(.93); }
.icon-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ————— board ————— */

#boardFrame {
  position: relative;
  border-radius: 18px;
  padding: 9px;
  background:
    linear-gradient(160deg, rgba(247,227,164,.14), rgba(169,129,47,.05) 30%, rgba(0,0,0,0) 60%),
    linear-gradient(180deg, var(--velvet-700), var(--velvet-800));
  border: 1px solid rgba(229, 195, 106, .38);
  box-shadow:
    inset 0 0 0 1px rgba(8,5,18,.8),
    inset 0 2px 14px rgba(0,0,0,.5),
    0 14px 40px rgba(0,0,0,.5);
}

#boardFrame::before {
  /* engraved inner keyline, like a certificate border */
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 14px;
  border: 1px solid rgba(229, 195, 106, .18);
  pointer-events: none;
}

#board {
  display: block;
  width: 100%;
  border-radius: 12px;
  touch-action: none;
  cursor: pointer;
}

.colophon {
  text-align: center;
  font-size: 11px;
  letter-spacing: .14em;
  color: var(--muted);
  user-select: none;
  transition: color .2s;
}
.colophon.aiming { color: var(--gold); }

/* ————— booster tray ————— */

.boosters {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 2px;
}

.bank {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(229, 195, 106, .35);
  background: rgba(13, 8, 32, .6);
  font-weight: 800;
  font-size: 16px;
  color: var(--gold-bright);
  font-variant-numeric: tabular-nums;
  user-select: none;
}
.bank svg { width: 16px; height: 16px; fill: var(--gold); filter: drop-shadow(0 0 4px rgba(229,195,106,.6)); }

.booster {
  position: relative;
  width: 52px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(229, 195, 106, .32);
  background: linear-gradient(180deg, rgba(42, 29, 84, .8), rgba(21, 14, 43, .8));
  color: var(--gold);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform .12s, border-color .2s, box-shadow .2s, opacity .2s;
}
.booster svg { width: 22px; height: 22px; }
.booster .b-plus { font-family: var(--font-ui); font-weight: 800; font-size: 17px; line-height: 1; }
.booster .b-cost {
  position: absolute;
  bottom: -7px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: .02em;
  padding: 1px 6px;
  border-radius: 999px;
  color: #241a06;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold-deep));
  box-shadow: 0 1px 4px rgba(0,0,0,.5);
  pointer-events: none;
}
.booster:hover:not(:disabled) { transform: translateY(-1px); border-color: rgba(229,195,106,.6); }
.booster:active:not(:disabled) { transform: scale(.94); }
.booster:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.booster:disabled { opacity: .38; cursor: default; }
.booster.armed {
  border-color: var(--gold-bright);
  box-shadow: 0 0 14px rgba(229, 195, 106, .55), inset 0 0 8px rgba(229, 195, 106, .25);
  animation: armedPulse 1.1s ease-in-out infinite;
}
@keyframes armedPulse {
  50% { box-shadow: 0 0 22px rgba(229, 195, 106, .8), inset 0 0 10px rgba(229, 195, 106, .35); }
}

/* ————— overlay panels ————— */

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 5, 18, .72);
  backdrop-filter: blur(6px);
  z-index: 50;
  opacity: 1;
  transition: opacity .28s;
}
.overlay.hidden { opacity: 0; pointer-events: none; }

.panel {
  width: min(400px, 92vw);
  border-radius: 20px;
  padding: 2px;
  background: linear-gradient(160deg, var(--gold-bright), var(--gold-deep) 40%, #4a3a17 80%);
  box-shadow: 0 24px 70px rgba(0,0,0,.65);
  transform: translateY(0) scale(1);
  transition: transform .32s cubic-bezier(.34,1.4,.44,1);
}
.overlay.hidden .panel { transform: translateY(14px) scale(.96); }

.panel-inner {
  border-radius: 18px;
  background:
    radial-gradient(120% 100% at 50% 0%, var(--velvet-600) 0%, var(--velvet-800) 60%, var(--velvet-900) 100%);
  padding: 26px 24px 24px;
  text-align: center;
}

.panel-kicker {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .4em;
  text-indent: .4em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.panel-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 30px;
  letter-spacing: .06em;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold) 55%, var(--gold-deep));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 12px;
}

.panel-body { color: var(--ivory); font-size: 15px; line-height: 1.5; margin-bottom: 18px; }
.panel-body .dim { color: var(--muted); font-size: 13px; }

.panel-goals {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 4px 0 18px;
}
.panel-goals .goal-chip { padding: 6px 12px 6px 7px; }
.panel-goals .goal-chip canvas { width: 30px; height: 30px; }
.panel-goals .goal-chip .gc-count { font-size: 16px; }

.panel-stars {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 2px 0 16px;
}
.panel-stars svg {
  width: 52px; height: 52px;
  fill: #3a2f5e;
  stroke: rgba(229,195,106,.4);
  stroke-width: 1;
  transform: scale(.6);
  opacity: .5;
  transition: transform .4s cubic-bezier(.34,1.6,.44,1), fill .3s, opacity .3s, filter .3s;
}
.panel-stars svg.lit {
  fill: var(--gold);
  opacity: 1;
  transform: scale(1);
  filter: drop-shadow(0 0 12px rgba(229,195,106,.75));
}
.panel-stars svg:nth-child(2) { transform: scale(.68) translateY(-6px); }
.panel-stars svg:nth-child(2).lit { transform: scale(1.14) translateY(-6px); }

.panel-score {
  font-weight: 800;
  font-size: 26px;
  color: var(--gold-bright);
  font-variant-numeric: tabular-nums;
  margin-bottom: 16px;
}
.panel-score small { display: block; font-size: 10px; font-weight: 700; letter-spacing: .3em; color: var(--muted); }

.btn {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #241a06;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold) 55%, var(--gold-deep));
  border: none;
  border-radius: 12px;
  padding: 13px 34px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(229,195,106,.3), inset 0 1px 0 rgba(255,255,255,.5);
  transition: transform .12s, box-shadow .2s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 7px 22px rgba(229,195,106,.4), inset 0 1px 0 rgba(255,255,255,.5); }
.btn:active { transform: translateY(1px) scale(.98); }
.btn:focus-visible { outline: 2px solid var(--ivory); outline-offset: 3px; }

.btn-quiet {
  display: block;
  margin: 12px auto 0;
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .1em;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.btn-quiet:hover { color: var(--ivory); }

/* ————— small screens ————— */

@media (max-width: 420px) {
  #app { padding: 10px 8px 14px; gap: 8px; }
  .goals { gap: 5px; }
  .goal-chip { padding: 3px 7px 3px 4px; }
  .goal-chip canvas { width: 20px; height: 20px; }
  .score-num { min-width: 48px; font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
