:root {
  --navy: #082b47;
  --ink: #173b4b;
  --teal: #006f79;
  --teal-deep: #07535a;
  --sea: #1ea7b7;
  --gold: #efb84c;
  --orange: #f08a3b;
  --sand: #f5d99e;
  --paper: #fff2ce;
  --paper-light: #fff9e9;
  --muted: #5d6d6b;
  --line: #d8b982;
  --found: #d2eee1;
}

* { box-sizing: border-box; }
html { scroll-behavior: auto; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--navy);
  font: 16px/1.45 'Trebuchet MS', Arial, sans-serif;
  background:
    radial-gradient(circle at 8% 16%, #bfe9e0 0 1px, transparent 2px) 0 0 / 38px 38px,
    linear-gradient(180deg, #97dce4 0%, #d6eee5 42%, #f5ddac 100%);
}
button, select { font: inherit; }
button { cursor: pointer; color: inherit; }
button:disabled { cursor: default; opacity: .48; }
button:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid #0a67b2; outline-offset: 3px; }
[hidden] { display: none !important; }
::selection { background: #f4bb64; color: var(--navy); }

header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 28px 14px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--navy);
  font: 900 24px/1 Georgia, serif;
  letter-spacing: -.6px;
  text-shadow: 0 1px 0 #fff8;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: none;
  color: #fff4ca;
  font: 700 34px/1 Georgia, serif;
  background: radial-gradient(circle, #0e8b96 0 43%, #0b5964 44% 59%, #d2922a 61% 72%, #ffe39b 74%);
  border: 2px solid #8e5b23;
  border-radius: 50%;
  box-shadow: 0 3px 0 #124c5170, 0 6px 12px #164c4c30;
}
.help {
  min-height: 44px;
  border: 2px solid #0d6370;
  border-radius: 100px;
  padding: 7px 17px;
  background: #e8f5ec;
  color: #075461;
  font-weight: 800;
  box-shadow: 0 3px 0 #0d637030;
}
.help span { margin-right: 5px; }

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(350px, 460px);
  gap: 24px;
  align-items: start;
  max-width: 1180px;
  padding: 0 28px 30px;
  margin: 0 auto;
}
.adventure-hero {
  grid-column: 1 / -1;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 420px;
  padding: 32px 24px 28px;
  overflow: hidden;
  isolation: isolate;
  text-align: center;
  background: #54bfce url('/trail/treasure-island.png') center top / cover no-repeat;
  border: 7px solid #0a6772;
  border-radius: 33px;
  box-shadow: 0 9px 0 #07515b, 0 24px 40px #0a4d5870, inset 0 0 0 3px #c8ecdc;
}
.adventure-hero::after {
  content: '';
  position: absolute;
  z-index: -1;
  inset: 0;
  background: linear-gradient(180deg, #e4f7f4bf 0%, #e3f9f196 34%, transparent 58%, #013b578f 100%);
  pointer-events: none;
}
.birthday-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 auto 4px;
  padding: 8px 19px;
  border: 3px solid #0a5259;
  border-radius: 14px;
  background: linear-gradient(#0f7980, #07545b);
  color: #ffedae;
  box-shadow: 0 4px 0 #073f44, 0 8px 18px #053e4d50;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 2px;
}
.birthday-badge::before { content: '✦'; color: #ffbd60; font-size: 17px; }
.adventure-hero h1 {
  max-width: 850px;
  margin: 9px 0 0;
  color: #072746;
  font: 900 clamp(48px, 7vw, 85px)/.98 Georgia, serif;
  letter-spacing: -2.5px;
  text-shadow: 0 3px 0 #f8f4d2, 0 6px 12px #f6f4dfb0;
}
.intro {
  max-width: 630px;
  margin: 9px 0 24px;
  color: #082e49;
  font-size: clamp(16px, 2.2vw, 22px);
  font-weight: 900;
  text-shadow: 0 1px 0 #fff, 0 2px 8px #fff;
}
.hero-cta {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  margin: auto auto 0;
  padding: 10px 24px;
  border: 3px solid #004b58;
  border-radius: 100px;
  color: #fff8de;
  background: linear-gradient(#078f9a, #006977);
  box-shadow: 0 5px 0 #034b54, 0 10px 20px #002c4370, inset 0 2px 0 #4bd1c7;
  font-size: 17px;
  font-weight: 900;
  text-decoration: none;
}
.hero-cta::before {
  content: '➤';
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  background: #fff3cc;
  color: #006d78;
  font-size: 19px;
  transform: rotate(-38deg);
}
.hero-cta:hover { filter: brightness(1.07); }

.story, .game {
  min-width: 0;
  border: 3px solid #c99658;
  border-radius: 28px;
  background:
    radial-gradient(circle at 15% 25%, #e8bd7430 0 2px, transparent 3px) 0 0 / 26px 27px,
    linear-gradient(145deg, var(--paper-light), var(--paper) 65%, #f8dfa7);
  box-shadow: 0 6px 0 #b77f47, 0 15px 26px #0c5a4a38, inset 0 0 0 3px #fff9e4;
}
.story { padding: 26px; }
.section-kicker {
  margin: 0 0 8px;
  color: #9d5e31;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 2px;
  text-transform: uppercase;
}
.story-title {
  margin: 0 0 18px;
  color: var(--navy);
  font: 900 28px/1.1 Georgia, serif;
  letter-spacing: -.7px;
}
.modes {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  padding: 5px;
  margin: 0 0 21px;
  border: 2px solid #d6b278;
  border-radius: 16px;
  background: #f6dda9;
}
.mode {
  min-height: 48px;
  padding: 6px 3px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: #30596a;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.15;
}
.mode[aria-pressed='true'] {
  color: #fff9e3;
  background: linear-gradient(#097f88, #075761);
  box-shadow: 0 3px 0 #06484e, inset 0 1px 0 #77d5ce;
}
.puzzle-picker { margin: 0 0 20px; }
.puzzle-picker label { display: block; margin-bottom: 7px; color: #345164; font-size: 14px; font-weight: 900; }
.puzzle-picker select {
  width: 100%;
  min-height: 49px;
  padding: 10px 14px;
  border: 2px solid #b6824f;
  border-radius: 13px;
  background: #fffaf0;
  color: var(--navy);
  font-weight: 800;
}
.picker-actions { display: flex; gap: 9px; margin-top: 10px; }
.picker-actions button, .restart {
  flex: 1;
  min-height: 44px;
  padding: 9px 14px;
  border: 2px solid #b48556;
  border-radius: 12px;
  background: #fff8e8;
  color: #26465c;
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 2px 0 #cda16e;
}
.daily-note { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.theme {
  position: relative;
  padding: 21px 23px;
  overflow: hidden;
  border: 3px solid #0b6268;
  border-radius: 20px;
  background: linear-gradient(135deg, #0b737a, #084c61);
  color: #fff7d8;
  box-shadow: 0 4px 0 #074450, inset 0 0 0 2px #3babaa;
}
.theme::after {
  content: '✦';
  position: absolute;
  right: 8px;
  bottom: -42px;
  color: #ffffff12;
  font: 170px/1 Georgia, serif;
  pointer-events: none;
}
.theme-icon { position: relative; z-index: 1; float: right; font-size: 37px; }
.eyebrow { color: #bfe9dd; font-size: 11px; font-weight: 900; letter-spacing: 1.6px; text-transform: uppercase; }
.theme h2 { position: relative; z-index: 1; margin: 8px 0 5px; font: 900 30px/1.1 Georgia, serif; }
.theme p { position: relative; z-index: 1; max-width: 380px; margin: 0; color: #e2f5e7; font-size: 15px; }
.progress-head { display: flex; justify-content: space-between; gap: 12px; margin: 24px 1px 9px; font-size: 14px; font-weight: 900; }
.progress-head span:last-child { color: #456874; }
progress { display: block; width: 100%; height: 12px; overflow: hidden; border: 2px solid #c49256; border-radius: 100px; background: #f8dfab; }
progress::-webkit-progress-bar { background: #f8dfab; }
progress::-webkit-progress-value { background: linear-gradient(90deg, #e78937, #f4bb4b); border-radius: 100px; }
progress::-moz-progress-bar { background: linear-gradient(90deg, #e78937, #f4bb4b); border-radius: 100px; }
.words { display: flex; flex-wrap: wrap; gap: 9px; padding: 0; margin: 17px 0 0; list-style: none; }
.word {
  display: grid;
  place-items: center;
  min-width: 65px;
  min-height: 38px;
  padding: 6px 10px;
  border: 2px dashed #c99559;
  border-radius: 100px;
  background: #fff6e4;
  color: #855838;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 3px;
}
.word.found { border-style: solid; border-color: #0e7c7d; background: var(--trail-colour, var(--found)); color: #173f48; letter-spacing: 0; }
.little-note { margin: 20px 2px 0; color: #5e6d6a; font-size: 13px; }
.win { margin-top: 22px; padding: 19px; border: 2px solid #ca8e4b; border-radius: 16px; background: #ffe4aa; text-align: center; }
.win h2 { margin: 0 0 6px; font: 900 25px Georgia, serif; }
.win p { margin: 0 0 11px; }
.win .restart { margin: 5px; }

.game {
  position: relative;
  padding: 19px;
  border-color: #0c6770;
  box-shadow: 0 6px 0 #064e59, 0 15px 28px #0c5a4a42, inset 0 0 0 3px #ddf2dc;
  scroll-margin-top: 14px;
}
.game-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 2px 3px 13px; color: #315b69; font-size: 13px; font-weight: 900; }
.daily-label { display: inline-flex; align-items: center; gap: 7px; }
.daily-label::before { content: '✦'; color: #db8732; font-size: 22px; line-height: 0; }
.board {
  position: relative;
  isolation: isolate;
  padding: 12px;
  border: 4px solid #0b5560;
  border-radius: 20px;
  background: linear-gradient(140deg, #0f8690, #065e6e);
  box-shadow: inset 0 0 0 3px #4bc0ba, 0 4px 0 #063f50;
  touch-action: none;
  user-select: none;
}
.grid { position: relative; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 7px; }
.tile {
  position: relative;
  min-width: 0;
  aspect-ratio: 1;
  padding: 0;
  border: 2px solid #d5ad6e;
  border-radius: 16px;
  background: linear-gradient(#fffaf0, #f7e4b9);
  color: var(--navy);
  box-shadow: 0 3px 0 #ad874f;
  font: 900 27px/1 Georgia, serif;
  transition: background .13s, box-shadow .13s;
}
.tile .letter { position: relative; z-index: 3; text-shadow: 0 1px 0 #fff7; }
.tile.selected { border-color: #d76922; background: #ffd393; }
.tile.solved { border-color: #2f928b; background: var(--trail-colour, var(--found)); box-shadow: 0 2px 0 #0b6867; }
.tile.hinted { outline: 3px dashed #fff0a2; outline-offset: -5px; }
.tile.blank { visibility: hidden; pointer-events: none; }
.tile .step { position: absolute; z-index: 4; top: -4px; right: -4px; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--navy); color: #fff; font: 900 11px/1 Arial, sans-serif; }
.trail-layer { position: absolute; z-index: 2; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.entry { display: flex; align-items: center; justify-content: center; min-height: 58px; color: #0a5261; font: 900 24px Georgia, serif; letter-spacing: 4px; text-align: center; }
.entry.empty { color: #5f7772; font: 700 13px 'Trebuchet MS', Arial, sans-serif; letter-spacing: 0; }
.actions { display: grid; grid-template-columns: 1fr 1.55fr; gap: 10px; }
.action {
  min-height: 50px;
  padding: 11px 10px;
  border: 2px solid #b98753;
  border-radius: 12px;
  background: #fff8e8;
  font-size: 15px;
  font-weight: 900;
  box-shadow: 0 3px 0 #bd8f5f;
}
.action.primary {
  border-color: #075765;
  background: linear-gradient(#0b8b94, #07626f);
  color: #fff9df;
  box-shadow: 0 3px 0 #064755;
}
.hint { width: 100%; min-height: 46px; margin-top: 12px; padding: 9px; border: 2px solid #d39a59; border-radius: 12px; background: #ffeba9; color: #77502e; font-size: 14px; font-weight: 900; }
.message { min-height: 42px; margin: 14px 3px 0; color: #42616b; font-size: 14px; line-height: 1.4; text-align: center; }
footer { max-width: 1180px; margin: auto; padding: 5px 28px 28px; color: #245969; font-size: 13px; font-weight: 700; text-align: center; }
dialog { width: min(450px, calc(100% - 30px)); padding: 28px; border: 4px solid #0b6770; border-radius: 23px; background: var(--paper-light); color: var(--navy); box-shadow: 0 20px 70px #001a2f99; }
dialog::backdrop { background: #053a50c7; }
dialog h2 { margin: 0 0 16px; font: 900 31px Georgia, serif; }
dialog li { margin: 12px 0; }
dialog ol { padding-left: 23px; }
dialog .primary { width: 100%; margin-top: 10px; }

@media (max-width: 820px) {
  main { grid-template-columns: 1fr; max-width: 620px; gap: 16px; padding: 0 16px 30px; }
  .adventure-hero { grid-column: 1; min-height: 350px; }
  .story, .game { width: 100%; }
}
@media (max-width: 520px) {
  header { padding: 13px 16px 11px; }
  .brand { gap: 8px; font-size: 20px; }
  .brand-mark { width: 40px; height: 40px; font-size: 29px; }
  .help { padding: 7px 11px; font-size: 12px; }
  main { gap: 14px; padding: 0 10px 24px; }
  .adventure-hero { min-height: 295px; padding: 22px 12px 20px; border-width: 5px; border-radius: 24px; background-position: center top; }
  .birthday-badge { padding: 6px 10px; font-size: 10px; letter-spacing: 1.3px; }
  .adventure-hero h1 { margin-top: 10px; font-size: clamp(41px, 12vw, 62px); letter-spacing: -2px; }
  .intro { max-width: 330px; margin-top: 7px; font-size: 15px; }
  .hero-cta { min-height: 46px; padding: 7px 14px; font-size: 14px; }
  .hero-cta::before { width: 26px; height: 26px; }
  .story { padding: 19px 17px; }
  .story-title { margin-bottom: 15px; font-size: 25px; }
  .mode { font-size: 10px; }
  .theme { padding: 18px; }
  .theme h2 { font-size: 27px; }
  .game { padding: 12px; }
  .board { padding: 7px; border-width: 3px; border-radius: 17px; }
  .grid { gap: 5px; }
  .tile { border-radius: 12px; font-size: clamp(20px, 7vw, 30px); }
  .easy .tile { font-size: clamp(24px, 8vw, 33px); }
  .entry { min-height: 51px; }
}
@media (max-width: 360px) {
  .brand { font-size: 17px; }
  .help { font-size: 11px; }
  .adventure-hero { min-height: 275px; }
  .story { padding: 16px 13px; }
  .mode { min-height: 47px; font-size: 9px; }
  .game { padding: 9px; }
  .board { padding: 5px; }
  .grid { gap: 3px; }
  .tile { border-radius: 9px; font-size: 19px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }
