/* ============================================================
   PhysioCase — style.css  v5
   Navy + cyan palette, centred layout, conditional side ads
   ============================================================ */

:root {
  --navy:        #1a2f5e;
  --blue:        #2557a7;
  --blue-mid:    #3b82c4;
  --blue-pale:   #daeaf8;
  --cyan:        #00bcd4;
  --cyan-pale:   #e0f7fa;
  --bone:        #f4f7fb;
  --bone-dark:   #e4eaf4;
  --ink:         #0d1b3e;
  --ink-mid:     #2c3e6b;
  --ink-light:   #6b7a99;
  --accent:      #c4734a;
  --accent-pale: #f5e4d8;
  --success:     #1e7e4a;
  --success-pale:#d4eddf;
  --danger:      #9b2335;
  --danger-pale: #f5d0d5;
  --warning:     #856a10;
  --warning-pale:#fef3cd;
  --radius-sm:   6px;
  --radius-md:   12px;
  --radius-lg:   20px;
  --shadow-sm:   0 1px 4px rgba(13,27,62,.08);
  --shadow-md:   0 4px 24px rgba(13,27,62,.13);
  --font-serif:  'Playfair Display', Georgia, serif;
  --font-sans:   'DM Sans', system-ui, sans-serif;
  --transition:  0.2s ease;
  --content-w:   680px;   /* max width of the game column */
  --ad-w:        160px;   /* width of each sidebar ad */
  --ad-gap:      24px;    /* gap between ad and content */
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--bone);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
}

/* ── HEADER ─────────────────────────────────────── */
.site-header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--blue) 100%);
  position: sticky; top: 0; z-index: 100;
  border-bottom: 3px solid var(--cyan);
  box-shadow: 0 2px 12px rgba(13,27,62,.2);
}
.header-inner {
  /* Always centred, never wider than content column */
  max-width: var(--content-w);
  margin: 0 auto;
  padding: .65rem 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: .6rem; }
.logo-img { height: 38px; width: auto; filter: drop-shadow(0 1px 3px rgba(0,0,0,.3)); }
.logo-text { font-family: var(--font-serif); font-size: 1.55rem; font-weight: 700; color: #fff; letter-spacing: -.5px; }
.logo-accent { color: var(--cyan); }
.header-nav { display: flex; align-items: center; gap: .6rem; }
.btn-icon {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,.35);
  background: transparent; color: #fff;
  font-size: .95rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition), border-color var(--transition);
}
.btn-icon:hover { background: rgba(255,255,255,.15); border-color: rgba(255,255,255,.6); }
.header-date { font-size: .75rem; color: rgba(255,255,255,.55); font-style: italic; }

/* ── DISCLAIMER ─────────────────────────────────── */
.disclaimer-banner {
  background: var(--warning-pale);
  border-bottom: 1px solid rgba(133,106,16,.2);
  padding: .5rem 1.5rem;
  display: flex; align-items: center; gap: .6rem; justify-content: center;
}
.disclaimer-banner p { font-size: .73rem; color: var(--warning); line-height: 1.4; }
.disclaimer-icon { font-size: .9rem; flex-shrink: 0; }

/* ── PAGE WRAPPER ────────────────────────────────────
   Centres the game column. When the viewport is wide
   enough (>= 1180px) and the ad asides are uncommented,
   they float to the sides without shifting the content.
───────────────────────────────────────────────────── */
.page-wrapper {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: var(--ad-gap);
  padding: 0 1rem;    /* breathing room on small screens */
}

/* ── AD SIDEBARS ─────────────────────────────────────
   Hidden by default. Become visible only when the full
   layout fits: content (680) + 2 ads (160 each) + 4 gaps
   (24 each) = 1096px minimum. We use 1180px for comfort.
───────────────────────────────────────────────────── */
.ad-sidebar {
  display: none;          /* hidden until wide enough */
  flex-shrink: 0;
  width: var(--ad-w);
  position: sticky;
  top: 80px;             /* below sticky header */
  min-height: 600px;
  background: var(--bone-dark);
  border: 1px dashed rgba(0,0,0,.1);
  border-radius: var(--radius-sm);
  font-size: .72rem;
  color: var(--ink-light);
  align-items: center;
  justify-content: center;
}
@media (min-width: 1180px) {
  .ad-sidebar { display: flex; }
}

/* ── GAME CONTAINER ──────────────────────────────── */
.game-container {
  width: 100%;
  max-width: var(--content-w);
  padding: 2rem 0 3rem;
  /* No horizontal padding here — page-wrapper handles it */
}

/* ── PROGRESS BAR ───────────────────────────────── */
.clue-progress-bar {
  display: flex; align-items: flex-start; justify-content: center;
  margin-bottom: 2.5rem; padding: 1.25rem .5rem .5rem;
}
.clue-step { display: flex; flex-direction: column; align-items: center; gap: .4rem; flex: 0 0 auto; }
.clue-dot {
  width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid var(--bone-dark); background: var(--bone);
  color: var(--ink-light); font-size: .82rem; font-weight: 500;
  display: flex; align-items: center; justify-content: center;
  transition: all .35s ease; position: relative; z-index: 2; user-select: none;
}
.clue-dot.active   { background: var(--blue);      border-color: var(--blue);     color: #fff; box-shadow: 0 0 0 4px var(--blue-pale); }
.clue-dot.unlocked { background: var(--blue-pale);  border-color: var(--blue-mid); color: var(--blue); }
.clue-dot.correct  { background: var(--blue);       border-color: var(--blue);     color: #fff; }
.clue-label { font-size: .62rem; color: var(--ink-light); text-align: center; max-width: 68px; line-height: 1.2; }
.clue-connector { flex: 1; height: 2px; background: var(--bone-dark); margin-top: 17px; min-width: 16px; transition: background .35s ease; }
.clue-connector.filled { background: var(--blue-mid); }

/* ── CLUE CARDS ─────────────────────────────────── */
.clues-area { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 2rem; }
.clue-card {
  background: #fff; border-radius: var(--radius-md);
  border: 1px solid var(--bone-dark); padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
  animation: slideIn .4s ease forwards; opacity: 0; transform: translateY(8px);
}
@keyframes slideIn { to { opacity:1; transform:translateY(0); } }
.clue-card-header { display: flex; align-items: center; gap: .6rem; margin-bottom: .75rem; }
.clue-tag {
  font-size: .68rem; font-weight: 500; text-transform: uppercase; letter-spacing: .08em;
  color: var(--blue); background: var(--blue-pale); padding: .2rem .65rem; border-radius: 999px;
}
.clue-num { font-size: .68rem; color: var(--ink-light); }
.clue-card-body { font-size: .97rem; color: var(--ink-mid); line-height: 1.7; }
.clue-card.last-resort { border-color: var(--cyan); background: linear-gradient(135deg, #fff 0%, var(--cyan-pale) 100%); }
.clue-card.last-resort .clue-tag { background: var(--cyan-pale); color: #00838f; }

/* ── GUESS SECTION ──────────────────────────────── */
.guess-section {
  background: #fff; border-radius: var(--radius-lg);
  border: 1px solid var(--bone-dark); padding: 1.5rem; box-shadow: var(--shadow-md);
}
.guess-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 1rem; flex-wrap: wrap; gap: .5rem; }
.guess-header h2 { font-family: var(--font-serif); font-size: 1.15rem; }
.guess-counter { font-size: .78rem; color: var(--ink-light); font-style: italic; }
.guess-input-row { display: flex; gap: .75rem; margin-bottom: 1.25rem; }
.autocomplete-wrapper { flex: 1; position: relative; }
.guess-input {
  width: 100%; height: 46px;
  border: 1.5px solid var(--bone-dark); border-radius: var(--radius-sm);
  padding: 0 1rem; font-family: var(--font-sans); font-size: .95rem;
  color: var(--ink); background: var(--bone); outline: none;
  transition: border-color var(--transition);
}
.guess-input:focus { border-color: var(--blue-mid); background: #fff; }
.guess-input:disabled { opacity: .5; cursor: not-allowed; }
.autocomplete-list {
  position: absolute; top: 100%; left: 0; right: 0;
  background: #fff; border: 1px solid var(--bone-dark); border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  list-style: none; max-height: 220px; overflow-y: auto;
  z-index: 50; display: none; box-shadow: var(--shadow-md);
}
.autocomplete-list.open { display: block; }
.autocomplete-list li {
  padding: .6rem 1rem; font-size: .9rem; cursor: pointer;
  border-bottom: 1px solid var(--bone-dark); color: var(--ink-mid);
  transition: background var(--transition);
}
.autocomplete-list li:last-child { border-bottom: none; }
.autocomplete-list li:hover,
.autocomplete-list li.active { background: var(--blue-pale); color: var(--blue); }
.autocomplete-list li.already-guessed { color: var(--ink-light); text-decoration: line-through; cursor: not-allowed; background: var(--bone); pointer-events: none; }
.btn-guess {
  height: 46px; padding: 0 1.5rem;
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-mid) 100%);
  color: #fff; border: none; border-radius: var(--radius-sm);
  font-family: var(--font-sans); font-size: .9rem; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  transition: opacity var(--transition), transform var(--transition);
  box-shadow: 0 2px 8px rgba(37,87,167,.3);
}
.btn-guess:hover:not(:disabled)  { opacity: .88; }
.btn-guess:active:not(:disabled) { transform: scale(.97); }
.btn-guess:disabled { background: var(--bone-dark); color: var(--ink-light); cursor: not-allowed; box-shadow: none; }

.guess-history { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1.25rem; }
.guess-item { display: flex; align-items: center; gap: .75rem; padding: .6rem .9rem; border-radius: var(--radius-sm); font-size: .88rem; animation: popIn .3s cubic-bezier(.34,1.56,.64,1); }
@keyframes popIn { from { transform:scale(.92); opacity:0; } to { transform:scale(1); opacity:1; } }
.guess-item.wrong   { background: var(--danger-pale);  border: 1px solid rgba(155,35,53,.2);  color: var(--danger); }
.guess-item.correct { background: var(--success-pale); border: 1px solid rgba(30,126,74,.2);  color: var(--success); }
.guess-item-icon { font-size: 1rem; flex-shrink: 0; }
.guess-item-text { flex: 1; font-weight: 500; }
.guess-item-note { font-size: .78rem; opacity: .75; font-style: italic; }

.action-buttons { display: flex; gap: .75rem; flex-wrap: wrap; }
.btn-next-clue {
  flex: 1; min-width: 160px; height: 44px;
  background: transparent; border: 1.5px solid var(--blue-mid);
  border-radius: var(--radius-sm); color: var(--blue);
  font-family: var(--font-sans); font-size: .88rem; font-weight: 500;
  cursor: pointer; transition: background var(--transition);
}
.btn-next-clue:hover:not(:disabled) { background: var(--blue-pale); }
.btn-next-clue:disabled { border-color: var(--bone-dark); color: var(--ink-light); cursor: not-allowed; }
.btn-skip {
  height: 44px; padding: 0 1.25rem;
  background: transparent; border: 1.5px solid var(--bone-dark);
  border-radius: var(--radius-sm); color: var(--ink-light);
  font-family: var(--font-sans); font-size: .85rem; cursor: pointer; transition: all var(--transition);
}
.btn-skip:hover:not(:disabled) { border-color: var(--danger); color: var(--danger); background: var(--danger-pale); }
.btn-skip:disabled { opacity: .4; cursor: not-allowed; }

/* ── BOOK RECOMMENDATIONS ───────────────────────── */
.book-recommendations { margin-top: 2rem; background: #fff; border-radius: var(--radius-md); border: 1px solid var(--bone-dark); padding: 1.25rem 1.5rem; box-shadow: var(--shadow-sm); }
.book-recommendations.hidden { display: none; }
.books-title { font-family: var(--font-serif); font-size: 1.05rem; margin-bottom: .4rem; }
.books-disclaimer { font-size: .72rem; color: var(--ink-light); margin-bottom: 1rem; font-style: italic; }
.books-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px,1fr)); gap: .75rem; }
.book-card { display: flex; align-items: center; gap: .75rem; padding: .75rem; border-radius: var(--radius-sm); border: 1px solid var(--bone-dark); background: var(--bone); text-decoration: none; color: var(--ink); transition: box-shadow var(--transition), border-color var(--transition); }
.book-card:hover { box-shadow: var(--shadow-md); border-color: var(--blue-mid); }
.book-cover-placeholder { font-size: 2rem; flex-shrink: 0; }
.book-info { display: flex; flex-direction: column; gap: .15rem; }
.book-title  { font-size: .82rem; font-weight: 500; line-height: 1.3; }
.book-author { font-size: .72rem; color: var(--ink-light); }

/* ── FOOTER ─────────────────────────────────────── */
.site-footer {
  background: linear-gradient(135deg, var(--navy) 0%, var(--blue) 100%);
  padding: .9rem 1.5rem; text-align: center; margin-top: auto;
}
.site-footer p { font-size: .78rem; color: rgba(255,255,255,.65); }
.site-footer a { color: var(--cyan); text-decoration: none; transition: opacity var(--transition); }
.site-footer a:hover { opacity: .8; text-decoration: underline; }

/* ── MODALS ─────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(13,27,62,.65);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 1.5rem;
  opacity: 0; pointer-events: none; transition: opacity .3s ease;
}
.modal-overlay[inert]  { visibility: hidden; }
.modal-overlay.open    { opacity: 1; pointer-events: all; visibility: visible; }
.modal {
  background: #fff; border-radius: var(--radius-lg);
  width: 100%; max-width: 500px; max-height: 90vh;
  overflow-y: auto; padding: 2rem;
  box-shadow: 0 24px 64px rgba(13,27,62,.22);
  transform: translateY(20px); transition: transform .3s ease;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-sm { max-width: 360px; text-align: center; }
.modal-close-row { display: flex; justify-content: flex-end; margin-bottom: .5rem; }
.btn-close-modal {
  width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--bone-dark); background: var(--bone);
  color: var(--ink-light); font-size: .75rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
}
.btn-close-modal:hover { background: var(--bone-dark); }
.modal-title { font-family: var(--font-serif); font-size: 1.35rem; color: var(--ink); margin-bottom: 1.5rem; text-align: center; }

.modal-header { text-align: center; padding: 1rem 0 .5rem; }
.result-emoji { font-size: 3.5rem; display: block; margin-bottom: .5rem; }
.result-title { font-family: var(--font-serif); font-size: 1.5rem; margin-bottom: .25rem; }
.result-title.win  { color: var(--success); }
.result-title.lose { color: var(--danger); }
.result-subtitle { font-size: .88rem; color: var(--ink-light); }
.result-score { display: inline-block; margin-top: .75rem; font-size: 1.1rem; font-weight: 500; color: var(--blue); background: var(--blue-pale); padding: .3rem 1.1rem; border-radius: 999px; }

/* Container for the avg-score + percentile lines, shown below the score badge */
.result-stats-block {
  margin-top: .85rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .3rem;
}

/* Base style for both stat lines */
.result-stat-line {
  font-size: .82rem;
  color: var(--ink-light);
  min-height: 1.1rem;      /* reserves space so the block doesn't jump on async fill */
  line-height: 1.4;
}

/* Percentile line gets a subtle highlight */
.result-stat-highlight {
  font-weight: 600;
  color: var(--blue);
  font-size: .88rem;
}
.correct-answer-box { background: var(--bone); border-radius: var(--radius-md); border-left: 4px solid var(--blue); padding: 1rem 1.25rem; margin-bottom: 1rem; }
.correct-answer-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--blue); font-weight: 500; margin-bottom: .25rem; }
.correct-answer-text  { font-family: var(--font-serif); font-size: 1.2rem; font-weight: 700; }
.explanation-section  { background: var(--bone); border-radius: var(--radius-md); padding: 1.25rem; margin-top: 1rem; }
.explanation-section h3 { font-family: var(--font-serif); font-size: 1rem; color: var(--blue); margin-bottom: .75rem; border-bottom: 1px solid var(--bone-dark); padding-bottom: .5rem; margin-top: .75rem; }
.explanation-section h3:first-child { margin-top: 0; }
.explanation-section p  { font-size: .88rem; color: var(--ink-mid); line-height: 1.7; margin-bottom: .75rem; }
.clue-link-list { list-style: none; display: flex; flex-direction: column; gap: .4rem; }
.clue-link-list li { font-size: .83rem; color: var(--ink-mid); display: flex; gap: .5rem; }
.clue-link-list li::before { content: '\2192'; color: var(--blue-mid); flex-shrink: 0; }
.modal-footer { text-align: center; margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--bone-dark); }
.btn-primary {
  height: 46px; padding: 0 2rem;
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-mid) 100%);
  color: #fff; border: none; border-radius: var(--radius-sm);
  font-family: var(--font-sans); font-size: .95rem; font-weight: 500;
  cursor: pointer; transition: opacity var(--transition);
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(37,87,167,.3);
}
.btn-primary:hover { opacity: .88; }
.btn-primary.btn-danger { background: var(--danger); box-shadow: none; }
.btn-primary.btn-danger:hover { opacity: .85; }
.btn-secondary {
  height: 46px; padding: 0 2rem;
  background: transparent; border: 1.5px solid var(--bone-dark);
  border-radius: var(--radius-sm); font-family: var(--font-sans); font-size: .95rem; color: var(--ink-mid);
  cursor: pointer; transition: background var(--transition);
  margin-top: .6rem; display: inline-flex; align-items: center; justify-content: center;
}
.btn-secondary:hover { background: var(--bone); }
.next-game-label { margin-top: 1.2rem; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-light); }
.next-game-countdown { font-family: var(--font-serif); font-size: 2.6rem; font-weight: 700; color: var(--blue); letter-spacing: .06em; margin-top: .1rem; font-variant-numeric: tabular-nums; }
.streak-display    { margin-top: .75rem; font-size: 1rem; font-weight: 500; color: var(--accent); min-height: 1.4rem; }


.giveup-icon { font-size: 3rem; margin-bottom: .5rem; }
.giveup-body { font-size: .9rem; color: var(--ink-mid); line-height: 1.55; margin-bottom: 1.5rem; }
.giveup-actions { display: flex; flex-direction: column; gap: .5rem; align-items: center; }

.howto-steps { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 1.5rem; }
.howto-step  { display: flex; align-items: flex-start; gap: .9rem; }
.howto-num   { width: 28px; height: 28px; border-radius: 50%; background: var(--blue-pale); color: var(--blue); font-weight: 500; font-size: .85rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.howto-step p { font-size: .9rem; color: var(--ink-mid); line-height: 1.55; }
.scoring-table { background: var(--bone); border-radius: var(--radius-md); padding: 1rem; margin-bottom: 1rem; }
.scoring-table h3 { font-size: .82rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-light); margin-bottom: .75rem; }
.scoring-table table { width: 100%; font-size: .85rem; }
.scoring-table td { padding: .3rem 0; color: var(--ink-mid); }
.score-val { text-align: right; font-weight: 500; color: var(--blue); }
.scoring-note { font-size: .78rem; color: var(--ink-light); margin-top: .5rem; font-style: italic; }
.disclaimer-box { background: var(--warning-pale); border-radius: var(--radius-sm); padding: .75rem 1rem; font-size: .82rem; color: var(--warning); line-height: 1.5; }

.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: .75rem; margin-bottom: 1.5rem; }
.stat-box   { background: var(--bone); border-radius: var(--radius-md); padding: .9rem .5rem; text-align: center; }
.stat-num   { font-family: var(--font-serif); font-size: 1.6rem; font-weight: 700; color: var(--blue); display: block; }
.stat-label { font-size: .7rem; color: var(--ink-light); line-height: 1.25; margin-top: .15rem; }
.stats-distribution h3 { font-size: .82rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-light); margin-bottom: .75rem; }
.dist-row  { display: flex; align-items: center; gap: .6rem; margin-bottom: .4rem; }
.dist-label { font-size: .8rem; color: var(--ink-mid); width: 16px; text-align: center; font-variant-numeric: tabular-nums; }
.dist-bar-wrap { flex: 1; background: var(--bone-dark); border-radius: 999px; height: 14px; overflow: hidden; }
.dist-bar { height: 100%; background: var(--blue-mid); border-radius: 999px; transition: width .8s ease; display: flex; align-items: center; justify-content: flex-end; padding-right: .35rem; }
.dist-bar.highlight { background: var(--blue); }
.dist-bar.dist-loss { background: var(--danger); }
.dist-count { font-size: .72rem; color: #fff; font-weight: 500; }

/* ── UTILITIES ──────────────────────────────────── */
.hidden { display: none !important; }
@keyframes shake { 0%,100%{transform:translateX(0)} 20%{transform:translateX(-8px)} 40%{transform:translateX(8px)} 60%{transform:translateX(-5px)} 80%{transform:translateX(5px)} }
.shake { animation: shake .4s ease; }
.toast {
  position: fixed; bottom: 2rem; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--ink); color: #fff; font-size: .88rem;
  padding: .65rem 1.4rem; border-radius: 999px;
  z-index: 300; opacity: 0; transition: opacity .25s ease, transform .25s ease;
  white-space: nowrap; pointer-events: none;
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── RESPONSIVE ─────────────────────────────────── */
@media (max-width: 600px) {
  .clue-label      { display: none; }
  .header-date     { display: none; }
  .game-container  { padding: 1.25rem 0 2.5rem; }
  .stats-grid      { grid-template-columns: repeat(2,1fr); }
  .guess-input-row { flex-direction: column; }
  .btn-guess       { width: 100%; height: 44px; }
  .next-game-countdown { font-size: 2rem; }
  .books-grid      { grid-template-columns: 1fr; }
  .modal           { padding: 1.5rem 1.25rem; }
  .logo-text       { font-size: 1.3rem; }
  .page-wrapper    { padding: 0 .75rem; }
}