/* Theme: a snowy wooden advent cabin at night. Windows are the doors; opened ones glow warm.
   Day pages sit on cream paper cards; the tokens are re-mapped inside .panel so the apps keep working. */
:root {
  --night: #0e1830; --wall: #22325c; --frame: #3a4d85; --glass: #111b36;
  --lamp: #ffc857; --lamp-hot: #ffe7a8; --lamp-deep: #e3962b;
  --snow: #f4f8fc; --muted: #a9b6d3; --ok: #7fd6a8; --err: #ff9b9b;
  --ink: #2b1d12; --paper: #fbf3e2; --gold: #d9a648; --gold-ink: #8a5a12;
  --wood: #5c3a22; --wood-dark: #3f2615; --wood-frame: #7a4a2a; --holly: #2f6b3a; --berry: #c8262e;
  --display: 'Young Serif', Georgia, serif;
  --body: 'Figtree', system-ui, sans-serif;
  --script: 'Yellowtail', 'Brush Script MT', cursive;
  --holly-img: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 24'%3E%3Cg fill='%232f6b3a'%3E%3Cellipse cx='16' cy='14' rx='14' ry='6' transform='rotate(-14 16 14)'/%3E%3Cellipse cx='44' cy='14' rx='14' ry='6' transform='rotate(14 44 14)'/%3E%3C/g%3E%3Cg fill='%23d0303a'%3E%3Ccircle cx='25' cy='10' r='5'/%3E%3Ccircle cx='35' cy='10' r='5'/%3E%3Ccircle cx='30' cy='16' r='5'/%3E%3C/g%3E%3C/svg%3E");
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; } /* author display rules would otherwise beat [hidden] */

body {
  margin: 0; min-height: 100dvh; font: 16px/1.55 var(--body); color: var(--snow); overflow-x: hidden;
  background:
    radial-gradient(2px 2px at 20px 30px, #fffc, transparent), radial-gradient(1.5px 1.5px at 110px 90px, #fff9, transparent),
    radial-gradient(2.5px 2.5px at 170px 20px, #fffa, transparent), radial-gradient(1.5px 1.5px at 60px 150px, #fff8, transparent),
    radial-gradient(2px 2px at 200px 170px, #fffb, transparent), radial-gradient(1px 1px at 140px 210px, #fff9, transparent),
    linear-gradient(#0a1430, #13234a 45%, #1c2f5c);
  background-size: 230px 230px, 230px 230px, 230px 230px, 230px 230px, 230px 230px, 230px 230px, 100% 100%;
  background-attachment: fixed;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
h1, h2 { font-family: var(--display); font-weight: 400; margin: 0; line-height: 1.15; }
h1 { font-size: 1.45rem; color: var(--lamp); }
h2 { font-size: 1.5rem; }
a { color: var(--lamp); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--lamp-hot); outline-offset: 3px; }

button, input, textarea, select { font: inherit; font-size: 16px; } /* < 16px makes iOS zoom on focus */
button {
  background: linear-gradient(#ffd27a, var(--lamp) 60%, var(--lamp-deep)); color: var(--night); border: 0; border-radius: 999px;
  padding: 12px 22px; min-height: 48px; font-weight: 700; cursor: pointer; box-shadow: 0 2px 0 #0003;
}
button:disabled { opacity: .45; cursor: default; }
button.quiet { background: none; box-shadow: none; color: var(--muted); padding: 6px 4px; min-height: 40px; font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }
input, textarea, select {
  width: 100%; background: var(--glass); color: inherit; border: 2px solid var(--frame);
  border-radius: 10px; padding: 12px;
}
input:focus, textarea:focus, select:focus { border-color: var(--lamp); outline: none; }
.muted { color: var(--muted); }
.err { color: var(--err); min-height: 1.5em; margin: 0; }

/* Header */
header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 6px; max-width: 760px; margin: auto; }
nav { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 6px 12px; min-width: 0; font-size: .9rem; color: var(--snow); }
nav a, nav .quiet { color: var(--snow); }
#who { max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score {
  display: inline-flex; align-items: center; justify-content: center; gap: 3px; min-width: 46px; height: 46px; padding: 0 12px; border-radius: 999px; white-space: nowrap;
  font: 1rem var(--display); color: var(--ink); background: radial-gradient(circle at 40% 35%, #ffe7a8, var(--lamp) 60%, var(--lamp-deep));
  box-shadow: 0 0 16px #ffc85766;
}
.logo { font: 400 2.4rem/.85 var(--script); color: #fff1d0; text-shadow: 0 0 10px #ffcf7a99, 0 0 2px #ffcf7a; position: relative; padding: 4px 0 0 6px; }
.logo span { display: block; }
.logo span + span { padding-left: .7em; }
.logo::before { content: ''; position: absolute; left: -10px; bottom: -6px; width: 34px; height: 14px; background: var(--holly-img) center / contain no-repeat; rotate: -20deg; }

/* The cabin */
.house { position: relative; max-width: 560px; margin: 4px auto 0; padding: 0 22px 40px; }
.status { display: flex; align-items: center; gap: 10px; margin: 0 0 6px; text-align: center; font-family: var(--display); color: #f6ead0; }
.status::before, .status::after { content: '✦'; flex: 1; color: var(--lamp); font-size: .8rem; text-align: right; background: linear-gradient(90deg, transparent, #d9a64899) left center / calc(100% - 1.2em) 1px no-repeat; }
.status::after { text-align: left; background: linear-gradient(90deg, #d9a64899, transparent) right center / calc(100% - 1.2em) 1px no-repeat; }
.status span { max-width: 22em; }
.status b { display: block; font-weight: 400; font-size: 1.2rem; color: #fff6e3; }
.roof { display: block; width: calc(100% + 28px); margin: 0 -14px -3px; position: relative; z-index: 1; }
.facade {
  position: relative; display: grid; grid-template-columns: repeat(4, 1fr); gap: 26px 10px; padding: 16px 12px 30px;
  border-inline: 10px solid var(--wood-dark);
  background: linear-gradient(#0004, transparent 30%), repeating-linear-gradient(90deg, var(--wood) 0 34px, #4e3019 34px 36px);
  box-shadow: 0 6px 18px #0007;
}
.ground { position: relative; z-index: 2; height: 26px; margin: -6px -22px 0; background: linear-gradient(#fff, #dde7f3); border-radius: 50% 50% 0 0 / 100% 100% 0 0; }
.deco { position: absolute; pointer-events: none; z-index: 3; }
.deco.tree-l { left: -30px; bottom: 52px; width: 70px; z-index: 0; }
.deco.tree-r { right: -28px; bottom: 56px; width: 64px; z-index: 0; }
.deco.lantern-l { left: 2px; top: 34%; width: 22px; }
.deco.lantern-r { right: 2px; top: 64%; width: 22px; }
.deco.snowman { left: -10px; bottom: 30px; width: 56px; }
.deco.gifts { right: -8px; bottom: 32px; width: 60px; }

/* Windows */
.win {
  position: relative; aspect-ratio: 3 / 4; display: grid; place-items: center; padding: 0; min-height: 0; cursor: pointer;
  border: 5px solid var(--wood-frame); border-radius: 50% 50% 8px 8px / 30% 30% 8px 8px;
  color: #8fa0c5; text-decoration: none; font: 400 1.7rem var(--display); box-shadow: inset 0 0 0 2px #0003, 0 2px 0 #0005;
  /* dark glass with mullions */
  background: linear-gradient(90deg, transparent calc(50% - 1.5px), var(--wood-frame) 0 calc(50% + 1.5px), transparent 0),
    linear-gradient(transparent calc(52% - 1.5px), var(--wood-frame) 0 calc(52% + 1.5px), transparent 0), linear-gradient(#1d2d52, #0f1a33);
}
.win::after { /* snowy sill */
  content: ''; position: absolute; left: -16%; right: -16%; bottom: -15px; height: 13px; border-radius: 8px;
  background: linear-gradient(#fff, #d9e3ef); box-shadow: 0 2px 2px #0006;
}
.win::before { /* holly on the sill */
  content: ''; position: absolute; z-index: 1; left: 50%; bottom: -19px; width: 52%; aspect-ratio: 60 / 24; translate: -50% 0;
  background: var(--holly-img) center / contain no-repeat;
}
.win .num { position: relative; z-index: 1; font-variant-numeric: lining-nums; line-height: 1; padding: 2px 4px; border-radius: 6px; }
.win:not(.lit) .num { background: #16244a; }
.win.lit {
  color: var(--ink); box-shadow: inset 0 0 0 2px #0002, 0 0 22px #ffc85766;
  background: radial-gradient(circle at 50% 40%, #fffaf0, #ffe6ad 50%, #f2bd5c);
}
.win.done { background: radial-gradient(circle at 50% 40%, #f8ecd2, #e6cc95 75%); box-shadow: inset 0 0 0 2px #0002; }
.win .tag { position: absolute; z-index: 1; bottom: 9%; left: 0; right: 0; text-align: center; font: 700 .68rem var(--body); color: var(--ink); }
.win:not(.lit) .tag { color: var(--muted); }
.win.today { animation: glow 2.4s ease-in-out infinite alternate; }
@keyframes glow { to { box-shadow: inset 0 0 0 2px #0002, 0 0 34px 8px #ffc857bb; } }
.win:active { scale: .96; }
.shake { animation: shake .35s; }
@keyframes shake { 25% { translate: -5px; } 75% { translate: 5px; } }

@media (min-width: 600px) {
  .logo { font-size: 3rem; }
  .facade { grid-template-columns: repeat(6, 1fr); gap: 30px 16px; padding: 24px 22px 34px; }
  .house { max-width: 760px; padding-inline: 60px; }
  .deco.tree-l { left: -10px; width: 110px; } .deco.tree-r { right: -6px; width: 100px; }
  .deco.lantern-l, .deco.lantern-r { width: 30px; } .deco.lantern-l { left: 34px; } .deco.lantern-r { right: 34px; }
  .deco.snowman { left: 10px; width: 90px; } .deco.gifts { right: 14px; width: 100px; }
}
@media (prefers-reduced-motion: reduce) { .win.today, .shake { animation: none; } }

/* Panels (login, day apps, admin): cream paper with a gold edge. */
.panel {
  --snow: #fffdf8; --muted: #6e5a44; --glass: #fffaf0; --frame: #dccaa4; --wall: var(--paper);
  --lamp: #eab04a; --lamp-hot: #b8731a; --err: #b3261e; --ok: #2f7d4f;
  color: var(--ink); background: var(--paper) var(--holly-img) right 14px bottom 10px / 54px auto no-repeat;
  max-width: 560px; margin: 12px; padding: 20px 20px 34px; border: 3px solid var(--gold); border-radius: 26px;
  box-shadow: 0 0 0 4px #fbf3e233, 0 10px 30px #0008; overflow-x: auto;
}
@media (min-width: 600px) { .panel { margin: 24px auto; padding: 28px 28px 40px; } }
.panel.wide { max-width: 960px; }
.panel a { color: var(--gold-ink); }
.panel > a:first-child {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 16px 6px 12px; border-radius: 999px;
  font-family: var(--display); color: var(--ink); text-decoration: none;
  background: linear-gradient(#ffeec2, #f2c063); border: 2px solid #c9952f; box-shadow: 0 2px 4px #0002;
}
.panel > a:first-child::before { content: '★'; color: #a8650f; }
.panel > a:first-child:active { scale: .97; }
.panel h2 { color: var(--ink); }
#login { display: grid; gap: 12px; }
#login h2 { margin-bottom: 4px; }

/* Day app pieces */
.day-head { display: flex; align-items: center; gap: 14px; margin: 14px 0 10px; }
.day-head .win {
  width: 58px; aspect-ratio: 1; flex: none; cursor: default; font-size: 1.6rem; color: var(--ink);
  border: 2px solid #c9952f; border-radius: 14px; background: linear-gradient(#ffeec2, #f2c063); box-shadow: 0 2px 6px #0002;
}
.day-head .win::before, .day-head .win::after { display: none; }
.choices { display: grid; gap: 10px; margin: 16px 0; border: 0; padding: 0; }
.choice {
  display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 10px 14px;
  border: 2px solid var(--frame); border-radius: 12px; cursor: pointer; background: var(--glass);
}
.choice:has(input:checked) { border-color: var(--lamp); background: #ffc85733; }
.choice input { width: 20px; height: 20px; accent-color: var(--lamp-deep); margin: 0; }
textarea { margin: 16px 0; resize: vertical; }

/* Admin tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid #0000001a; vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .9rem; }
pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; min-width: 160px; max-width: 420px; font: inherit; }
td input { width: 5.5em; }
td button { min-height: 44px; padding: 8px 16px; }
/* Phones: answer rows become stacked blocks instead of a wide table. */
@media (max-width: 599px) {
  table.stack thead { display: none; }
  table.stack tr { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 14px 0; border-bottom: 1px solid #0000001a; }
  table.stack td { border: 0; padding: 0; }
  table.stack td:has(pre) { flex-basis: 100%; }
  table.stack pre { max-width: none; background: var(--glass); padding: 10px; border-radius: 10px; }
}
