/* =====================================================
   Feed the Children — Resilience Jeopardy
   Brand palette extracted from the FTC logo
   ===================================================== */

:root {
  /* Primary brand identity */
  --ftc-gray:        #776C68;     /* primary brand gray (logo text) */
  --ftc-gray-dark:   #5A524F;
  --ftc-gray-soft:   #B5ADA8;

  /* Patchwork accent palette */
  --ftc-orange:      #F37A2F;
  --ftc-orange-dk:   #D85F18;
  --ftc-magenta:     #CF2885;
  --ftc-magenta-dk:  #A91E6B;
  --ftc-green:       #7CBD44;
  --ftc-green-dk:    #5E9B30;
  --ftc-teal:        #67ABBB;
  --ftc-teal-dk:     #4A8995;
  --ftc-tan:         #BDAF7B;
  --ftc-tan-dk:      #9D8F5C;

  /* Neutrals */
  --ftc-cream:       #FAF7F2;     /* warm off-white background */
  --ftc-paper:       #FFFFFF;
  --ftc-ink:         #2A2620;
  --ftc-ink-soft:    #6F6963;
  --ftc-border:      #E5E0D8;

  /* Game board (derived from logo teal, pushed darker for contrast) */
  --board-bg:        #2D5868;
  --board-bg-dark:   #1F4050;
  --board-bg-hover:  #3D6B7C;
  --board-gold:      #F5C242;     /* warmer gold to match brand */

  --shadow-sm: 0 2px 6px rgba(0,0,0,.06);
  --shadow-md: 0 6px 20px rgba(0,0,0,.10);
  --shadow-lg: 0 14px 40px rgba(0,0,0,.20);
  --radius: 10px;
}

* { box-sizing: border-box; }

/* [hidden] must always win over component CSS */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--ftc-cream);
  color: var(--ftc-ink);
  min-height: 100vh;
  position: relative;
}

/* Subtle patchwork background — echoes the FTC logo blocks */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.07;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 400'><g><rect x='0'   y='0'   width='90'  height='40'  fill='%237CBD44'/><rect x='95'  y='0'   width='110' height='35'  fill='%23F37A2F'/><rect x='210' y='0'   width='80'  height='30'  fill='%23BDAF7B'/><rect x='0'   y='45'  width='40'  height='75'  fill='%237CBD44'/><rect x='45'  y='40'  width='130' height='80'  fill='%23CF2885'/><rect x='180' y='38'  width='60'  height='65'  fill='%23BDAF7B'/><rect x='245' y='35'  width='100' height='70'  fill='%23F37A2F'/><rect x='0'   y='125' width='60'  height='100' fill='%2367ABBB'/><rect x='65'  y='125' width='100' height='95'  fill='%237CBD44'/><rect x='170' y='110' width='80'  height='115' fill='%23F37A2F'/><rect x='255' y='110' width='95'  height='110' fill='%2367ABBB'/><rect x='0'   y='230' width='110' height='80'  fill='%23CF2885'/><rect x='115' y='225' width='80'  height='90'  fill='%23BDAF7B'/><rect x='200' y='230' width='95'  height='75'  fill='%237CBD44'/><rect x='300' y='225' width='90'  height='90'  fill='%23F37A2F'/><rect x='0'   y='315' width='90'  height='80'  fill='%23F37A2F'/><rect x='95'  y='320' width='100' height='75'  fill='%2367ABBB'/><rect x='200' y='310' width='75'  height='90'  fill='%23CF2885'/><rect x='280' y='320' width='115' height='80'  fill='%237CBD44'/></g></svg>");
  background-size: 600px 600px;
  background-repeat: repeat;
}

/* Ensure all UI sits above the watermark */
.ftc-header, main, .ftc-footer, .modal { position: relative; z-index: 1; }
.ftc-header { z-index: 50; }
.modal { z-index: 100; }

/* ---------- Header ---------- */
.ftc-header {
  background: var(--ftc-paper);
  color: var(--ftc-gray);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--ftc-border);
}
.brand { display: flex; align-items: center; gap: 16px; }
.brand-logo {
  height: 50px;
  width: auto;
  display: block;
}
.brand-divider {
  width: 1px;
  height: 38px;
  background: var(--ftc-border);
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.brand-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--ftc-gray);
  letter-spacing: .2px;
}
.brand-sub {
  font-size: 12px;
  color: var(--ftc-ink-soft);
  text-transform: uppercase;
  letter-spacing: 1.2px;
}
.header-nav { display: flex; gap: 12px; align-items: center; }
.nav-link {
  background: var(--ftc-cream);
  color: var(--ftc-gray);
  border: 1px solid var(--ftc-border);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
}
.nav-link:hover { background: var(--ftc-border); }
.score-chip {
  background: var(--ftc-orange);
  color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
}

/* Brand stripe under header (echoes the patchwork) */
.ftc-header::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -4px;
  height: 4px;
  background: linear-gradient(90deg,
    var(--ftc-green)   0%, var(--ftc-green)   20%,
    var(--ftc-orange)  20%, var(--ftc-orange)  40%,
    var(--ftc-magenta) 40%, var(--ftc-magenta) 60%,
    var(--ftc-tan)     60%, var(--ftc-tan)     80%,
    var(--ftc-teal)    80%, var(--ftc-teal)   100%);
}

/* ---------- Layout ---------- */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 36px 24px 80px;
}
.screen { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px);} to { opacity:1; transform:none; } }

.screen-title {
  font-size: 32px;
  margin: 0 0 8px;
  color: var(--ftc-gray);
  font-weight: 700;
}
.screen-sub {
  margin: 0 0 28px;
  color: var(--ftc-ink-soft);
  font-size: 15px;
}

/* ---------- Topic pills ---------- */
/* Each pill takes one of the brand patchwork colors as its identity */
.topic-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 28px;
}
.pill {
  background: var(--ftc-paper);
  color: var(--ftc-gray);
  border: 2px solid var(--ftc-border);
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all .18s ease;
  position: relative;
}
/* Color each pill in topic order with one of the patchwork colors */
.pill[data-color="orange"]  { border-color: var(--ftc-orange);  color: var(--ftc-orange-dk); }
.pill[data-color="magenta"] { border-color: var(--ftc-magenta); color: var(--ftc-magenta-dk); }
.pill[data-color="green"]   { border-color: var(--ftc-green);   color: var(--ftc-green-dk); }
.pill[data-color="teal"]    { border-color: var(--ftc-teal);    color: var(--ftc-teal-dk); }
.pill[data-color="tan"]     { border-color: var(--ftc-tan);     color: var(--ftc-tan-dk); }

.pill:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.pill[data-color="orange"]:hover:not(:disabled)  { background: var(--ftc-orange);  color: #fff; }
.pill[data-color="magenta"]:hover:not(:disabled) { background: var(--ftc-magenta); color: #fff; }
.pill[data-color="green"]:hover:not(:disabled)   { background: var(--ftc-green);   color: #fff; }
.pill[data-color="teal"]:hover:not(:disabled)    { background: var(--ftc-teal);    color: #fff; }
.pill[data-color="tan"]:hover:not(:disabled)     { background: var(--ftc-tan);     color: #fff; }

.pill.is-selected {
  color: #fff;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.pill[data-color="orange"].is-selected  { background: var(--ftc-orange);  border-color: var(--ftc-orange-dk); }
.pill[data-color="magenta"].is-selected { background: var(--ftc-magenta); border-color: var(--ftc-magenta-dk); }
.pill[data-color="green"].is-selected   { background: var(--ftc-green);   border-color: var(--ftc-green-dk); }
.pill[data-color="teal"].is-selected    { background: var(--ftc-teal);    border-color: var(--ftc-teal-dk); }
.pill[data-color="tan"].is-selected     { background: var(--ftc-tan);     border-color: var(--ftc-tan-dk); }

.pill:disabled, .pill.is-disabled {
  opacity: .45;
  cursor: not-allowed;
  border-style: dashed;
  background: var(--ftc-cream);
  color: var(--ftc-gray-soft) !important;
  border-color: var(--ftc-border) !important;
}
.pill.is-placeholder::after {
  content: "Coming soon";
  position: absolute;
  top: -10px; right: 10px;
  background: var(--ftc-tan);
  color: #fff;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: .3px;
}

/* ---------- Buttons ---------- */
.btn {
  border: none;
  padding: 12px 22px;
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all .15s ease;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--ftc-orange); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--ftc-orange-dk); }
.btn-ghost { background: transparent; color: var(--ftc-ink-soft); border: 1px solid var(--ftc-border); }
.btn-ghost:hover { background: var(--ftc-cream); }
.btn-ghost-light {
  background: transparent; color: rgba(255,255,255,.85);
  border: 1px solid rgba(255,255,255,.35);
}
.btn-ghost-light:hover { background: rgba(255,255,255,.12); }
.btn-success { background: var(--ftc-green); color: #fff; }
.btn-success:hover { background: var(--ftc-green-dk); }
.btn-danger { background: var(--ftc-magenta); color: #fff; }
.btn-danger:hover { background: var(--ftc-magenta-dk); }

.topic-actions { display: flex; gap: 12px; }

/* ---------- Game grid ---------- */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}
.game-card {
  background: var(--ftc-paper);
  border: 1px solid var(--ftc-border);
  border-radius: var(--radius);
  padding: 22px 20px;
  cursor: pointer;
  transition: all .15s ease;
  text-align: left;
  position: relative;
}
.game-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--ftc-orange);
}
.game-card .level {
  font-size: 12px; font-weight: 700; color: var(--ftc-orange);
  text-transform: uppercase; letter-spacing: .8px;
}
.game-card h3 { margin: 6px 0 10px; font-size: 22px; color: var(--ftc-gray); }
.game-card p { margin: 0; color: var(--ftc-ink-soft); font-size: 14px; line-height: 1.4; }
.game-card .difficulty-bar {
  display: flex; gap: 4px; margin-top: 14px;
}
.game-card .difficulty-bar span {
  flex: 1; height: 6px; border-radius: 3px; background: var(--ftc-border);
}
.game-card .difficulty-bar span.on {
  background: linear-gradient(90deg, var(--ftc-green), var(--ftc-orange), var(--ftc-magenta));
}

/* ---------- Board ---------- */
.board-header {
  display: flex; flex-wrap: wrap; align-items: center;
  justify-content: space-between; gap: 12px;
  margin-bottom: 20px;
}
.board-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.diff-chip {
  background: var(--ftc-tan); color: #fff;
  padding: 6px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px;
}

.board {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  background: var(--ftc-gray-dark);
  padding: 6px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.cat-cell, .clue-cell {
  background: var(--board-bg);
  color: #fff;
  text-align: center;
  display: grid;
  place-items: center;
  padding: 14px 8px;
  font-weight: 700;
  border-radius: 4px;
  user-select: none;
}
.cat-cell {
  background: linear-gradient(180deg, var(--board-bg) 0%, var(--board-bg-dark) 100%);
  text-transform: uppercase;
  font-size: 13px;
  min-height: 90px;
  letter-spacing: .4px;
  font-family: "Impact", "Oswald", "Helvetica Neue", sans-serif;
  text-shadow: 1px 1px 0 rgba(0,0,0,.3);
}
.clue-cell {
  font-size: 30px;
  color: var(--board-gold);
  min-height: 90px;
  cursor: pointer;
  transition: transform .12s ease, background .12s ease;
  font-family: "Impact", "Oswald", "Helvetica Neue", sans-serif;
  text-shadow: 1px 1px 0 rgba(0,0,0,.35);
}
.clue-cell:hover { transform: scale(1.02); background: var(--board-bg-hover); }
.clue-cell.is-used {
  background: #4A6470; color: transparent; cursor: default;
  pointer-events: none;
  opacity: .55;
}

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(42,38,32,.75);
  display: grid; place-items: center;
  z-index: 100;
  padding: 20px;
}
.modal-card {
  background: linear-gradient(160deg, var(--board-bg) 0%, var(--board-bg-dark) 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 36px 40px;
  max-width: 720px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: pop .25s ease;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: rgba(255,255,255,.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,.25);
  width: 34px; height: 34px;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: grid; place-items: center;
  transition: background .15s ease;
}
.modal-close:hover { background: rgba(255,255,255,.28); }
@keyframes pop { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 22px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255,255,255,.2);
  padding-right: 44px; /* leave room for close button */
}
.modal-cat {
  font-size: 13px; text-transform: uppercase; letter-spacing: .8px;
  opacity: .85;
}
.modal-val {
  background: var(--board-gold); color: var(--ftc-ink);
  padding: 6px 14px; border-radius: 999px;
  font-weight: 800;
}
.modal-clue {
  font-size: 26px;
  line-height: 1.4;
  text-align: center;
  padding: 30px 0;
  color: var(--board-gold);
  font-family: "Impact", "Oswald", "Helvetica Neue", sans-serif;
  font-weight: 400;
  text-shadow: 2px 2px 0 rgba(0,0,0,.5);
}
.modal-answer {
  background: rgba(255,255,255,.12);
  padding: 16px 18px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 18px;
  text-align: center;
}
.answer-row { margin-bottom: 8px; }
.answer-label {
  font-weight: 700; color: var(--board-gold);
  margin-right: 8px;
}
.reference-row {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,.18);
  font-size: 13px;
  color: rgba(255,255,255,.85);
  font-style: italic;
}
.reference-label {
  font-weight: 700;
  color: var(--board-gold);
  font-style: normal;
  margin-right: 8px;
}
.modal-actions {
  display: flex; gap: 12px; justify-content: center;
  flex-wrap: wrap;
}

/* ---------- Game over ---------- */
.final-message {
  font-size: 18px; color: var(--ftc-ink-soft);
  margin: 14px 0 28px;
}

/* ---------- Footer ---------- */
.ftc-footer {
  text-align: center;
  padding: 18px;
  font-size: 13px;
  color: var(--ftc-ink-soft);
  border-top: 1px solid var(--ftc-border);
  margin-top: 40px;
  background: var(--ftc-paper);
}

/* ---------- Responsive ---------- */
@media (max-width: 800px) {
  .board { grid-template-columns: repeat(6, 1fr); gap: 3px; padding: 3px; }
  .cat-cell { font-size: 10px; min-height: 60px; padding: 6px 3px; }
  .clue-cell { font-size: 18px; min-height: 60px; }
  .modal-clue { font-size: 20px; padding: 20px 0; }
  .modal-card { padding: 24px 20px; }
  .screen-title { font-size: 24px; }
  main { padding: 20px 14px; }
  .brand-logo { height: 38px; }
  .brand-divider, .brand-text { display: none; }
}
