:root {
  color-scheme: dark;
  --bg: #061024;
  --panel: rgba(8, 18, 42, 0.86);
  --panel-strong: rgba(9, 23, 55, 0.96);
  --line: rgba(64, 209, 255, 0.28);
  --cyan: #40d7ff;
  --blue: #2d8bff;
  --pink: #f45cff;
  --green: #73ff69;
  --yellow: #ffe65a;
  --orange: #ffad38;
  --red: #ff4d4d;
  --text: #f2fbff;
  --muted: #9fb7d1;
  --shadow: 0 0 22px rgba(64, 215, 255, 0.18), 0 0 70px rgba(244, 92, 255, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 50% -15%, rgba(70, 159, 255, 0.24), transparent 34%),
    radial-gradient(circle at 20% 18%, rgba(244, 92, 255, 0.14), transparent 28%),
    radial-gradient(circle at 80% 78%, rgba(115, 255, 105, 0.10), transparent 32%),
    linear-gradient(180deg, #050914 0%, #08142c 52%, #040712 100%);
  overflow-x: hidden;
  touch-action: manipulation;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.18;
  background-image:
    linear-gradient(rgba(75, 215, 255, 0.10) 1px, transparent 1px),
    linear-gradient(90deg, rgba(75, 215, 255, 0.10) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at center, black, transparent 82%);
}

button {
  color: inherit;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

.game-shell {
  width: min(100%, 1160px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) clamp(10px, 2vw, 22px) max(12px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto auto minmax(390px, 1fr) auto auto;
  gap: clamp(8px, 1.4vh, 14px);
}

.topbar,
.hud,
.control-panel,
.club-panel,

.club-panel {
  position: relative;
  z-index: 2;
  border-radius: 22px;
  padding: 10px 12px 12px;
  overflow: hidden;
}

.club-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}

.club-header strong {
  display: block;
  margin-top: 2px;
  font-size: 0.98rem;
}

#unlockStatus {
  color: var(--yellow);
  font-size: 0.82rem;
  font-weight: 900;
  white-space: nowrap;
}

.club-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 9px;
}

.club-card {
  min-height: 78px;
  border: 1px solid rgba(64, 215, 255, 0.24);
  border-radius: 18px;
  padding: 9px 10px;
  background: linear-gradient(180deg, rgba(8, 21, 49, 0.74), rgba(3, 9, 22, 0.82));
  cursor: pointer;
  text-align: left;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.025);
  display: grid;
  grid-template-columns: 50px 1fr;
  gap: 10px;
  align-items: center;
}

.club-copy { min-width: 0; }

.club-art {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04), 0 0 18px rgba(64,215,255,0.14);
  position: relative;
  overflow: hidden;
}

.club-art::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,0.26), transparent 34%);
}

.club-art span {
  position: relative;
  z-index: 1;
  font-size: 1.42rem;
  line-height: 1;
  text-shadow: 0 0 12px rgba(255,255,255,0.32);
}

.club-art--balanced { background: linear-gradient(145deg, rgba(47,139,255,0.44), rgba(14,46,102,0.96)); color: #dff9ff; }
.club-art--skimmer { background: linear-gradient(145deg, rgba(78,241,132,0.46), rgba(16,88,42,0.96)); color: #efffe8; }
.club-art--wedgeback { background: linear-gradient(145deg, rgba(255,225,90,0.5), rgba(122,86,18,0.96)); color: #fffbe6; }
.club-art--flarecore { background: linear-gradient(145deg, rgba(255,96,196,0.52), rgba(94,20,121,0.98)); color: #fff1fe; }

.club-card strong {
  display: block;
  font-size: 0.9rem;
  line-height: 1.1;
}

.club-card span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.15;
}

.club-card .club-tag {
  display: inline-flex;
  font-style: normal;
  margin-top: 7px;
  padding: 3px 7px;
  border-radius: 999px;
  color: #071026;
  background: var(--cyan);
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.club-card.is-selected {
  border-color: rgba(115, 255, 105, 0.82);
  box-shadow: 0 0 18px rgba(115, 255, 105, 0.16), inset 0 0 0 1px rgba(115,255,105,0.22);
}

.club-card.is-locked {
  opacity: 0.55;
  cursor: not-allowed;
  filter: saturate(0.75);
}

.club-card.is-locked .club-tag {
  background: rgba(255,255,255,0.18);
  color: var(--text);
}


.course-meta {
  position: relative;
  z-index: 2;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-hex {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: var(--cyan);
  border: 1px solid rgba(64, 215, 255, 0.44);
  background: linear-gradient(145deg, rgba(47, 139, 255, 0.24), rgba(244, 92, 255, 0.11));
  box-shadow: 0 0 24px rgba(64, 215, 255, 0.22);
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.19em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.75rem, 7vw, 3.9rem);
  line-height: 0.9;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-shadow: 0 0 18px rgba(64, 215, 255, 0.42), 0 0 34px rgba(244, 92, 255, 0.24);
}

.icon-button,
.primary-button,
.ghost-button,
.shoot-button {
  border: 1px solid rgba(64, 215, 255, 0.42);
  border-radius: 17px;
  background: linear-gradient(180deg, rgba(12, 42, 84, 0.96), rgba(6, 15, 35, 0.96));
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease, opacity 0.14s ease;
}

.icon-button {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  font-size: 1.12rem;
}

button:active { transform: translateY(1px) scale(0.985); }
button:focus-visible { outline: 3px solid rgba(255, 230, 90, 0.75); outline-offset: 3px; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(8px, 1.2vw, 12px);
}

.hud-card,
.course-panel,
.step-card,
.power-card,
.club-panel,
.course-meta,
.overlay-card {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(8, 21, 49, 0.92), rgba(4, 10, 24, 0.86));
  box-shadow: var(--shadow);
}

.hud-card {
  min-height: 70px;
  padding: 10px clamp(9px, 1.8vw, 15px);
  border-radius: 19px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}

.hud-card span,
.course-meta span,
.step-label {
  color: var(--muted);
  font-size: clamp(0.65rem, 2.3vw, 0.82rem);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 800;
}

.hud-card strong {
  margin-top: 4px;
  font-size: clamp(1.14rem, 4.8vw, 2.25rem);
  line-height: 1;
  white-space: nowrap;
}

#totalDistanceValue { color: var(--green); text-shadow: 0 0 14px rgba(115, 255, 105, 0.4); }

.course-panel {
  position: relative;
  min-height: 390px;
  border-radius: 28px;
  background:
    radial-gradient(circle at 50% 8%, rgba(244, 92, 255, 0.16), transparent 26%),
    radial-gradient(circle at 50% 70%, rgba(64, 215, 255, 0.13), transparent 38%),
    linear-gradient(180deg, rgba(8, 18, 45, 0.84), rgba(3, 8, 20, 0.94));
  overflow: hidden;
  isolation: isolate;
}

.course-panel::before,
.course-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.course-panel::before {
  background:
    linear-gradient(130deg, transparent 0 18%, rgba(64, 215, 255, 0.07) 18.4%, transparent 19%),
    linear-gradient(35deg, transparent 0 62%, rgba(244, 92, 255, 0.05) 62.4%, transparent 63%);
}

.course-panel::after {
  border-radius: 28px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04), inset 0 0 60px rgba(64, 215, 255, 0.08);
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.toast-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.toast {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: clamp(0.75rem, 2.8vw, 1rem);
  font-weight: 900;
  text-shadow: 0 2px 16px rgba(0,0,0,0.55);
  white-space: nowrap;
  animation: toastFloat 0.95s ease forwards;
}

@keyframes toastFloat {
  0% { opacity: 0; transform: translate(-50%, -15%); }
  15% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -145%); }
}

.overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(3, 8, 20, 0.58);
  backdrop-filter: blur(5px);
  z-index: 5;
}

.overlay-visible { display: flex; }

.overlay-card {
  width: min(100%, 510px);
  border-radius: 24px;
  padding: 18px;
}

.overlay-kicker {
  margin: 0 0 6px;
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.74rem;
}

.overlay-card h2 {
  margin: 0 0 10px;
  font-size: clamp(1.35rem, 5vw, 2.1rem);
  line-height: 1.05;
}

.overlay-card p {
  color: #d6e9ff;
  line-height: 1.45;
}

.small-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

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

.result-grid div {
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid rgba(64, 215, 255, 0.18);
  background: rgba(2, 8, 19, 0.5);
}

.result-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.result-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 1.22rem;
}

.overlay-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-button,
.ghost-button,
.shoot-button {
  min-height: 46px;
  padding: 0 16px;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.primary-button {
  background: linear-gradient(180deg, rgba(25, 115, 207, 0.96), rgba(6, 25, 58, 0.96));
}

.ghost-button {
  background: linear-gradient(180deg, rgba(15, 38, 72, 0.94), rgba(6, 15, 35, 0.96));
}

.shoot-button {
  min-height: 58px;
  padding-inline: 22px;
  border-radius: 22px;
  color: #f5fbff;
  background: linear-gradient(180deg, rgba(244, 92, 255, 0.32), rgba(20, 53, 116, 0.96));
  text-transform: uppercase;
  font-size: clamp(1.02rem, 4vw, 1.35rem);
}

.control-panel {
  display: grid;
  grid-template-columns: 0.9fr 1.7fr 0.8fr;
  gap: clamp(8px, 1.3vw, 12px);
}

.step-card,
.power-card {
  min-height: 82px;
  border-radius: 22px;
  padding: 12px 14px;
}

.aim-card {
  display: grid;
  align-content: center;
}

.aim-card strong {
  margin-top: 2px;
  font-size: clamp(1.5rem, 5vw, 2.25rem);
}

.hint {
  color: var(--muted);
  font-size: 0.86rem;
}

.power-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.power-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.power-heading strong {
  color: var(--cyan);
  font-size: 0.9rem;
}

.power-meter {
  position: relative;
  height: 34px;
  margin-top: 10px;
  border-radius: 999px;
  border: 1px solid rgba(64, 215, 255, 0.35);
  background: rgba(3, 8, 20, 0.8);
  overflow: hidden;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.35);
}

.power-zone {
  position: absolute;
  top: 6px;
  bottom: 6px;
}

.zone-safe {
  left: 2%;
  width: 39%;
  border-radius: 999px 0 0 999px;
  background: linear-gradient(90deg, rgba(115,255,105,0.22), rgba(115,255,105,0.52));
}

.zone-good {
  left: 41%;
  width: 34%;
  background: linear-gradient(90deg, rgba(255,230,90,0.52), rgba(255,173,56,0.62));
}

.zone-hot {
  left: 75%;
  right: 2%;
  border-radius: 0 999px 999px 0;
  background: linear-gradient(90deg, rgba(255,100,70,0.62), rgba(255,77,77,0.5));
}

#powerNeedle {
  position: absolute;
  top: 1px;
  bottom: 1px;
  left: 50%;
  width: 7px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 0 12px rgba(255,255,255,0.85), 0 0 24px rgba(64,215,255,0.45);
  transform: translateX(-50%);
}

.button-stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.course-meta {
  border-radius: 20px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  align-items: center;
  gap: 10px;
}

.course-meta div {
  min-width: 0;
}

.course-meta strong {
  display: block;
  margin-top: 3px;
  white-space: nowrap;
}

.compact {
  min-height: 40px;
  padding-inline: 12px;
}

@media (max-width: 860px) {
  .game-shell {
    grid-template-rows: auto auto minmax(41svh, 1fr) auto auto;
  }

  .hud {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .course-panel {
    min-height: 41svh;
  }

  .control-panel {
    grid-template-columns: 1fr;
  }

  .button-stack {
    grid-template-columns: 1fr 1fr;
  }

  .course-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .club-list {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    scroll-snap-type: x proximity;
  }

  .club-card {
    min-width: 176px;
    scroll-snap-align: start;
  }

  .course-meta .compact {
    grid-column: span 2;
  }
}

@media (max-width: 520px) {
  .game-shell {
    padding-inline: 9px;
    gap: 7px;
    grid-template-rows: auto auto minmax(35svh, 1fr) auto auto;
  }

  .brand-hex {
    width: 38px;
    height: 38px;
  }

  h1 {
    font-size: clamp(1.45rem, 9vw, 2.05rem);
  }

  .eyebrow {
    font-size: 0.64rem;
  }

  .icon-button {
    width: 42px;
    height: 42px;
  }

  .hud-card {
    min-height: 61px;
    padding: 8px 9px;
    border-radius: 16px;
  }

  .hud-card strong {
    font-size: clamp(1.02rem, 5.3vw, 1.35rem);
  }

  .course-panel {
    min-height: 36svh;
    border-radius: 22px;
  }

  .control-panel {
    gap: 7px;
    position: sticky;
    bottom: max(6px, env(safe-area-inset-bottom));
    z-index: 8;
  }

  .club-panel {
    padding: 9px 10px 10px;
    border-radius: 18px;
  }

  .club-header {
    align-items: center;
    margin-bottom: 7px;
  }

  .club-header strong {
    font-size: 0.86rem;
  }

  #unlockStatus {
    font-size: 0.74rem;
  }

  .club-card {
    min-width: 172px;
    min-height: 70px;
    padding: 8px 9px;
    grid-template-columns: 44px 1fr;
  }

  .club-art {
    width: 40px;
    height: 40px;
    border-radius: 12px;
  }

  .club-art span {
    font-size: 1.2rem;
  }

  .step-card,
  .power-card {
    min-height: 68px;
    padding: 10px 12px;
    border-radius: 18px;
  }

  .power-meter {
    height: 30px;
  }

  .shoot-button {
    min-height: 50px;
  }

  .primary-button,
  .ghost-button {
    min-height: 44px;
    padding-inline: 12px;
  }

  .overlay {
    padding: 12px;
  }

  .overlay-card {
    padding: 15px;
    border-radius: 20px;
  }
}

@media (min-width: 1000px) {
  .course-panel {
    min-height: 58vh;
  }
}


.control-panel { scroll-margin-bottom: 16px; }


/* Hex Pin Golf mobile playability pass */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tools-button {
  display: none;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid rgba(64, 215, 255, 0.42);
  border-radius: 15px;
  background: linear-gradient(180deg, rgba(15, 38, 72, 0.94), rgba(6, 15, 35, 0.96));
  box-shadow: var(--shadow);
  font-weight: 900;
}

@media (max-width: 700px) {
  html, body {
    height: 100%;
    overflow: hidden;
  }

  body {
    position: fixed;
    inset: 0;
    width: 100%;
  }

  body::before {
    opacity: 0.10;
  }

  .game-shell {
    height: 100svh;
    min-height: 100svh;
    padding: max(5px, env(safe-area-inset-top)) 7px max(5px, env(safe-area-inset-bottom));
    gap: 5px;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
  }

  .topbar {
    min-height: 36px;
    gap: 7px;
  }

  .brand {
    gap: 7px;
  }

  .brand-hex {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    font-size: 0.95rem;
  }

  .eyebrow {
    display: none;
  }

  h1 {
    font-size: clamp(1.08rem, 5.2vw, 1.45rem);
    line-height: 1;
    letter-spacing: 0.035em;
  }

  .icon-button {
    width: 36px;
    height: 36px;
    border-radius: 13px;
    font-size: 0.95rem;
  }

  .tools-button {
    display: inline-grid;
    place-items: center;
    height: 36px;
    min-height: 36px;
    padding: 0 10px;
    font-size: 0.82rem;
  }

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

  .hud-card {
    min-height: 42px;
    padding: 5px 5px 6px;
    border-radius: 12px;
  }

  .hud-card span {
    font-size: 0.53rem;
    letter-spacing: 0.07em;
  }

  .hud-card strong {
    margin-top: 2px;
    font-size: clamp(0.7rem, 3.3vw, 0.98rem);
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .course-panel {
    min-height: 0;
    height: 100%;
    border-radius: 18px;
  }

  .control-panel {
    position: relative;
    bottom: auto;
    z-index: 7;
    grid-template-columns: 0.62fr 1.12fr 0.82fr;
    gap: 5px;
    align-items: stretch;
  }

  .step-card,
  .power-card {
    min-height: 54px;
    padding: 7px 8px;
    border-radius: 14px;
  }

  .step-label {
    font-size: 0.54rem;
    letter-spacing: 0.08em;
  }

  .aim-card strong {
    font-size: clamp(1rem, 5vw, 1.28rem);
  }

  .hint {
    display: none;
  }

  .power-heading strong {
    font-size: 0.72rem;
  }

  .power-meter {
    height: 26px;
    margin-top: 6px;
  }

  .button-stack {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .primary-button,
  .ghost-button,
  .shoot-button {
    min-height: 0;
    height: 100%;
    padding: 0 8px;
    border-radius: 14px;
    font-size: 0.78rem;
    letter-spacing: 0.02em;
  }

  .shoot-button {
    min-height: 36px;
    font-size: 0.9rem;
  }

  #lockAimButton {
    min-height: 31px;
  }

  .club-panel,
  .course-meta {
    display: none;
  }

  body.mobile-tools-open .club-panel {
    display: block;
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: max(8px, env(safe-area-inset-bottom));
    z-index: 30;
    max-height: 58svh;
    overflow: auto;
    padding: 10px;
    border-radius: 18px;
    backdrop-filter: blur(8px);
  }

  body.mobile-tools-open .course-meta {
    display: grid;
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(max(8px, env(safe-area-inset-bottom)) + min(58svh, 296px));
    z-index: 29;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 8px 10px;
    border-radius: 16px;
    font-size: 0.76rem;
    backdrop-filter: blur(8px);
  }

  body.mobile-tools-open .course-meta .compact {
    display: none;
  }

  .club-header {
    margin-bottom: 7px;
  }

  .club-header strong {
    font-size: 0.86rem;
  }

  #unlockStatus {
    font-size: 0.76rem;
  }

  .club-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    overflow: visible;
  }

  .club-card {
    min-width: 0;
    min-height: 66px;
    padding: 7px;
    grid-template-columns: 38px 1fr;
    border-radius: 14px;
  }

  .club-card strong {
    font-size: 0.76rem;
  }

  .club-card span {
    font-size: 0.66rem;
    line-height: 1.08;
  }

  .club-card .club-tag {
    margin-top: 4px;
    padding: 2px 6px;
    font-size: 0.57rem;
  }

  .club-art {
    width: 34px;
    height: 34px;
    border-radius: 11px;
  }

  .club-art span {
    font-size: 1rem;
  }

  .overlay {
    padding: 10px;
  }

  .overlay-card {
    max-height: 76svh;
    overflow: auto;
    padding: 14px;
    border-radius: 18px;
  }

  .overlay-card h2 {
    font-size: clamp(1.05rem, 5vw, 1.45rem);
  }

  .overlay-card p {
    font-size: 0.9rem;
  }

  .result-grid {
    gap: 7px;
  }

  .result-grid div {
    padding: 8px 9px;
  }
}


/* Hex Pin Golf V7 phone layout pass */
@media (max-width: 700px) {
  html, body {
    height: 100%;
    overflow: hidden;
  }

  body {
    position: fixed;
    inset: 0;
    width: 100%;
  }

  .game-shell {
    position: relative;
    height: 100svh;
    min-height: 100svh;
    padding: max(4px, env(safe-area-inset-top)) 6px max(5px, env(safe-area-inset-bottom));
    gap: 4px;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .topbar {
    position: absolute;
    top: max(6px, env(safe-area-inset-top));
    right: 8px;
    z-index: 40;
    justify-content: flex-end;
    pointer-events: none;
  }

  .topbar .brand {
    display: none;
  }

  .header-actions {
    pointer-events: auto;
    display: flex;
    gap: 6px;
  }

  .tools-button {
    display: inline-grid;
    place-items: center;
    height: 34px;
    min-height: 34px;
    padding: 0 10px;
    border-radius: 13px;
    font-size: 0.78rem;
  }

  .icon-button {
    width: 34px;
    height: 34px;
    border-radius: 13px;
    font-size: 0.88rem;
  }

  .hud {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    padding-right: 93px;
  }

  .hud-card {
    min-height: 39px;
    padding: 4px 5px 5px;
    border-radius: 12px;
  }

  .hud-card span {
    font-size: 0.49rem;
    letter-spacing: 0.055em;
  }

  .hud-card strong {
    margin-top: 1px;
    font-size: clamp(0.64rem, 3.05vw, 0.93rem);
  }

  .course-panel {
    min-height: 0;
    height: 100%;
    border-radius: 17px;
  }

  .control-panel {
    position: relative;
    bottom: auto;
    grid-template-columns: 0.60fr 1.14fr 0.82fr;
    gap: 5px;
    z-index: 8;
  }

  .step-card,
  .power-card {
    min-height: 52px;
    padding: 7px 8px;
    border-radius: 14px;
  }

  .step-label {
    font-size: 0.52rem;
    letter-spacing: 0.065em;
  }

  .aim-card strong {
    font-size: clamp(0.98rem, 4.8vw, 1.24rem);
  }

  .hint {
    display: none;
  }

  .power-heading strong {
    font-size: 0.68rem;
  }

  .power-meter {
    height: 25px;
    margin-top: 6px;
  }

  .button-stack {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .primary-button,
  .ghost-button,
  .shoot-button {
    min-height: 0;
    height: 100%;
    padding: 0 7px;
    border-radius: 14px;
    font-size: 0.76rem;
  }

  #lockAimButton {
    min-height: 30px;
  }

  .shoot-button {
    min-height: 34px;
    font-size: 0.86rem;
  }

  .club-panel,
  .course-meta {
    display: none;
  }

  body.mobile-tools-open .club-panel {
    display: block;
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: max(8px, env(safe-area-inset-bottom));
    z-index: 50;
    max-height: 58svh;
    overflow: auto;
    padding: 10px;
    border-radius: 18px;
    backdrop-filter: blur(8px);
  }

  body.mobile-tools-open .course-meta {
    display: grid;
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(max(8px, env(safe-area-inset-bottom)) + min(58svh, 296px));
    z-index: 49;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 8px 10px;
    border-radius: 16px;
    font-size: 0.74rem;
    backdrop-filter: blur(8px);
  }

  body.mobile-tools-open .course-meta .compact {
    display: none;
  }
}

@media (max-width: 700px) and (orientation: portrait) {
  .game-shell {
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .course-panel {
    min-height: 0;
  }
}

@media (max-height: 520px) and (max-width: 980px) and (orientation: landscape) {
  html, body {
    height: 100%;
    overflow: hidden;
  }

  body {
    position: fixed;
    inset: 0;
    width: 100%;
  }

  .game-shell {
    position: relative;
    height: 100svh;
    min-height: 100svh;
    padding: 4px 6px;
    gap: 0;
    grid-template-rows: minmax(0, 1fr);
  }

  .topbar {
    position: absolute;
    top: 6px;
    right: 8px;
    z-index: 45;
    pointer-events: none;
  }

  .topbar .brand {
    display: none;
  }

  .header-actions {
    pointer-events: auto;
  }

  .tools-button {
    display: inline-grid;
    height: 32px;
    min-height: 32px;
    padding: 0 9px;
    border-radius: 12px;
    font-size: 0.74rem;
  }

  .icon-button {
    width: 32px;
    height: 32px;
    border-radius: 12px;
    font-size: 0.82rem;
  }

  .hud {
    position: absolute;
    top: 6px;
    left: 8px;
    z-index: 9;
    width: min(530px, 61vw);
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    padding-right: 0;
    pointer-events: none;
  }

  .hud-card {
    min-height: 34px;
    padding: 3px 6px 4px;
    border-radius: 11px;
    background: rgba(5, 13, 31, 0.72);
    backdrop-filter: blur(5px);
  }

  .hud-card span {
    font-size: 0.48rem;
  }

  .hud-card strong {
    font-size: clamp(0.62rem, 1.9vw, 0.9rem);
  }

  .course-panel {
    grid-row: 1;
    height: 100%;
    min-height: 0;
    border-radius: 16px;
  }

  .control-panel {
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: max(7px, env(safe-area-inset-bottom));
    z-index: 12;
    grid-template-columns: 0.54fr 1.16fr 0.82fr;
    gap: 5px;
    max-width: 760px;
  }

  .step-card,
  .power-card {
    min-height: 46px;
    padding: 6px 8px;
    border-radius: 13px;
    background: rgba(5, 13, 31, 0.78);
    backdrop-filter: blur(5px);
  }

  .step-label {
    font-size: 0.48rem;
  }

  .aim-card strong {
    font-size: clamp(0.84rem, 3vw, 1.12rem);
  }

  .hint {
    display: none;
  }

  .power-meter {
    height: 22px;
    margin-top: 4px;
  }

  .button-stack {
    grid-template-columns: 1fr 1fr;
    gap: 5px;
  }

  #lockAimButton,
  .shoot-button {
    min-height: 46px;
    height: 46px;
    border-radius: 13px;
    font-size: 0.8rem;
  }

  .club-panel,
  .course-meta {
    display: none;
  }

  body.mobile-tools-open .club-panel {
    display: block;
    position: fixed;
    right: 8px;
    top: 44px;
    bottom: 58px;
    left: auto;
    width: min(360px, 42vw);
    z-index: 50;
    overflow: auto;
    padding: 10px;
    border-radius: 16px;
    backdrop-filter: blur(8px);
  }

  body.mobile-tools-open .club-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 7px;
  }

  body.mobile-tools-open .course-meta {
    display: none;
  }
}


/* Hex Pin Golf V8: force phone landscape + full-hole mobile layout */
.rotate-prompt {
  display: none;
}

@media (max-width: 700px) and (orientation: portrait) {
  html, body {
    height: 100%;
    overflow: hidden;
  }

  body {
    position: fixed;
    inset: 0;
    width: 100%;
    background: radial-gradient(circle at 50% 18%, rgba(64,215,255,0.22), transparent 35%), #050914;
  }

  .rotate-prompt {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    padding: 22px;
    background:
      radial-gradient(circle at 50% 20%, rgba(64,215,255,0.24), transparent 34%),
      radial-gradient(circle at 20% 80%, rgba(244,92,255,0.16), transparent 32%),
      rgba(3, 8, 20, 0.96);
    color: var(--text);
    text-align: center;
  }

  .rotate-card {
    width: min(100%, 360px);
    border: 1px solid rgba(64,215,255,0.42);
    border-radius: 26px;
    padding: 26px 20px;
    background: linear-gradient(180deg, rgba(8,21,49,0.92), rgba(4,10,24,0.96));
    box-shadow: 0 0 28px rgba(64,215,255,0.18), 0 0 80px rgba(244,92,255,0.12);
  }

  .rotate-icon {
    width: 76px;
    height: 76px;
    margin: 0 auto 14px;
    display: grid;
    place-items: center;
    border-radius: 24px;
    border: 1px solid rgba(64,215,255,0.5);
    background: rgba(6,18,42,0.9);
    color: var(--cyan);
    font-size: 2.6rem;
    text-shadow: 0 0 18px rgba(64,215,255,0.7);
  }

  .rotate-card h2 {
    margin: 0 0 8px;
    font-size: 1.7rem;
    line-height: 1.1;
  }

  .rotate-card p {
    margin: 0;
    color: #c9def5;
    line-height: 1.45;
  }
}

@media (max-height: 560px) and (max-width: 1020px) and (orientation: landscape) {
  html, body {
    height: 100%;
    overflow: hidden;
  }

  body {
    position: fixed;
    inset: 0;
    width: 100%;
  }

  .rotate-prompt {
    display: none !important;
  }

  .game-shell {
    height: 100dvh;
    min-height: 100dvh;
    width: 100%;
    padding: 4px 6px;
    gap: 0;
    grid-template-rows: minmax(0, 1fr);
  }

  .topbar {
    position: absolute;
    top: 7px;
    right: 8px;
    z-index: 60;
    pointer-events: none;
  }

  .topbar .brand {
    display: none;
  }

  .header-actions {
    pointer-events: auto;
  }

  .tools-button {
    display: inline-grid;
    min-height: 32px;
    height: 32px;
    padding: 0 10px;
    border-radius: 12px;
    font-size: 0.76rem;
    background: rgba(5,13,31,0.74);
    backdrop-filter: blur(6px);
  }

  .icon-button {
    width: 32px;
    height: 32px;
    border-radius: 12px;
    background: rgba(5,13,31,0.74);
    backdrop-filter: blur(6px);
  }

  .hud {
    position: absolute;
    top: 7px;
    left: 8px;
    z-index: 35;
    width: min(560px, 58vw);
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    padding: 0;
    pointer-events: none;
  }

  .hud-card {
    min-height: 32px;
    padding: 3px 6px;
    border-radius: 11px;
    background: rgba(4, 11, 27, 0.62);
    backdrop-filter: blur(6px);
  }

  .hud-card span {
    font-size: 0.46rem;
    letter-spacing: 0.055em;
  }

  .hud-card strong {
    margin-top: 1px;
    font-size: clamp(0.58rem, 1.7vw, 0.84rem);
  }

  .course-panel {
    height: 100%;
    min-height: 0;
    border-radius: 16px;
    grid-row: 1;
  }

  .control-panel {
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: max(7px, env(safe-area-inset-bottom));
    z-index: 50;
    display: grid;
    grid-template-columns: 0.56fr 1.22fr 1.02fr;
    gap: 5px;
    max-width: 820px;
  }

  .step-card,
  .power-card {
    min-height: 44px;
    padding: 6px 8px;
    border-radius: 13px;
    background: rgba(5, 13, 31, 0.72);
    backdrop-filter: blur(6px);
  }

  .step-label {
    font-size: 0.46rem;
    letter-spacing: 0.055em;
  }

  .aim-card strong {
    font-size: clamp(0.82rem, 2.7vw, 1.08rem);
  }

  .hint {
    display: none;
  }

  .power-card {
    justify-content: center;
  }

  .power-heading strong {
    font-size: 0.66rem;
  }

  .power-meter {
    height: 21px;
    margin-top: 4px;
  }

  .button-stack {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
  }

  #lockAimButton,
  .shoot-button {
    height: 44px;
    min-height: 44px;
    border-radius: 13px;
    font-size: 0.82rem;
    padding: 0 8px;
  }

  .club-panel,
  .course-meta {
    display: none;
  }

  body.mobile-tools-open .club-panel {
    display: block;
    position: fixed;
    right: 8px;
    top: 46px;
    bottom: 58px;
    left: auto;
    width: min(360px, 42vw);
    max-height: none;
    z-index: 80;
    overflow: auto;
    padding: 10px;
    border-radius: 16px;
    backdrop-filter: blur(10px);
  }

  body.mobile-tools-open .club-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 7px;
  }

  body.mobile-tools-open .course-meta {
    display: none;
  }
}


/* Hex Pin Golf V8.1 overlay safety fix */
body.has-active-overlay {
  overflow: hidden;
}

body.has-active-overlay .course-panel,
.course-panel:has(.overlay-visible) {
  z-index: 9998;
  overflow: visible;
}

body.has-active-overlay .topbar,
body.has-active-overlay .hud,
body.has-active-overlay .control-panel,
body.has-active-overlay .club-panel,
body.has-active-overlay .course-meta {
  display: none !important;
}

body.has-active-overlay .overlay-visible {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex !important;
  align-items: center;
  justify-content: center;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  background:
    radial-gradient(circle at 50% 15%, rgba(64,215,255,0.18), transparent 34%),
    radial-gradient(circle at 50% 82%, rgba(244,92,255,0.16), transparent 30%),
    rgba(3, 8, 20, 0.90);
  backdrop-filter: blur(7px);
}

body.has-active-overlay .overlay-card {
  width: min(94vw, 520px);
  max-height: min(86svh, 560px);
  overflow: auto;
  border-radius: 22px;
  padding: clamp(14px, 3vw, 20px);
}

@media (max-height: 560px) and (max-width: 1020px) and (orientation: landscape) {
  body.has-active-overlay .game-shell {
    display: block;
    height: 100svh;
    padding: 0;
  }

  body.has-active-overlay .course-panel {
    height: 100svh;
    border-radius: 0;
  }

  body.has-active-overlay .overlay-visible {
    padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }

  body.has-active-overlay .overlay-card {
    width: min(92vw, 620px);
    max-height: 88svh;
    padding: 12px 14px;
    border-radius: 18px;
  }

  body.has-active-overlay .overlay-kicker {
    font-size: 0.62rem;
    margin-bottom: 4px;
  }

  body.has-active-overlay .overlay-card h2 {
    font-size: clamp(1rem, 3.2vw, 1.45rem);
    line-height: 1.05;
    margin-bottom: 7px;
  }

  body.has-active-overlay .overlay-card p,
  body.has-active-overlay .small-note {
    font-size: 0.82rem;
    line-height: 1.32;
  }

  body.has-active-overlay .result-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
    margin: 8px 0 10px;
  }

  body.has-active-overlay .result-grid div {
    padding: 7px 8px;
    border-radius: 12px;
  }

  body.has-active-overlay .result-grid span {
    font-size: 0.58rem;
  }

  body.has-active-overlay .result-grid strong {
    font-size: 0.9rem;
  }

  body.has-active-overlay .overlay-actions {
    gap: 8px;
  }

  body.has-active-overlay .primary-button,
  body.has-active-overlay .ghost-button {
    min-height: 38px;
    height: 38px;
    border-radius: 13px;
    padding: 0 14px;
    font-size: 0.86rem;
  }
}

@media (max-width: 700px) and (orientation: portrait) {
  body.has-active-overlay .rotate-prompt {
    display: none !important;
  }
}


/* Hex Pin Golf V8.3 quick restart button */
.quick-restart-button {
  display: none;
  width: 36px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(64, 215, 255, 0.42);
  border-radius: 13px;
  background: linear-gradient(180deg, rgba(15, 38, 72, 0.94), rgba(6, 15, 35, 0.96));
  box-shadow: var(--shadow);
  font-weight: 900;
  font-size: 1rem;
  line-height: 1;
}

@media (max-width: 700px), (max-height: 560px) and (max-width: 1020px) and (orientation: landscape) {
  .quick-restart-button {
    display: inline-grid;
  }
}

@media (max-height: 560px) and (max-width: 1020px) and (orientation: landscape) {
  .quick-restart-button {
    width: 32px;
    height: 32px;
    min-height: 32px;
    border-radius: 12px;
    background: rgba(5,13,31,0.74);
    backdrop-filter: blur(6px);
    font-size: 0.92rem;
  }
}
