@font-face {
  font-family: "Upheaval";
  src: url("../fonts/upheaval.woff2?v=74def210") format("woff2"), url("../fonts/upheaval.ttf?v=2d6cbf09") format("truetype");
  font-display: swap;
}

/* ============ Theme: Sky Glass ============ */
:root {
  --navy: #1e2a6e;
  --navy-2: #2a3a8f;
  --text: #ffffff;
  --muted: #e8efff;
  --glass: rgba(255, 255, 255, 0.22);
  --glass-edge: rgba(255, 255, 255, 0.65);
  --pink: #ff8fb8;
  --pink-dark: #c45e88;
  --pink-text: #3a1d4a;
  --green: #2fbf71;
  --orange: #f5a623;
  --red: #e5486a;
  --cell: 72px;
  --radius: 12px;
  --pixel: "Upheaval", "Inter", system-ui, sans-serif;
  --outline: 2px 0 0 var(--navy), -2px 0 0 var(--navy), 0 2px 0 var(--navy), 0 -2px 0 var(--navy);
  --outline-lg: 3px 0 0 var(--navy), -3px 0 0 var(--navy), 0 3px 0 var(--navy), 0 -3px 0 var(--navy),
                3px 3px 0 var(--navy), -3px 3px 0 var(--navy), 3px -3px 0 var(--navy), -3px -3px 0 var(--navy),
                0 7px 0 rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  position: relative;
}

/* Background layers (back to front):
   1. html::before  still image = first frame of the video, so nothing jumps when the video starts
   2. .bg-video     looping video (game page only)
   3. body::before  soft dark gradient for readability
   The still and the video use the SAME size/position rules so they line up exactly. */
html { background: #4a63c9; }
html::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -3;
  pointer-events: none;
  background: url("../images/bg.jpg?v=78205216") center center / cover no-repeat;
  background: image-set(url("../images/bg.webp?v=9f94f7d2") type("image/webp"), url("../images/bg.jpg?v=78205216") type("image/jpeg")) center center / cover no-repeat;
  image-rendering: pixelated;
}
.bg-video {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  z-index: -2;
  pointer-events: none;
  image-rendering: pixelated;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.bg-video.ready { opacity: 1; }
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(10, 16, 48, 0) 0%, rgba(10, 16, 48, 0) 45%, rgba(10, 16, 48, 0.35) 100%);
}

a { color: #fff; }

/* ---------- Header ---------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 760px;
  margin: 0 auto;
  padding: 14px 16px 0;
}
.brand {
  color: #fff;
  text-decoration: none;
  font-family: var(--pixel);
  font-size: 20px;
  letter-spacing: 0.06em;
  text-shadow: var(--outline);
}
.brand b { color: var(--pink); font-weight: normal; }
.header-btns { display: flex; gap: 8px; }
.icon-btn {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 1px solid var(--glass-edge);
  background: var(--glass);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #fff;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--pixel);
  font-size: 20px;
  text-decoration: none;
  text-shadow: var(--outline);
}
.icon-btn svg { filter: drop-shadow(1px 0 0 var(--navy)) drop-shadow(-1px 0 0 var(--navy)) drop-shadow(0 1px 0 var(--navy)) drop-shadow(0 -1px 0 var(--navy)); }
#sound-btn .snd-off { display: none; }
#sound-btn.muted .snd-on { display: none; }
#sound-btn.muted .snd-off { display: block; }
.icon-btn:hover { background: rgba(255, 255, 255, 0.35); }

.title-wrap { text-align: center; padding: 18px 16px 6px; }
.title {
  margin: 0;
  font-family: var(--pixel);
  font-weight: normal;
  font-size: clamp(48px, 14vw, 88px);
  line-height: 1;
  letter-spacing: 0.04em;
  color: #fff;
  text-shadow: var(--outline-lg);
}
.subtitle {
  margin: 10px 0 0;
  font-family: var(--pixel);
  font-size: 20px;
  letter-spacing: 0.08em;
  color: #fff;
  text-shadow: var(--outline);
}
.day-tag {
  margin-top: 6px;
  font-family: var(--pixel);
  font-size: 18px;
  color: #fff;
  text-shadow: var(--outline);
}

/* ---------- Streak badge ---------- */
.streak-badge {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 12px; padding: 7px 16px 7px 12px;
  background: var(--navy); border: 2px solid #fff; border-radius: 999px;
  box-shadow: 0 4px 0 rgba(30, 42, 110, 0.35);
  font-family: var(--pixel); color: #fff;
}
.streak-badge[hidden] { display: none; }
.streak-badge .flame { width: 20px; height: 24px; shape-rendering: crispEdges; transform-origin: 50% 50%; flex: none; }
.streak-badge .fo { fill: #ff7a3d; }
.streak-badge .fi { fill: #ffd45c; }
.streak-badge .streak-num { font-size: 22px; line-height: 1; color: #ffd45c; }
.streak-badge .streak-txt { font-size: 13px; letter-spacing: 0.05em; line-height: 1.2; text-align: left; }
.streak-badge.cold { background: rgba(30, 42, 110, 0.7); }
.streak-badge.cold .fo { fill: #8a93c4; }
.streak-badge.cold .fi { fill: #c9cff0; }
.streak-badge.pop { animation: streakpop 0.7s ease; }
@keyframes streakpop { 0% { transform: scale(1); } 35% { transform: scale(1.18); } 100% { transform: scale(1); } }
.streak-badge .flame { animation: flicker 0.9s infinite; }
.streak-badge.cold .flame { animation: none; }
@keyframes flicker { 0%, 49.9% { transform: scaleX(1); } 50%, 100% { transform: scaleX(-1); } }
@media (prefers-reduced-motion: reduce) { .streak-badge .flame, .streak-badge.pop { animation: none; } }

/* Staging banner (added by js/analytics.js on non-production hosts) */
.env-banner { position: sticky; top: 0; z-index: 100; background: repeating-linear-gradient(45deg, #ffd45c, #ffd45c 14px, #ffc021 14px, #ffc021 28px); color: #1e2a6e; font: 800 13px/1 Inter, Arial, sans-serif; letter-spacing: 0.08em; text-align: center; padding: 8px 10px; border-bottom: 2px solid #1e2a6e; }

/* Anything marked hidden stays hidden, whatever its display style */
[hidden] { display: none !important; }

/* ---------- Archive ---------- */
a.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; text-decoration: none; }
a.btn[hidden] { display: none; }
.btn.btn-navy { color: #fff; background: var(--navy); border: 2px solid #fff; box-shadow: 0 4px 0 rgba(30, 42, 110, 0.45); font-size: 17px; }
.btn.btn-navy:active { box-shadow: 0 1px 0 rgba(30, 42, 110, 0.45); }
.btn-navy svg { flex: none; }
.arch-links { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 18px; }
.arch-links:not(:has(a:not([hidden]))) { display: none; }
.arch-title { font-family: var(--pixel); font-weight: normal; font-size: 40px; color: #fff; margin: 0; text-shadow: var(--outline); }
.arch-sub { color: #fff; font-weight: 600; font-size: 14px; margin: 6px 0 0; text-shadow: 0 1px 2px rgba(20, 30, 90, 0.8); }
.tabs { display: flex; gap: 8px; justify-content: center; margin-top: 14px; }
.tab { font-family: var(--pixel); font-size: 14px; padding: 7px 14px; border-radius: 999px; border: 2px solid #fff; background: rgba(255, 255, 255, 0.85); color: var(--navy); cursor: pointer; }
.tab[aria-pressed="true"] { background: var(--navy); color: #fff; }
.arch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.arch-tile { display: block; border-radius: 12px; padding: 12px 6px; text-align: center; text-decoration: none; font-family: var(--pixel); color: #fff; border: 2px solid rgba(255, 255, 255, 0.85); box-shadow: 0 3px 0 rgba(30, 42, 110, 0.3); transition: transform 0.1s; }
.arch-tile:hover { transform: translateY(-2px); }
.arch-tile .n { display: block; font-size: 22px; }
.arch-tile .s { display: block; font-size: 12px; letter-spacing: 0.04em; margin-top: 5px; }
.arch-tile.won { background: var(--green, #2fbf71); }
.arch-tile.lost { background: var(--red, #e5486a); }
.arch-tile.new, .arch-tile.going { background: rgba(30, 42, 110, 0.6); }
.arch-tile.going { border-style: dashed; }
.arch-tile.today { background: var(--pink); color: var(--pink-text); }
.arch-summary { text-align: center; margin: 14px 0 0; }
.arch-empty { text-align: center; color: #fff; font-weight: 600; margin: 6px 0; }

/* ---------- Glass panels ---------- */
main { max-width: 760px; margin: 0 auto; padding: 0 12px 40px; }

.panel {
  position: relative;
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  border-radius: 16px;
  padding: 16px;
  margin: 14px auto;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(20, 30, 90, 0.25);
}
.panel.search-panel { z-index: 10; }

.prompt {
  text-align: center;
  margin: 0 0 12px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(20, 30, 90, 0.8);
}

/* ---------- Search ---------- */
.search { position: relative; max-width: 440px; margin: 0 auto; }
.search-row { display: flex; gap: 8px; }
#guess-input {
  flex: 1;
  min-width: 0;
  height: 50px;
  padding: 0 14px;
  font-family: var(--pixel);
  font-size: 20px;
  color: var(--navy);
  background: rgba(255, 255, 255, 0.88);
  border: 2px solid #fff;
  border-radius: var(--radius);
  outline: none;
}
#guess-input::placeholder { color: #6a76b0; font-family: var(--pixel); }
#guess-input:focus { box-shadow: 0 0 0 3px rgba(255, 143, 184, 0.7); }
#guess-input:disabled { opacity: 0.6; }

.btn {
  height: 50px;
  padding: 0 18px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--pixel);
  font-size: 20px;
  letter-spacing: 0.05em;
  color: var(--pink-text);
  background: var(--pink);
  box-shadow: 0 4px 0 var(--pink-dark);
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--pink-dark); }
.btn:disabled { filter: grayscale(0.8); opacity: 0.6; cursor: default; }

.suggestions {
  position: absolute;
  z-index: 20;
  left: 0; right: 0; top: 56px;
  max-height: 300px;
  overflow-y: auto;
  margin: 0; padding: 4px;
  list-style: none;
  background: rgba(255, 255, 255, 0.96);
  border: 2px solid #fff;
  border-radius: var(--radius);
  box-shadow: 0 14px 34px rgba(20, 30, 90, 0.35);
}
.suggestions[hidden] { display: none; }
.suggestions li {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--navy);
  font-family: var(--pixel);
  font-size: 20px;
}
.suggestions li.active, .suggestions li:hover { background: #ffe3ee; }
.suggestions .thumb { width: 38px; height: 38px; font-size: 14px; }

/* ---------- Hero thumbnails ---------- */
.thumb {
  flex: none;
  width: var(--cell); height: var(--cell);
  border-radius: 10px;
  overflow: hidden;
  display: grid; place-items: center;
  font-family: var(--pixel);
  font-size: 22px;
  color: #fff;
  background: var(--navy-2);
  border: 2px solid #fff;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- Board ---------- */
.board-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
.board { display: grid; gap: 6px; min-width: max-content; margin: 0 auto; width: max-content; }
.row { display: grid; grid-template-columns: repeat(7, var(--cell)); gap: 6px; }
.head-row div {
  font-family: var(--pixel);
  font-size: 13px;
  line-height: 1;
  letter-spacing: 0.03em;
  color: #fff;
  text-align: center;
  text-shadow: none;
  background: rgba(30, 42, 110, 0.78);
  border-radius: 6px;
  padding: 6px 2px 5px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
}
.cell {
  width: var(--cell); height: var(--cell);
  display: grid; place-items: center;
  text-align: center;
  padding: 3px;
  font-family: var(--pixel);
  font-size: 15px;
  line-height: 1;
  letter-spacing: 0.02em;
  border-radius: 10px;
  color: #fff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
  border: 2px solid rgba(255, 255, 255, 0.7);
  white-space: pre-line;
  opacity: 0;
  transform: rotateX(90deg);
  animation: flip 0.45s ease forwards;
}
.cell.green { background: var(--green); }
.cell.orange { background: var(--orange); }
.cell.red { background: var(--red); }
.cell .arrow { display: block; font-size: 18px; line-height: 1; margin-bottom: 2px; font-family: "Inter", system-ui, sans-serif; }
.row .thumb { opacity: 0; animation: flip 0.45s ease forwards; }

@keyframes flip {
  from { opacity: 0; transform: rotateX(90deg); }
  to   { opacity: 1; transform: rotateX(0); }
}

.legend {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 12px;
  margin-top: 12px; font-size: 12px; font-weight: 600; color: #fff;
  text-shadow: 0 1px 2px rgba(20, 30, 90, 0.8);
}
.legend span[class^="l-"]::before { content: ""; display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; border: 1px solid #fff; }
.legend .l-green::before { background: var(--green); }
.legend .l-orange::before { background: var(--orange); }
.legend .l-red::before { background: var(--red); }

.guess-count { text-align: center; color: #fff; font-family: var(--pixel); font-size: 20px; margin-top: 10px; text-shadow: var(--outline); }

/* ---------- Win panel ---------- */
.win { text-align: center; }
.win[hidden] { display: none; }
.win h2 { margin: 0 0 6px; font-family: var(--pixel); font-weight: normal; color: #fff; font-size: 40px; text-shadow: var(--outline-lg); }
.win .answer { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 10px 0; }
.win .answer .thumb { width: 72px; height: 72px; }
.win .answer strong { font-family: var(--pixel); font-weight: normal; font-size: 30px; text-shadow: var(--outline); }
.win p { text-shadow: 0 1px 2px rgba(20, 30, 90, 0.8); font-weight: 600; }
.win .btns { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.countdown { font-family: var(--pixel); font-variant-numeric: tabular-nums; font-size: 40px; margin-top: 4px; text-shadow: var(--outline); }
.small { font-size: 13px; color: #fff; }

.yesterday { text-align: center; font-size: 13px; color: #fff; text-shadow: 0 1px 2px rgba(20, 30, 90, 0.8); }
.yesterday b { color: #fff; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; margin-top: 12px; }
.stats div b { display: block; font-family: var(--pixel); font-weight: normal; font-size: 40px; color: #fff; text-shadow: var(--outline); }
.stats div span { display: inline-block; font-family: var(--pixel); font-size: 13px; line-height: 1; color: #fff; background: rgba(30, 42, 110, 0.78); border-radius: 6px; padding: 5px 8px 4px; margin-top: 4px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #fff; color: var(--navy); padding: 10px 16px; border-radius: 10px;
  font-weight: 700; font-size: 14px; z-index: 50;
  box-shadow: 0 8px 24px rgba(20, 30, 90, 0.4);
}
.toast[hidden] { display: none; }

/* ---------- Ads ---------- */
/* Room at the bottom so Google's anchor (sticky bottom) ad never covers the footer */
body { padding-bottom: 90px; }

/* ---------- Content pages (more opaque for long reading) ---------- */
.panel.page {
  background: rgba(255, 255, 255, 0.92);
  color: var(--navy);
}
.page h1 { font-family: var(--pixel); font-weight: normal; font-size: 40px; color: var(--navy); margin-top: 0; }
.page h2 { font-family: var(--pixel); font-weight: normal; font-size: 24px; color: var(--navy); margin-top: 24px; }
.page p, .page li { line-height: 1.6; color: #2b3566; }
.page a { color: #c4407a; }
.page table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 14px; color: #2b3566; }
.page td, .page th { border: 1px solid #cfd7f5; padding: 8px; text-align: left; vertical-align: top; }
.page .btn { color: var(--pink-text); }
.socials { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 10px 0 6px; }
.social {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center;
  padding: 12px 14px; min-height: 56px; border-radius: 12px; text-decoration: none;
  background: #eef2ff; border: 2px solid #d5ddff; color: var(--navy) !important;
}
.social:hover { background: #ffe3ee; border-color: var(--pink); }
.social svg { grid-row: 1 / span 2; }
.social span { font-family: var(--pixel); font-size: 18px; line-height: 1; }
.social small { font-size: 12px; color: #4b5590; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: -2px; }

/* ---------- Footer ---------- */
footer { max-width: 760px; margin: 0 auto; padding: 10px 16px 30px; text-align: center; font-size: 12px; color: #fff; text-shadow: 0 1px 2px rgba(10, 16, 48, 0.9); }
footer nav { display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
footer nav a { color: #fff; text-decoration: none; font-weight: 600; }
footer nav a:hover { color: var(--pink); }

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  /* show the left side of the art (character + blossom tree) */
  html::before { background-position: left center; }
  .bg-video { object-position: left center; }
}
/* Phones in portrait get the pre-cropped video (see index.html) and the matching still */
@media (max-width: 700px) and (orientation: portrait) {
  html::before {
    background: url("../images/bg-mobile.jpg?v=771cedc8") left center / cover no-repeat;
    background: image-set(url("../images/bg-mobile.webp?v=da8a1462") type("image/webp"), url("../images/bg-mobile.jpg?v=771cedc8") type("image/jpeg")) left center / cover no-repeat;
  }
}
@media (max-width: 460px) {
  :root { --cell: 52px; }
  .cell { font-size: 10px; letter-spacing: 0; padding: 2px; border-width: 1.5px; }
  .head-row div { font-size: 10px; letter-spacing: 0; padding: 6px 0 5px; }
  .subtitle { font-size: 16px; }
  .panel { padding: 12px 10px; }
}
@media (max-width: 380px) {
  :root { --cell: 47px; }
  .row, .board { gap: 4px; }
  main { padding: 0 6px 30px; }
  .panel { padding: 10px 6px; }
  .cell { font-size: 9px; }
  .head-row div { font-size: 9px; padding: 5px 0 4px; }
}

@media (prefers-reduced-motion: reduce) {
  .cell, .row .thumb { animation: none; opacity: 1; transform: none; }
  .bg-video { display: none; }
}

/* ---------- Lives ---------- */
.lives { display: flex; justify-content: center; gap: 10px; margin-top: 14px; }
.heart { width: 34px; height: 32px; display: inline-block; }
.heart svg { width: 100%; height: 100%; display: block; overflow: visible; shape-rendering: crispEdges; }
.heart .ol { fill: var(--navy); }
.heart .fill { fill: #ff5c8a; }
.heart.lost .fill { fill: #5a6399; }
.heart.breaking { animation: heartbreak 0.6s ease; }
@keyframes heartbreak {
  0% { transform: scale(1); } 30% { transform: scale(1.35) rotate(-8deg); } 60% { transform: scale(0.8) rotate(6deg); } 100% { transform: scale(1); }
}

/* ---------- Defeat ---------- */
.win.defeat h2 { color: #ffd1dc; }
.win.defeat .answer .thumb { border-color: #ff5c8a; }

/* ---------- 7-column board sizing ---------- */
@media (max-width: 460px) {
  :root { --cell: 45px; }
  .row, .board { gap: 4px; }
  .cell { font-size: 8.5px; padding: 2px 0; letter-spacing: -0.02em; }
  .cell .arrow { font-size: 14px; }
  .head-row div { font-size: 8.5px; letter-spacing: 0; padding: 5px 0 4px; }
  .heart { width: 30px; height: 28px; }
}
@media (max-width: 380px) {
  :root { --cell: 41px; }
  .row, .board { gap: 3px; }
  .cell { font-size: 8px; }
  .head-row div { font-size: 7.5px; }
}
