/* Shared look for the homepage and every game: sky, glass panels, HUD, overlays, effects. */

:root {
  --sky-top: #a9d4ee;
  --sky-mid: #d7ecf6;
  --sky-bottom: #f6efe4;
  --ink: #22314d;
  --ink-soft: #5b6b85;
  --accent: #4b4fb8;
  --accent-dark: #34378a;
  --glass: rgba(255, 255, 255, 0.58);
  --glass-edge: rgba(255, 255, 255, 0.85);
  --shadow: 0 10px 30px rgba(34, 49, 77, 0.12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 55%, var(--sky-bottom) 100%);
  color: var(--ink);
  font-family: 'Outfit', system-ui, sans-serif;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button { font-family: inherit; color: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
svg { display: block; width: 100%; height: 100%; }

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  backdrop-filter: blur(14px) saturate(1.2);
}

/* ---------- scenery (added by scene.js) ---------- */

#scenery {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.sun-glow {
  position: absolute;
  top: -18vh;
  right: -12vw;
  width: 60vh;
  height: 60vh;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 236, 190, 0.9) 0%, rgba(255, 236, 190, 0) 65%);
}
.cloud { position: absolute; left: 0; height: auto; fill: #fff; opacity: 0.85; }
.hills { position: absolute; left: 0; bottom: 0; height: 18vh; }

/* ---------- top bar ---------- */

.hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 22vh;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2vh 16px 0 calc(16px + clamp(48px, 8vh, 64px) + 12px);
  z-index: 2;
}

.round-button {
  flex: none;
  width: clamp(64px, 13vh, 104px);
  height: clamp(64px, 13vh, 104px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 50%;
  color: var(--accent);
}
.round-button svg { width: 52%; height: 52%; }
.round-button:active { transform: scale(0.94); }

.home-button {
  position: fixed;
  top: calc(2vh + 12px);
  left: 16px;
  z-index: 6; /* above the start screen and star overlays (5), so it always works */
  width: clamp(48px, 8vh, 64px);
  height: clamp(48px, 8vh, 64px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 18px;
  color: var(--ink-soft);
}
.home-button svg { width: 56%; height: 56%; }

.progress {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1vh;
  padding: 1.4vh 14px;
  border-radius: 20px;
}
.dots { display: flex; gap: 6px; }
.dot {
  width: clamp(10px, 1.8vh, 16px);
  height: clamp(10px, 1.8vh, 16px);
  border-radius: 50%;
  background: rgba(34, 49, 77, 0.14);
}
.dot.filled { background: linear-gradient(180deg, #ffd66e, #f2a93b); box-shadow: 0 0 10px rgba(242, 169, 59, 0.6); }
.star-count {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: clamp(18px, 3.2vh, 28px);
  font-weight: 700;
}
.star-icon { width: clamp(22px, 3.6vh, 32px); height: clamp(22px, 3.6vh, 32px); }

/* ---------- letter tiles (Build-a-Word, Word Slots) ---------- */

:root { --tile: clamp(56px, min(15vw, 11vh), 108px); }

.tile {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--tile);
  height: calc(var(--tile) * 1.1);
  padding: 0 0 6%;
  border: none;
  border-radius: 18px;
  background:
    radial-gradient(circle at 30% 22%, rgba(255, 255, 255, 0.45), transparent 40%),
    var(--color);
  box-shadow: 0 6px 0 var(--shade), 0 12px 20px rgba(34, 49, 77, 0.18);
  color: #fff;
  font-family: 'Andika', sans-serif;
  font-size: calc(var(--tile) * 0.62);
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.15);
}
.tile.hint { box-shadow: 0 6px 0 var(--shade), 0 0 0 5px #fff, 0 0 32px 12px #fff59d; }

.start-tiles {
  --tile: clamp(56px, 10vh, 84px);
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 3vh;
}

/* ---------- effect pieces (positioned and animated by effects.js) ---------- */

.shard, .confetti, .spark, .ring {
  position: fixed;
  pointer-events: none;
  z-index: 3;
}
.shard { width: 22px; height: 12px; margin: -6px 0 0 -11px; border-radius: 60% 60% 30% 30%; }
.confetti { width: 9px; height: 14px; margin: -7px 0 0 -4px; border-radius: 2px; }
.ring { width: 40px; height: 40px; margin: -20px 0 0 -20px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, 0.9); }
.spark {
  width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, #ffd66e 45%, rgba(242, 169, 59, 0) 72%);
}

/* ---------- overlays ---------- */

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  text-align: center;
  z-index: 5;
  overflow-y: auto;
}
.hidden { display: none; }

.start { background: rgba(169, 212, 238, 0.35); }

.card {
  width: 100%;
  max-width: 460px;
  padding: 28px 24px 22px;
  border-radius: 32px;
}
.card h1 {
  margin: 0;
  font-size: clamp(36px, 7vh, 60px);
  font-weight: 700;
  letter-spacing: -0.02em;
}
.card h2 { margin: 0 0 3vh; font-size: clamp(30px, 5.5vh, 48px); }
.tagline {
  margin: 0.6vh 0 3vh;
  font-size: clamp(16px, 2.4vh, 20px);
  color: var(--ink-soft);
}

.big-button {
  border: none;
  border-radius: 999px;
  padding: 2vh 9vh;
  background: linear-gradient(180deg, #5f63d0, var(--accent));
  color: #fff;
  font-size: clamp(26px, 5vh, 40px);
  font-weight: 600;
  letter-spacing: 0.02em;
  box-shadow: 0 6px 0 var(--accent-dark), 0 14px 28px rgba(75, 79, 184, 0.35);
}
.big-button:active { transform: translateY(3px); box-shadow: 0 3px 0 var(--accent-dark), 0 8px 18px rgba(75, 79, 184, 0.3); }

/* Settings for grown-ups: a pill that opens into groups of option tiles and switches.
   Markup stays plain (fieldset > legend + label > input); a label may hold
   <strong>title</strong><small>detail</small>. */
.settings {
  margin-top: 3vh;
  font-size: 15px;
  text-align: left;
  color: var(--ink-soft);
}
.settings summary {
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  margin: 0 auto;
  padding: 9px 14px 9px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--glass-edge);
  font-weight: 600;
  list-style: none;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.settings summary::-webkit-details-marker { display: none; }
/* gear icon and chevron, drawn with masks so they follow the text colour */
.settings summary::before, .settings summary::after {
  content: '';
  flex: none;
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}
.settings summary::before {
  width: 18px;
  height: 18px;
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 6h18M3 12h18M3 18h18' stroke='black' stroke-width='2' stroke-linecap='round'/%3E%3Ccircle cx='9' cy='6' r='3'/%3E%3Ccircle cx='16' cy='12' r='3'/%3E%3Ccircle cx='7' cy='18' r='3'/%3E%3C/svg%3E");
}
.settings summary::after {
  width: 12px;
  height: 12px;
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  transition: transform 0.25s;
}
.settings summary:hover { background: rgba(255, 255, 255, 0.85); color: var(--ink); }
.settings[open] summary { background: var(--accent); border-color: var(--accent); color: #fff; }
.settings[open] summary::after { transform: rotate(180deg); }

.settings fieldset {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 0;
  padding: 12px;
  border: none;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.45);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.8);
  color: var(--ink);
}
/* floated, the legend becomes an ordinary flex item that can span the row */
.settings legend {
  float: left;
  flex: 1 1 100%;
  padding: 0 4px 2px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.settings label {
  position: relative;
  flex: 1 1 140px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 2px;
  min-height: 52px;
  padding: 10px 12px;
  border: 2px solid transparent;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.75);
  font-weight: 600;
  line-height: 1.25;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s, transform 0.15s;
}
/* exactly three options: one row of three instead of two plus one */
.settings fieldset:has(> label:nth-of-type(3):last-of-type) label { flex-basis: 96px; }
.settings label:hover { background: #fff; }
.settings label:active { transform: scale(0.98); }
.settings label strong { font-weight: 700; padding-right: 24px; } /* room for the radio dot */
.settings label > span { display: flex; flex-direction: column; gap: 2px; }
.settings label small { font-size: 13px; font-weight: 400; color: var(--ink-soft); }
.settings label:has(input:focus-visible) { outline: 3px solid rgba(75, 79, 184, 0.45); outline-offset: 2px; }

/* radio: a tile that lights up, with a dot in the corner */
.settings input[type="radio"] {
  -webkit-appearance: none;
  appearance: none;
  position: absolute;
  top: 10px;
  right: 10px;
  width: 20px;
  height: 20px;
  margin: 0;
  border: 2px solid rgba(34, 49, 77, 0.22);
  border-radius: 50%;
  background: #fff;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.settings input[type="radio"]:checked { border-color: var(--accent); background: var(--accent); box-shadow: inset 0 0 0 4px #fff; }
.settings label:has(input[type="radio"]:checked) {
  border-color: var(--accent);
  background: rgba(240, 241, 255, 0.95);
  box-shadow: 0 6px 16px rgba(75, 79, 184, 0.18);
  color: var(--accent-dark);
}

/* checkbox: a full-width row with a switch on the right */
.settings label:has(input[type="checkbox"]) {
  flex-basis: 100%;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-right: 14px;
}
.settings input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  order: 2;
  position: relative;
  flex: none;
  width: 48px;
  height: 28px;
  margin: 0;
  border-radius: 999px;
  background: rgba(34, 49, 77, 0.2);
  transition: background 0.25s;
}
.settings input[type="checkbox"]::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(34, 49, 77, 0.25);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.settings input[type="checkbox"]:checked { background: #2a9d8f; }
.settings input[type="checkbox"]:checked::before { transform: translateX(20px); }

/* the explanation at the bottom, as a tip card */
.settings .note {
  position: relative;
  margin: 12px 0 0;
  padding: 12px 14px 12px 44px;
  border-radius: 16px;
  background: rgba(255, 214, 110, 0.22);
  box-shadow: inset 0 0 0 1px rgba(242, 177, 52, 0.3);
  font-size: 13.5px;
  line-height: 1.5;
  color: #5c4a1e;
}
.settings .note:empty { display: none; }
.settings .note::before {
  content: 'i';
  position: absolute;
  top: 12px;
  left: 14px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #f2b134;
  color: #fff;
  font: 700 13px/20px Georgia, serif;
  text-align: center;
}

/* "Go home?" check */
.confirm { z-index: 7; background: rgba(34, 49, 77, 0.35); }
.confirm .card { max-width: 380px; }
.confirm-buttons { display: flex; justify-content: center; gap: 24px; }
.confirm-buttons button {
  width: clamp(80px, 14vh, 110px);
  height: clamp(80px, 14vh, 110px);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: clamp(36px, 7vh, 56px);
  font-weight: 700;
}
.confirm-yes { background: #2a9d8f; box-shadow: 0 6px 0 #1a6a60; }
.confirm-no { background: #ef6f6c; box-shadow: 0 6px 0 #b03f45; }

/* star celebration */
.cheer {
  gap: 2vh;
  background: rgba(34, 49, 77, 0.35);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  cursor: pointer;
}
.cheer-star { position: relative; width: 34vh; height: 34vh; }
.cheer-star .big-star { position: absolute; inset: 14%; filter: drop-shadow(0 12px 24px rgba(242, 169, 59, 0.5)); }
.cheer-star .rays {
  position: absolute;
  inset: -30%;
  border-radius: 50%;
  background: repeating-conic-gradient(rgba(255, 236, 190, 0.5) 0deg 10deg, rgba(255, 236, 190, 0) 10deg 30deg);
  -webkit-mask: radial-gradient(circle, #000 30%, transparent 70%);
  mask: radial-gradient(circle, #000 30%, transparent 70%);
}
.cheer p {
  margin: 0;
  font-size: clamp(32px, 6.5vh, 60px);
  font-weight: 700;
  color: #fff;
  text-shadow: 0 4px 18px rgba(34, 49, 77, 0.4);
}
