/* Golf Stars — mobile-first, portrait-only styling. */
:root {
  --ink: #20303a;
  --accent: #ff5d8f;
  --accent2: #ffd23f;
  --good: #39d3c0;
  --panel: rgba(255, 255, 255, 0.92);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: #8fd6ff;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  position: fixed;
  inset: 0;
  /* Landscape-first: fill the viewport so more of the course is visible. */
  overflow: hidden;
  background: #8fd6ff;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 12px calc(10px + env(safe-area-inset-top, 0));
  padding-top: max(10px, env(safe-area-inset-top, 0));
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.28), rgba(0, 0, 0, 0));
  color: #fff;
  z-index: 5;
  font-weight: 700;
}
.hud-item { display: flex; flex-direction: column; line-height: 1.1; text-shadow: 0 1px 2px rgba(0,0,0,0.4); }
.hud-item span:last-child { font-size: 22px; }
.hud-label { font-size: 11px; opacity: 0.85; letter-spacing: 0.06em; }
#hud .hud-item:nth-child(2) { flex: 1; align-items: center; }
#hud-level { font-size: 16px; }
/* The flexible level name (nth-child(2)) pushes the trailing controls right. */
.mute, .quit {
  flex: 0 0 auto;
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  width: 40px; height: 40px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Spin control ---------- */
#spin-bar {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: max(10px, env(safe-area-inset-bottom, 0));
  display: none;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: rgba(20, 30, 40, 0.5);
  border-radius: 16px;
  z-index: 5;
}
.spin-label {
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  opacity: 0.8;
  padding: 0 4px;
}
.spin-btn {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.spin-btn.active {
  background: var(--good);
  border-color: #fff;
}

/* ---------- Screens ---------- */
#screen-title {
  background-image:
    linear-gradient(rgba(20,40,60,0.35), rgba(20,40,60,0.45)),
    url('../assets/title-bg.webp');
  background-size: cover;
  background-position: center;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 10;
  background: rgba(20, 40, 60, 0.35);
  backdrop-filter: blur(2px);
  overflow-y: auto;
}
.screen.active { display: flex; }

.panel {
  background: var(--panel);
  border-radius: 22px;
  padding: 22px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
  text-align: center;
  max-height: 92vh;
  overflow-y: auto;
}

h1, h2, h3 { margin: 0 0 10px; }
h2 { font-size: 26px; }
h3 { font-size: 16px; text-align: left; margin-top: 14px; color: #5a6b76; }
.sub { color: #5a6b76; margin: 6px 0 14px; }

.logo {
  font-size: 52px;
  font-weight: 900;
  letter-spacing: -2px;
  color: var(--accent);
  line-height: 0.9;
  transform: rotate(-3deg);
  text-shadow: 3px 3px 0 var(--accent2);
}
.logo span { display: block; color: var(--good); }
.tag { font-size: 15px; color: #5a6b76; margin: 14px 0 22px; }

/* ---------- Buttons ---------- */
.big-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 16px;
  padding: 16px 22px;
  font-size: 20px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 5px 0 #d63a6c;
  transition: transform 0.05s;
}
.big-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #d63a6c; }
.ghost-btn {
  background: #eef2f5;
  color: var(--ink);
  border: none;
  border-radius: 14px;
  padding: 13px 18px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 10px;
}
.big-btn { margin-top: 10px; }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.row button { margin-top: 0; }

/* ---------- Cards / grids ---------- */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 8px 0; }
.card {
  background: #fff;
  border: 3px solid transparent;
  border-radius: 16px;
  padding: 12px;
  cursor: pointer;
  text-align: center;
  box-shadow: 0 3px 10px rgba(0,0,0,0.08);
}
.card.selected { border-color: var(--good); }
.char-card canvas { width: 90px; height: 90px; }
.card-name { font-weight: 800; font-size: 16px; }
.card-blurb { font-size: 12px; color: #6b7a85; margin-top: 4px; }
.level-card { grid-column: span 2; text-align: left; }

/* ---------- Chips (gear) ---------- */
.chips { display: flex; flex-direction: column; gap: 8px; }
.chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  background: #fff;
  border: 3px solid transparent;
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  font: inherit;
}
.chip b { font-size: 15px; }
.chip span { font-size: 12px; color: #6b7a85; }
.chip.selected { border-color: var(--good); }
.chip.locked { opacity: 0.55; cursor: default; }
.chip.locked b::before { content: "🔒 "; }

/* ---------- Stars & challenges ---------- */
.stars-row { display: flex; justify-content: center; gap: 6px; margin: 4px 0 8px; }
.star { font-size: 40px; color: #d7dee3; line-height: 1; }
.star.earned { color: var(--accent2); text-shadow: 0 2px 0 rgba(0,0,0,0.12); }
.star.pop { animation: starpop 0.5s ease; }
@keyframes starpop {
  0% { transform: scale(0.2) rotate(-30deg); opacity: 0; }
  60% { transform: scale(1.35) rotate(8deg); }
  100% { transform: scale(1) rotate(0); }
}
.lvl-stars { color: var(--accent2); font-size: 14px; letter-spacing: 1px; }

.challenge-list { list-style: none; padding: 0; margin: 8px 0; text-align: left; }
.challenge {
  font-size: 14px;
  font-weight: 700;
  padding: 7px 12px;
  border-radius: 10px;
  margin-bottom: 5px;
  background: #f2f5f7;
  color: #8a97a0;
}
.challenge.done { color: var(--good); background: #e5fbf4; }
.challenge.just { background: var(--accent2); color: var(--ink); animation: pop 0.4s ease; }
.nexthint { font-size: 13px; color: #8a97a0; font-weight: 700; margin: 6px 0; }

.level-card.locked { opacity: 0.6; cursor: default; box-shadow: none; }

/* ---------- Results ---------- */
.score-big { font-size: 46px; font-weight: 900; color: var(--accent); margin: 6px 0; }
.flag { color: var(--good); font-weight: 800; font-size: 13px; }
.shots { list-style: none; padding: 0; margin: 10px 0; text-align: left; font-size: 14px; }
.shots li { padding: 6px 10px; background: #f2f5f7; border-radius: 8px; margin-bottom: 5px; }
.unlock-toast {
  background: var(--accent2);
  border-radius: 12px;
  padding: 10px;
  margin: 8px 0;
  font-weight: 800;
  animation: pop 0.4s ease;
}
@keyframes pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- Leaderboard ---------- */
.board { list-style: none; padding: 0; margin: 10px 0; }
.board li {
  display: flex;
  justify-content: space-between;
  padding: 10px 14px;
  background: #f2f5f7;
  border-radius: 10px;
  margin-bottom: 6px;
  font-size: 15px;
}
.board li b { color: var(--accent); }

/* Portrait nudge: the range plays best in landscape. */
@media (orientation: portrait) and (max-width: 700px) {
  .panel::before {
    content: "📱 Turn your phone sideways to see more of the course!";
    display: block;
    background: var(--accent2);
    border-radius: 10px;
    padding: 8px;
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 700;
  }
}

/* On short landscape screens keep menu panels compact and scrollable. */
@media (orientation: landscape) and (max-height: 560px) {
  .panel { padding: 16px 20px; max-height: 96vh; }
  .grid { gap: 8px; }
  .char-card canvas { width: 64px; height: 64px; }
  h2 { font-size: 22px; margin-bottom: 6px; }
  .logo { font-size: 40px; }
}
