/* Santa's Notebook — midnight, spruce, brass. No frameworks, no webfonts required. */

:root {
  --midnight: #0B1220;
  --spruce: #0F3D2E;
  --brass: #D8A94B;
  --gold: #F2C14E;
  --snow: #F6F7F2;
  --berry: #B5322F;
  --pine: #2E9E5B;
  --muted: #9BA8B4;
  --card: rgba(15, 61, 46, 0.42);
  --edge: rgba(216, 169, 75, 0.28);
  --display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--midnight);
  color: var(--snow);
  font-family: var(--body);
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--midnight);
}

/* Ambient light lives on its own fixed viewport layer. background-attachment:fixed
   is unreliable on iOS and pixel-sized gradients don't follow a resize/fullscreen. */
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(85% 55% at 50% 0%, rgba(22, 35, 58, 0.95) 0%, rgba(22, 35, 58, 0) 70%),
    radial-gradient(75% 55% at 50% 100%, rgba(15, 61, 46, 0.55) 0%, rgba(15, 61, 46, 0) 70%);
}

h1, h2, h3 { font-family: var(--display); font-weight: 600; margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
input, textarea { font: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
[hidden] { display: none !important; }

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

/* ------------------------------------------------------------------ dial */

#snow {
  position: fixed; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 0; opacity: 0.75;
}

.stage {
  position: relative; z-index: 1;
  max-width: 720px; margin: 0 auto;
  padding: clamp(12px, 3vw, 28px) clamp(12px, 4vw, 24px) 40px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  transition: transform 2.4s ease, opacity 0.4s ease;
}

.masthead { display: flex; align-items: center; gap: 10px; opacity: 0.92; }
.masthead h1 {
  font-size: clamp(17px, 2.4vw, 22px); letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--gold);
}
.seal { color: var(--gold); font-size: 20px; }

.instrument { position: relative; width: min(94vw, 560px, 62vh); margin-top: 0; }
#gauge { width: 100%; height: auto; display: block; overflow: visible; }

.readout { text-align: center; margin-top: 6px; }
.child {
  margin: 0; font-family: var(--display); letter-spacing: 0.34em;
  text-transform: uppercase; color: var(--brass); font-size: clamp(13px, 2vw, 16px);
}
.score {
  margin: 2px 0 0; display: flex; flex-direction: column; align-items: center;
  font-variant-numeric: tabular-nums;
}
#score {
  font-family: var(--display); font-size: clamp(52px, 11vw, 84px); line-height: 1.02;
  color: var(--snow); text-shadow: 0 0 26px rgba(242, 193, 78, 0.18);
}
.score-label { color: var(--muted); font-size: 13px; letter-spacing: 0.08em; margin-top: 2px; }
.verdict {
  display: inline-block; margin: 12px 0 0; padding: 7px 18px; border-radius: 999px;
  border: 1px solid var(--edge); background: var(--card);
  font-family: var(--display); font-size: clamp(17px, 2.6vw, 22px); color: var(--gold);
}
.meta { color: var(--muted); font-size: 14px; margin: 12px 0 0; }
.meta .dot { margin: 0 8px; opacity: 0.6; }

.chips {
  list-style: none; margin: 18px 0 0; padding: 0; display: flex; flex-wrap: wrap;
  gap: 8px; justify-content: center; max-width: 560px;
}
.chips li {
  border: 1px solid rgba(255, 255, 255, 0.09); background: rgba(255, 255, 255, 0.045);
  border-radius: 999px; padding: 6px 13px; font-size: 13px; color: #D7DEE5;
  animation: chip-in 0.25s ease both;
}
.chips li b { font-variant-numeric: tabular-nums; margin-right: 6px; }
.chips li.pos b { color: #7BD89F; }
.chips li.neg b { color: #EE8A84; }
@keyframes chip-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

.live-plate {
  position: absolute; left: 50%; bottom: 6%;
  transform: translate(-50%, 16px); opacity: 0;
  min-width: 240px; max-width: 90%; text-align: center;
  padding: 12px 20px; border-radius: 12px;
  background: linear-gradient(180deg, #F6D98A, #C9993C);
  color: #241A05; box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45);
  transition: transform 0.5s cubic-bezier(0.2, 1.3, 0.4, 1), opacity 0.3s ease;
  pointer-events: none;
}
.live-plate.show { transform: translate(-50%, 0); opacity: 1; }
.plate-points { font-family: var(--display); font-size: 26px; font-weight: 700; margin-right: 8px; }
.plate-label { font-size: 15px; font-weight: 600; }
#thoughts { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.thought {
  position: absolute; left: 0; top: 0; max-width: min(420px, 62vw);
  will-change: transform;
  font-family: var(--display); font-style: italic;
  font-size: clamp(15px, 2.1vw, 23px); line-height: 1.55; text-align: center;
  white-space: pre-line; color: var(--snow); opacity: 0;
  text-shadow: 0 0 24px rgba(246, 247, 242, 0.28);
  display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden;
  transition: opacity 2.6s ease;
}
.thought::before {
  content: ""; position: absolute; inset: -26px -32px; z-index: -1;
  background: radial-gradient(60% 60% at 50% 50%, rgba(246, 247, 242, 0.07), transparent 70%);
}
.thought.visible { opacity: 0.3; }
.thought.leaving { opacity: 0; }

.ghost.danger { color: #EE8A84; border-color: rgba(238, 138, 132, 0.35); }

.grownups {
  margin-top: 26px; font-size: 13px; color: var(--muted); text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.12); padding: 8px 16px; border-radius: 999px;
}
.grownups:hover { color: var(--gold); border-color: var(--edge); }

.offline {
  position: fixed; inset: auto 0 0 0; padding: 12px; text-align: center;
  background: rgba(11, 18, 32, 0.92); color: var(--gold); backdrop-filter: blur(6px);
}

.stage.dim .masthead, .stage.dim .chips, .stage.dim .grownups, .stage.dim .meta {
  opacity: 0.25; transition: opacity 0.4s ease;
}

/* ---------------------------------------------------------------- picker */

.picker-page { padding-bottom: 92px; }

.bar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px clamp(14px, 4vw, 28px); border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.brand { color: var(--gold); text-decoration: none; font-family: var(--display); letter-spacing: 0.06em; }
.who { margin-left: auto; color: var(--muted); font-size: 14px; }

.picker-main { max-width: 720px; margin: 0 auto; padding: clamp(16px, 4vw, 28px); }

.card {
  background: var(--card); border: 1px solid var(--edge); border-radius: 18px;
  padding: clamp(16px, 4vw, 26px); backdrop-filter: blur(4px);
}

.adults { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.adults button {
  min-height: 52px; padding: 12px 22px; border-radius: 14px; font-size: 17px;
  background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.14);
}

#pinform { margin-top: 18px; display: flex; flex-direction: column; gap: 12px; }
#pin {
  font-size: 30px; text-align: center; letter-spacing: 0.4em; padding: 12px;
  border-radius: 12px; border: 1px solid var(--edge); background: rgba(0, 0, 0, 0.28);
  color: var(--snow); width: 100%;
}
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.keypad button {
  min-height: 54px; font-size: 22px; border-radius: 12px;
  background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.1);
}
.keypad button:active { background: rgba(216, 169, 75, 0.25); }

.primary {
  min-height: 54px; border-radius: 14px; border: none; font-size: 18px; font-weight: 650;
  background: linear-gradient(180deg, #F6D98A, #C9993C); color: #241A05;
}
.primary:disabled { opacity: 0.5; }
.ghost {
  min-height: 44px; padding: 8px 14px; border-radius: 12px; font-size: 15px;
  background: transparent; border: 1px solid rgba(255, 255, 255, 0.16); color: var(--snow);
}
.error { color: #EE8A84; margin: 0; min-height: 18px; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.hint.warn { color: var(--gold); }

.prompt { text-align: center; font-size: clamp(20px, 3vw, 26px); margin-bottom: 18px; }
.doors { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.door {
  min-height: clamp(150px, 26vh, 220px); border-radius: 20px; padding: 18px;
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 8px;
  border: 1px solid transparent; transition: transform 0.16s ease, box-shadow 0.26s ease;
  animation: door-in 0.26s ease both;
}
.door:active { transform: translateY(2px) scale(0.99); }
.door-word { font-family: var(--display); font-size: clamp(30px, 6vw, 44px); }
.door-sub { font-size: 14px; opacity: 0.85; }
.door.nice {
  background: linear-gradient(160deg, #1C6B47, #0F3D2E);
  border-color: rgba(123, 216, 159, 0.4); box-shadow: 0 0 0 rgba(46, 158, 91, 0);
}
.door.nice:hover { box-shadow: 0 10px 44px rgba(46, 158, 91, 0.3); }
.door.naughty {
  background: linear-gradient(160deg, #8E2A28, #4A1512);
  border-color: rgba(238, 138, 132, 0.4);
}
.door.naughty:hover { box-shadow: 0 10px 44px rgba(181, 50, 47, 0.3); }
@keyframes door-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; } }

.row { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tile {
  min-height: 76px; padding: 12px 14px; border-radius: 14px; text-align: left;
  display: flex; align-items: center; gap: 12px;
  background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.11);
  animation: tile-in 0.2s ease both;
}
.tile:active { transform: scale(0.985); }
.tile .glyph { font-size: 24px; }
.tile .t-label { font-size: 15px; line-height: 1.25; }
.tile .t-sugg { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }
.tile.else { border-style: dashed; border-color: var(--edge); justify-content: center; }
.tile.group {
  grid-column: 1 / -1; background: none; border: none; min-height: 0; padding: 12px 2px 0;
  color: var(--brass); font-family: var(--display); letter-spacing: 0.14em;
  text-transform: uppercase; font-size: 12px; cursor: default; animation: none;
}
@keyframes tile-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }

body.pol-nice .picker-main { box-shadow: inset 0 0 120px rgba(46, 158, 91, 0.12); }
body.pol-naughty .picker-main { box-shadow: inset 0 0 120px rgba(181, 50, 47, 0.12); }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(9, 15, 26, 0.94); border-top: 1px solid rgba(255, 255, 255, 0.09);
  backdrop-filter: blur(10px); padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  min-height: 58px; background: none; border: none; color: var(--muted); font-size: 14px;
}
.tabs button.active { color: var(--gold); }

.drawer {
  position: fixed; inset: auto 0 58px 0; max-height: 74vh; overflow-y: auto; z-index: 19;
  background: #0E1626; border-top: 1px solid var(--edge); padding: 18px;
  border-radius: 18px 18px 0 0;
}
.drawer h3 { margin-bottom: 12px; }
.ledger-row, .today-row {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07); font-size: 14px;
}
.ledger-row .pts, .today-row .pts {
  font-variant-numeric: tabular-nums; font-weight: 700; min-width: 46px;
}
.pts.pos { color: #7BD89F; } .pts.neg { color: #EE8A84; }
.ledger-row .note, .today-row .note { color: var(--muted); font-size: 13px; margin-top: 3px; }
.ledger-row .by, .today-row .by { color: var(--muted); font-size: 12px; margin-left: auto; white-space: nowrap; }
.voided { opacity: 0.45; text-decoration: line-through; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 90px; margin: 10px 0 18px; }
.bars .bar-wrap { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; }
.bars .bar-i { width: 100%; border-radius: 3px; min-height: 3px; }
.bars .bar-d { font-size: 9px; color: var(--muted); margin-top: 4px; }

.settings-grid { display: grid; gap: 8px; }
.settings-grid .s-row {
  display: grid; grid-template-columns: 1fr 74px; gap: 10px; align-items: center;
  font-size: 14px; padding: 6px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.settings-grid input {
  width: 100%; padding: 8px; border-radius: 8px; border: 1px solid var(--edge);
  background: rgba(0, 0, 0, 0.3); color: var(--snow); text-align: center;
}
.settings-add { display: grid; gap: 8px; margin-top: 14px; }
.settings-add input, .settings-add select, .settings-add textarea {
  padding: 11px; border-radius: 10px; border: 1px solid var(--edge);
  background: rgba(0, 0, 0, 0.3); color: var(--snow); width: 100%;
}

/* ----------------------------------------------------------------- sheet */

.backdrop {
  position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end;
  justify-content: center; background: rgba(4, 8, 14, 0.6); backdrop-filter: blur(5px);
  animation: fade-in 0.18s ease both;
}
.sheet {
  width: min(560px, 100%); background: #122032; border: 1px solid var(--edge);
  border-radius: 20px 20px 0 0; padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 12px;
  animation: sheet-up 0.28s cubic-bezier(0.2, 1.1, 0.35, 1) both;
  max-height: 92vh; overflow-y: auto;
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.sheet h3 { font-size: 22px; }
.sheet-pol { margin: 0; font-size: 12px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--brass); }
.points-row { display: grid; grid-template-columns: 56px 1fr 56px; gap: 10px; align-items: center; }
.stepper {
  min-height: 56px; font-size: 30px; border-radius: 12px;
  background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.14);
}
#magnitude {
  font-size: 40px; text-align: center; padding: 8px; border-radius: 12px;
  border: 1px solid var(--edge); background: rgba(0, 0, 0, 0.3); color: var(--snow);
  font-variant-numeric: tabular-nums; width: 100%;
}
.quick { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.quick button {
  min-height: 44px; border-radius: 10px; background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.quick button.on { border-color: var(--gold); color: var(--gold); }
.field { font-size: 13px; color: var(--muted); }
#note {
  resize: vertical; padding: 12px; border-radius: 12px; border: 1px solid var(--edge);
  background: rgba(0, 0, 0, 0.3); color: var(--snow);
}
.share { display: flex; gap: 10px; align-items: center; font-size: 14px; color: var(--muted); }
.share input { width: 20px; height: 20px; }

.toast {
  position: fixed; left: 50%; top: 16px; transform: translateX(-50%); z-index: 60;
  background: linear-gradient(180deg, #F6D98A, #C9993C); color: #241A05;
  padding: 12px 20px; border-radius: 12px; font-weight: 600; font-size: 15px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4); animation: sheet-up 0.24s ease both;
  max-width: 92vw; text-align: center;
}
.toast.bad { background: linear-gradient(180deg, #F3A29C, #C0554F); color: #2B0B09; }

/* ------------------------------------------------------------- responsive */

@media (min-width: 700px) {
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .doors { gap: 20px; }
}
@media (min-width: 1100px) {
  .picker-main { max-width: 900px; }
  .tiles { grid-template-columns: repeat(4, 1fr); }
}
@media (max-height: 700px) and (orientation: landscape) {
  .instrument { width: min(52vh, 420px); }
  #score { font-size: 46px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.12s !important; transition-duration: 0.12s !important;
  }
  #snow { display: none; }
}
