/**
 * game.css - Extracted from game.html
 * All game-specific styles
 */

/* ============================================================
   CSS VARIABLES
   ============================================================ */
:root {
  --bg: #0b0f10;
  --panel: #0f1719;
  --ink: #f5deb3;
  --muted: #cfc4a6;
  --teal: #55A1B3;
  --sky: #69D5FF;
  --red: #e11d48;
  --green: #22c55e;
  --card: #0e1416;
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
  html {
    height: -webkit-fill-available;
  }
  
  body {
    min-height: -webkit-fill-available;
  }
}

/* ============================================================
   BASE STYLES
   ============================================================ */
* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: #0b0f10;
  color: #fff;
  font-family: 'Nunito Sans', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
}

/* ============================================================
   HEADER
   ============================================================ */
.header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: linear-gradient(180deg, rgba(11,15,16,.95), rgba(11,15,16,.75));
  backdrop-filter: blur(6px);
  border-bottom: 1px solid rgba(85,161,179,.25);
}

.wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.yk-logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  user-select: none;
  animation: ykPop .4s ease;
}

@keyframes ykPop {
  from {
    opacity: 0;
    transform: translateY(4px) scale(.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.yk-mark {
  width: 44px;
  height: 44px;
  display: block;
}

.yk-word {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.yk-you, .yk-know {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 800;
  letter-spacing: .5px;
  font-size: clamp(22px, 4.2vw, 34px);
}

.yk-you {
  color: var(--ink);
  text-shadow: 0 0 10px rgba(245,222,179,.15);
  transform: translateY(1px);
}

.yk-know {
  background: linear-gradient(90deg, var(--sky), var(--teal));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 18px rgba(105,213,255,.18);
  margin-top: -2px;
}

.yk-tag {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .2px;
  opacity: .9;
}

/* ============================================================
   NAVIGATION
   ============================================================ */
.nav-container {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.nav-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid var(--teal);
  background: transparent;
  color: var(--ink);
  min-height: 44px;
  white-space: nowrap;
}

.nav-button:hover {
  background: rgba(85,161,179,0.1);
  border-color: var(--sky);
}

.nav-button svg {
  width: 16px;
  height: 16px;
}

.profile-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  border: none;
  min-height: 44px;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.profile-btn.logged-in {
  background: var(--teal);
  color: var(--bg);
}

.profile-btn.logged-in:hover {
  background: #4a8f9f;
}

.profile-btn.guest {
  background: linear-gradient(90deg, var(--teal), var(--sky));
  color: var(--bg);
  box-shadow: 0 4px 0 #2b7685;
}

.profile-btn.guest:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #2b7685;
}

.profile-btn svg {
  width: 16px;
  height: 16px;
}

.nickname-display {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: var(--panel);
  border: 1px solid var(--teal);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 100;
  display: none;
}

.profile-dropdown.show {
  display: block;
  animation: dropdownSlide 0.2s ease;
}

@keyframes dropdownSlide {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.profile-dropdown-header {
  color: var(--ink);
  font-weight: 700;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(85,161,179,0.2);
  word-break: break-word;
}

.profile-dropdown-item {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  border-radius: 6px;
  font-size: 14px;
  margin-top: 4px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.profile-dropdown-item:hover {
  background: rgba(85,161,179,0.1);
  color: var(--ink);
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
.main {
  max-width: 780px;
  margin: 28px auto;
  padding: 0 16px;
}

.card {
  background: var(--panel);
  border: 1px solid rgba(85,161,179,.18);
  border-radius: 16px;
  padding: 18px 16px;
  box-shadow: 0 18px 48px rgba(0,0,0,.28);
}

/* ============================================================
   GAME HUD
   ============================================================ */
.hud {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.badge {
  font: 800 12px/1 'Barlow Condensed', sans-serif;
  background: var(--teal);
  color: #0b0f10;
  padding: 7px 10px;
  border-radius: 10px;
  box-shadow: 0 2px 0 #2b7685;
}

.progress {
  display: flex;
  gap: 6px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(245,222,179,.2);
  outline: 1px solid rgba(245,222,179,.25);
}

.dot.correct {
  background: var(--green);
  outline-color: var(--green);
}

.dot.wrong {
  background: var(--red);
  outline-color: var(--red);
}

.score {
  color: #fff;
  font-weight: 800;
}

.timer {
  color: #cdefff;
  font-weight: 800;
}

/* ============================================================
   GAME SCREEN
   ============================================================ */
#game {
  position: relative;
}

.qbox {
  background: var(--card);
  border: 1px solid rgba(85,161,179,.18);
  border-radius: 14px;
  padding: 18px;
}

.qtext {
  font: 800 22px/1.25 'Barlow Condensed', sans-serif;
  margin: 0 0 12px;
}

.opts {
  display: grid;
  gap: 10px;
}

.opt {
  position: relative;
  background: #101a1d;
  border: 1px solid #2a3a3f;
  border-radius: 14px;
  color: #fff;
  padding: 14px 12px;
  text-align: center;
  font-weight: 900;
  cursor: pointer;
  transition: transform .08s ease, border-color .2s ease, background .2s ease, box-shadow .2s ease, opacity .3s ease;
  box-shadow: 0 0 0 0 rgba(85,161,179,0);
  -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) and (pointer: fine) {
  .opt:hover {
    background: #121e22;
    border-color: var(--teal);
  }
}

.opt:active {
  transform: scale(.98);
}

.opt.correct {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(85,161,179,.25) inset, 0 0 12px rgba(105,213,255,.18);
}

.opt.wrong {
  border-color: var(--red);
  box-shadow: 0 0 0 2px rgba(225,29,72,.15) inset;
}

.opt:focus, .opt:focus-visible {
  outline: none;
}

.opt, .opt * {
  -webkit-user-select: none;
  user-select: none;
}

.opt {
  -webkit-touch-callout: none;
  touch-action: none;
}

.opt.fadeout {
  opacity: .28;
  transform: scale(.98);
}

.hold-ring {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hold-ring rect {
  fill: none;
  stroke: var(--sky);
  stroke-width: 3;
  opacity: 0;
  transition: opacity .12s ease;
}

.opt.reveal {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(85,161,179,.35) inset, 0 0 12px rgba(105,213,255,.22);
  animation: revealPulse .5s ease-in-out 2;
}

@keyframes revealPulse {
  0% {
    box-shadow: 0 0 0 2px rgba(85,161,179,.0) inset;
  }
  45% {
    box-shadow: 0 0 0 6px rgba(85,161,179,.35) inset, 0 0 18px rgba(105,213,255,.35);
  }
  100% {
    box-shadow: 0 0 0 2px rgba(85,161,179,.3) inset;
  }
}

.feedback {
  min-height: 1.6em;
  margin: 10px 2px 2px;
  color: var(--sky);
  font-weight: 800;
  text-align: center;
}

/* ============================================================
   VISUAL EFFECTS
   ============================================================ */
#hitFlash {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 10;
  background: radial-gradient(circle at center, rgba(225,17,72,.35), rgba(225,17,72,0) 55%);
  opacity: 0;
  transition: opacity .25s ease;
}

#hitFlash.show {
  opacity: 1;
}

#timeWarning {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 8;
  background: radial-gradient(circle at center, rgba(225,17,72,.25), rgba(225,17,72,0) 60%);
  opacity: 0;
  transition: opacity .3s ease;
}

#timeWarning.pulse {
  animation: warningPulse .6s ease-in-out;
}

@keyframes warningPulse {
  0% { opacity: 0; }
  50% { opacity: 1; }
  100% { opacity: 0; }
}

#confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9;
}

/* ============================================================
   RESULTS SCREEN
   ============================================================ */
.results h2 {
  margin: 0 0 16px;
  font: 800 32px/1 'Barlow Condensed', sans-serif;
  color: var(--ink);
}

.results h3 {
  margin: 0 0 12px;
  font: 800 22px/1 'Barlow Condensed', sans-serif;
  color: var(--ink);
}

.kpi {
  display: flex;
  gap: 8px;
  margin: 0 0 20px;
  flex-wrap: wrap;
}

.chip {
  background: #101a1d;
  border: 1px solid rgba(105,213,255,.25);
  color: #fff;
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 800;
  font-size: 14px;
}

.shareSection {
  margin: 20px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sharePreviewCard {
  background: #10171a;
  border: 2px solid rgba(85,161,179,.25);
  border-radius: 12px;
  padding: 16px;
}

.sharePreviewLabel {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.sharePreviewText {
  font-family: monospace;
  font-size: 16px;
  line-height: 1.6;
  color: #fff;
  white-space: pre-wrap;
}

.shareButtons {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.shareButtons .btn {
  border: none;
  border-radius: 12px;
  padding: 14px 20px;
  font-weight: 900;
  cursor: pointer;
  background: linear-gradient(90deg, var(--teal), var(--sky));
  color: #0b0f10;
  box-shadow: 0 6px 0 #2b7685;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  transition: transform 0.1s ease;
}

.shareButtons .btn:active {
  transform: translateY(2px);
  box-shadow: 0 4px 0 #2b7685;
}

.shareButtons .btn.outline {
  background: transparent;
  color: var(--ink);
  border: 2px solid var(--teal);
  box-shadow: none;
  flex: 0 0 auto;
  min-width: 90px;
  padding: 14px 16px;
}

.socialShare {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.socialBtn {
  flex: 1;
  min-width: 140px;
  background: #0f1518;
  border: 1px solid rgba(105,213,255,.22);
  color: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.socialBtn:hover {
  background: #151d21;
  border-color: rgba(105,213,255,.35);
}

.socialBtn:active {
  transform: scale(0.98);
}

.socialBtn svg {
  opacity: 0.8;
}

.shareLegend {
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  padding: 8px;
  background: rgba(85,161,179,.05);
  border-radius: 8px;
  line-height: 1.4;
}

.resultsLeaderboard {
  margin: 32px 0 24px;
  padding: 20px;
  background: #0e1416;
  border: 1px solid rgba(85,161,179,.15);
  border-radius: 12px;
}

.sectionHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.viewAllLink {
  color: var(--sky);
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  transition: color 0.2s ease;
}

.viewAllLink:hover {
  color: var(--teal);
}

.resultsLeaderboard .lb-list {
  display: grid;
  gap: 6px;
}

.resultsLeaderboard .lb-row {
  background: #10171a;
  border: 1px solid rgba(85,161,179,.15);
  border-radius: 10px;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: 28px minmax(100px, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}

.resultsLeaderboard .lb-row.user-highlight {
  background: #1a2f35;
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(85,161,179,.15);
}

.resultsLeaderboard .lb-row .rank {
  font-weight: 800;
  color: #cdefff;
  opacity: 0.9;
  font-size: 14px;
}

.resultsLeaderboard .lb-row:nth-child(1) .rank {
  color: #FFD700;
}

.resultsLeaderboard .lb-row:nth-child(2) .rank {
  color: #C0C0C0;
}

.resultsLeaderboard .lb-row:nth-child(3) .rank {
  color: #CD7F32;
}

.resultsLeaderboard .lb-row .nickname {
  font-weight: 800;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.resultsLeaderboard .lb-row .score {
  font-weight: 800;
  color: #fff;
  white-space: nowrap;
}

.resultsLeaderboard .lb-row .time {
  color: #cdefff;
  font-size: 14px;
  opacity: 0.85;
}

.resultsLeaderboard .loading {
  text-align: center;
  color: var(--muted);
  padding: 20px;
  font-size: 14px;
}

.historyLink {
  text-align: center;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid rgba(85,161,179,.15);
}

.historyLink .btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.historyLink .btn span:last-child {
  font-size: 16px;
}

.review {
  margin-top: 24px;
}

.revItem {
  border-top: 1px solid rgba(105,213,255,.15);
  padding: 10px 0;
}

.revQ {
  font-weight: 800;
  margin: 0 0 6px;
}

.revAns {
  font-size: 14px;
  color: #cdefff;
}

.revAns .wrong {
  color: var(--red);
}

.revAns .correct {
  color: var(--green);
}

.revAns .timeout {
  color: #ffdd87;
}

/* ============================================================
   NO QUIZ SCREEN
   ============================================================ */
.no-quiz {
  text-align: center;
  padding: 40px 20px;
}

.no-quiz h2 {
  color: var(--ink);
  margin: 0 0 12px;
}

.no-quiz p {
  color: var(--muted);
  margin: 0 0 20px;
}

.countdown {
  font: 800 48px/1 'Barlow Condensed', sans-serif;
  color: var(--sky);
  margin: 20px 0;
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.hidden {
  display: none !important;
}

/* ============================================================
   RESPONSIVE - MOBILE
   ============================================================ */
@media (max-width: 480px) {
  .yk-mark {
    width: 36px;
    height: 36px;
  }
  
  .yk-tag {
    display: none;
  }
  
  .nav-container {
    gap: 6px;
  }
  
  .nav-button .btn-text-full {
    display: none !important;
  }
  
  .nav-button .btn-text-short {
    display: inline !important;
  }
  
  .nav-button {
    padding: 10px 12px;
    font-size: 13px;
    min-width: 44px;
  }
  
  .profile-btn {
    padding: 10px !important;
    min-width: 44px !important;
    max-width: 44px !important;
  }
  
  .profile-btn .nickname-display {
    display: none !important;
    width: 0 !important;
    overflow: hidden !important;
  }
  
  .profile-btn #profileBtnText {
    display: none !important;
    width: 0 !important;
    overflow: hidden !important;
  }
  
  .profile-btn #profileChevron {
    display: none !important;
    width: 0 !important;
  }
  
  .profile-dropdown {
    right: 0;
    left: auto;
    min-width: 160px;
  }
  
  .shareButtons {
    flex-direction: column;
  }
  
  .shareButtons .btn.outline {
    width: 100%;
  }
  
  .socialShare {
    flex-direction: column;
  }
  
  .socialBtn {
    width: 100%;
  }
  
  .sectionHeader {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .resultsLeaderboard .lb-row {
    grid-template-columns: 24px 1fr auto;
    font-size: 13px;
  }
  
  .resultsLeaderboard .lb-row .time {
    display: none;
  }
}

@media (min-width: 641px) {
  .nav-button .btn-text-short {
    display: none;
  }
  
  .nav-button .btn-text-full {
    display: inline;
  }
}
/* ==================== SOURCE CITATIONS ==================== */
.source-citation {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(85,161,179,0.1);
}

.source-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--sky);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 6px;
  transition: all 0.2s;
  background: rgba(105,213,255,0.05);
}

.source-link:hover {
  background: rgba(105,213,255,0.15);
  transform: translateX(2px);
}

.source-icon {
  flex-shrink: 0;
  opacity: 0.8;
}

.source-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

@media(max-width: 640px) {
  .source-text {
    max-width: 150px;
  }
}