:root {
  --primary: #0284c7;
  --primary-dark: #0369a1;
  --primary-light: #e0f2fe;
  --emerald: #10b981;
  --amber: #f59e0b;
  --rose: #e11d48;
  --indigo: #6366f1;
  --ink: #0f172a;
  --muted: #64748b;
  --border: #cbd5e1;
  --surface: #ffffff;
  --bg: #f8fafc;
  --xray-bg: #09131f;
  --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.05);
  --shadow-md: 0 8px 24px rgba(2, 132, 199, 0.12);
  --shadow-lg: 0 16px 36px rgba(15, 23, 42, 0.16);
}

* {
  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: 1120px;
  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(--primary);
  text-decoration: none;
  background: var(--primary-light);
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  transition: all 0.2s;
}

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

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

.brand h1 {
  font-family: var(--display-font);
  font-size: 1.45rem;
  font-weight: 800;
  color: #0369a1;
  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(--primary-dark);
}

.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;
}

.lang-btn {
  font-family: var(--body-font);
  font-size: 0.85rem;
  font-weight: 700;
  color: #047857;
  background: #ecfdf5;
  border-color: #a7f3d0;
}

/* Main Container */
.main-container {
  max-width: 1100px;
  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.65rem;
  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.92rem;
  font-weight: 700;
  padding: 0.6rem 1.3rem;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: #475569;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

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

/* View Intro */
.view-intro {
  background: var(--surface);
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-lg);
  padding: 1.4rem 1.6rem;
  box-shadow: var(--shadow-sm);
}

.view-tag {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #0369a1;
  background: #e0f2fe;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  display: inline-block;
  margin-bottom: 0.35rem;
}

.view-intro h2 {
  font-family: var(--display-font);
  font-size: 1.55rem;
  font-weight: 800;
  color: #0c4a6e;
}

.view-intro p {
  font-size: 0.92rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

/* 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: SKELETON SCANNER */
.scanner-layout {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 1.5rem;
  align-items: start;
}

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

.svg-scanner-wrap {
  background: var(--xray-bg);
  border: 3px solid #0284c7;
  border-radius: var(--radius-lg);
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 30px rgba(2, 132, 199, 0.25);
  position: relative;
  overflow: hidden;
}

.svg-scanner-wrap::before {
  content: "X-RAY ANATOMY SCANNER";
  position: absolute;
  top: 10px;
  left: 14px;
  font-family: monospace;
  font-size: 0.7rem;
  font-weight: 700;
  color: #38bdf8;
  letter-spacing: 0.15em;
  opacity: 0.8;
}

.xray-screen {
  width: 100%;
}

#skeleton-svg {
  width: 100%;
  max-height: 520px;
}

.bone-target {
  cursor: pointer;
  transition: all 0.2s;
}

.bone-shape {
  fill: #e2e8f0;
  stroke: #94a3b8;
  stroke-width: 1.5;
  transition: all 0.2s;
}

.bone-target:hover .bone-shape,
.bone-target.active .bone-shape {
  fill: #38bdf8;
  stroke: #ffffff;
  filter: drop-shadow(0 0 10px #38bdf8);
}

.hotspot-pulse {
  fill: rgba(56, 189, 248, 0.4);
  animation: pulseHotspot 2s infinite ease-in-out;
  transform-origin: center;
  pointer-events: none;
}

@keyframes pulseHotspot {
  0% { transform: scale(0.8); opacity: 0.9; }
  50% { transform: scale(1.4); opacity: 0.15; }
  100% { transform: scale(0.8); opacity: 0.9; }
}

.anatomy-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;
}

.bone-badge {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #0284c7;
  letter-spacing: 0.05em;
}

.panel-header h3 {
  font-family: var(--display-font);
  font-size: 1.6rem;
  font-weight: 800;
  color: #0c4a6e;
  margin-top: 0.2rem;
}

.gaeilge-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: #059669;
  margin-top: 0.15rem;
}

.bone-desc {
  font-size: 0.95rem;
  line-height: 1.6;
  color: #334155;
}

.fact-box {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-md);
  padding: 0.9rem 1.1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-size: 0.88rem;
  line-height: 1.5;
  color: #166534;
  margin: 0.9rem 0;
}

.fact-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.bone-challenge {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.1rem;
}

.bone-challenge h4 {
  font-size: 0.82rem;
  font-weight: 800;
  color: #0369a1;
  text-transform: uppercase;
  margin-bottom: 0.4rem;
}

.bone-challenge p {
  font-size: 0.94rem;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 0.8rem;
}

.challenge-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.bone-opt-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;
}

.bone-opt-btn:hover {
  background: #f0f9ff;
  border-color: #7dd3fc;
}

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

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

/* VIEW 2: ORGANS GRID */
.organs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.25rem;
}

.organ-card {
  background: var(--surface);
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
}

.organ-card:hover {
  transform: translateY(-4px);
  border-color: #38bdf8;
  box-shadow: var(--shadow-md);
}

.organ-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.organ-icon {
  font-size: 2.4rem;
  line-height: 1;
}

.organ-system-tag {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  background: #f1f5f9;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  color: #475569;
}

.organ-name {
  font-family: var(--display-font);
  font-size: 1.3rem;
  font-weight: 800;
  color: #0f172a;
}

.organ-gaeilge {
  font-size: 0.95rem;
  font-weight: 700;
  color: #059669;
}

.organ-desc {
  font-size: 0.9rem;
  line-height: 1.5;
  color: #475569;
}

.organ-fact {
  font-size: 0.85rem;
  background: #f8fafc;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-md);
  border-left: 3px solid #0284c7;
  color: #334155;
}

/* VIEW 3: FOOD PYRAMID */
.pyramid-layout {
  display: grid;
  grid-template-columns: 1.3fr 0.9fr;
  gap: 1.5rem;
  align-items: start;
}

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

.pyramid-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}

.pyramid-shelf {
  width: 100%;
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  border: 2px solid;
  transition: all 0.2s;
}

.shelf-label {
  font-family: var(--display-font);
  font-size: 0.92rem;
  font-weight: 800;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.shelf-recom {
  font-size: 0.78rem;
  font-weight: 600;
  opacity: 0.85;
}

.shelf-dropzone {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  min-height: 48px;
  background: rgba(255, 255, 255, 0.45);
  border-radius: 8px;
  padding: 0.4rem;
}

/* Shelf Colour Gradient Levels */
.shelf-6 {
  width: 55%;
  background: #ffe4e6;
  border-color: #f43f5e;
  color: #9f1239;
}

.shelf-5 {
  width: 65%;
  background: #ffedd5;
  border-color: #fb923c;
  color: #9a3412;
}

.shelf-4 {
  width: 75%;
  background: #fef3c7;
  border-color: #f59e0b;
  color: #92400e;
}

.shelf-3 {
  width: 85%;
  background: #e0e7ff;
  border-color: #6366f1;
  color: #3730a3;
}

.shelf-2 {
  width: 95%;
  background: #ecfeff;
  border-color: #06b6d4;
  color: #0e7490;
}

.shelf-1 {
  width: 100%;
  background: #dcfce7;
  border-color: #22c55e;
  color: #15803d;
}

.food-tray-panel {
  background: var(--surface);
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.tray-title {
  font-family: var(--display-font);
  font-size: 1.25rem;
  font-weight: 800;
  color: #0f172a;
}

.tray-sub {
  font-size: 0.88rem;
  color: var(--muted);
}

.food-items-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  min-height: 160px;
  background: #f8fafc;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 0.9rem;
}

.food-pill {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font-size: 0.88rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  user-select: none;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
}

.food-pill:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: 0 4px 10px rgba(2, 132, 199, 0.15);
}

.food-pill.selected {
  border-color: var(--primary);
  background: #e0f2fe;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.25);
}

.food-pill.placed {
  font-size: 0.8rem;
  padding: 0.25rem 0.65rem;
  background: #ffffff;
  border-color: transparent;
  cursor: default;
}

.tray-actions {
  display: flex;
  justify-content: flex-end;
}

/* VIEW 4: 5 SENSES */
.senses-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.25rem;
}

.sense-card {
  background: var(--surface);
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
}

.sense-card:hover {
  transform: translateY(-3px);
  border-color: #38bdf8;
  box-shadow: var(--shadow-md);
}

.sense-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sense-icon {
  font-size: 2.6rem;
  line-height: 1;
}

.sense-organ-tag {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  background: #e0f2fe;
  color: #0369a1;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
}

.sense-name {
  font-family: var(--display-font);
  font-size: 1.35rem;
  font-weight: 800;
  color: #0f172a;
}

.sense-gaeilge {
  font-size: 0.95rem;
  font-weight: 700;
  color: #059669;
}

.sense-desc {
  font-size: 0.92rem;
  line-height: 1.55;
  color: #334155;
}

.sense-test {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.8rem 1rem;
  font-size: 0.85rem;
  line-height: 1.45;
  color: #1e293b;
}

/* Action Buttons */
.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(--primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.3);
}

.action-btn.primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
}

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

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

/* 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: #0369a1;
}

.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;
}
