:root {
  --bg: #1d3a26;
  --panel: rgba(15, 29, 20, 0.94);
  --panel-border: rgba(255, 255, 255, 0.09);
  --chip: rgba(10, 22, 14, 0.74);
  --text: #f6f2e4;
  --muted: #b4c1b0;
  --accent: #ffd166;
  --accent-hover: #ffdc88;
  --accent-ink: #3a2900;
  --accent-shadow: #c99a2e;
  --green: #7fd88c;
  --red: #ff7d6e;
  --font-display: 'Fredoka', ui-rounded, 'SF Pro Rounded', system-ui, sans-serif;
  --font-body: 'Nunito', ui-rounded, system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#game {
  position: fixed;
  inset: 0;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

.hidden {
  display: none !important;
}

kbd {
  font-family: var(--font-body);
  font-size: 0.8em;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(0, 0, 0, 0.12);
}

/* ---------------------------------------------------------------- HUD */

#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) 12px 10px;
  pointer-events: none;
  z-index: 5;
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 60px;
  padding: 6px 12px;
  border-radius: 12px;
  background: var(--chip);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.hud-item .lbl {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.hud-item .val {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 600;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.hud-item.warn {
  border-color: rgba(255, 125, 110, 0.5);
}

.hud-item.warn .val {
  color: var(--red);
}

.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: var(--chip);
  color: var(--text);
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.icon-btn:hover {
  background: rgba(30, 50, 36, 0.9);
}

.icon-btn svg {
  width: 22px;
  height: 22px;
}

#btn-mute .ic-off,
#btn-mute.muted .ic-on {
  display: none;
}

#btn-mute.muted .ic-off {
  display: block;
}

.hud-code {
  font: 600 12px ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--muted);
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(10, 22, 14, 0.55);
  cursor: pointer;
}

.hud-code:hover {
  color: var(--text);
}

@media (max-width: 600px) {
  .hud-item {
    min-width: 46px;
    padding: 4px 8px;
  }
  .hud-item .val {
    font-size: 17px;
  }
  .hud-item .lbl {
    font-size: 9px;
  }
  .hud-code {
    display: none;
  }
  .icon-btn {
    width: 40px;
    height: 40px;
  }
}

/* ---------------------------------------------------------------- banner / toast / hint */

#banner {
  position: fixed;
  top: 24%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  opacity: 0;
  z-index: 4;
}

#banner.show {
  animation: banner 2.1s ease forwards;
}

.b-title {
  font-family: var(--font-display);
  font-size: clamp(38px, 7vw, 66px);
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.22), 0 10px 30px rgba(0, 0, 0, 0.4);
}

.b-sub {
  margin-top: 6px;
  font-size: clamp(14px, 2.4vw, 18px);
  font-weight: 800;
  color: var(--accent);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}

@keyframes banner {
  0% { opacity: 0; transform: translate(-50%, -38%) scale(0.96); }
  12% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  75% { opacity: 1; transform: translate(-50%, -50%); }
  100% { opacity: 0; transform: translate(-50%, -58%); }
}

#toast {
  position: fixed;
  bottom: max(22px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(10, 22, 14, 0.88);
  border: 1px solid var(--panel-border);
  font-weight: 800;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  z-index: 6;
}

#toast.show {
  animation: toast 2.2s ease forwards;
}

@keyframes toast {
  0% { opacity: 0; transform: translate(-50%, 8px); }
  10% { opacity: 1; transform: translate(-50%, 0); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

#hint {
  position: fixed;
  bottom: max(70px, calc(env(safe-area-inset-bottom) + 56px));
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 14px;
  background: rgba(10, 22, 14, 0.8);
  border: 1px solid var(--panel-border);
  color: var(--text);
  font-weight: 700;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s;
  z-index: 4;
}

#hint.show {
  opacity: 1;
}

/* ---------------------------------------------------------------- overlay cards */

#overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow-y: auto;
  background: radial-gradient(ellipse at center, rgba(8, 18, 12, 0.3), rgba(8, 18, 12, 0.72));
  z-index: 10;
}

.card {
  width: min(440px, 100%);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 26px 24px;
  border-radius: 22px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
  animation: pop 0.24s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

@keyframes pop {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

.card h2 {
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 600;
}

.card p {
  margin: 0 0 12px;
  line-height: 1.45;
  color: #e3e8dc;
}

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

.stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn {
  font: inherit;
  font-weight: 800;
  font-size: 15px;
  color: var(--text);
  padding: 12px 18px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.07);
  cursor: pointer;
  transition: transform 0.08s, background 0.15s;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.13);
}

.btn:active {
  transform: translateY(1px) scale(0.99);
}

.btn:focus-visible {
  outline: 3px solid rgba(255, 209, 102, 0.6);
  outline-offset: 2px;
}

.btn.primary {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: transparent;
  box-shadow: 0 4px 0 var(--accent-shadow);
}

.btn.primary:hover {
  background: var(--accent-hover);
}

.btn.primary:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--accent-shadow);
}

.btn.ghost {
  background: transparent;
}

.btn.ghost:hover {
  background: rgba(255, 255, 255, 0.07);
}

.btn.danger {
  color: var(--red);
}

.btn.big {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  padding: 16px 18px;
  text-align: left;
}

.btn-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 23px;
  font-weight: 600;
}

.btn-sub {
  margin-top: 2px;
  font-size: 14px;
  font-weight: 700;
  opacity: 0.8;
}

.btn-badge {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.25);
}

/* menu */

.menu-card {
  text-align: center;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.logo h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(36px, 9vw, 46px);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.logo-ball {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff 0 30%, #e9e9e4 60%, #b9bcb5 100%);
  box-shadow: 3px 5px 0 rgba(0, 0, 0, 0.3);
}

.tag {
  margin: 6px 0 20px !important;
  color: var(--muted) !important;
  font-weight: 700;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.menu-row {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 14px;
}

/* stats */

.stats-card {
  width: min(600px, 100%);
}

.section-lbl {
  margin: 16px 0 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(124px, 1fr));
  gap: 8px;
}

.tile {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.tile-val {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tile-lbl {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.tile.gold .tile-val {
  color: var(--accent);
}

.tile.good .tile-val {
  color: var(--green);
}

.fine {
  margin-top: 16px !important;
  font-size: 12px;
  color: var(--muted) !important;
  text-align: center;
}

/* help */

.help-card {
  width: min(520px, 100%);
}

.legend {
  display: grid;
  gap: 8px;
  margin: 14px 0 16px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
}

.legend > div {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  line-height: 1.35;
}

.sw {
  width: 18px;
  height: 18px;
  flex: none;
  border-radius: 5px;
}

.sw-sand { background: #ead59c; }
.sw-water { background: #3e8fd6; }
.sw-ice { background: #d6f2fc; }
.sw-slope { background: linear-gradient(90deg, #8ad884, #3f8c3b); }
.sw-belt { background: repeating-linear-gradient(90deg, #545a63 0 4px, #3d4148 4px 7px); }
.sw-move { background: #e0524b; border-radius: 50%; }

/* results */

.result-card {
  text-align: center;
}

.result-hole {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.result-name {
  margin: 4px 0 2px;
  font-family: var(--font-display);
  font-size: clamp(38px, 10vw, 52px);
  font-weight: 700;
  line-height: 1.05;
}

.result-name.ace { color: var(--accent); }
.result-name.great { color: #ffe08a; }
.result-name.good { color: var(--green); }
.result-name.meh { color: #e6dcc3; }
.result-name.bad { color: var(--red); }

.result-line {
  font-size: 17px;
  font-weight: 800;
}

.result-extra {
  margin-top: 6px;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
}

.result-extra b {
  color: var(--accent);
}

.bank-change {
  display: inline-block;
  margin-top: 14px;
  padding: 8px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  font-weight: 800;
}

.bank-change.pos { color: var(--green); }
.bank-change.neg { color: var(--red); }

.bank-change .arrow {
  opacity: 0.6;
  margin: 0 4px;
}

.big-number {
  font-family: var(--font-display);
  font-size: 80px;
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
}

@media (prefers-reduced-motion: reduce) {
  .card,
  #banner.show,
  #toast.show {
    animation-duration: 0.01s;
  }
}
