:root {
  --ink: #123a2d;
  --ink-deep: #08291f;
  --paper: #fffdf2;
  --paper-deep: #f3edce;
  --sun: #ffd447;
  --coral: #ff6b55;
  --sky: #8ed8f8;
  --blue: #196d8d;
  --grass: #2d9a58;
  --line: rgba(18, 58, 45, 0.19);
  --shadow: 0 18px 45px rgba(8, 41, 31, 0.16);
}

* { box-sizing: border-box; }

html { background: #d9f1e4; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 212, 71, 0.45), transparent 22rem),
    repeating-linear-gradient(90deg, transparent 0 47px, rgba(18, 58, 45, 0.035) 48px),
    #d9f1e4;
  font-family: "Trebuchet MS", "Avenir Next", Arial, sans-serif;
}

button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible {
  outline: 4px solid var(--sun);
  outline-offset: 3px;
}

.game-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 max(34px, env(safe-area-inset-bottom));
}

.masthead, .level-ribbon, .header-actions, .brand-lockup, .action-row, .result-actions {
  display: flex;
  align-items: center;
}

.masthead { justify-content: space-between; margin-bottom: 14px; }
.brand-lockup { gap: 11px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 3px solid var(--ink);
  border-radius: 50% 50% 42% 58%;
  background: var(--sun);
  box-shadow: 4px 4px 0 var(--ink);
  font-size: 28px;
  transform: rotate(-3deg);
}

h1, h2, p { margin: 0; }
h1, h2 { letter-spacing: -0.045em; }
h1 { font-family: Georgia, "Times New Roman", serif; font-size: clamp(29px, 4vw, 42px); line-height: 0.95; }
.eyebrow { font-size: 11px; font-weight: 900; letter-spacing: 0.16em; text-transform: uppercase; }
.header-actions { gap: 9px; }
.icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 3px 3px 0 var(--ink);
  font-weight: 900;
  cursor: pointer;
}
.icon-button:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }

.level-ribbon {
  position: relative;
  z-index: 2;
  justify-content: space-between;
  gap: 18px;
  min-height: 82px;
  padding: 14px 18px;
  border: 2px solid var(--ink);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  background: var(--paper);
}
.level-ribbon h2 { font-family: Georgia, serif; font-size: clamp(22px, 3vw, 31px); }
.level-dots { display: flex; gap: 8px; }
.level-dot {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: transparent;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}
.level-dot[aria-current="true"] { background: var(--sun); box-shadow: 2px 2px 0 var(--ink); }
.level-dot.complete::after { content: "✓"; }
.level-dot.complete { font-size: 0; background: #bfe49d; }
.level-dot:disabled { opacity: 0.35; cursor: not-allowed; }
.score-card { display: grid; grid-template-columns: auto auto 1px auto auto; align-items: baseline; gap: 7px; }
.score-card span { font-size: 11px; font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; }
.score-card strong { font-family: Georgia, serif; font-size: 29px; }
.score-card .score-divider { width: 1px; height: 25px; margin: 0 5px; background: var(--line); }

.course-card {
  position: relative;
  overflow: hidden;
  border: 2px solid var(--ink);
  background: var(--sky);
  box-shadow: var(--shadow);
}
#gameCanvas { display: block; width: 100%; aspect-ratio: 12 / 7; background: var(--sky); touch-action: none; }
.course-badge, .status-pill, .course-tip {
  position: absolute;
  border: 2px solid var(--ink);
  background: rgba(255, 253, 242, 0.93);
  box-shadow: 3px 3px 0 var(--ink);
  font-weight: 900;
}
.course-badge { top: 15px; left: 15px; padding: 8px 11px; border-radius: 8px; font-size: 11px; letter-spacing: 0.08em; }
.status-pill { top: 15px; left: 50%; transform: translateX(-50%); padding: 8px 16px; border-radius: 999px; color: var(--paper); background: var(--ink); white-space: nowrap; }
.course-tip {
  right: 15px;
  bottom: 15px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: min(350px, calc(100% - 30px));
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.3;
}

.control-deck {
  padding: 18px;
  border: 2px solid var(--ink);
  border-top: 0;
  border-radius: 0 0 22px 22px;
  background: var(--paper);
}
.dial-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.dial-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  padding: 13px 14px 10px;
  border: 1.5px solid var(--line);
  border-radius: 13px;
  background: #fffef9;
}
.dial-label { align-self: center; font-size: 13px; font-weight: 900; }
.dial-value { display: flex; align-items: baseline; gap: 5px; }
.dial-value strong { font-family: Georgia, serif; font-size: 29px; line-height: 1; }
.dial-value small { font-size: 11px; font-weight: 900; }
.dial-card input { grid-column: 1 / -1; width: 100%; accent-color: var(--coral); cursor: pointer; }
.range-ends { grid-column: 1 / -1; display: flex; justify-content: space-between; color: #547267; font-size: 10px; font-weight: 900; text-transform: uppercase; }
.dial-card.is-fixed { background: var(--paper-deep); }
.dial-card.is-fixed .range-ends::after { content: "Fixed for this hole"; color: var(--coral); }
.dial-card.is-fixed .range-ends > span { display: none; }

.action-row { justify-content: flex-end; gap: 12px; margin-top: 15px; }
.reset-button, .launch-button, .dialog-action {
  min-height: 50px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  font-weight: 900;
  cursor: pointer;
}
.reset-button { padding: 0 20px; background: transparent; }
.launch-button, .dialog-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  min-width: 250px;
  padding: 0 22px;
  color: var(--ink-deep);
  background: var(--sun);
  box-shadow: 4px 4px 0 var(--ink);
  font-size: 17px;
}
.launch-button:hover:not(:disabled), .dialog-action:hover { background: #ffe175; transform: translateY(-1px); }
.launch-button:active:not(:disabled), .dialog-action:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.launch-button:disabled { opacity: 0.48; cursor: wait; box-shadow: none; }
.launch-arrow { font-size: 23px; }

.lab-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin-top: 16px;
  overflow: hidden;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--line);
}
.lab-strip div { display: flex; justify-content: space-between; gap: 10px; padding: 9px 12px; background: var(--paper-deep); }
.lab-strip span { font-size: 11px; font-weight: 900; letter-spacing: 0.06em; text-transform: uppercase; }
.lab-strip strong { font-size: 13px; }

.game-dialog {
  width: min(560px, calc(100% - 28px));
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 20px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 8px 8px 0 var(--ink);
}
.game-dialog::backdrop { background: rgba(8, 41, 31, 0.67); backdrop-filter: blur(4px); }
.game-dialog form { position: relative; padding: 30px; }
.game-dialog h2 { margin: 4px 40px 20px 0; font-family: Georgia, serif; font-size: clamp(28px, 6vw, 42px); line-height: 1; }
.game-dialog ol { display: grid; gap: 13px; padding-left: 23px; line-height: 1.42; }
.dialog-close { position: absolute; top: 16px; right: 17px; border: 0; background: transparent; font-size: 31px; cursor: pointer; }
.keyboard-note { margin: 18px 0; padding: 12px; border-radius: 8px; background: var(--paper-deep); font-size: 13px; }
kbd { padding: 2px 6px; border: 1px solid var(--ink); border-radius: 4px; background: white; box-shadow: 0 2px 0 var(--ink); }
.dialog-action { width: 100%; }
.result-dialog { text-align: center; }
.result-flag { margin: -10px 0 4px; font-size: 58px; }
.stars { margin: 3px 0 11px; color: #e0a900; font-size: 35px; letter-spacing: 0.12em; }
.result-actions { gap: 10px; margin-top: 23px; }
.result-actions > * { flex: 1; min-width: 0; }

@media (max-width: 760px) {
  .game-shell { width: min(100% - 16px, 620px); padding-top: 9px; }
  .masthead { margin-bottom: 9px; }
  .brand-mark { width: 43px; height: 43px; font-size: 23px; }
  .level-ribbon { display: grid; grid-template-columns: 1fr auto; min-height: 76px; padding: 11px 12px; }
  .level-dots { grid-column: 1 / -1; grid-row: 2; justify-content: center; }
  .level-dot { width: 29px; height: 29px; }
  .score-card { grid-column: 2; grid-row: 1; }
  .course-badge { top: 8px; left: 8px; padding: 5px 7px; font-size: 9px; }
  .status-pill { top: 8px; right: 8px; left: auto; transform: none; padding: 5px 9px; font-size: 11px; }
  .course-tip { right: 8px; bottom: 8px; width: min(310px, calc(100% - 16px)); padding: 7px 9px; font-size: 11px; }
  .control-deck { padding: 11px; }
  .dial-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .gravity-card { grid-column: 1 / -1; }
  .dial-card { padding: 10px; }
  .dial-value strong { font-size: 24px; }
  .action-row { display: grid; grid-template-columns: auto 1fr; gap: 8px; }
  .launch-button { min-width: 0; }
  .lab-strip div { flex-direction: column; gap: 2px; }
}

@media (max-width: 440px) {
  .brand-lockup .eyebrow { display: none; }
  .header-actions { gap: 6px; }
  .icon-button { width: 39px; height: 39px; }
  .level-ribbon { gap: 8px; }
  .level-ribbon .eyebrow { font-size: 8px; }
  .level-ribbon h2 { font-size: 20px; }
  .score-card span, .score-card .score-divider { display: none; }
  .score-card strong:first-of-type::after { content: " / "; }
  .score-card { display: flex; gap: 2px; }
  .score-card strong { font-size: 22px; }
  #gameCanvas { min-height: 260px; object-fit: contain; }
  .course-tip { display: none; }
  .dial-grid { grid-template-columns: 1fr; }
  .gravity-card { grid-column: auto; }
  .dial-card { grid-template-columns: 1fr auto; }
  .action-row { grid-template-columns: 1fr; }
  .reset-button { order: 2; }
  .launch-button { order: 1; min-height: 54px; }
  .lab-strip span { font-size: 8px; }
  .lab-strip strong { font-size: 11px; }
  .game-dialog form { padding: 24px 20px; }
  .result-actions { align-items: stretch; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
