/* The round: paper scorecard, the pixel-art stage, aiming controls, the shot, results */

/* Shot ratings: any element with a tier-* class gets --tier (and a readable text color) */
.tier-ace { --tier: var(--tier-ace); --tier-text: #1a1710; }
.tier-eagle { --tier: var(--tier-eagle); }
.tier-birdie { --tier: var(--tier-birdie); }
.tier-par { --tier: var(--tier-par); --tier-text: #1a1710; }
.tier-bogey { --tier: var(--tier-bogey); --tier-text: #1a1710; }
.tier-double { --tier: var(--tier-double); }
.tier-lost { --tier: var(--tier-lost); }

/* ---------- Paper scorecard ---------- */
.scorecard {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto repeat(7, 1fr) 1.2fr;
  background: var(--paper);
  color: var(--paper-ink);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
  font-variant-numeric: tabular-nums;
}
.sc-col { display: grid; grid-template-rows: 22px 22px 34px; border-right: 1px solid var(--paper-line); }
.sc-col:last-child { border-right: none; }
.sc-cell { display: grid; place-items: center; font-size: 0.8rem; border-bottom: 1px solid var(--paper-line); position: relative; }
.sc-cell:last-child { border-bottom: none; }
.sc-hole { background: var(--paper-head); color: var(--paper-head-ink); font-family: var(--font-pixel); font-weight: 700; font-size: 0.75rem; }
.sc-par { color: var(--paper-muted); font-size: 0.75rem; }
.sc-score { font-weight: 700; font-size: 0.95rem; }
.sc-labels .sc-cell { padding: 0 7px; font-size: 0.6rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; justify-items: start; }
.sc-labels .sc-par, .sc-labels .sc-score { color: var(--paper-muted); }
.sc-labels .sc-hole { font-family: var(--font-main); }
.sc-col.current .sc-cell { background: var(--paper-highlight); }
.sc-col.current .sc-hole { background: var(--color-accent); color: var(--color-accent-text); }
.sc-total .sc-cell { background: var(--paper-head-soft); }
.sc-total .sc-hole { background: var(--paper-head); }
.sc-topar { font-family: var(--font-pixel); font-size: 1.05rem; }
.sc-caddie { position: absolute; top: -1px; right: 0; font-size: 0.55rem; }

/* Golf scorecard marks: circle = birdie, double circle = eagle, square = bogey, double square = worse */
.mark { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 3px; line-height: 1; color: var(--tier); }
.mark.circle { border: 1.5px solid currentColor; border-radius: 50%; }
.mark.circle2 { border: 1.5px solid currentColor; border-radius: 50%; box-shadow: 0 0 0 2px var(--paper), 0 0 0 3.5px currentColor; }
.mark.square { border: 1.5px solid currentColor; border-radius: 1px; }
.mark.square2 { border: 1.5px solid currentColor; border-radius: 1px; box-shadow: 0 0 0 2px var(--paper), 0 0 0 3.5px currentColor; }
.mark.ace { background: var(--tier-ace); color: #1a1710; border-radius: 50%; }
.sc-col.tier-par .mark { color: var(--paper-ink); }

/* ---------- The hole ---------- */
.hole-label {
  font-family: var(--font-pixel);
  font-size: 0.85rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.par-chip {
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  background: var(--color-surface-2);
  color: var(--color-text);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
}
.subject-label { font-family: var(--font-pixel); font-weight: 700; font-size: 1rem; color: var(--color-accent); margin-bottom: -4px; }

/* Everything in the card stays a comfortable reading width, except the course itself */
.card > * { max-width: 600px; }
.card > .stage { max-width: none; }

/* The stage: pixel-art fairway with the word floating in the sky. Full-bleed in the card. */
.stage {
  position: relative;
  width: calc(100% + 36px);
  margin: 0 -18px;
  overflow: hidden;
  background: #0b0f0a;
  line-height: 0;
}
/* Phones: the card and the course run edge to edge for the longest possible fairway */
@media (max-width: 640px) {
  main { padding-left: 0; padding-right: 0; }
  .scorecard { width: calc(100% - 24px); }
  .card { border-left: 0; border-right: 0; border-radius: 0; padding-left: 14px; padding-right: 14px; }
  .stage { width: calc(100% + 28px); margin: 0 -14px; }
}
.stage-canvas { width: 100%; display: flex; justify-content: center; }
.pixel-canvas { display: block; image-rendering: pixelated; image-rendering: crisp-edges; touch-action: pan-y; cursor: ew-resize; }
.stage-word {
  position: absolute;
  top: 8%;
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--font-word);
  font-weight: 800;
  font-size: clamp(2.2rem, 8.5vw, 4.2rem);
  line-height: 1.05;
  letter-spacing: 0.01em;
  color: #fffaf0;
  /* a clean outline plus a hard drop shadow: easy to read, still feels like a game */
  -webkit-text-stroke: 1px #2a2620;
  paint-order: stroke fill;
  text-shadow: 0 2px 0 #2a2620, 2px 0 0 #2a2620, -2px 0 0 #2a2620, 0 -2px 0 #2a2620, 0 5px 0 rgba(20, 16, 10, 0.55);
  overflow-wrap: anywhere;
  padding: 0 12px;
  pointer-events: none;
  animation: word-in 0.4s steps(4) both;
}
@keyframes word-in { from { opacity: 0; transform: translateY(-10px); } }
.prompt { color: var(--color-muted); max-width: 34ch; font-size: 0.92rem; }
.prompt b { color: var(--color-text); }

/* Aiming: nudge buttons around the chosen year */
.aim-controls { display: flex; align-items: center; justify-content: center; gap: 6px; }
.aim-year {
  min-width: 4.6ch;
  text-align: center;
  font-family: var(--font-pixel);
  font-weight: 700;
  font-size: 2.2rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  padding: 6px 10px 4px;
  background: var(--color-surface-2);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.3);
}
.nudge {
  width: 44px;
  height: 44px;
  font-family: var(--font-pixel);
  font-size: 0.85rem;
  color: var(--color-text);
  background: var(--color-surface-2);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
  user-select: none;
  touch-action: manipulation;
}
.nudge:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35); }

.lock-btn {
  width: min(100%, 320px);
  min-height: 56px;
  margin-top: 4px;
  font-family: var(--font-pixel);
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: 0.04em;
  color: var(--color-accent-text);
  background: var(--color-accent);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.35), inset 0 -3px 0 rgba(0, 0, 0, 0.15);
  transition: transform 0.06s, box-shadow 0.06s;
}
.lock-btn:hover { filter: brightness(1.06); }
.lock-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35); }

/* ---------- The shot result ---------- */
.reveal { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.reveal:empty { display: none; }
.shot-result { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; opacity: 0; transform: translateY(8px); }
.shot-result.show { opacity: 1; transform: none; transition: opacity 0.25s steps(5), transform 0.25s steps(5); }
.verdict { display: flex; align-items: center; gap: 10px; margin-top: 2px; }
.verdict-label { font-family: var(--font-pixel); font-size: 1.8rem; font-weight: 700; color: var(--tier); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35); }
.shot-result.show .tier-ace .verdict-label { animation: ace-pop 0.6s steps(6); }
@keyframes ace-pop { 40% { transform: scale(1.25); } }
.verdict-strokes {
  font-family: var(--font-pixel);
  font-weight: 700;
  font-size: 1.1rem;
  background: var(--tier);
  color: var(--tier-text);
  padding: 2px 10px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
}
.commentary { font-family: var(--font-display); font-style: italic; font-size: 1.05rem; }
.peak-line { font-size: 0.98rem; }
.peak-line strong { font-variant-numeric: tabular-nums; }
.stroke-line { font-size: 0.82rem; color: var(--color-muted); margin-top: -4px; }

/* ---------- End of round ---------- */
.total-big {
  font-family: var(--font-pixel);
  font-size: 3.6rem;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.total-sub { text-align: center; color: var(--color-muted); font-size: 0.9rem; margin-top: -2px; }

.results { list-style: none; width: 100%; margin: 6px 0; }
.results li {
  display: grid;
  grid-template-columns: 1fr auto 3.2rem;
  gap: 10px;
  align-items: center;
  padding: 8px 4px;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
}
.results li:last-child { border-bottom: none; }
.r-word { font-family: var(--font-pixel); font-weight: 700; font-size: 1.1rem; overflow-wrap: anywhere; }
.r-years { color: var(--color-muted); font-size: 0.88rem; font-variant-numeric: tabular-nums; }
.r-strokes { text-align: right; font-family: var(--font-pixel); font-weight: 700; color: var(--tier); }
.r-hint { font-size: 0.85rem; }

.next-puzzle { color: var(--color-muted); font-size: 0.9rem; text-align: center; margin-top: 10px; }
.countdown { font-weight: 700; color: var(--color-text); font-variant-numeric: tabular-nums; }

/* ---------- Ask the caddie ---------- */
.definition { width: 100%; display: flex; justify-content: center; min-height: 36px; }
.definition:empty { display: none; }
.def-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  border: 2px dashed var(--color-border);
  color: var(--color-muted);
  font-size: 0.9rem;
  font-weight: 600;
}
.def-btn:hover { color: var(--color-text); border-color: var(--color-muted); }
.def-price { font-family: var(--font-pixel); font-size: 0.75rem; font-weight: 700; padding: 1px 8px; background: var(--tier-double); color: #fff; }
.def-price.free { background: var(--tier-birdie); }
.def-confirm { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; font-size: 0.9rem; font-weight: 600; }
.def-confirm > span { flex-basis: 100%; text-align: center; }
.def-card {
  width: 100%;
  text-align: left;
  background: var(--paper);
  color: var(--paper-ink);
  padding: 10px 12px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
  animation: fade-up 0.25s steps(4);
}
@keyframes fade-up { from { opacity: 0; transform: translateY(6px); } }
.def-head { font-family: var(--font-pixel); font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--paper-muted); }
.def-pos { font-family: var(--font-display); font-style: italic; text-transform: none; letter-spacing: 0; font-size: 0.85rem; }
.def-text { font-size: 0.95rem; margin: 2px 0 4px; }
.def-cost { font-size: 0.72rem; font-weight: 700; color: var(--paper-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.def-none { font-size: 0.8rem; color: var(--color-muted); align-self: center; }

/* Help popup: rating marks */
.help-mark { font-size: 0.75rem; font-weight: 700; min-width: 20px; height: 20px; }

/* ---------- A hole fits on one screen (no scrolling) ---------- */
body.playing .site-footer { display: none; }
#play.fit { height: 100dvh; overflow: hidden; }
#play.fit main { flex: 1; min-height: 0; padding-top: 10px; padding-bottom: 8px; gap: 10px; }
#play.fit .sc-col { grid-template-rows: 20px 20px 30px; }
.card.card-play {
  flex: 1;
  min-height: 0;
  padding: 0;
  gap: 8px;
  background: none;
  border: 0;
  border-radius: 0;
}
.card-play .stage { flex: 1; min-height: 170px; width: 100%; margin: 0; border-radius: 6px; display: flex; }
@media (max-width: 640px) { .card-play .stage { border-radius: 0; } }

/* the course: stacked layers (pixel sky, smooth graph, pixel foreground) filling the stage */
.stage-canvas { position: relative; flex: 1; min-height: 0; width: 100%; }
.stage-canvas .layer, .scene .layer { position: absolute; top: 0; left: 50%; transform: translateX(-50%); }
.usage-graph { pointer-events: none; overflow: visible; filter: drop-shadow(0 1px 0 rgba(20, 16, 10, 0.35)); }

/* the caddie note floats on the course under the word */
.def-note {
  position: absolute;
  left: 50%;
  top: calc(8% + clamp(2.8rem, 10vw, 5rem));
  transform: translateX(-50%);
  width: min(92%, 520px);
  line-height: normal;
  pointer-events: none;
  z-index: 2;
}
.def-note:empty { display: none; }
.def-note .def-card { padding: 8px 12px; opacity: 0.96; }
.def-note .def-text { font-size: 0.9rem; margin: 2px 0 0; }

/* the control panel: same fixed height for aiming and for the result, so nothing jumps */
.panel {
  width: 100%;
  max-width: 600px;
  height: 172px;
  flex: none;
  padding: 0 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.hole-info {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-pixel);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-muted);
  white-space: nowrap;
  overflow: hidden;
}
.hole-info .subject-label { margin: 0; font-size: 0.85rem; text-transform: none; letter-spacing: 0; }
.hole-info .aim-hint {
  margin-left: auto;
  font-family: var(--font-main);
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.78rem;
  overflow: hidden;
  text-overflow: ellipsis;
}
.panel .aim-year { font-size: 1.9rem; padding: 5px 10px 3px; }
.panel .nudge { height: 42px; }
.panel-actions { width: 100%; display: flex; gap: 8px; align-items: stretch; }
.panel-actions .definition { flex: 1; min-height: 52px; min-width: 0; }
.panel-actions .def-btn { width: 100%; justify-content: center; padding: 0 8px; font-size: 0.85rem; }
.panel-actions .lock-btn { flex: 1.5; width: auto; min-height: 52px; margin: 0; font-size: 1.2rem; }
.panel-actions .def-confirm { font-size: 0.78rem; gap: 6px; }
.panel-actions .def-confirm .btn-small { min-height: 30px; padding: 0 12px; }
.def-used, .panel-actions .def-none { align-self: center; width: 100%; text-align: center; font-size: 0.8rem; color: var(--color-muted); }
.panel-wait { font-family: var(--font-pixel); color: var(--color-muted); font-size: 1.1rem; animation: blink 0.8s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.4; } }
.panel .shot-result { gap: 4px; }
.panel .verdict-label { font-size: 1.55rem; }
.panel .commentary { font-size: 1rem; }
.panel .peak-line { font-size: 0.9rem; text-align: center; }
.panel .stroke-line { display: inline; font-size: 0.8rem; }
.panel .shot-result .btn { margin-top: 4px; min-height: 44px; }

/* very short screens (landscape phones): squeeze the panel a little */
@media (max-height: 640px) {
  #play.fit .scorecard { display: none; }
  .panel { height: 150px; gap: 6px; }
}
.def-note.faded { opacity: 0.22; transition: opacity 0.4s steps(4); }
.def-btn { white-space: nowrap; }
@media (max-width: 420px) { .def-ask { display: none; } }

/* ---------- Big moments: HOLE IN ONE / SO CLOSE banners ---------- */
.stage-banner {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 3;
  line-height: 1;
}
.stage-banner span {
  font-family: var(--font-pixel);
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.04em;
  padding: 0 12px;
  animation: banner-in 0.5s steps(6) both, banner-out 0.45s steps(5) forwards;
}
.stage-banner.ace span {
  font-size: clamp(2.6rem, 12vw, 6rem);
  background: linear-gradient(100deg, #f2b632 0%, #fbe7a1 22%, #fff8dc 30%, #f7d774 40%, #d99a1a 62%, #f7d774 80%, #fbe7a1 100%);
  background-size: 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 0 #5a3d08) drop-shadow(0 0 22px rgba(247, 215, 116, 0.55));
  animation: banner-in 0.55s steps(6) both, shine 1.6s linear 0.5s 2, banner-out 0.5s steps(5) 2.9s forwards;
}
.stage-banner.close span {
  font-size: clamp(1.8rem, 8vw, 3.6rem);
  color: #fffaf0;
  text-shadow: 0 3px 0 #2a2620, 3px 0 0 #2a2620, -3px 0 0 #2a2620, 0 -3px 0 #2a2620;
  animation: banner-in 0.4s steps(5) both, banner-out 0.4s steps(4) 1.75s forwards;
}
@keyframes banner-in {
  0% { opacity: 0; transform: scale(0.4); }
  70% { opacity: 1; transform: scale(1.12); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes banner-out { to { opacity: 0; transform: translateY(-12px); } }
@keyframes shine { from { background-position: 100% 0; } to { background-position: -150% 0; } }
.stage-flash {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(circle at 50% 60%, rgba(255, 228, 140, 0.6), rgba(255, 228, 140, 0) 65%);
  animation: flash 0.9s ease-out forwards;
}
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }
