:root {
  --celtic-green: #065f46;
  --celtic-gold: #d97706;
  --gold-light: #fef3c7;
  --emerald: #10b981;
  --ink: #0f172a;
  --muted: #64748b;
  --border: #cbd5e1;
  --surface: #ffffff;
  --bg: #f8fafc;
  --slate-dark: #1e293b;
  --display-font: "Bricolage Grotesque", system-ui, sans-serif;
  --body-font: "Lexend", system-ui, sans-serif;
  --radius-lg: 16px;
  --radius-md: 12px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 8px 24px rgba(6, 95, 70, 0.12);
  --shadow-lg: 0 16px 36px rgba(15, 23, 42, 0.18);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--body-font);
  background-color: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  background: var(--surface);
  border-bottom: 2px solid #e2e8f0;
  padding: 0.75rem 1.25rem;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.back-link {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--celtic-green);
  text-decoration: none;
  background: #ecfdf5;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  transition: all 0.2s;
}

.back-link:hover {
  background: #d1fae5;
}

.logo-icon {
  font-size: 2.2rem;
  line-height: 1;
}

.brand h1 {
  font-family: var(--display-font);
  font-size: 1.45rem;
  font-weight: 800;
  color: #064e3b;
  line-height: 1.2;
}

.subtitle {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
}

.header-stats {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.stat-pill {
  background: #f1f5f9;
  border: 1px solid var(--border);
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.stat-label {
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
}

.stat-val {
  font-weight: 800;
  color: var(--celtic-green);
}

.ctrl-btn {
  background: #f1f5f9;
  border: 1px solid var(--border);
  font-size: 1.1rem;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s;
}

.ctrl-btn:hover {
  background: #e2e8f0;
}

/* Main Container */
.main-container {
  max-width: 1080px;
  width: 100%;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Mode Navigation Tabs */
.mode-tabs {
  display: flex;
  gap: 0.75rem;
  background: #e2e8f0;
  padding: 0.35rem;
  border-radius: 999px;
  align-self: center;
  max-width: 100%;
  overflow-x: auto;
}

.mode-tab {
  font-family: var(--body-font);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.6rem 1.4rem;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: #475569;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

.mode-tab.active {
  background: var(--surface);
  color: var(--celtic-green);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Quest Banner */
.quest-banner {
  background: linear-gradient(135deg, #064e3b 0%, #065f46 100%);
  color: #ffffff;
  border-radius: var(--radius-lg);
  padding: 1.6rem 1.8rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.quest-banner::after {
  content: "☘️";
  position: absolute;
  right: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 4rem;
  opacity: 0.2;
  pointer-events: none;
}

.quest-tag {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #fde68a;
  letter-spacing: 0.08em;
  margin-bottom: 0.35rem;
}

.quest-banner h2 {
  font-family: var(--display-font);
  font-size: 1.55rem;
  font-weight: 800;
  margin-bottom: 0.3rem;
}

.quest-banner p {
  font-size: 0.95rem;
  color: #d1fae5;
  max-width: 720px;
}

/* Views */
.game-view {
  display: none;
  flex-direction: column;
  gap: 1.5rem;
  animation: fadeIn 0.3s ease;
}

.game-view.active {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* VIEW 1: HERO & RELIC MATCH */
.match-game-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 768px) {
  .match-game-grid {
    grid-template-columns: 1fr;
  }
}

.match-col {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.col-title {
  font-family: var(--display-font);
  font-size: 1.15rem;
  font-weight: 800;
  color: #1e293b;
}

.cards-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.celtic-card {
  background: var(--surface);
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 1.1rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  gap: 0.85rem;
  box-shadow: var(--shadow-sm);
  user-select: none;
}

.celtic-card:hover {
  transform: translateY(-2px);
  border-color: #6ee7b7;
  box-shadow: 0 4px 12px rgba(6, 95, 70, 0.1);
}

.celtic-card.selected {
  border-color: var(--celtic-gold);
  background: #fffbeb;
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.25);
  transform: scale(1.02);
}

.celtic-card.matched {
  border-color: var(--emerald);
  background: #ecfdf5;
  opacity: 0.75;
  cursor: default;
  pointer-events: none;
}

.celtic-card.matched .card-title {
  color: #065f46;
}

.celtic-card.wrong-shake {
  animation: shake 0.4s ease;
  border-color: #e11d48;
  background: #fff1f2;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.card-icon {
  font-size: 2rem;
  line-height: 1;
  flex-shrink: 0;
}

.card-info {
  flex: 1;
}

.card-title {
  font-family: var(--display-font);
  font-size: 1.1rem;
  font-weight: 700;
  color: #0f172a;
}

.card-desc {
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.4;
  margin-top: 0.2rem;
}

.match-footer {
  display: flex;
  justify-content: center;
}

.action-btn {
  font-family: var(--body-font);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.75rem 1.6rem;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.action-btn.primary {
  background: var(--celtic-green);
  color: #fff;
  box-shadow: 0 4px 14px rgba(6, 95, 70, 0.3);
}

.action-btn.primary:hover {
  background: #064e3b;
  transform: translateY(-2px);
}

.action-btn.secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
}

.action-btn.secondary:hover {
  background: #f1f5f9;
}

/* VIEW 2: MAP OF IRELAND */
.map-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 820px) {
  .map-layout {
    grid-template-columns: 1fr;
  }
}

.map-svg-wrap {
  background: #ecfeff;
  border: 2px solid #cffafe;
  border-radius: var(--radius-lg);
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

#ireland-myth-svg {
  width: 100%;
  max-height: 540px;
}

.island-bg {
  fill: #d1fae5;
  stroke: #059669;
  stroke-width: 2.5;
  filter: drop-shadow(2px 6px 10px rgba(5, 150, 105, 0.15));
}

.prov-line {
  fill: none;
  stroke: #10b981;
  stroke-width: 1.5;
  stroke-dasharray: 4 4;
}

.prov-label {
  font-family: var(--display-font);
  font-size: 11px;
  font-weight: 800;
  fill: #065f46;
  opacity: 0.45;
  letter-spacing: 0.1em;
}

.map-marker {
  cursor: pointer;
  transition: all 0.2s;
}

.map-marker:hover .marker-dot {
  fill: #d97706;
  transform: scale(1.2);
}

.marker-pulse {
  fill: rgba(16, 185, 129, 0.35);
  animation: pulseMarker 2s infinite ease-in-out;
  transform-origin: center;
}

@keyframes pulseMarker {
  0% { transform: scale(0.8); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 0.2; }
  100% { transform: scale(0.8); opacity: 0.8; }
}

.marker-dot {
  fill: #047857;
  stroke: #ffffff;
  stroke-width: 2;
  transition: all 0.2s;
}

.marker-icon {
  font-size: 13px;
  pointer-events: none;
}

.marker-name {
  font-family: var(--body-font);
  font-size: 10px;
  font-weight: 700;
  fill: #064e3b;
  paint-order: stroke;
  stroke: #ffffff;
  stroke-width: 2.5px;
  stroke-linejoin: round;
}

.map-site-panel {
  background: var(--surface);
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-lg);
  padding: 1.6rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.site-badge {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #047857;
  background: #d1fae5;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  display: inline-block;
  margin-bottom: 0.3rem;
}

.site-header h3 {
  font-family: var(--display-font);
  font-size: 1.5rem;
  font-weight: 800;
  color: #064e3b;
}

.site-lore {
  font-size: 0.95rem;
  line-height: 1.6;
  color: #334155;
  margin-bottom: 1rem;
}

.site-quest-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.2rem;
}

.site-quest-box h4 {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--celtic-gold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}

.site-quest-box p {
  font-size: 0.95rem;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 0.8rem;
}

.site-answers {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.site-ans-btn {
  font-family: var(--body-font);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}

.site-ans-btn:hover {
  background: #ecfdf5;
  border-color: #6ee7b7;
}

.site-ans-btn.correct {
  background: #d1fae5;
  border-color: var(--emerald);
  color: #065f46;
  font-weight: 700;
}

.site-ans-btn.wrong {
  background: #ffe4e6;
  border-color: #f43f5e;
  color: #9f1239;
}

/* VIEW 3: LORE MASTER QUIZ */
.quiz-container {
  background: var(--surface);
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-sm);
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.quiz-progress-bar {
  height: 8px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.quiz-progress-fill {
  height: 100%;
  width: 10%;
  background: linear-gradient(90deg, #10b981, #065f46);
  border-radius: 999px;
  transition: width 0.3s;
}

.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
}

.quiz-topic-tag {
  background: #fef3c7;
  color: #92400e;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  text-transform: uppercase;
  font-size: 0.72rem;
}

.quiz-question-text {
  font-family: var(--display-font);
  font-size: 1.35rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.4;
}

.quiz-options-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.quiz-opt-btn {
  font-family: var(--body-font);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.9rem 1.2rem;
  border-radius: var(--radius-md);
  border: 2px solid #e2e8f0;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.quiz-opt-btn:hover {
  border-color: #6ee7b7;
  background: #f8fafc;
}

.quiz-opt-btn.correct {
  border-color: var(--emerald);
  background: #ecfdf5;
  color: #065f46;
  font-weight: 700;
}

.quiz-opt-btn.wrong {
  border-color: #f43f5e;
  background: #fff1f2;
  color: #9f1239;
}

.quiz-explanation {
  font-size: 0.92rem;
  line-height: 1.5;
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius-md);
  display: none;
}

.quiz-explanation.show {
  display: block;
}

/* Modal Popup */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1.5rem;
}

.modal-overlay.open {
  display: flex;
}

.modal-card {
  background: var(--surface);
  border-radius: 24px;
  padding: 2.2rem;
  max-width: 440px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-icon {
  font-size: 3.5rem;
  line-height: 1;
  margin-bottom: 0.8rem;
}

.modal-card h3 {
  font-family: var(--display-font);
  font-size: 1.6rem;
  font-weight: 800;
  color: #064e3b;
}

.modal-card p {
  color: var(--muted);
  margin-top: 0.5rem;
  font-size: 0.95rem;
}

.modal-stars {
  font-size: 2rem;
  letter-spacing: 0.3rem;
  margin: 1rem 0 0.5rem;
}
