/* ===== Fonts ===== */

@font-face {
  font-family: VT323;
  src: url("./assets/fonts/VT323-Regular.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "CS Willard Pixel";
  src: url("./assets/fonts/CSWillardPixel-Demo.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}


/* ===== Theme and defaults ===== */

:root {
  --ink: #3c0960;
  --purple: #66149b;
  --paper: #e5cba1;
  --peach: #ffcc80;
  --orange: #ff9800;

  font-family: VT323, monospace;
  color: var(--ink);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 24px 32px;
  min-height: 100vh;

  background: #390660;
  background-image: repeating-linear-gradient(
    0deg,
    transparent 0 4px,
    #21172b30 4px 6px
  );

  font-size: 22px;
}


/* ===== Main frame ===== */

.board {
  max-width: 1180px;
  min-height: calc(100svh - 48px);
  margin: auto;
  position: relative;

  display: flex;
  flex-direction: column;

  border: 3px solid var(--ink);
  outline: 2px solid #dcc192;
  box-shadow: 8px 8px 0 #24152d;
  background: var(--paper);
}


/* ===== Header and date ===== */

.masthead {
  display: flex;
  justify-content: space-between;
  align-items: center;

  padding: 13px 24px;
  border-bottom: 2px solid var(--ink);
  background: #E2C79B;
}

.eyebrow {
  display: block;
  font-size: 16px;
  letter-spacing: 2px;
}

.masthead time {
  display: block;
  font-size: 29px;
}

.header-mark {
  font-size: 38px;
}


/* ===== Background ===== */

.world {
  position: relative;
  isolation: isolate;
  flex: 1;

  display: flex;
  flex-direction: column;
  align-items: center;

  width: 100%;
  padding: 50px 24px 0;
  background: #c8b6cc;
  overflow: hidden;
}

.world:before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;

  background-image: url("./assets/tiles.png");
  background-position: center;
  background-size: 200% auto;
  background-repeat: no-repeat;

  image-rendering: pixelated;
  opacity: 1;
  pointer-events: none;
}


/* ===== Title card ===== */

.title-card {
  width: 600px;
  height: 240px;
  position: relative;
  flex: none;

  filter: drop-shadow(5px 6px 0 #3c096025);
}

.title-art {
  width: 100%;
  height: 100%;
  display: block;

  image-rendering: pixelated;
}

.site-title {
  position: absolute;
  inset: 16% 8% auto;
  margin: 0;

  text-align: center;
  font-family: VT323, monospace;
  font-weight: 400;
  font-size: 92px;
  line-height: 1.1;
  white-space: nowrap;

  color: #4a165d;
  text-shadow: 2px 2px 0 #b580b44d;
}

.tagline {
  position: absolute;
  top: 69%;
  left: 8%;

  width: 84%;
  margin: 0;

  text-align: center;
  font-size: 27px;
  line-height: 1;
}


/* ===== Discovery area ===== */

.discovery {
  width: 100%;
  max-width: 680px;
  min-height: 175px;

  display: flex;
  flex-direction: column;
  align-items: center;

  margin: 65px 0 55px;
  text-align: center;
}


/* ===== Generate button ===== */

.generate {
  position: relative;
  width: 408px;
  height: 88px;
  padding: 0;
  flex: none;

  border: 0;
  background: none;
  cursor: pointer;

  color: #ffe4ad;
  font: inherit;

  filter: drop-shadow(4px 5px 0 #3c096040);
  transition:
    transform 100ms,
    filter 100ms;
}

.generate img {
  width: 100%;
  height: 100%;
  display: block;

  image-rendering: pixelated;
}

.generate span {
  position: absolute;
  inset: 0;

  display: grid;
  place-items: center;

  padding: 0 18px;
  font-size: 32px;
  white-space: nowrap;

  transform: translateY(-10px);
}

.generate:hover {
  transform: translateY(-3px);

  filter:
    drop-shadow(4px 8px 0 #3c096040)
    brightness(1.12);
}

.generate:active {
  transform: translateY(2px);
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 6px;
}

.generate:disabled {
  cursor: not-allowed;
  opacity: .68;
}

.generate:disabled:hover,
.generate:disabled:active {
  transform: none;
  filter: drop-shadow(4px 5px 0 #3c096040);
}


/* ===== Status message ===== */

.status {
  font-size: 24px;
  margin: 22px 0 0;
  color: #593766;
}


/* ===== Fact panel ===== */

.fact-sheet {
  width: 100%;
  text-align: left;
  padding: 26px 30px;

  background: #f4e4c4;
  border: 2px solid #7b5280;
  outline: 5px solid #f4e4c4;
  box-shadow: 9px 9px 0 #3c096025;

  scroll-margin: 25px;
}

.fact-sheet:focus {
  outline: 5px solid #f4e4c4;
}

.fact-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;

  border-bottom: 1px dashed #99758e;
  padding-bottom: 12px;

  font-size: 18px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.fact-sheet h2 {
  font-size: 39px;
  line-height: 1.08;
  font-weight: 400;

  margin: 22px 0 15px;
}

.fact-sheet > p {
  font-size: 26px;
  line-height: 1.3;

  margin: 0 0 25px;
}

.fact-footer {
  border-top: 1px dashed #99758e;
  padding-top: 14px;

  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;

  font-size: 18px;
}

.fact-footer a {
  color: var(--ink);
  text-underline-offset: 4px;
}

.fact-footer span {
  font-size: 15px;
}


/* ===== Page footer ===== */

footer {
  margin-top: auto;
  width: calc(100% + 48px);

  border-top: 1px solid #8c6b92;
  background: #E2C79B;

  display: flex;
  justify-content: space-between;
  gap: 12px;

  padding: 16px 24px;
  font-size: 15px;
  letter-spacing: 1px;
}


/* ===== Decorative corner pins ===== */

.pin {
  position: absolute;
  width: 10px;
  height: 10px;

  background: var(--orange);
  border: 2px solid var(--ink);
  z-index: 2;
}

.top-left {
  top: -6px;
  left: -6px;
}

.top-right {
  top: -6px;
  right: -6px;
}

.bottom-left {
  bottom: -6px;
  left: -6px;
}

.bottom-right {
  bottom: -6px;
  right: -6px;
}


/* ===== Visibility and accessibility ===== */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;

  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

[hidden] {
  display: none !important;
}


/* ===== Optional moving checker background ===== */

/*
  To enable this background, change:
  data-pattern="baroque"
  to:
  data-pattern="checker"
  in index.html.
*/

.world[data-pattern="checker"]:before {
  background-image: conic-gradient(
    #69467c 25%,
    transparent 0 50%,
    #69467c 0 75%,
    transparent 0
  );

  background-size: 64px 64px;
  opacity: 0.1;
  animation: checker-drift 14s linear infinite;
}

@keyframes checker-drift {
  from {
    background-position: 0 0;
  }

  to {
    background-position: 64px 64px;
  }
}


/* ===== Tablet and smaller screens ===== */

@media (max-width: 760px) {
  body {
    padding: 15px 14px;
  }

  .board {
    min-height: calc(100svh - 30px);
  }

  .world {
    padding: 38px 14px 0;
  }

  .title-card {
    width: 450px;
    height: 180px;
  }

  .site-title {
    font-size: 69px;
  }

  .tagline {
    font-size: 21px;
  }

  .discovery {
    margin-top: 50px;
  }

  .generate {
    width: 306px;
    height: 66px;
  }

  .generate span {
    font-size: 25px;
  }

  .fact-sheet {
    padding: 22px;
  }

  .fact-sheet h2 {
    font-size: 33px;
  }

  .fact-sheet > p {
    font-size: 24px;
  }

  footer {
    width: calc(100% + 28px);
    padding: 15px 12px;
    font-size: 13px;
  }

  footer span:last-child {
    display: none;
  }
}


/* ===== Mobile screens ===== */

@media (max-width: 520px) {
  .masthead {
    padding: 12px 16px;
  }

  .eyebrow {
    font-size: 14px;
  }

  .masthead time {
    font-size: 26px;
  }

  .title-card {
    width: 300px;
    height: 120px;
  }

  .site-title {
    font-size: 46px;
  }

  .tagline {
    font-size: 15px;
  }

  .world {
    padding-top: 42px;
  }

  .discovery {
    margin: 50px 0;
    min-height: 150px;
  }

  .fact-sheet {
    padding: 20px 16px;
  }

  .fact-meta {
    font-size: 15px;
  }

  .fact-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 9px;
  }

  .status {
    font-size: 20px;
  }

  footer {
    justify-content: center;
    text-align: center;
  }
}


/* ===== Extra-small mobile screens ===== */

@media (max-width: 365px) {
  body {
    padding: 10px;
  }

  .world {
    padding-inline: 10px;
  }

  .title-card {
    width: 270px;
    height: 108px;
  }

  .site-title {
    font-size: 41px;
  }

  .tagline {
    font-size: 14px;
  }

  .generate {
    width: 275.4px;
    height: 59.4px;
  }

  .generate span {
    font-size: 22px;
  }

  footer {
    width: calc(100% + 20px);
  }
}


/* ===== Reduced-motion preference ===== */

@media (prefers-reduced-motion: reduce) {
  .generate {
    transition: none;
  }

  .world[data-pattern="checker"]:before {
    animation: none;
  }
}
/* Quiz: the panel takes the title card's place, without an empty title-sized gap. */
.world.quiz-open { padding-top: 32px; }
.quiz-open .discovery { margin-top: 0; max-width: 720px; }
.answer-label { display:block; margin: 18px 0 8px; font-size:24px; }
.answer-frame {
  width: 100%;
  min-height: 0;
  padding: 8px 0;
  border: 0;
  border-bottom: 2px solid var(--ink);
  background: transparent;
}
.answer-frame input {
  display:block; width:100%; min-width:0; padding:0 6px; border:0;
  background:transparent; color:var(--ink); font:26px/1.2 VT323,monospace;
}
.answer-frame:focus-within {
  outline: none;
  border-bottom-color: #a64de0;
  box-shadow: none;
}
.answer-frame input:focus { outline:none; }
.submit-answer {
  display:block; position:relative; width:255px; height:75px; max-width:100%;
  margin:24px auto 0; padding:0; border:0; background:none;
  cursor:pointer; color:#ffe4ad; font:30px VT323,monospace;
}
.submit-answer img { width:100%;height:100%;display:block;image-rendering:pixelated; }
.submit-answer span { position:absolute;inset:0;display:grid;place-items:center; transform: translateY(-5px); }
.submit-answer:hover { filter:brightness(1.12); }
button:disabled { cursor:wait; opacity:.65; }
.answer-hint { text-align:center; font-size:19px; margin:14px 0 0; }
.answer-results { padding-left:22px; font-size:23px; }
.fact-sheet { overflow-wrap:anywhere; }
@media(max-width:520px) {
  .world.quiz-open { padding-top:24px; }
  .quiz-open .discovery { margin-bottom:32px; }
  .answer-frame {
  border-width: 0 0 2px;
}
  .submit-answer { width:221px;height:65px; }
  .fact-sheet h2 { font-size:30px; }
  .title-card { max-width:100%; }
  .generate { max-width:100%; }
}

/* Completed boxes show progress only; correctness is reserved for the result. */
.round-progress { display:flex; justify-content:center; gap:12px; list-style:none; padding:0; margin:28px 0 0; }
.progress-box { width:18px; height:18px; border:2px solid var(--purple); background:transparent; }
.progress-box.completed { background:var(--purple); }
/* Reuse the exact illustrated main button for continuing the round. */
.next-question { display: block; margin: 24px auto 0; width: min(408px, 100%); height: auto; aspect-ratio: 102 / 22; }
.next-question span { font-size: clamp(22px, 4vw, 32px); }
.round-review details { border-top:1px dashed #99758e; padding:14px 0; font-size:23px; }
.round-review summary { cursor:pointer; }
.round-review a { color:var(--ink); }
.generate span { font-size:30px; }
@media(max-width:760px) { .generate span { font-size:23px; } }
@media(max-width:365px) { .generate span { font-size:21px; } }

/* ===== Optional category wager ===== */
.wager-setup { width: min(100%, 760px); text-align: center; }
.setup-kicker { margin: 0 0 4px; letter-spacing: 2px; font-size: 19px; }
.wager-setup h2 { font-size: 45px; font-weight: normal; margin: 0 0 6px; }
.setup-description { margin: 0 0 17px; font-size: 24px; }
.category-cards { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; margin: 0 auto; width: 100%; min-width: 0; }
.category-card { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; position: relative; width: 100%; min-width: 0; aspect-ratio: 2 / 3; border: 0; padding: 16% 10% 23%; background: url('./assets/category-card-idle.png') center / 100% 100% no-repeat; image-rendering: pixelated; font: inherit; color: #4a165d; cursor: pointer; filter: drop-shadow(4px 5px 0 #3c096040); transition: transform 100ms, filter 100ms; }
.category-card:hover { transform: translateY(-5px); filter: drop-shadow(4px 9px 0 #3c096040) brightness(1.09); }
.category-card:active { transform: translateY(2px); }
.category-card[aria-pressed="true"] { background-image: url('./assets/category-card-selected.png'); transform: translateY(-3px); filter: drop-shadow(4px 7px 0 #3c096040); }
.category-card[aria-pressed="true"]:hover { transform: translateY(-6px); }
.category-card-name { max-width: 100%; overflow-wrap: anywhere; font-size: clamp(23px, 3.5vw, 37px); line-height: 0.94; text-shadow: 1px 1px 0 #f8e2ae; }
.category-card-excerpt { display: block; max-width: 100%; font-size: clamp(15px, 1.85vw, 21px); line-height: 1.05; text-wrap: pretty; }
.category-card[aria-pressed="true"] { color: #fff; }
.category-card[aria-pressed="true"] .category-card-name { text-shadow: 1px 2px 0 #4a165d; }
.category-card[aria-pressed="true"] .category-card-excerpt,
.category-card[aria-pressed="true"] small { color: #fff; text-shadow: 1px 1px 0 #4a165d; }
.category-card small { position: absolute; bottom: 16%; font-size: 20px; }
.wager-rules { font-size: 21px; line-height: 1.2; margin: 23px 0 18px; }
.wager-actions { display: flex; justify-content: center; flex-wrap: wrap; align-items: center; gap: 18px; }
.wager-button { width: min(100%, 320px); height: 72px; aspect-ratio: 102 / 22; }
.wager-button span { font-size: clamp(24px, 3vw, 30px); line-height: .92; white-space: normal; text-align: center; padding: 0 20px; }
.wager-button--skip { width: min(100%, 470px); color: #fff; }
.wager-button--skip span { text-shadow: 1px 1px 0 #4a165d; }
.wager-button--skip span { font-size: clamp(22px, 2.6vw, 30px); }
.wager-indicator { margin: 14px 0 0 !important; font-size: 22px !important; color: #8f3163; }
.wager-indicator[data-state="won"] { color: #41701d; }
.wager-indicator[data-state="lost"] { color: #a13d36; }
.score-breakdown {
  display: grid;
  gap: 2px;
  margin: 0 0 22px;
  padding: 16px 18px;
  border: 2px solid #7b5280;
  background: #f8ecd3;
}
.score-breakdown-label { font-size: 19px; letter-spacing: 1px; text-transform: uppercase; }
.score-breakdown-total { font-size: clamp(52px, 9vw, 68px); line-height: .88; color: #4a165d; }
.score-breakdown-note { font-size: 24px; }
@media (max-width: 520px) {
  .wager-setup h2 { font-size: 36px; }
  .setup-description { font-size: 20px; }
  .category-cards { gap: 6px; }
  /* Three equal-width cards; never let their text set a wider minimum width. */
  .category-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
  .category-card {
    display: grid;
    width: 100%;
    min-width: 0;
    min-height: 0;
    aspect-ratio: 2 / 3;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    justify-items: center;
    align-content: stretch;
    padding: 14% 7% 18%;
    gap: 2px;
  }
  .category-card-name {
    min-width: 0;
    width: 100%;
    overflow-wrap: anywhere;
    font-size: clamp(15px, 4.2vw, 21px);
    line-height: .95;
  }
  .category-card-excerpt {
    min-width: 0;
    width: 100%;
    align-self: center;
    overflow-wrap: anywhere;
    font-size: clamp(11px, 2.9vw, 14px);
    line-height: 1;
  }
  .category-card small {
    position: static;
    min-width: 0;
    align-self: end;
    font-size: clamp(12px, 3.3vw, 15px);
    line-height: 1;
  }
  .wager-rules { font-size: 19px; }
  .wager-button { width: min(100%, 100%); height: 66px; }
  .wager-button span { font-size: clamp(20px, 5vw, 26px); }
  .wager-button--skip span { font-size: clamp(19px, 4.5vw, 24px); }
  .score-breakdown-note { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) { .category-card, .wager-button, .generate { transition: none; } }

/* Native hidden must override display:grid on all screen sizes. */
.score-breakdown[hidden] { display: none; }

/* ===== Multi-wager category selection ===== */
.wager-selection-count { margin: 12px 0 0; font-size: 22px; color: var(--ink); }
@media (max-width: 520px) { .wager-selection-count { font-size: 19px; } }
