@import url('tokens.css');
/* Fonts carregades via <link> al HTML per evitar duplicats */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; }

body {
  background: linear-gradient(135deg, var(--bg-gradient-1), var(--bg-gradient-2));
  background-attachment: fixed;
  color: var(--text-color);
  font-family: var(--text-font);
  min-height: 100vh; /* fallback */
  min-height: 100dvh;
  overflow-x: hidden; /* només bloquegem horitzontal; vertical lliure */
  overflow-y: auto;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--accent-color); border-radius: 3px; }

/* ═══════════════════════════════════════════════
   CONTENIDOR PRINCIPAL
   Ocupa TOTA l'alçada disponible. Flux intern.
═══════════════════════════════════════════════ */
.game-container {
  width: 100%;
  max-width: 1400px;
  min-height: 100vh; /* fallback */
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  /* Sense caixa: fons transparent, sense vores ni arrodoniments */
  background: transparent;
  padding: 12px clamp(14px, 3vw, 32px) 16px;
  position: relative;
}

/* ─── TOP NAV ─── */
.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--panel-border);
  margin-bottom: 14px;
  flex-shrink: 0;
}

.back-home-btn {
  color: var(--text-muted);
  text-decoration: none;
  font-family: var(--title-font);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color 0.2s;
}
.back-home-btn:hover { color: var(--accent-color); }

.ideorum-mark-game {
  display: flex;
  align-items: center;
  height: 60px;
  text-decoration: none;
  transition: opacity 0.2s ease;
}
.ideorum-mark-game:hover { opacity: 0.75; }
.ideorum-mark-game img { height: 100%; width: auto; display: block; max-width: none; }
@media (max-width: 900px) {
  .ideorum-mark-game { height: 48px; }
}
@media (max-width: 600px) {
  .ideorum-mark-game { height: 38px; }
}

/* ═══════════════════════════════════════════════
   PANTALLA D'INICI
═══════════════════════════════════════════════ */
#main-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
#start-screen {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

/* Títol compacte — 2 línies màxim */
.title-banner {
  text-align: center;
  flex-shrink: 0;
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--panel-border);
}
.title-banner h1 {
  font-family: var(--title-font);
  font-size: clamp(1.3rem, 3.5vw, 2.8rem);
  font-weight: 700;
  color: var(--text-color);
  letter-spacing: 0.02em;
  line-height: 1.15;
}
.title-banner span {
  display: block;
  font-size: clamp(0.65rem, 1.5vw, 0.9rem);
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-top: 4px;
}

/* Dues columnes — creixen amb el contingut, body fa scroll si cal */
.start-content-wrapper {
  display: flex;
  gap: 16px;
  flex: 1;
  min-height: 0;
}

.intro-col, .objectives-col {
  flex: 1;
  background: #ffffff;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: 0 2px 8px rgba(31,41,55,0.04);
}

.intro-text {
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.stats-explainer { display: grid; gap: 8px; }

.stat-desc {
  background: rgba(138,150,108,0.08);
  padding: 8px 12px;
  border-radius: 8px;
  border-left: 3px solid var(--accent-color);
  font-size: 0.87rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.4;
}

.learning-objectives h2 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text-color);
  display: flex;
  align-items: center;
  gap: 8px;
}
.learning-objectives ul { list-style: none; }
.learning-objectives li {
  margin-bottom: 10px;
  padding-left: 22px;
  position: relative;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.45;
}
.learning-objectives li::before {
  content: '→';
  color: var(--accent-color);
  font-weight: bold;
  position: absolute;
  left: 0; top: 0;
}

/* Botó COMENÇAR — sempre visible al fons */
.start-btn-container {
  padding-top: 12px;
  text-align: center;
  flex-shrink: 0;
}
.start-btn {
  background: linear-gradient(135deg, var(--accent-color), #0284c7);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  padding: 13px 40px;
  font-family: var(--title-font);
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 2px;
  cursor: pointer;
  box-shadow: 0 6px 18px var(--accent-glow);
  width: 100%;
  max-width: 480px;
  transition: all 0.25s ease;
  text-transform: uppercase;
}
.start-btn:hover { transform: translateY(-2px); box-shadow: 0 10px 28px var(--accent-glow); }
.start-btn:active { transform: translateY(1px); }

#start-error {
  margin-top: 8px;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 600;
  background: rgba(244,67,54,0.1);
  padding: 8px;
  border-radius: 8px;
  display: none;
}

/* ═══════════════════════════════════════════════
   UI DEL JOC
═══════════════════════════════════════════════ */
#game-ui {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* Capçalera: títol + torn */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--panel-border);
  flex-shrink: 0;
  gap: 10px;
}
header h1 {
  font-size: clamp(0.9rem, 2vw, 1.5rem);
  font-weight: 600;
  color: var(--text-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.turn-counter {
  font-family: var(--number-font);
  font-size: 0.9rem;
  font-weight: 700;
  background: rgba(56,189,248,0.1);
  color: var(--accent-color);
  padding: 5px 12px;
  border-radius: 7px;
  border: 1px solid rgba(56,189,248,0.3);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Barres de stats — fila horitzontal compacta */
.resources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
  flex-shrink: 0;
}
.resource-box {
  background: rgba(31,41,55,0.10);
  border: 1px solid var(--panel-border);
  border-radius: 9px;
  padding: 8px 6px;
  text-align: center;
}
.resource-header {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 5px;
  margin-bottom: 5px;
}
.resource-icon { font-size: 1rem; }
.resource-name {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  line-height: 1.2;
}
.progress-bar-container {
  width: 100%;
  height: 5px;
  background: rgba(31,41,55,0.08);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s cubic-bezier(0.4,0,0.2,1);
  position: relative;
}
.progress-bar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.45), transparent);
  animation: shimmer 2s infinite;
}
@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

#bar-stat1 { background-color: var(--stat1-color); box-shadow: 0 0 6px var(--stat1-color); }
#bar-stat2 { background-color: var(--stat2-color); box-shadow: 0 0 6px var(--stat2-color); }
#bar-stat3 { background-color: var(--stat3-color); box-shadow: 0 0 6px var(--stat3-color); }
#bar-stat4 { background-color: var(--stat4-color); box-shadow: 0 0 6px var(--stat4-color); }

.resource-value {
  font-family: var(--number-font);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-color);
  margin-top: 4px;
}

/* Zona principal: text + opcions costat a costat */
.game-content-wrapper {
  display: flex;
  gap: 14px;
  flex: 1;
  min-height: 0;
}

.story-area {
  flex: 1.3;
  background: #ffffff;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(31, 41, 55, 0.04);
  padding: 16px 18px;
  font-size: 0.95rem;
  line-height: 1.65;
  overflow-y: auto;
  position: relative;
  min-height: 0;
}
.story-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0.13;
  z-index: 0;
  border-radius: 12px;
}
.story-area > * { position: relative; z-index: 1; }
.story-area p { margin-bottom: 12px; color: #374151; }

.choices-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  padding-right: 2px;
}

.choice-btn {
  background: rgba(31,41,55,0.04);
  color: var(--text-color);
  border: 1px solid rgba(31,41,55,0.08);
  border-radius: 9px;
  padding: 12px 14px;
  font-family: var(--text-font);
  font-size: 0.9rem;
  line-height: 1.5;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  word-wrap: break-word;
  flex-shrink: 0;
}
.choice-btn:hover {
  background: rgba(31,41,55,0.08);
  border-color: var(--accent-color);
  transform: translateX(3px);
}
.choice-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  background: rgba(31,41,55,0.06);
  border-color: rgba(31,41,55,0.04);
}

.consequence-box {
  margin-top: 14px;
  background: rgba(56,189,248,0.07);
  border-left: 3px solid var(--accent-color);
  padding: 12px 14px;
  border-radius: 0 9px 9px 0;
  animation: fadeIn 0.35s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.consequence-box h3 {
  color: var(--accent-color);
  font-size: 0.82rem;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.effect-line {
  margin: 5px 0;
  font-family: var(--number-font);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 7px;
}
.effect-pos { color: #15803d; }
.effect-neg { color: #b91c1c; }

.continue-btn {
  background: var(--accent-color);
  color: #1f2937;
  border: none;
  border-radius: 9px;
  padding: 12px;
  font-family: var(--title-font);
  font-weight: 800;
  font-size: 0.9rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  margin-top: 8px;
  transition: all 0.25s ease;
  width: 100%;
  flex-shrink: 0;
}
.continue-btn:hover { background: var(--accent-color-dark); transform: translateY(-1px); }

/* ═══════════════════════════════════════════════
   PANTALLA FINAL (overlay)
═══════════════════════════════════════════════ */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(249,247,242,0.97);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 30px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  overflow-y: auto;
}
.overlay.active { opacity: 1; pointer-events: all; }

.overlay h2 {
  font-family: var(--title-font);
  font-size: clamp(1.6rem, 4vw, 2.8rem);
  font-weight: 800;
  margin-bottom: 14px;
}
.overlay.victory h2 { color: var(--stat3-color); text-shadow: 0 0 25px rgba(74,222,128,0.5); }
.overlay.defeat h2  { color: var(--stat4-color); text-shadow: 0 0 25px rgba(248,113,113,0.5); }

.overlay p {
  font-size: clamp(0.95rem, 1.05vw, 1.05rem);
  color: var(--text-muted);
  max-width: min(960px, 92vw);
  line-height: 1.6;
  margin-bottom: 14px;
  padding: 0 10px;
  text-align: left;
}
.overlay p:first-of-type { margin-top: 4px; }
.overlay p em { display: block; text-align: center; margin-top: 6px; }

/* En pantalles grans (desktop), ampliem encara més per evitar scroll
   en finals novel·lístics llargs. Mantenim text llegible (~80ch). */
@media (min-width: 1200px) {
  .overlay p { max-width: 1040px; }
}

.end-stats {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
  flex-wrap: wrap;
  justify-content: center;
}
.end-stat-item {
  background: rgba(31,41,55,0.04);
  padding: 9px 16px;
  border-radius: 9px;
  font-size: 0.9rem;
  box-shadow: inset 0 0 0 1px rgba(31,41,55,0.08);
}
.end-stat-item strong {
  font-family: var(--number-font);
  color: var(--accent-color);
  margin-left: 4px;
}

.end-buttons { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.restart-btn {
  background: #ffffff;
  color: #1f2937;
  border: none;
  border-radius: 9px;
  padding: 12px 28px;
  font-family: var(--title-font);
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.25s ease;
  text-transform: uppercase;
  text-decoration: none;
  display: inline-block;
}
.restart-btn.secondary-btn {
  background: rgba(31,41,55,0.08);
  color: var(--text-color);
  border: 1px solid rgba(31,41,55,0.18);
}
.restart-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(31,41,55,0.18); }
.restart-btn.secondary-btn:hover {
  background: rgba(31,41,55,0.15);
  border-color: var(--accent-color);
}

.restart-btn.share-btn {
  background: var(--accent-color);
  color: #ffffff;
  border: 1px solid var(--accent-color);
}
.restart-btn.share-btn:hover {
  background: var(--accent-color-dark);
  border-color: var(--accent-color-dark);
  box-shadow: 0 8px 20px var(--accent-glow);
}
.restart-btn.share-btn:disabled {
  opacity: 0.6;
  cursor: wait;
  transform: none;
  box-shadow: none;
}

/* ─── Banner "Reprendre partida" ─── */
.resume-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  background: linear-gradient(135deg, rgba(29,174,159,0.12), rgba(29,174,159,0.05));
  border: 1px solid rgba(29,174,159,0.4);
  border-radius: 12px;
  padding: 14px 18px;
  margin: 0 auto 22px;
  max-width: 720px;
  width: 100%;
  animation: resumeFadeIn 0.4s ease-out;
}
@keyframes resumeFadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.resume-info {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.resume-icon { font-size: 1.8rem; line-height: 1; flex-shrink: 0; }
.resume-info > div { display: flex; flex-direction: column; min-width: 0; }
.resume-info strong {
  color: var(--text-color);
  font-family: var(--title-font);
  font-weight: 700;
  font-size: 0.95rem;
}
.resume-meta {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 400;
  margin-top: 2px;
}
.resume-actions { display: flex; gap: 8px; flex-shrink: 0; }
.resume-btn {
  font-family: var(--title-font);
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.18s ease;
  border: 1px solid transparent;
}
.resume-primary {
  background: var(--accent-color);
  color: #ffffff;
}
.resume-primary:hover {
  background: var(--accent-color-dark);
  box-shadow: 0 4px 12px var(--accent-glow);
}
.resume-secondary {
  background: transparent;
  color: var(--text-muted);
  border-color: rgba(31,41,55,0.15);
}
.resume-secondary:hover {
  color: var(--text-color);
  border-color: rgba(31,41,55,0.35);
}
@media (max-width: 600px) {
  .resume-banner { flex-direction: column; align-items: stretch; }
  .resume-actions { justify-content: stretch; }
  .resume-btn { flex: 1; }
}

/* ─── Panell de fites desbloquejades ─── */
.achievements-panel {
  margin: 18px auto 14px;
  max-width: 560px;
  width: 100%;
  text-align: left;
  animation: achFadeIn 0.5s ease-out;
}
@keyframes achFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.ach-title {
  font-family: var(--title-font);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent-color);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  text-align: center;
  margin-bottom: 10px;
}
.ach-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ach-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(29, 174, 159, 0.08);
  border: 1px solid rgba(29, 174, 159, 0.25);
  border-radius: 10px;
  padding: 10px 14px;
  animation: achPop 0.45s cubic-bezier(.4,1.6,.5,1) backwards;
}
.ach-item.ach-global {
  background: rgba(250, 166, 51, 0.08);
  border-color: rgba(250, 166, 51, 0.35);
}
.ach-item:nth-child(1) { animation-delay: 0.1s; }
.ach-item:nth-child(2) { animation-delay: 0.2s; }
.ach-item:nth-child(3) { animation-delay: 0.3s; }
.ach-item:nth-child(4) { animation-delay: 0.4s; }
.ach-item:nth-child(n+5) { animation-delay: 0.5s; }
@keyframes achPop {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}
.ach-icon { font-size: 1.6rem; line-height: 1; flex-shrink: 0; }
.ach-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ach-text strong {
  color: #1f2937;
  font-weight: 700;
  font-size: 0.95rem;
  font-family: var(--title-font);
}
.ach-text span {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 300;
  line-height: 1.35;
}

/* ═══════════════════════════════════════════════
   RESPONSIVE — MÒBIL / TABLET (≤ 900px amplada)
   Aquí el contenidor passa a ser scroll de pàgina
═══════════════════════════════════════════════ */
@media (max-width: 900px) {
  body {
    height: auto;
    overflow: auto;
    align-items: flex-start;
  }
  .game-container {
    width: 100%;
    max-width: 100%;
    height: auto;
    min-height: 100dvh;
    padding: 12px 14px 20px;
    overflow: visible;
  }

  /* Start screen: tot en columna, scroll de pàgina */
  #start-screen { overflow: visible; height: auto; }
  .start-content-wrapper {
    flex-direction: column;
    overflow: visible;
    height: auto;
  }
  .intro-col, .objectives-col {
    overflow: visible;
    height: auto;
  }
  .start-btn { max-width: 100%; }

  /* Joc: layout vertical */
  #game-ui { overflow: visible; height: auto; }
  .game-content-wrapper {
    flex-direction: column;
    overflow: visible;
    height: auto;
  }
  .story-area { overflow: visible; height: auto; flex: none; }
  .choices-area { overflow: visible; flex: none; padding-right: 0; padding-bottom: 16px; }

  .resources-grid { grid-template-columns: repeat(2, 1fr); }

  /* Overlay final: fixed */
  .overlay { position: fixed; border-radius: 0; }
}

/* ─── Mòbil petit ─── */
@media (max-width: 480px) {
  .game-container { padding: 10px 10px 16px; }
  .title-banner h1 { font-size: 1.2rem; }
  header h1 { font-size: 0.85rem; }
  .choice-btn { font-size: 0.85rem; padding: 10px 11px; }
  .resources-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .resource-name { font-size: 0.6rem; }
  .resource-value { font-size: 0.85rem; }
  .intro-col, .objectives-col { padding: 14px 14px; }
  .start-btn { padding: 12px 24px; font-size: 1rem; }
}

/* ═══════════════════════════════════════════════
   PANTALLES BAIXES D'AULA (≤ 720px alçada, desktop)
   Reduïm paddings i marges per evitar overflow
═══════════════════════════════════════════════ */
@media (max-height: 720px) and (min-width: 901px) {
  .game-container { padding: 8px 24px 10px; }
  .title-banner { padding-bottom: 6px; margin-bottom: 6px; }
  .title-banner h1 { font-size: clamp(1.1rem, 2.8vw, 2.2rem); }
  .start-content-wrapper { gap: 12px; }
  .intro-col, .objectives-col { padding: 12px 14px; }
  .intro-text { font-size: 0.85rem; line-height: 1.5; margin-bottom: 10px; }
  .stat-desc { font-size: 0.8rem; padding: 6px 10px; }
  .learning-objectives li { font-size: 0.82rem; margin-bottom: 7px; }
  .start-btn-container { padding-top: 8px; }
  .start-btn { padding: 10px 32px; font-size: 0.95rem; }
  header { margin-bottom: 6px; padding-bottom: 6px; }
  .resources-grid { gap: 6px; margin-bottom: 6px; }
  .resource-box { padding: 6px 4px; }
  .game-content-wrapper { gap: 10px; }
  .story-area { padding: 12px 14px; font-size: 0.9rem; line-height: 1.55; }
}

/* ═══════════════════════════════════════════════
   PANTALLES MOLT BAIXES (≤ 600px alçada)
═══════════════════════════════════════════════ */
@media (max-height: 600px) and (min-width: 901px) {
  .game-container { padding: 6px 20px 8px; }
  .title-banner h1 { font-size: 1rem; }
  .title-banner span { font-size: 0.6rem; margin-top: 2px; }
  .stats-explainer { gap: 5px; }
  .stat-desc { font-size: 0.75rem; padding: 5px 8px; }
  .resource-box { padding: 5px 3px; }
  .resource-icon { font-size: 0.85rem; }
  .resource-value { font-size: 0.8rem; margin-top: 2px; }
  .progress-bar-container { height: 4px; }
}

/* ═══════════════════════════════════════════════
   PANTALLES MOLT AMPLES (≥ 1600px)
   Limitem ample del contingut per llegibilitat
═══════════════════════════════════════════════ */
@media (min-width: 1600px) {
  .story-area { font-size: 1rem; line-height: 1.7; }
  .choice-btn { font-size: 0.95rem; }
}

/* ═══════════════════════════════════════════════
   ACCESSIBILITAT (a11y) · WCAG 2.1 AA
═══════════════════════════════════════════════ */
/* Text només per a lectors de pantalla */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Skip link — apareix només quan rep focus */
.skip-link {
  position: absolute;
  top: -40px;
  left: 8px;
  background: var(--accent-color, #1DAE9F);
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 6px;
  font-weight: 700;
  text-decoration: none;
  z-index: 10000;
  font-family: 'Outfit', sans-serif;
}
.skip-link:focus {
  top: 8px;
  outline: 3px solid var(--brand-orange);
  outline-offset: 2px;
}

/* Focus visible global (WCAG 2.4.7) */
:focus-visible {
  outline: 3px solid var(--brand-orange) !important;
  outline-offset: 3px !important;
  border-radius: 4px;
}
button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  box-shadow: 0 0 0 5px rgba(232, 146, 61, 0.30);
}

/* Reducció de moviment (WCAG 2.3.3) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ═══════════════════════════════════════════════
   LOMLOE · Guia docent plegable a la pantalla d'inici
═══════════════════════════════════════════════ */
.lomloe-panel {
  margin-top: 18px;
  background: rgba(31, 41, 55, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.lomloe-panel > summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent-color);
  list-style: none;
  padding: 4px 0;
  letter-spacing: 0.3px;
  user-select: none;
}
.lomloe-panel > summary::-webkit-details-marker { display: none; }
.lomloe-panel > summary::after {
  content: ' ▸';
  font-size: 0.7rem;
  transition: transform 0.2s ease;
  display: inline-block;
}
.lomloe-panel[open] > summary::after { transform: rotate(90deg); }
.lomloe-body {
  padding-top: 10px;
  display: grid;
  gap: 12px;
}
.lomloe-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: 0.82rem;
  color: var(--text-color);
  opacity: 0.85;
}
.lomloe-section h4 {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-color);
  margin-bottom: 6px;
  opacity: 0.75;
}
.lomloe-section ul {
  list-style: none;
  display: grid;
  gap: 5px;
}
.lomloe-section li {
  padding-left: 18px;
  position: relative;
  line-height: 1.45;
}
.lomloe-section li::before {
  content: '·';
  color: var(--accent-color);
  position: absolute;
  left: 6px; top: -2px;
  font-weight: bold;
  font-size: 1.1rem;
}
.lomloe-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.lomloe-chip {
  background: rgba(29, 174, 159, 0.15);
  border: 1px solid rgba(29, 174, 159, 0.4);
  color: var(--accent-color);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.4px;
}
.lomloe-copy {
  justify-self: start;
  background: transparent;
  border: 1px solid var(--accent-color);
  color: var(--accent-color);
  padding: 6px 14px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.lomloe-copy:hover {
  background: var(--accent-color);
  color: #ffffff;
}
@media print {
  .lomloe-panel { border: 1px solid #888; background: #ffffff; color: #000; }
  .lomloe-panel[open] > summary { color: #000; }
  .lomloe-chip { background: #eee; color: #000; border-color: #888; }
  .lomloe-copy { display: none; }
}

/* ═══════════════════════════════════════════════
   DIFICULTAT — picker + insígnia
═══════════════════════════════════════════════ */
.difficulty-picker {
  border: 1px solid rgba(31,41,55,0.08);
  border-radius: 10px;
  padding: 10px 14px 12px;
  margin: 14px auto;
  max-width: 480px;
  background: rgba(31,41,55,0.04);
}
.difficulty-picker legend {
  font-size: 0.78rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  padding: 0 8px;
}
.difficulty-options {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.difficulty-opt { cursor: pointer; }
.difficulty-opt input { position: absolute; opacity: 0; pointer-events: none; }
.difficulty-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1.5px solid rgba(255,255,255,0.15);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-color);
  transition: all 0.15s ease;
  user-select: none;
}
.difficulty-opt:hover .difficulty-chip { border-color: var(--accent-color); }
.difficulty-opt input:checked + .difficulty-chip {
  background: var(--accent-color);
  color: #ffffff;
  border-color: var(--accent-color);
}
.difficulty-opt input:focus-visible + .difficulty-chip {
  outline: 3px solid var(--brand-orange);
  outline-offset: 2px;
}
.difficulty-badge {
  margin-left: auto;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(29,174,159,0.15);
  border: 1px solid rgba(29,174,159,0.5);
  color: var(--accent-color);
  letter-spacing: 0.5px;
}

/* ═══════════════════════════════════════════════
   GUIA DOCENT IMPRIMIBLE
   Hidden on screen, només visible a @media print
═══════════════════════════════════════════════ */
#print-teacher-guide { display: none; }

@media print {
  /* Amaga tota la UI del simulador */
  .game-container,
  #sw-update-toast,
  .top-nav { display: none !important; }

  body { background: #fff !important; color: #000 !important; }

  #print-teacher-guide {
    display: block !important;
    font-family: 'Outfit', 'Helvetica', sans-serif;
    color: #111;
    line-height: 1.5;
    font-size: 10.5pt;
    padding: 10mm 0;
  }
  #print-teacher-guide * { color: #111 !important; }

  .pg-header {
    border-bottom: 3px solid #1DAE9F;
    padding-bottom: 10px;
    margin-bottom: 18px;
  }
  .pg-brand {
    font-size: 9pt;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #1DAE9F !important;
    font-weight: 600;
  }
  .pg-title {
    font-size: 22pt;
    font-weight: 800;
    margin-top: 2px;
    line-height: 1.15;
  }
  .pg-subtitle { font-size: 11pt; font-style: italic; color: #555 !important; }
  .pg-level {
    display: inline-block;
    margin-top: 6px;
    font-size: 9pt;
    background: #1DAE9F !important;
    color: #fff !important;
    padding: 2px 10px;
    border-radius: 3px;
    font-weight: 600;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .pg-section {
    margin: 14px 0;
    page-break-inside: avoid;
  }
  .pg-section h2 {
    font-size: 12pt;
    font-weight: 700;
    border-left: 4px solid #1DAE9F;
    padding-left: 8px;
    margin-bottom: 8px;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .pg-section p { margin: 4px 0; }
  .pg-section ul, .pg-section ol { margin: 6px 0 6px 22px; }
  .pg-section li { margin-bottom: 4px; }
  .pg-sub { margin: 8px 0; }
  .pg-sub strong { display: inline-block; margin-bottom: 3px; }
  .pg-sub .lomloe-chips { margin: 4px 0 8px 0; }

  .pg-meta-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 4px 20px;
    border: 1px solid #ccc;
    padding: 10px 14px;
    background: #f7f7f7 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  #print-teacher-guide .lomloe-chip {
    background: #e8f7f5 !important;
    border: 1px solid #1DAE9F !important;
    color: #0b6b60 !important;
    padding: 1px 8px;
    font-size: 8.5pt;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .pg-note {
    font-style: italic;
    color: #555 !important;
    font-size: 9.5pt;
    margin-top: 6px;
  }

  .pg-rubric {
    width: 100%;
    border-collapse: collapse;
    font-size: 9.5pt;
    margin-top: 6px;
  }
  .pg-rubric th, .pg-rubric td {
    border: 1px solid #888;
    padding: 5px 7px;
    text-align: left;
    vertical-align: top;
  }
  .pg-rubric th {
    background: #f0f0f0 !important;
    font-weight: 700;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .pg-footer {
    margin-top: 20px;
    padding-top: 8px;
    border-top: 1px solid #ccc;
    font-size: 8.5pt;
    text-align: center;
    color: #666 !important;
  }

  @page { margin: 14mm; }
}

/* ═══════════════════════════════════════════════
   FOOTER GLOBAL (compartit a totes les pàgines)
═══════════════════════════════════════════════ */
.site-footer {
  padding: 1rem 1.5rem 1.25rem;
  text-align: center;
  color: rgba(255,255,255,.75);
  font-size: .82rem;
  background: var(--footer-bg);
}
.site-footer a { color: rgba(255,255,255,.85); text-decoration: none; }
.site-footer a:hover, .site-footer a:focus { color: var(--accent-color); text-decoration: underline; }
.site-footer .footer-links { margin-bottom: .4rem; }
.site-footer .footer-links a { margin: 0 .5rem; }
.site-footer .license-line { font-size: .78rem; opacity: .85; }
@media (max-width: 480px) {
  .site-footer { padding: .8rem .6rem; font-size: .75rem; }
  .site-footer .footer-links a { display: inline-block; margin: .1rem .3rem; }
}
@media print { .site-footer { display: none; } }

/* ═══════════════════════════════════════════════
   MODE FOSC · overrides per a colors hardcoded
═══════════════════════════════════════════════ */
@media (prefers-color-scheme: dark) {
  .story-area { background: #1e293b; box-shadow: 0 2px 8px rgba(0,0,0,0.3); }
  .story-area p { color: #cbd5e1; }
  .intro-col, .objectives-col { background: #1e293b; box-shadow: 0 2px 8px rgba(0,0,0,0.3); }
  .restart-btn { background: #f1f5f9; color: #0f172a; }
  .restart-btn.secondary-btn { background: rgba(255,255,255,0.08); color: var(--text-color); border-color: rgba(255,255,255,0.18); }
  .restart-btn.secondary-btn:hover { background: rgba(255,255,255,0.15); }
  .turn-counter { background: rgba(94,234,212,0.10); border-color: rgba(94,234,212,0.30); }
  .stat-desc { background: rgba(201,212,168,0.10); }
  header h1, .resource-value { color: var(--text-color); }
  /* Resources box on dark bg */
  .resource-box { background: rgba(255,255,255,0.04); }
  .progress-bar-container { background: rgba(255,255,255,0.06); }
  /* Choices on dark bg */
  .choice-btn { background: rgba(255,255,255,0.03); border-color: rgba(255,255,255,0.10); }
  .choice-btn:hover { background: rgba(255,255,255,0.08); }
  /* Overlay finals */
  .overlay { background: rgba(15,23,42,0.97); }
}
