:root {
  --ink: #102c3c;
  --ink-soft: #234657;
  --pond: #79c9ba;
  --pond-deep: #2f918e;
  --cream: #fff5d6;
  --paper: #f6e7bc;
  --sun: #ffd347;
  --coral: #f36f61;
  --berry: #a64061;
  --white: #fffdf4;
  --shadow: rgba(10, 40, 52, 0.22);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--ink);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 14% 4%, rgba(255, 228, 130, 0.75), transparent 23rem),
    linear-gradient(180deg, #f7e8b7 0, #e8d699 24rem, #6ebeb1 24rem, #2d8888 100%);
  font-family: "Avenir Next", Avenir, "Trebuchet MS", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:not(:disabled) {
  cursor: pointer;
}

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

.page-noise {
  position: fixed;
  z-index: 20;
  inset: 0;
  pointer-events: none;
  opacity: 0.07;
  background-image:
    repeating-linear-gradient(17deg, transparent 0 3px, rgba(16, 44, 60, 0.28) 4px),
    repeating-linear-gradient(103deg, transparent 0 7px, rgba(255, 255, 255, 0.22) 8px);
  background-size: 11px 13px, 17px 19px;
  mix-blend-mode: multiply;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.8rem 1rem;
  transform: translateY(-160%);
  color: var(--white);
  background: var(--ink);
  border-radius: 0.4rem;
}

.skip-link:focus {
  transform: none;
}

.masthead {
  position: relative;
  z-index: 2;
  width: min(1480px, calc(100% - 3rem));
  margin: 0 auto;
  padding: 2rem 0 1.6rem;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

.title-lockup {
  grid-column: 2;
  text-align: center;
}

.eyebrow,
.overline,
.score-label,
.microcopy,
.site-footer,
.key-hints {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.7rem;
  font-weight: 800;
}

.eyebrow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  margin: 0 0 0.4rem;
}

.eyebrow span {
  display: block;
  width: 2.2rem;
  height: 1px;
  background: currentColor;
}

.masthead h1 {
  margin: 0;
  font-family: "Iowan Old Style", Baskerville, Georgia, serif;
  font-size: clamp(3rem, 7vw, 6.8rem);
  line-height: 0.78;
  letter-spacing: -0.075em;
  font-weight: 700;
}

.masthead h1 em,
.overlay-copy h2 em,
.result-card h2 em {
  color: var(--coral);
  font-weight: 400;
}

.dek {
  margin: 1rem 0 0;
  font-family: "Iowan Old Style", Baskerville, Georgia, serif;
  font-size: clamp(0.95rem, 2vw, 1.2rem);
  font-style: italic;
}

.top-controls {
  grid-column: 3;
  justify-self: end;
  display: flex;
  gap: 0.7rem;
}

.round-control {
  min-width: 3.1rem;
  min-height: 3.1rem;
  padding: 0 0.95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: var(--ink);
  background: rgba(255, 253, 244, 0.58);
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  box-shadow: 3px 3px 0 rgba(16, 44, 60, 0.12);
  font-weight: 800;
}

.round-control:hover {
  background: var(--white);
  transform: translateY(-2px);
}

.control-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.layout {
  position: relative;
  z-index: 1;
  width: min(1480px, calc(100% - 3rem));
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 315px);
  gap: 1.2rem;
  align-items: stretch;
}

.game-card,
.pond-ledger {
  border: 1.5px solid var(--ink);
  box-shadow: 8px 9px 0 rgba(16, 44, 60, 0.18);
}

.game-card {
  min-width: 0;
  overflow: hidden;
  background: rgba(255, 245, 214, 0.92);
  border-radius: 1.2rem;
}

.scoreboard {
  min-height: 5.4rem;
  display: grid;
  grid-template-columns: 1.35fr repeat(3, 1fr) auto;
  border-bottom: 1.5px solid var(--ink);
  background: var(--white);
}

.score-stat {
  padding: 0.75rem 1rem 0.65rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-right: 1px solid rgba(16, 44, 60, 0.2);
}

.score-label {
  margin-bottom: 0.1rem;
  color: #56717c;
  font-size: 0.62rem;
}

.score-stat strong {
  font-variant-numeric: tabular-nums;
  font-size: clamp(1.05rem, 2vw, 1.5rem);
  line-height: 1;
}

.score-stat small {
  margin-left: 0.15rem;
  color: #789099;
  font-size: 0.64em;
}

.pause-button {
  min-width: 5.5rem;
  border: 0;
  background: var(--sun);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.pause-button span:first-child {
  font-size: 1.15rem;
  letter-spacing: -0.15em;
}

.pause-button:disabled {
  color: #6a7375;
  background: #d8d8cb;
}

.playfield {
  position: relative;
  isolation: isolate;
  width: 100%;
  aspect-ratio: 10 / 7;
  min-height: 360px;
  overflow: hidden;
  background: #7fcbbd;
}

#duckCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

#duckCanvas.is-pulling {
  cursor: grabbing;
}

.game-overlay {
  position: absolute;
  z-index: 5;
  inset: 0;
}

.game-overlay[hidden] {
  display: none;
}

.game-overlay--intro {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  align-items: center;
  padding: clamp(1.2rem, 4vw, 4rem);
  background: linear-gradient(90deg, rgba(16, 44, 60, 0.04), rgba(16, 44, 60, 0.8) 62%, rgba(16, 44, 60, 0.9));
}

.overlay-copy {
  grid-column: 2;
  color: var(--white);
  text-align: left;
}

.overlay-copy h2,
.result-card h2,
.pause-card h2,
.help-dialog h2,
.ledger-heading h2 {
  margin: 0.25rem 0 0.7rem;
  font-family: "Iowan Old Style", Baskerville, Georgia, serif;
  font-size: clamp(2.1rem, 4.5vw, 4.8rem);
  line-height: 0.88;
  letter-spacing: -0.055em;
}

.overlay-copy > p:not(.overline, .microcopy) {
  max-width: 28rem;
  margin: 1rem 0 1.25rem;
  color: rgba(255, 253, 244, 0.83);
  line-height: 1.5;
}

.overline {
  margin: 0;
  color: var(--coral);
}

.microcopy {
  margin: 0.8rem 0 0;
  color: rgba(255, 253, 244, 0.55);
  font-size: 0.58rem;
}

.ticket {
  position: absolute;
  top: 1rem;
  left: 1rem;
  padding: 0.5rem 0.7rem;
  transform: rotate(-3deg);
  color: var(--ink);
  background: var(--sun);
  border: 1px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.primary-button {
  min-height: 3.15rem;
  padding: 0.8rem 1.2rem;
  border: 1.5px solid var(--ink);
  border-radius: 0.45rem;
  color: var(--ink);
  background: var(--sun);
  box-shadow: 4px 4px 0 var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 1.4rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.075em;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.primary-button:hover:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--ink);
}

.primary-button:disabled {
  opacity: 0.65;
}

.game-overlay--pause,
.game-overlay--result {
  display: grid;
  place-items: center;
  padding: 1.2rem;
  background: rgba(16, 44, 60, 0.72);
  backdrop-filter: blur(8px);
}

.game-overlay--result {
  overflow-y: auto;
}

.pause-card,
.result-card {
  width: min(92%, 600px);
  padding: clamp(1.5rem, 4vw, 2.6rem);
  text-align: center;
  background: var(--cream);
  border: 1.5px solid var(--ink);
  border-radius: 0.8rem;
  box-shadow: 8px 8px 0 var(--ink);
}

.pause-card h2 {
  color: var(--berry);
}

.result-card {
  width: min(96%, 720px);
}

.result-card h2 {
  font-size: clamp(2.3rem, 5vw, 4.2rem);
}

.result-numbers {
  margin: 1rem 0 1.2rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-block: 1px solid rgba(16, 44, 60, 0.25);
}

.result-numbers div {
  padding: 0.8rem 0.4rem;
  display: flex;
  flex-direction: column;
}

.result-numbers div + div {
  border-left: 1px solid rgba(16, 44, 60, 0.25);
}

.result-numbers strong {
  font-size: clamp(1.1rem, 2.8vw, 1.8rem);
  font-variant-numeric: tabular-nums;
}

.result-numbers span,
.score-form label {
  color: #5f777f;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.score-form label {
  display: block;
  margin-bottom: 0.45rem;
}

.name-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.55rem;
}

.name-row input {
  min-width: 0;
  min-height: 3.15rem;
  padding: 0.7rem 0.9rem;
  color: var(--ink);
  background: var(--white);
  border: 1.5px solid var(--ink);
  border-radius: 0.45rem;
  font-weight: 700;
}

.submit-message {
  min-height: 1.3rem;
  margin: 0.75rem 0 0;
  color: var(--berry);
  font-size: 0.8rem;
  font-weight: 800;
}

.text-button {
  padding: 0.4rem;
  border: 0;
  color: var(--ink);
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  font-size: 0.78rem;
  font-weight: 800;
}

.gesture-hint {
  position: absolute;
  z-index: 3;
  left: 31%;
  bottom: 14%;
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.7rem;
  color: var(--ink);
  background: rgba(255, 253, 244, 0.9);
  border-radius: 99px;
  box-shadow: 0 3px 15px var(--shadow);
  font-size: 0.67rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  pointer-events: none;
}

.gesture-hint.is-visible {
  display: flex;
  animation: hint-bob 1.4s ease-in-out infinite;
}

.gesture-hand {
  font-size: 1.35rem;
}

.game-footer {
  min-height: 3.1rem;
  padding: 0.65rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-top: 1.5px solid var(--ink);
  background: var(--white);
  font-size: 0.72rem;
}

.game-footer p {
  margin: 0;
}

.status-dot {
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  margin-right: 0.45rem;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 0 4px rgba(243, 111, 97, 0.14);
}

kbd {
  min-width: 1.45rem;
  padding: 0.14rem 0.25rem;
  display: inline-block;
  text-align: center;
  color: var(--ink-soft);
  background: #ecebdc;
  border: 1px solid #b9c2bd;
  border-bottom-width: 2px;
  border-radius: 0.2rem;
  font-family: inherit;
  font-size: 0.57rem;
}

.pond-ledger {
  position: relative;
  overflow: hidden;
  padding: 1.4rem;
  background:
    linear-gradient(rgba(16, 44, 60, 0.055) 1px, transparent 1px) 0 7rem / 100% 2.25rem,
    var(--paper);
  border-radius: 1.2rem;
}

.ledger-heading {
  position: relative;
  padding-bottom: 1.1rem;
  border-bottom: 2px solid var(--ink);
}

.ledger-heading h2 {
  font-size: clamp(2.5rem, 5vw, 4rem);
}

.wax-seal {
  position: absolute;
  right: -0.25rem;
  bottom: 1.1rem;
  width: 4rem;
  height: 4rem;
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--cream);
  background: var(--berry);
  border: 2px dotted var(--cream);
  border-radius: 50%;
  box-shadow: 0 0 0 4px var(--berry);
  transform: rotate(8deg);
}

.wax-seal span,
.wax-seal strong {
  display: block;
  line-height: 1;
}

.wax-seal span {
  font-size: 0.48rem;
  letter-spacing: 0.14em;
}

.wax-seal strong {
  font-family: Georgia, serif;
  font-size: 1.5rem;
}

.leaderboard {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: rank;
}

.leaderboard li {
  min-height: 2.25rem;
  display: grid;
  grid-template-columns: 1.6rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.45rem;
  counter-increment: rank;
  font-size: 0.76rem;
}

.leaderboard li::before {
  content: counter(rank, decimal-leading-zero);
  color: var(--berry);
  font-family: Georgia, serif;
  font-size: 0.65rem;
  font-style: italic;
}

.leaderboard .leader-name {
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard .leader-score {
  font-variant-numeric: tabular-nums;
  font-weight: 900;
}

.leaderboard li:nth-child(-n + 3) .leader-score {
  color: var(--berry);
}

.leaderboard-empty {
  grid-template-columns: 1fr !important;
  min-height: 8rem !important;
  place-items: center;
  text-align: center;
  color: #65767a;
  counter-increment: none !important;
}

.leaderboard-empty::before {
  display: none;
}

.leaderboard-empty span {
  font-family: Georgia, serif;
  font-size: 2.5rem;
}

.leaderboard-empty p {
  margin: 0;
}

.ledger-note {
  margin: 1rem 0;
  padding-top: 1rem;
  border-top: 1px solid rgba(16, 44, 60, 0.35);
  color: #5a6e73;
  font-family: Georgia, serif;
  font-size: 0.78rem;
  font-style: italic;
  line-height: 1.4;
}

.duck-fact {
  position: absolute;
  right: 1.4rem;
  bottom: 1.25rem;
  left: 1.4rem;
  padding: 0.8rem;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.6rem;
  color: var(--cream);
  background: var(--ink);
  border-radius: 0.4rem;
  transform: rotate(-1deg);
}

.duck-fact p {
  margin: 0;
  font-size: 0.66rem;
  line-height: 1.4;
}

.duck-fact strong {
  display: block;
  color: var(--sun);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.site-footer {
  width: min(1480px, calc(100% - 3rem));
  margin: 0 auto;
  padding: 1rem 0 1.4rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.55rem;
}

.help-dialog {
  width: min(92vw, 720px);
  padding: clamp(1.5rem, 4vw, 3rem);
  color: var(--ink);
  background: var(--cream);
  border: 1.5px solid var(--ink);
  border-radius: 0.8rem;
  box-shadow: 12px 12px 0 var(--ink);
}

.help-dialog::backdrop {
  background: rgba(16, 44, 60, 0.72);
  backdrop-filter: blur(6px);
}

.dialog-close {
  position: absolute;
  top: 0.7rem;
  right: 0.8rem;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--ink);
  border-radius: 50%;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
}

.help-dialog h2 {
  font-size: clamp(2.3rem, 6vw, 4.2rem);
}

.instruction-grid {
  margin: 1.5rem 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-block: 1px solid rgba(16, 44, 60, 0.3);
}

.instruction-grid > div {
  padding: 1rem;
}

.instruction-grid > div + div {
  border-left: 1px solid rgba(16, 44, 60, 0.3);
}

.instruction-grid span {
  color: var(--coral);
  font-family: Georgia, serif;
  font-size: 1.4rem;
  font-style: italic;
}

.instruction-grid h3 {
  margin: 0.25rem 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.instruction-grid p,
.keyboard-help {
  margin: 0;
  color: #536b74;
  font-size: 0.78rem;
  line-height: 1.45;
}

.keyboard-help {
  margin-bottom: 1.2rem;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@keyframes hint-bob {
  0%, 100% { transform: translate(0, 0) rotate(-2deg); }
  50% { transform: translate(-0.5rem, -0.65rem) rotate(2deg); }
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) 260px;
  }

  .control-label,
  .key-hints {
    display: none;
  }

  .pond-ledger {
    padding: 1.1rem;
  }

  .duck-fact {
    right: 1.1rem;
    left: 1.1rem;
  }
}

@media (max-width: 820px) {
  body {
    background: linear-gradient(180deg, #f7e8b7 0, #e8d699 18rem, #6ebeb1 18rem, #2d8888 100%);
  }

  .masthead {
    width: min(100% - 1.2rem, 720px);
    padding: 1.5rem 0 1rem;
    grid-template-columns: 1fr auto;
  }

  .title-lockup {
    grid-column: 1;
    text-align: left;
  }

  .eyebrow {
    justify-content: flex-start;
    font-size: 0.56rem;
  }

  .eyebrow span {
    display: none;
  }

  .masthead h1 {
    font-size: clamp(2.6rem, 12vw, 4.8rem);
  }

  .dek {
    font-size: 0.82rem;
  }

  .top-controls {
    grid-column: 2;
    gap: 0.35rem;
  }

  .round-control {
    min-width: 2.8rem;
    min-height: 2.8rem;
    padding: 0;
  }

  .layout {
    width: min(100% - 1rem, 720px);
    grid-template-columns: 1fr;
  }

  .game-card,
  .pond-ledger {
    border-radius: 0.75rem;
    box-shadow: 5px 6px 0 rgba(16, 44, 60, 0.2);
  }

  .scoreboard {
    min-height: 4.5rem;
    grid-template-columns: 1.2fr repeat(3, 1fr) 3.5rem;
  }

  .score-stat {
    padding: 0.55rem 0.45rem;
  }

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

  .score-stat strong {
    font-size: clamp(0.85rem, 3.3vw, 1.2rem);
  }

  .pause-button {
    min-width: 0;
  }

  .pause-button span:last-child {
    display: none;
  }

  .playfield {
    min-height: 0;
  }

  .game-footer {
    min-height: 2.7rem;
    font-size: 0.62rem;
  }

  .pond-ledger {
    min-height: 530px;
  }

  .ledger-heading h2 {
    font-size: 3.5rem;
  }

  .site-footer {
    width: calc(100% - 1rem);
    flex-direction: column;
    text-align: center;
  }
}

@media (max-width: 560px) {
  .masthead {
    align-items: end;
  }

  .dek {
    display: none;
  }

  .scoreboard {
    grid-template-columns: 1.2fr 0.8fr 0.8fr 3.3rem;
  }

  .score-stat:nth-of-type(4) {
    display: none;
  }

  .playfield.showing-result {
    min-height: 590px;
    aspect-ratio: auto;
  }

  .playfield.showing-result #duckCanvas {
    height: auto;
    aspect-ratio: 10 / 7;
  }

  .game-overlay--intro {
    display: flex;
    align-items: flex-end;
    padding: 1.2rem;
    background: linear-gradient(0deg, rgba(16, 44, 60, 0.95), rgba(16, 44, 60, 0.05) 78%);
  }

  .overlay-copy {
    grid-column: auto;
  }

  .overlay-copy h2 {
    font-size: clamp(2rem, 10vw, 3.2rem);
  }

  .overlay-copy > p:not(.overline, .microcopy) {
    margin: 0.7rem 0 0.9rem;
    font-size: 0.78rem;
  }

  .microcopy {
    display: none;
  }

  .ticket {
    font-size: 0.48rem;
  }

  .primary-button {
    min-height: 2.8rem;
    padding: 0.65rem 0.9rem;
    font-size: 0.72rem;
  }

  .result-card {
    padding: 1rem;
  }

  .result-card h2 {
    font-size: 2.2rem;
  }

  .result-numbers {
    margin: 0.6rem 0;
  }

  .name-row {
    grid-template-columns: 1fr;
  }

  .name-row input,
  .name-row .primary-button {
    min-height: 2.7rem;
  }

  .instruction-grid {
    grid-template-columns: 1fr;
  }

  .instruction-grid > div + div {
    border-top: 1px solid rgba(16, 44, 60, 0.3);
    border-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
