﻿:root {
  --bg-1: #04121f;
  --bg-2: #10283d;
  --panel: rgba(12, 32, 53, 0.78);
  --panel-strong: rgba(9, 24, 41, 0.94);
  --line: rgba(255, 255, 255, 0.24);
  --text: #f3fbff;
  --muted: #c6e4f2;
  --accent: #24d1a7;
  --accent-2: #49b6ff;
  --warn: #ffcc5c;
  --danger: #ff7b7b;
  --ok: #7ef7a0;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  --focus: 0 0 0 4px rgba(36, 209, 167, 0.4);
  --radius: 18px;
  --title-font: "Trebuchet MS", "Segoe UI", Tahoma, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: linear-gradient(150deg, var(--bg-1), var(--bg-2));
  color: var(--text);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

.bg-motion {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(circle at 10% 12%, rgba(73, 182, 255, 0.24), transparent 36%),
    radial-gradient(circle at 80% 8%, rgba(36, 209, 167, 0.18), transparent 32%),
    radial-gradient(circle at 35% 88%, rgba(255, 204, 92, 0.12), transparent 26%);
  animation: bgFloat 18s ease-in-out infinite alternate;
}

@keyframes bgFloat {
  from {
    transform: translateY(0px) scale(1);
    filter: saturate(1);
  }
  to {
    transform: translateY(-18px) scale(1.03);
    filter: saturate(1.08);
  }
}

body.high-contrast {
  --bg-1: #000;
  --bg-2: #0d0d0d;
  --panel: rgba(0, 0, 0, 0.95);
  --panel-strong: #000;
  --line: rgba(255, 255, 255, 0.9);
  --text: #fff;
  --muted: #fff;
  --accent: #00ff9c;
  --accent-2: #55c7ff;
  --focus: 0 0 0 4px #fff;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.glass {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.06));
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.top-nav {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin: 14px;
  border-radius: var(--radius);
  padding: 14px 16px;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 1.8rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
}

.brand-title {
  margin: 0;
  font-family: var(--title-font);
  font-size: clamp(1.3rem, 2.5vw, 2rem);
}

.brand-sub {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: clamp(0.95rem, 1.7vw, 1.1rem);
}

.status-wrap {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.status-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.28);
  font-size: clamp(0.95rem, 1.5vw, 1.08rem);
}

.nav-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn,
.select-input,
.name-input {
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.33);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: clamp(1rem, 1.6vw, 1.2rem);
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease, background 180ms ease;
}

.select-input,
.name-input {
  cursor: text;
}

.btn:hover,
.select-input:hover,
.name-input:hover {
  filter: brightness(1.1);
}

.btn:active,
.option-btn:active,
.tile:active {
  transform: translateY(1px) scale(0.99);
}

.btn:focus-visible,
.select-input:focus-visible,
.card-action:focus-visible,
.tile:focus-visible,
.option-btn:focus-visible,
.drop-zone:focus-visible,
.name-input:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.view {
  padding: 14px;
  flex: 1;
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  animation: pageIn 300ms ease;
}

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

.intro-panel,
.game-shell,
.overlay-card {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.intro-panel {
  padding: 20px;
  margin-bottom: 16px;
}

.intro-panel h2 {
  margin-top: 0;
  font-size: clamp(1.6rem, 3vw, 2.7rem);
  font-family: var(--title-font);
}

.intro-panel p,
.intro-panel li,
.game-shell p,
.game-shell li,
.overlay-card p,
.overlay-card li {
  font-size: clamp(1rem, 1.6vw, 1.24rem);
  line-height: 1.45;
}

.goal-list {
  margin: 0;
  padding-left: 20px;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.hub-card {
  position: relative;
  border-radius: 16px;
  border: 1px solid var(--line);
  padding: 18px;
  background: linear-gradient(135deg, rgba(36, 209, 167, 0.2), rgba(73, 182, 255, 0.12));
  min-height: 210px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.hub-card.active,
.hub-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.33);
}

.hub-card h3 {
  margin: 0 0 8px;
  font-size: clamp(1.3rem, 2.2vw, 1.8rem);
}

.hub-card p {
  margin: 0;
  color: var(--muted);
}

.card-action {
  margin-top: 16px;
  font-weight: 700;
  align-self: start;
}

.meter-wrap {
  margin-top: 14px;
}

.meter-track {
  height: 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 280ms ease;
}

.badges-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.badge-pill {
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.28);
  font-size: 0.95rem;
}

.game-shell {
  padding: 18px;
}

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

.game-title {
  margin: 0;
  font-size: clamp(1.4rem, 2.5vw, 2.2rem);
  font-family: var(--title-font);
}

.meta {
  color: var(--muted);
  font-size: 1rem;
}

.stat-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.stat-chip {
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 5px 12px;
  background: rgba(0, 0, 0, 0.3);
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.panel {
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  padding: 14px;
}

.microscope-viewport {
  border-radius: 16px;
  height: min(56vw, 430px);
  background: #0a2133;
  border: 2px solid rgba(255, 255, 255, 0.4);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.sample-wrap {
  width: 88%;
  height: 88%;
  border-radius: 50%;
  overflow: hidden;
  border: 4px solid rgba(255, 255, 255, 0.6);
  background: #113c58;
}

.sample-svg {
  width: 100%;
  height: 100%;
  transform-origin: center;
  transition: filter 180ms linear, transform 180ms linear;
}

.slider-wrap label {
  display: block;
  margin-bottom: 8px;
}

input[type="range"] {
  width: 100%;
}

.feedback {
  min-height: 38px;
  font-weight: 700;
}

.feedback.ok {
  color: var(--ok);
}

.feedback.bad {
  color: var(--danger);
}

.statement {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.25);
  padding: 10px;
}

.board {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.diagram-wrap {
  position: relative;
  min-height: 420px;
}

.g2-svg-host {
  width: 100%;
  height: 420px;
  position: relative;
  z-index: 1;
}

.g2-diagram-shell {
  position: relative;
  width: 100%;
  height: 420px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #0c2435;
}

.g2-cell-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.g2-zone-layer,
.g2-callout-layer {
  position: absolute;
  inset: 0;
}

.g2-zone-layer {
  z-index: 2;
}

.g2-dock-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.g2-callout-layer {
  z-index: 4;
  pointer-events: none;
}

.g2-zone-hit {
  position: absolute;
  border: 2px solid transparent;
  border-radius: 12px;
  background: rgba(100, 214, 167, 0.07);
  cursor: pointer;
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.g2-show-zones .g2-zone-hit {
  border-color: rgba(255, 255, 255, 0.42);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.g2-zone-hit.near {
  border-color: rgba(36, 209, 167, 0.9) !important;
  box-shadow: 0 0 0 4px rgba(36, 209, 167, 0.28);
}

.g2-zone-hit.candidate {
  border-color: rgba(73, 182, 255, 0.95) !important;
  box-shadow: 0 0 0 5px rgba(73, 182, 255, 0.32);
  background: rgba(73, 182, 255, 0.12);
}

.g2-zone-hit.correct {
  border-color: rgba(126, 247, 160, 0.95) !important;
  background: rgba(126, 247, 160, 0.18);
  box-shadow: 0 0 0 4px rgba(126, 247, 160, 0.24);
}

.g2-diagram-shell.dragging .g2-zone-hit {
  cursor: copy;
}

.g2-callout {
  position: absolute;
  transform: translate(-50%, -50%);
  min-width: 102px;
  max-width: 170px;
  text-align: center;
  line-height: 1.2;
  font-size: 0.84rem;
  padding: 4px 6px;
  border-radius: 9px;
  border: 1px dashed rgba(255, 255, 255, 0.82);
  background: rgba(1, 13, 20, 0.72);
  color: #fff;
  z-index: 4;
  display: none;
}

.g2-show-placeholders .g2-callout {
  display: block;
}

.g2-callout.near {
  box-shadow: 0 0 0 4px rgba(36, 209, 167, 0.25);
}

.g2-callout.candidate {
  box-shadow: 0 0 0 4px rgba(73, 182, 255, 0.26);
}

.g2-callout.correct {
  border-style: solid;
  border-color: var(--ok);
  background: rgba(64, 180, 108, 0.44);
}

.g2-dock-chip {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid rgba(126, 247, 160, 0.95);
  background: rgba(21, 74, 46, 0.88);
  color: #fff;
  font-weight: 700;
  font-size: 0.82rem;
  box-shadow: 0 0 0 4px rgba(126, 247, 160, 0.22);
}

.g2-fly-tile {
  position: fixed;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  background: linear-gradient(120deg, rgba(32, 60, 86, 0.98), rgba(17, 37, 56, 0.98));
  color: #fff;
  font-weight: 700;
  text-align: center;
  transition: transform 300ms cubic-bezier(0.22, 1, 0.36, 1), opacity 300ms ease;
  pointer-events: none;
}

.g2-fly-tile.return {
  transition-duration: 360ms;
}

.g2-fly-tile.dock {
  transition-duration: 300ms;
}

.cell-svg {
  width: 100%;
  height: 420px;
  border-radius: 12px;
  background: #112b3f;
  border: 1px solid var(--line);
}

.cell-svg .zone-target {
  cursor: pointer;
}

.cell-svg .zone-target.near-target {
  fill: rgba(36, 209, 167, 0.14);
  stroke: rgba(36, 209, 167, 0.75);
}

.cell-svg .zone-target.correct-target {
  fill: rgba(126, 247, 160, 0.18);
  stroke: rgba(126, 247, 160, 0.95);
}

.drop-zone {
  position: absolute;
  border: 2px dashed rgba(255, 255, 255, 0.86);
  border-radius: 10px;
  background: rgba(2, 10, 16, 0.62);
  color: #fff;
  padding: 5px 8px;
  font-size: 0.95rem;
  transform: scale(1);
  transition: transform 120ms ease, box-shadow 140ms ease, background 140ms ease;
}

.g2-zone-badge {
  transform: translate(-50%, -50%);
  min-width: 96px;
  max-width: 160px;
  text-align: center;
  line-height: 1.2;
  font-size: 0.86rem;
  z-index: 4;
}

.drop-zone.near {
  box-shadow: 0 0 0 4px rgba(36, 209, 167, 0.36);
  transform: scale(1.04);
}

.g2-zone-badge.near {
  transform: translate(-50%, -50%) scale(1.04);
}

.drop-zone.correct {
  border-style: solid;
  border-color: var(--ok);
  color: var(--text);
  background: rgba(64, 180, 108, 0.45);
}

.tile-bank {
  display: grid;
  gap: 10px;
  position: relative;
  z-index: 3;
}

.tile {
  padding: 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.92);
  background: linear-gradient(120deg, rgba(32, 60, 86, 0.98), rgba(17, 37, 56, 0.98));
  color: #ffffff;
  font-weight: 700;
  text-align: left;
  cursor: grab;
}

body.high-contrast .tile {
  background: #000;
  border-color: #fff;
  color: #fff;
}

.tile.done {
  opacity: 0.48;
  cursor: not-allowed;
}

.tile.bump {
  animation: pop 260ms ease;
}

.tile.shake {
  animation: shake 220ms ease;
}

@keyframes pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

@keyframes shake {
  0% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-3px); }
  100% { transform: translateX(0); }
}

.mode-toggle {
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.28);
}

.tooltip {
  margin-top: 8px;
  border-left: 4px solid var(--accent);
  padding: 8px 10px;
  background: rgba(36, 209, 167, 0.14);
}

.tooltip.bad {
  border-left-color: var(--danger);
  background: rgba(255, 123, 123, 0.16);
}

.rapid-arena {
  display: grid;
  gap: 12px;
}

.center-card {
  min-height: 170px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.33);
  padding: 14px;
  text-align: center;
  font-size: clamp(1.3rem, 2vw, 1.8rem);
}

.choice-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.choice-big {
  min-height: 70px;
  font-size: clamp(1.1rem, 1.9vw, 1.4rem);
}

.choice-big.active,
.mode-toggle.active {
  box-shadow: 0 0 0 4px rgba(73, 182, 255, 0.42);
}

.sequence-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.step-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.3);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.step-item.correct {
  border-color: var(--ok);
  background: rgba(42, 145, 87, 0.26);
}

.step-item.wrong {
  border-color: var(--danger);
  background: rgba(170, 55, 55, 0.24);
}

.step-item.locked {
  opacity: 0.78;
}

.step-controls {
  display: flex;
  gap: 6px;
}

.problem {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  margin-top: 10px;
  background: rgba(0, 0, 0, 0.22);
}

.problem h4 {
  margin: 0 0 8px;
}

.problem-hint {
  margin-top: 6px;
  color: #ffe9a8;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.76);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 50;
}

.overlay-card {
  width: min(900px, 95vw);
  max-height: 90vh;
  overflow: auto;
  padding: 18px;
}

.overlay-card h3 {
  margin-top: 0;
}

body.high-contrast .overlay-card {
  background: #000;
  color: #fff;
}

.gallery-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.thumb-grid {
  display: grid;
  gap: 8px;
}

.thumb-item {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.3);
  padding: 8px;
  cursor: pointer;
}

.thumb-item img {
  width: 100px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.preview-pane {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  padding: 8px;
}

.preview-pane img {
  width: 100%;
  max-height: 55vh;
  object-fit: contain;
  border-radius: 8px;
}

.toast-root {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 90;
  display: grid;
  gap: 8px;
}

.toast {
  min-width: 220px;
  max-width: 360px;
  border: 1px solid var(--line);
  background: rgba(8, 29, 44, 0.95);
  border-radius: 12px;
  padding: 10px;
  box-shadow: var(--shadow);
  animation: toastIn 220ms ease, toastOut 320ms ease 2600ms forwards;
}

body.high-contrast .toast {
  background: #000;
  border-color: #fff;
}

.toast strong {
  display: block;
  margin-bottom: 2px;
}

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

@keyframes toastOut {
  to { opacity: 0; transform: translateY(10px); }
}

.hide {
  display: none !important;
}

.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 70;
}

.confetti {
  position: absolute;
  top: -12px;
  width: 8px;
  height: 13px;
  opacity: 0.86;
  animation: fall 1100ms linear forwards;
}

@keyframes fall {
  to {
    transform: translateY(110vh) rotate(520deg);
    opacity: 0;
  }
}

@media (max-width: 900px) {
  .cols,
  .board,
  .gallery-wrap,
  .choice-row {
    grid-template-columns: 1fr;
  }

  .top-nav {
    margin: 10px;
  }

  .view {
    padding: 10px;
  }
}
