@font-face {
  font-family: 'Atkinson Hyperlegible Next';
  src: url('/fara-compas/assets/AtkinsonHyperlegibleNext.woff2') format('woff2');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/fara-compas/assets/IBMPlexMono-Regular.woff2') format('woff2');
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #090d14;
  --surface: #0f172a;
  --surface-raised: #1e293b;
  --border: #334155;
  --border-focus: #fbbf24;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --gold: #fbbf24;
  --gold-glow: rgba(251, 191, 36, 0.25);
  --vermilion: #ff4d4f;
  --vermilion-glow: rgba(255, 77, 79, 0.35);
  --cyan: #38bdf8;
  --font-sans: 'Atkinson Hyperlegible Next', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, monospace;
}

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

html {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(56, 189, 248, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 189, 248, 0.03) 1px, transparent 1px);
  background-size: 32px 32px;
  background-position: center center;
}

/* Accessibility Skip Link */
.skip-link {
  position: absolute;
  top: -999px;
  left: 1rem;
  background: var(--gold);
  color: #000;
  padding: 0.5rem 1rem;
  font-weight: 700;
  z-index: 1000;
  border-radius: 4px;
}

.skip-link:focus {
  top: 1rem;
}

/* Navigation */
.site-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
}

.brand {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand:hover, .brand:focus-visible {
  color: var(--gold);
}

.nav-links {
  display: flex;
  gap: 1.25rem;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.nav-links a:hover, .nav-links a:focus-visible {
  color: var(--text);
}

.lang-switch {
  padding: 0.25rem 0.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text) !important;
  font-weight: 600;
}

.lang-switch:hover, .lang-switch:focus-visible {
  border-color: var(--gold);
  color: var(--gold) !important;
}

/* Main Container */
main {
  flex: 1;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 0.5rem 1.5rem 4rem;
}

/* Hero Section */
.game-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 3.5rem;
}

.hero-header {
  text-align: center;
  max-width: 680px;
}

.eyebrow-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--cyan);
}

.round-badge {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--gold);
}

h1 {
  font-size: clamp(1.8rem, 4.5vw, 2.6rem);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 0.6rem;
  letter-spacing: -0.02em;
}

.deck {
  font-size: 1.05rem;
  color: var(--text-muted);
  line-height: 1.45;
}

/* Drafting Table Workspace */
.drafting-board {
  position: relative;
  width: 100%;
  max-width: 420px;
  aspect-ratio: 1 / 1;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  margin: 0.5rem 0;
  touch-action: none;
}

.board-ruler-top, .board-ruler-left {
  position: absolute;
  pointer-events: none;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-dim);
}

.board-ruler-top {
  top: 6px;
  left: 12px;
}

.board-ruler-left {
  bottom: 8px;
  right: 12px;
}

.canvas-svg {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

.canvas-svg:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: -2px;
}

/* SVG Elements Styling */
.geom-shape {
  transition: opacity 0.2s ease;
}

.geom-stroke {
  stroke: #f1f5f9;
  stroke-width: 2.2;
  fill: none;
}

.geom-fill {
  fill: #1e293b;
  stroke: #475569;
  stroke-width: 1.5;
}

.geom-mass {
  fill: rgba(56, 189, 248, 0.22);
  stroke: none;
}

.geom-arc {
  stroke-linecap: round;
}

/* Tolerance Rings */
.tolerance-ring {
  fill: none;
  stroke: var(--gold);
  stroke-width: 1;
  stroke-dasharray: 2 3;
  opacity: 0.4;
}

.ring-1mm { opacity: 0.6; }
.ring-2mm { opacity: 0.5; }
.ring-5mm { opacity: 0.35; }
.ring-10mm { opacity: 0.25; }

.tolerance-label {
  font-family: var(--font-mono);
  font-size: 9px;
  fill: var(--gold);
  opacity: 0.55;
  user-select: none;
}

/* Error Vector */
.error-vector {
  stroke: var(--vermilion);
  stroke-width: 1.5;
  stroke-dasharray: 3 3;
}

/* Center Pin (Gold) */
.center-pin .pin-head {
  fill: var(--gold);
  stroke: #000;
  stroke-width: 1;
}

.center-pin .pin-point {
  fill: #000;
}

.center-pin .pin-cross {
  stroke: var(--gold);
  stroke-width: 1;
}

/* User Marker (Vermilion) */
.user-marker .user-aura {
  fill: var(--vermilion-glow);
}

.user-marker .user-dot {
  fill: var(--vermilion);
  stroke: #fff;
  stroke-width: 1;
}

/* Keyboard Crosshair Cursor */
.kb-cursor-ring {
  fill: none;
  stroke: var(--cyan);
  stroke-width: 1.5;
}

.kb-cursor-line {
  stroke: var(--cyan);
  stroke-width: 1;
}

/* Control & Readout Column */
.round-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 420px;
  gap: 0.75rem;
}

.round-result-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.85rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.result-metric {
  display: flex;
  flex-direction: column;
}

.result-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
}

.result-mm {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--vermilion);
}

.result-details {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.result-percent {
  color: var(--text);
  font-weight: 600;
}

.result-bearing {
  color: var(--cyan);
}

.primary-btn {
  width: 100%;
  padding: 0.85rem 1.5rem;
  background: var(--gold);
  color: #0b1118;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 700;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.15s ease;
}

.primary-btn:hover {
  filter: brightness(1.08);
}

.primary-btn:active {
  transform: scale(0.99);
}

.primary-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.secondary-btn {
  padding: 0.75rem 1.25rem;
  background: transparent;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.secondary-btn:hover, .secondary-btn:focus-visible {
  border-color: var(--text);
  background: var(--surface-raised);
}

.hint-text {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
  text-align: center;
}

/* Summary Section */
.summary-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2rem;
  margin-bottom: 3.5rem;
}

.summary-header {
  text-align: center;
  margin-bottom: 2rem;
}

.summary-header h2 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-top: 0.25rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: center;
  margin-bottom: 2rem;
}

@media (max-width: 640px) {
  .summary-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
}

.reticle-container {
  display: flex;
  justify-content: center;
  align-items: center;
}

.summary-reticle {
  width: 100%;
  max-width: 280px;
  aspect-ratio: 1 / 1;
  background: #0b101b;
  border: 1px solid var(--border);
  border-radius: 50%;
}

.reticle-axis {
  stroke: var(--border);
  stroke-width: 1;
  stroke-dasharray: 2 2;
}

.reticle-ring {
  fill: none;
  stroke: rgba(251, 191, 36, 0.2);
  stroke-width: 1;
}

.reticle-label {
  font-family: var(--font-mono);
  font-size: 8px;
  fill: var(--text-dim);
}

.reticle-center {
  fill: var(--gold);
}

.summary-point .pt-dot {
  fill: var(--vermilion);
  stroke: #fff;
  stroke-width: 1;
}

.summary-point .pt-label {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  fill: var(--text);
}

.summary-stats {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.stat-label {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gold);
}

.diagnosis-box {
  background: var(--surface-raised);
  border-left: 3px solid var(--cyan);
  padding: 1rem;
  border-radius: 0 4px 4px 0;
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--text);
}

.summary-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.share-feedback {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--cyan);
  text-align: center;
  margin-top: 0.5rem;
  min-height: 1.25rem;
}

/* Explainer Section */
.explainer-section {
  border-top: 1px solid var(--border);
  padding-top: 3rem;
  margin-top: 2rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.5rem;
}

@media (max-width: 768px) {
  .explainer-section {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
}

.explainer-block h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.explainer-block p {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.55;
  margin-bottom: 0.75rem;
}

/* Footer */
footer {
  border-top: 1px solid var(--border);
  padding: 2rem 1.5rem;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-dim);
}

footer a {
  color: var(--text-muted);
  text-decoration: none;
}

footer a:hover, footer a:focus-visible {
  color: var(--gold);
}

/* Reduced Motion */
@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;
  }
}
