:root {
  --civics-red: #c41230;
  --civics-red-dark: #8f0d22;
  --charcoal: #211f20;
  --ink: #292526;
  --paper: #fffdfb;
  --cream: #f5f0eb;
  --line: #ddd5cf;
  --success: #16734a;
  --board-size: min(43vw, calc(100vh - 245px), 540px);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; }

body {
  margin: 0;
  color: var(--ink);
  background: radial-gradient(circle at 7% 95%, rgba(196, 18, 48, .08), transparent 25%), linear-gradient(145deg, #f6f1ec 0%, #eee7e1 100%);
  font-family: Inter, ui-rounded, "SF Pro Rounded", "Segoe UI", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

button { font: inherit; }
.small-screen-notice { display: none; }

.app-header {
  height: 92px;
  padding: 10px 26px 10px 20px;
  color: white;
  background: linear-gradient(110deg, #951027 0%, var(--civics-red) 52%, #d32643 100%);
  border-bottom: 6px solid white;
  box-shadow: 0 4px 18px rgba(56, 17, 23, .24);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand, .header-actions, .scoreboard, .team-card, .board-actions, .question-meta,
.answer-feedback, .panel-footer { display: flex; align-items: center; }
.brand { gap: 14px; }
.brand-logo { width: 72px; height: 72px; object-fit: contain; filter: drop-shadow(0 3px 2px rgba(0, 0, 0, .28)); }
.publisher-line { margin: 0 0 4px; display: flex; align-items: center; gap: 9px; }
.publisher-site { padding: 4px 9px; color: var(--civics-red-dark); background: white; border-radius: 7px; font-size: .98rem; line-height: 1; letter-spacing: .01em; box-shadow: 0 2px 5px rgba(63, 0, 11, .18); }
.publisher-company { font-size: .55rem; font-weight: 850; letter-spacing: .14em; text-transform: uppercase; opacity: .82; }

h1 {
  margin: 0;
  font-family: Rockwell, "Roboto Slab", Georgia, serif;
  font-size: clamp(2rem, 3.2vw, 3rem);
  line-height: .98;
  letter-spacing: -.035em;
}

.header-actions { gap: 13px; }
.question-total { display: grid; grid-template-columns: auto auto; column-gap: 8px; align-items: center; padding-right: 14px; border-right: 1px solid rgba(255,255,255,.45); }
.question-total strong { font-size: 1.8rem; line-height: 1; }
.question-total span { max-width: 68px; font-size: .72rem; font-weight: 800; line-height: 1.05; text-transform: uppercase; }
.icon-button, .source-button, .quiet-button { border: 0; background: transparent; cursor: pointer; }
.icon-button { display: flex; align-items: center; gap: 7px; padding: 9px 12px; color: white; border: 1px solid rgba(255,255,255,.5); border-radius: 12px; font-size: .82rem; font-weight: 800; }

.game-layout {
  height: calc(100vh - 92px);
  padding: 16px 20px 18px;
  display: grid;
  grid-template-columns: minmax(480px, 44%) minmax(500px, 1fr);
  gap: 18px;
}

.board-panel, .question-panel { min-width: 0; min-height: 0; }
.board-panel { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.scoreboard { width: min(100%, var(--board-size)); min-height: 58px; justify-content: space-between; margin-bottom: 10px; gap: 8px; }

.team-card {
  min-width: 132px;
  height: 50px;
  padding: 5px 9px;
  gap: 7px;
  border-radius: 13px;
  border: 2px solid transparent;
  opacity: .62;
  transition: opacity .15s, transform .15s, box-shadow .15s;
}
.team-card.active { opacity: 1; transform: translateY(-2px); box-shadow: 0 5px 14px rgba(44, 31, 31, .15); }
.red-team { background: var(--civics-red); color: white; }
.white-team { background: white; color: var(--charcoal); border-color: #bbb1aa; }
.team-mark { font-size: 1.55rem; font-weight: 1000; }
.team-name { font-size: .68rem; line-height: 1; font-weight: 900; }
.team-card strong { margin-left: auto; font-size: 1.7rem; }
.turn-pill { text-align: center; display: flex; flex-direction: column; }
.turn-pill span { font-size: .83rem; font-weight: 900; }
.turn-pill small { color: #766e68; font-size: .67rem; }

.board {
  width: var(--board-size);
  height: var(--board-size);
  padding: 9px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 8px;
  background: var(--charcoal);
  border: 5px solid white;
  border-radius: 24px;
  box-shadow: 0 16px 34px rgba(54, 39, 39, .2), 0 0 0 2px var(--charcoal);
}

.cell {
  position: relative;
  border: 0;
  border-radius: 12px;
  background: var(--paper);
  color: var(--charcoal);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: calc(var(--board-size) / 4.8);
  font-weight: 1000;
  line-height: 1;
  box-shadow: inset 0 -4px 0 #e4ddd7;
  transition: transform .12s, background .12s;
}
.cell:not(:disabled):hover { background: #fff3f5; transform: scale(.975); }
.cell:disabled { cursor: default; }
.cell.pending { background: #fff0c7; animation: pulse 700ms ease-in-out infinite alternate; }
.cell.x-mark { color: var(--civics-red); text-shadow: 0 2px 0 white; }
.cell.o-mark { color: white; background: var(--charcoal); text-shadow: -2px -2px 0 var(--civics-red), 2px -2px 0 var(--civics-red), -2px 2px 0 var(--civics-red), 2px 2px 0 var(--civics-red); }
.cell.win-cell { background: #ffe49a; animation: winner-pop 600ms ease-in-out infinite alternate; }

.board-actions { width: min(100%, var(--board-size)); justify-content: center; gap: 10px; margin-top: 12px; }
.secondary-button, .primary-button, .continue-button { border: 0; border-radius: 12px; padding: 11px 18px; font-weight: 900; cursor: pointer; }
.secondary-button { color: white; background: var(--charcoal); }
.quiet-button { color: #6b625d; padding: 9px; font-size: .8rem; font-weight: 800; text-decoration: underline; }
kbd { margin-left: 5px; padding: 2px 5px; color: inherit; background: rgba(255,255,255,.18); border: 1px solid currentColor; border-radius: 5px; font: 700 .65rem/1 ui-monospace, monospace; opacity: .8; }

.question-panel {
  position: relative;
  padding: 22px 26px 48px;
  overflow: hidden;
  background: rgba(255, 253, 251, .96);
  border: 1px solid #dfd5ce;
  border-radius: 22px;
  box-shadow: 0 14px 35px rgba(57, 36, 36, .13);
  display: flex;
  flex-direction: column;
}
.question-panel::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 8px; background: var(--civics-red); }
.question-meta { justify-content: space-between; gap: 12px; color: #746a65; font-size: .75rem; font-weight: 800; }
.category-badge { padding: 6px 10px; color: var(--civics-red-dark); background: #fbe4e8; border-radius: 99px; letter-spacing: .06em; }
.ready-state, .loading-state, .result-state { margin: auto; text-align: center; }

.ready-seal, .result-icon {
  width: 78px;
  height: 78px;
  margin: 0 auto 12px;
  border: 7px double white;
  outline: 5px solid var(--civics-red);
  border-radius: 50%;
  color: white;
  background: var(--civics-red);
  display: grid;
  place-items: center;
  font-size: 2rem;
}
.ready-state h2, .result-state h2 { margin: 0; font: 900 clamp(2rem, 4vw, 3.6rem)/1 Rockwell, Georgia, serif; color: var(--charcoal); }
.ready-state p { max-width: 600px; margin: 12px auto 22px; font-size: clamp(1rem, 1.6vw, 1.25rem); line-height: 1.45; color: #665c57; }
.how-to-play { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.how-to-play span { padding: 9px 12px; background: var(--cream); border-radius: 10px; font-size: .78rem; font-weight: 800; }
.how-to-play b { color: white; background: var(--civics-red); border-radius: 50%; display: inline-grid; place-items: center; width: 20px; height: 20px; margin-right: 4px; }
.paw-loader { font-size: 4.8rem; animation: paw-bounce .55s ease-in-out infinite alternate; }
.loading-state h2 { margin: 12px 0; font: 900 2rem Rockwell, Georgia, serif; }

.question-state { flex: 1; min-height: 0; padding: 13px 0 10px; display: flex; flex-direction: column; justify-content: center; }
.question-state h2 { margin: 0 0 13px; color: var(--charcoal); font: 900 clamp(1.35rem, 2.35vw, 2.15rem)/1.15 Rockwell, Georgia, serif; }
.question-state.compact h2 { font-size: clamp(1.12rem, 1.9vw, 1.7rem); }
.choices { display: grid; gap: 8px; }

.choice {
  width: 100%;
  min-height: 49px;
  padding: 8px 13px;
  color: #3b3532;
  background: #f5f1ee;
  border: 2px solid transparent;
  border-radius: 12px;
  text-align: left;
  cursor: pointer;
  display: grid;
  grid-template-columns: 32px 1fr;
  align-items: center;
  gap: 8px;
  font-size: clamp(.88rem, 1.26vw, 1.08rem);
  font-weight: 750;
  line-height: 1.18;
}
.compact .choice { min-height: 42px; padding-block: 6px; font-size: clamp(.75rem, 1.05vw, .94rem); }
.choice:hover { border-color: #c8bdb7; }
.choice:disabled { cursor: default; opacity: 1; }
.choice.correct-choice { color: #0d5f3a; border-color: #1a8b58; background: #e6f6ee; }
.choice.incorrect-choice { color: #882137; border-color: #d26b7e; background: #fdecef; }
.choice-letter { width: 29px; height: 29px; color: white; background: var(--charcoal); border-radius: 8px; display: grid; place-items: center; font-weight: 950; }
.correct-choice .choice-letter { background: var(--success); }
.incorrect-choice .choice-letter { background: var(--civics-red); }

.answer-feedback { flex: 0 0 auto; gap: 11px; margin-top: 7px; padding: 10px 11px; border: 2px solid; border-radius: 13px; }
.correct-feedback { color: #0d5f3a; background: #e6f6ee; border-color: #1a8b58; }
.incorrect-feedback { color: #7e2034; background: #fdecef; border-color: #d26b7e; }
.feedback-icon { flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%; color: white; background: var(--success); display: grid; place-items: center; font-weight: 1000; }
.incorrect-feedback .feedback-icon { background: var(--civics-red); }
.feedback-copy { min-width: 0; display: flex; flex-direction: column; gap: 2px; line-height: 1.12; }
.feedback-copy strong { font-size: 1rem; }
.feedback-copy span { font-size: clamp(.72rem, 1vw, .9rem); font-weight: 750; }
.continue-button { flex: 0 0 auto; margin-left: auto; color: white; background: var(--charcoal); }
.primary-button { margin-top: 22px; color: white; background: var(--civics-red); font-size: 1rem; }
.result-state p { margin: 0 0 8px; color: var(--civics-red); font-weight: 950; letter-spacing: .12em; }
.result-state h2 { max-width: 620px; }
.result-state .result-icon { animation: winner-pop 700ms ease-in-out infinite alternate; }

.panel-footer { position: absolute; right: 22px; bottom: 13px; left: 28px; justify-content: space-between; color: #7b716c; font-size: .67rem; }
.source-button { color: var(--civics-red-dark); font-size: .67rem; font-weight: 850; text-decoration: underline; }
.hidden { display: none !important; }
button:focus-visible { outline: 4px solid #f5b400; outline-offset: 2px; }

@keyframes pulse { to { filter: brightness(.93); } }
@keyframes paw-bounce { to { transform: translateY(-13px) rotate(-7deg); } }
@keyframes winner-pop { to { transform: scale(1.08) rotate(3deg); } }

@media (max-height: 760px) {
  :root { --board-size: min(42vw, calc(100vh - 220px), 470px); }
  .app-header { height: 80px; }
  .brand-logo { width: 60px; height: 60px; }
  .game-layout { height: calc(100vh - 80px); padding-block: 10px 12px; }
  .scoreboard { min-height: 48px; margin-bottom: 7px; }
  .team-card { height: 44px; }
  .board-actions { margin-top: 8px; }
  .question-panel { padding-top: 16px; }
}

@media (max-width: 1120px) {
  .game-layout { grid-template-columns: minmax(440px, 46%) 1fr; padding-inline: 12px; gap: 12px; }
  .question-panel { padding-inline: 20px; }
  .team-card { min-width: 112px; }
  .team-name, .question-total { display: none; }
}

@media (max-width: 999px) {
  .app-header, .game-layout { display: none; }
  .small-screen-notice {
    position: fixed;
    inset: 0;
    padding: 28px;
    background: linear-gradient(145deg, #fffdfb, #f2e9e5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
  }
  .small-screen-notice img { width: min(34vw, 190px); height: auto; margin-bottom: 18px; }
  .small-screen-notice h1 { color: var(--charcoal); font-size: clamp(2rem, 7vw, 3.5rem); }
  .small-screen-notice p { max-width: 580px; margin: 18px auto; color: #655b56; font-size: clamp(1rem, 2.7vw, 1.35rem); line-height: 1.45; }
  .small-screen-notice strong { color: var(--civics-red-dark); font-size: 1.05rem; }
}

/* Web-only publisher footer */
.footer-company { margin-left: auto; margin-right: 18px; font-weight: 850; letter-spacing: .06em; text-transform: uppercase; }
