/* Math Yeeting: the pages around the game (landing, profiles, progress,
   leaderboard). A tropical afternoon: sky, lagoon, sand, chunky rounded cards.
   The game page itself is styled in yeet.css. */
:root {
  --ink: #1b2d2a;          /* teal ink: text and outlines */
  --lagoon: #2ec4b6;
  --deep-sea: #0f6f8f;
  --mango: #ff9f1c;
  --hibiscus: #ff3d6e;
  --hibiscus-deep: #c2184f;
  --leaf: #6cc24a;
  --leaf-deep: #2f7d32;
  --sand: #f3d9a0;
  --sand-deep: #d9b778;
  --cream: #fff8e7;
  --paper: #fffdf6;
  --sky-top: #3fa9e8;
  --sky-mid: #8fd6f2;
  --horizon: #fbe3b8;
  --display: "Fredoka", "Baloo 2", "Trebuchet MS", system-ui, sans-serif;
  --sans: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  --chunk: 0 6px 0 var(--ink);
}

*, *::before, *::after { box-sizing: border-box; }
/* The hidden attribute wins over any display an element sets for itself. */
[hidden] { display: none !important; }

html { min-height: 100%; background: var(--sky-mid); -webkit-text-size-adjust: 100%; }

body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  font: 600 1rem/1.45 var(--sans); color: var(--ink);
}
/* The pages around the game wear class="page" (layouts/application); the game
   page (layouts/game, body.game-page) is styled by yeet.css, so the generic
   rules below are scoped to .page to stay out of the game's HUD. */
.page {
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 45%, var(--horizon) 100%) fixed;
}

/* :where() keeps these at element weight, so any class below overrides them. */
:where(.page) :is(h1, h2, h3, legend) { font-family: var(--display); font-weight: 600; line-height: 1.1; }
:where(.page) a { color: var(--deep-sea); }
:where(.page) :focus-visible { outline: 3px solid var(--deep-sea); outline-offset: 3px; border-radius: 6px; }

.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.page .hint { margin: 0; font-size: .92rem; font-weight: 600; opacity: .8; }
.page .form-error { margin: 0; color: var(--hibiscus-deep); font-weight: 800; }

.flash-msg {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 20;
  width: max-content; max-width: calc(100% - 32px); margin: 0; padding: 10px 20px; border-radius: 999px;
  font-weight: 800; text-align: center; background: var(--hibiscus-deep); color: #fff;
  border: 3px solid var(--ink); box-shadow: 0 5px 0 var(--ink);
}
.flash-msg.notice { background: var(--deep-sea); }

/* Buttons: chunky toy blocks that press down */
.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  font: 600 1.15rem/1 var(--display); letter-spacing: .01em;
  color: var(--ink); background: var(--paper);
  border: 3px solid var(--ink); border-radius: 16px; padding: 13px 22px;
  box-shadow: 0 5px 0 var(--ink); transition: transform .08s, box-shadow .08s, filter .12s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 0 var(--ink); filter: brightness(1.05); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: 0 5px 0 var(--ink); }
.btn-go { background: var(--mango); }
.btn-sea { background: var(--lagoon); }
.btn-big { font-size: 1.5rem; padding: 18px 30px; border-radius: 20px; box-shadow: 0 7px 0 var(--ink); }
.btn-big:hover { box-shadow: 0 8px 0 var(--ink); }
.btn-big:active { transform: translateY(6px); box-shadow: 0 1px 0 var(--ink); }
.btn-danger { background: var(--hibiscus-deep); color: #fff; font-size: 1rem; padding: 10px 16px; }

/* Cards */
.page .panel {
  background: var(--cream); border: 3px solid var(--ink); border-radius: 24px;
  padding: 20px; box-shadow: var(--chunk);
}
.page .panel h2 { margin: 0; font-size: 1.6rem; }

.home-link { color: var(--ink); font: 600 1.05rem/1.2 var(--display); text-decoration: none;
  background: rgba(255, 253, 246, .85); padding: 8px 14px; border-radius: 999px; border: 2px solid var(--ink); }
.home-link:hover { background: var(--paper); }

/* ---------- The island: the landing page's backdrop ---------- */
.island-scene { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none;
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 42%, var(--horizon) 64%, var(--horizon) 100%); }
.sun {
  position: absolute; top: clamp(24px, 7vh, 70px); right: clamp(24px, 12vw, 180px);
  width: clamp(90px, 16vw, 150px); aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 40% 38%, #fffbe8 0 30%, #ffe08a 62%, #ffc94a 100%);
  box-shadow: 0 0 0 14px rgba(255, 236, 160, .35), 0 0 0 34px rgba(255, 236, 160, .18), 0 0 90px 40px rgba(255, 214, 110, .45);
  animation: sun-breathe 6s ease-in-out infinite;
}
@keyframes sun-breathe { 50% { transform: scale(1.05); } }

.cloud { position: absolute; height: 34px; border-radius: 999px; background: #fff; opacity: .92;
  box-shadow: 0 6px 0 rgba(143, 214, 242, .55); animation: drift 60s linear infinite; }
.cloud::before, .cloud::after { content: ""; position: absolute; bottom: 10px; border-radius: 50%; background: #fff; }
.cloud::before { left: 18%; width: 48px; height: 48px; }
.cloud::after { left: 46%; width: 64px; height: 62px; }
.cloud-1 { top: 13vh; left: 6vw; width: 150px; }
.cloud-2 { top: 26vh; left: 62vw; width: 120px; transform: scale(.8); animation-duration: 80s; animation-delay: -30s; }
.cloud-3 { top: 6vh; left: 38vw; width: 110px; transform: scale(.65); opacity: .8; animation-duration: 95s; animation-delay: -60s; }
@keyframes drift { from { translate: -12vw 0; } to { translate: 14vw 0; } }

.yeet-arc { position: absolute; top: clamp(8px, 4vh, 40px); left: 50%; translate: -50% 0;
  width: min(96vw, 760px); height: auto; overflow: visible; }
.yeet-arc .trail { stroke: #fff; stroke-width: 5; stroke-linecap: round; stroke-dasharray: 1 14; opacity: .9;
  animation: trail 1.6s linear infinite; }
.yeet-arc .gnome { animation: bob 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 50%; }
@keyframes trail { to { stroke-dashoffset: -30; } }
@keyframes bob { 50% { transform: translate(4px, -6px) rotate(12deg); } }

.horizon { position: absolute; left: 0; bottom: 0; width: 100%; height: clamp(240px, 44vh, 460px); }
.horizon .volcano { fill: #6f8ea0; opacity: .55; }
.horizon .far-isle { fill: #4fa07a; opacity: .6; }
.horizon .hill-far { fill: #3e9e5a; }
.horizon .hill-mid { fill: var(--leaf); }
.horizon .sand { fill: var(--sand); }

.palms { position: absolute; bottom: 0; height: clamp(300px, 70vh, 640px); width: auto; max-width: 46vw; overflow: visible; }
.palms-left { left: 0; }
.palms-right { right: 0; }
.palm { transform-box: fill-box; }
.palm-back { fill: #1f6b3a; opacity: .85; }
.palm-front { fill: #134a33; }

/* ---------- Landing ---------- */
.landing {
  position: relative; z-index: 1;
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center;
  gap: 20px; padding: clamp(88px, 16vh, 150px) 16px 56px; text-align: center;
}
.landing > .panel { width: min(100%, 640px); }
.hero { display: grid; gap: 6px; justify-items: center; }
.wordmark {
  margin: 0; font: 700 clamp(3.1rem, 15vw, 6.6rem)/.9 var(--display); letter-spacing: -.01em;
  rotate: -3deg; display: flex; flex-wrap: wrap; justify-content: center; column-gap: .25em;
}
.wordmark span {
  -webkit-text-stroke: .1em var(--ink); paint-order: stroke fill;
  text-shadow: 0 .09em 0 var(--ink), 0 .16em 0 rgba(15, 111, 143, .35);
}
.wm-math { color: #fff; }
.wm-yeet { color: var(--mango); display: inline-block; animation: wobble 3.2s ease-in-out infinite; }
@keyframes wobble { 0%, 100% { rotate: 0deg; } 50% { rotate: 2.5deg; translate: 0 -3px; } }
.tagline {
  margin: 10px 0 4px; max-width: 30ch; padding: 8px 18px; border-radius: 999px;
  font: 600 clamp(1.05rem, 4.2vw, 1.3rem)/1.3 var(--display);
  background: rgba(255, 253, 246, .9); border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink);
}

.play-panel { display: grid; gap: 14px; justify-items: center; }
.play-actions { display: flex; flex-wrap: wrap; gap: 18px 24px; align-items: center; justify-content: center; }
.new-world { margin: 0; }
.start-hint { margin: 0; font: 600 1.15rem/1.3 var(--display); }

.join { display: grid; gap: 6px; justify-items: center; margin: 0; }
.join label { font: 600 1.05rem/1.2 var(--display); }
.join-row { display: flex; gap: 8px; align-items: stretch; }
.join input[type=text] {
  width: 8.6ch; min-width: 0; font: 600 1.45rem/1.2 var(--display); letter-spacing: .06em; text-transform: uppercase;
  text-align: center; padding: 8px 10px; color: var(--ink); background: var(--paper);
  border: 3px solid var(--ink); border-radius: 14px; box-sizing: content-box;
}
.join input[type=text]::placeholder { color: rgba(27, 45, 42, .35); }
.join .btn { padding: 10px 18px; font-size: 1.1rem; }

.worlds-panel { display: grid; gap: 12px; text-align: left; }
.worlds-panel h2 { text-align: center; }
.world-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.world-item { display: flex; align-items: center; gap: 10px; }
.world-link {
  flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px;
  padding: 10px 12px; color: var(--ink); text-decoration: none; background: var(--paper);
  border: 3px solid var(--sand-deep); border-radius: 16px; transition: border-color .12s, transform .08s;
}
.world-link:hover { border-color: var(--ink); }
.world-link:active { transform: translateY(2px); }
.code-tag {
  font: 700 1.15rem/1 var(--display); letter-spacing: .08em; padding: 6px 10px; border-radius: 10px;
  background: var(--sand); border: 2px dashed var(--ink); white-space: nowrap;
}
.code-tag.big { font-size: clamp(1.8rem, 9vw, 2.8rem); padding: 6px 16px; border-width: 3px; }
.world-name { font: 600 1.05rem/1.2 var(--display); }
.world-meta { font-size: .88rem; opacity: .8; }
.world-board { font: 600 .95rem/1 var(--display); color: var(--deep-sea); white-space: nowrap; }
.progress-link { margin: 0; }
.progress-link a { display: inline-block; color: var(--ink); font: 600 1.05rem/1.2 var(--display); text-decoration: none;
  background: rgba(255, 253, 246, .9); padding: 10px 18px; border-radius: 999px; border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink); }

/* ---------- Who's yeeting? Big tappable profiles ---------- */
.whos-playing { width: min(100%, 640px); display: grid; gap: 14px; text-align: center; }
.whos-playing h1, .whos-playing h2 { margin: 0; font-size: 1.7rem; }
.profiles { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; align-items: flex-start; }
.profile-pick { margin: 0; }
.profile {
  appearance: none; display: grid; justify-items: center; gap: 4px; min-width: 104px; padding: 12px 14px 10px; cursor: pointer;
  font: inherit; color: var(--ink); background: var(--paper); border: 3px solid var(--sand-deep); border-radius: 18px;
  transition: border-color .12s, transform .08s;
}
.profile:hover { border-color: var(--ink); }
.profile:active { transform: translateY(2px); }
.profile.chosen { border-color: var(--ink); background: #e3f8f4; box-shadow: inset 0 0 0 3px var(--lagoon), 0 4px 0 var(--ink); }
.profile.chosen::after { content: "yeeting"; font: 600 .7rem/1 var(--display); letter-spacing: .12em; text-transform: uppercase; color: var(--deep-sea); }
.profile strong { font: 600 1.2rem/1.1 var(--display); max-width: 12ch; overflow-wrap: anywhere; }
.profile small { font-size: .8rem; opacity: .75; }
.avatar {
  display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%;
  font: 700 1.5rem/1 var(--display); color: #fff; background: var(--player, var(--lagoon));
  border: 3px solid var(--ink); -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .18);
}
.avatar.plus { background: var(--sand); color: var(--ink); -webkit-text-stroke: 0; }
/* Closed, "New player" is one more tile; open, it takes the row and the form sits under it. */
.profile-new[open] { flex-basis: 100%; display: grid; justify-items: center; gap: 12px; }
.profile-new > summary { list-style: none; }
.profile-new > summary::-webkit-details-marker { display: none; }
.profile-new[open] > summary { border-color: var(--ink); }
.profile-form { width: 100%; display: grid; gap: 12px; justify-items: stretch; text-align: left; max-width: 360px; margin: 4px auto 0; }
.profile-form label { display: grid; gap: 4px; font-weight: 800; }
.profile-form label small { font-weight: 600; opacity: .7; }
.profile-form input[type=text] {
  font: 500 1.3rem/1.2 var(--display); padding: 9px 12px; color: var(--ink);
  border: 3px solid var(--ink); border-radius: 14px; background: var(--paper);
}
.profile-form .btn { justify-self: center; }
.profile-links { margin: 0; font-size: .92rem; }
.profile-links a { color: var(--deep-sea); font-weight: 800; }

.profiles-page { max-width: 680px; margin: 0 auto; padding: 28px 16px 48px; display: grid; gap: 18px; justify-items: center; }
.profiles-page .panel { width: 100%; }
.profiles-page h1 { margin: 0 0 12px; }
.profiles-page .whos-playing h1 { margin: 0; }
.profiles-page .panel > .profile-form { margin: 0; max-width: 420px; }
.danger-zone { display: grid; gap: 10px; justify-items: start; }
.danger-zone h2 { margin: 0; font-size: 1.3rem; }
.danger-zone form { margin: 0; }

/* ---------- Progress: a parent's view of what the island has learned ---------- */
/* minmax(0, 1fr): a wide fact grid scrolls inside its panel instead of widening the page. */
.progress-page { max-width: 980px; margin: 0 auto; padding: 24px 16px 56px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.progress-nav { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; }
.progress-head { padding: 4px 4px 0; }
.progress-head h1 { margin: 0; font-size: clamp(2.1rem, 8vw, 3.2rem); line-height: 1; color: #fff;
  -webkit-text-stroke: .1em var(--ink); paint-order: stroke fill; text-shadow: 0 .08em 0 var(--ink); }
.progress-head p { margin: 8px 0 0; }
.progress-head .hint { max-width: 60ch; opacity: .9; }
.progress-page .panel { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.progress-page h2 { margin: 0; font-size: 1.6rem; }
.empty-progress { justify-items: start; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.tile { display: grid; gap: 2px; padding: 14px 16px; background: var(--cream); border: 3px solid var(--ink); border-radius: 18px; box-shadow: 0 4px 0 var(--ink); }
.tile strong { font: 600 1.8rem/1.1 var(--display); }
.tile span { font-size: .85rem; font-weight: 700; opacity: .8; }
.needs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.needs li { display: flex; gap: 8px; align-items: baseline; padding: 6px 12px; border-radius: 999px; background: var(--paper); border: 2px solid var(--sand-deep); }
.needs li.stage-missed { border-color: var(--missed); }
.needs li strong { font: 600 1.1rem/1 var(--display); }
.needs li span { font-size: .8rem; opacity: .75; }

/* Fact grids. One green ramp, light to dark, for how well a fact is known (an
   ordinal scale); "just missed" is a status, red with a cross so it never
   rests on colour alone; "not seen" is an empty dashed square. */
:root { --grid-bg: #fdf3da; --learning: #5e8f48; --getting: #2f6b33; --fluent: #143220; --missed: #c2410c; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0; padding: 0; list-style: none; font-size: .85rem; font-weight: 700; }
.legend li { display: flex; align-items: center; gap: 6px; }
.cell { display: inline-block; width: 16px; height: 16px; border-radius: 4px; vertical-align: -3px; position: relative; }
.cell.stage-new { background: transparent; box-shadow: inset 0 0 0 2px #cdb98b; }
.cell.stage-missed { background: var(--missed); }
.cell.stage-missed::before { content: "✕"; position: absolute; inset: 0; display: grid; place-items: center; color: #fff8e7; font: 800 11px/1 var(--sans); }
.cell.stage-learning { background: var(--learning); }
.cell.stage-getting { background: var(--getting); }
.cell.stage-fluent { background: var(--fluent); }
.fact-grid { border-top: 3px dashed var(--sand-deep); padding-top: 12px; }
.fact-grid > header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; }
.fact-grid h3 { margin: 0; font: 600 1.25rem/1.2 var(--display); }
/* Sticks under the top of the screen while the grids scroll past, so the tapped fact stays in view. */
.fact-detail {
  position: sticky; top: 8px; z-index: 2; margin: 0; padding: 8px 14px; border-radius: 14px; min-height: 2.4em;
  font-weight: 800; color: var(--cream); background: var(--ink); box-shadow: 0 6px 16px rgba(0, 0, 0, .25);
}
.fact-grid .counts { font-size: .8rem; font-weight: 700; opacity: .75; }
.grid-scroll { overflow-x: auto; padding: 10px 0 4px; }
table.grid { border-collapse: separate; border-spacing: 2px; background: var(--grid-bg); border-radius: 12px; padding: 6px; margin: 0 auto; }
table.grid th { font-size: .75rem; font-weight: 800; min-width: 22px; height: 22px; text-align: center; opacity: .7; }
table.grid td.cell { display: table-cell; width: 26px; height: 26px; padding: 0; }
table.grid td.cell { cursor: pointer; }   /* iOS only sends a tap's click to an element that looks clickable */
table.grid td.cell.stage-missed::before { font-size: 13px; }
table.grid td.cell:hover, table.grid td.cell.shown, table.grid td.cell:focus { outline: 2px solid var(--ink); outline-offset: 1px; }
table.report { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.report th, table.report td { padding: 8px 10px; text-align: left; border-bottom: 2px solid var(--sand); }
table.report thead th { font-size: .75rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; opacity: .75; }
table.report tbody th { font-weight: 800; }

/* ---------- Leaderboard ---------- */
.board-page { max-width: 760px; margin: 0 auto; padding: 24px 16px 56px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.board-nav { display: flex; justify-content: space-between; gap: 12px; }
.board-head { display: grid; gap: 12px; justify-items: center; text-align: center; }
.board-head h1 { margin: 0; display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: center; }
.board-kicker { margin: 0; font: 700 clamp(2.2rem, 10vw, 3.4rem)/1 var(--display); color: #fff;
  -webkit-text-stroke: .1em var(--ink); paint-order: stroke fill; text-shadow: 0 .08em 0 var(--ink); rotate: -2deg; }
.board-page .panel { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.board-head .world-name { font-size: clamp(1.3rem, 5vw, 1.8rem); }
.empty-board p { margin: 0; font: 600 1.15rem/1.4 var(--display); text-align: center; }
.podium { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.podium-row {
  display: grid; grid-template-columns: 2.2em 14px 1fr auto auto; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--paper); border: 3px solid var(--sand-deep); border-radius: 16px;
}
.podium-row.place-1 { background: #ffe58a; border-color: var(--ink); }
.podium-row.place-2 { background: #e6f1f3; }
.podium-row.place-3 { background: #fbd3ad; }
.podium-row.mine { box-shadow: inset 0 0 0 3px var(--lagoon); border-color: var(--ink); }
.podium-row .place { font: 700 1.4rem/1 var(--display); text-align: center; }
.flag-chip { width: 14px; height: 28px; border-radius: 3px; background: var(--player, var(--lagoon)); border: 2px solid var(--ink); }
.podium-row .who { font: 600 1.2rem/1.1 var(--display); overflow-wrap: anywhere; }
.podium-row .how-far { font: 700 1.25rem/1 var(--display); white-space: nowrap; }
.podium-row .when { font-size: .85rem; opacity: .75; white-space: nowrap; }
.recent-yeets tr.mine th, .recent-yeets tr.mine td { background: #e3f8f4; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--player, var(--lagoon)); border: 2px solid var(--ink); vertical-align: -1px; }

/* ---------- Small screens ---------- */
@media (max-width: 560px) {
  .page .panel { padding: 16px 14px; border-radius: 20px; }
  .palms { opacity: .7; max-width: 52vw; }
  .yeet-arc { width: 108vw; }
  .btn-big { font-size: 1.3rem; padding: 16px 24px; }
  .podium-row { grid-template-columns: 1.8em 12px 1fr auto; }
  .podium-row .when { display: none; }
  table.report th, table.report td { padding: 7px 6px; }
}
@media (max-width: 420px) { .recent-yeets .col-right { display: none; } }
@media (max-width: 380px) {
  .profile { min-width: 92px; padding: 10px 10px 8px; }
  .join input[type=text] { font-size: 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  .sun, .cloud, .yeet-arc .trail, .yeet-arc .gnome, .wm-yeet { animation: none; }
  .btn, .profile, .world-link { transition: none; }
}
