:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #61717d;
  --blue: #2563eb;
  --red: #dc3f4f;
  --line: #dbe5ea;
  --surface: #ffffff;
  --page: #f3f6f5;
  font-family: "DM Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--page);
}

button, input { font: inherit; }

.app-shell {
  width: min(1460px, 100%);
  margin: 0 auto;
  padding: 28px clamp(16px, 3vw, 48px) 40px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 5px;
  color: #5f7469;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 2.65rem);
  font-weight: 500;
  letter-spacing: -0.04em;
}

.controls {
  display: flex;
  align-items: flex-end;
  gap: 22px;
}

.control {
  display: grid;
  gap: 8px;
  min-width: 205px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.control > span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

output {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  height: 4px;
  margin: 5px 0;
  accent-color: #1d6a45;
  cursor: pointer;
}

button {
  min-height: 38px;
  padding: 0 17px;
  border: 1px solid #ccd8d2;
  border-radius: 9px;
  color: #28543f;
  background: #fff;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}

button:hover { background: #f0f7f3; border-color: #a9c6b6; }
button:focus-visible, input:focus-visible { outline: 3px solid rgba(37, 99, 235, 0.28); outline-offset: 3px; }

.scene-card {
  overflow: hidden;
  border: 1px solid #dfe8e4;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 18px 55px rgba(35, 61, 49, 0.08);
}

.scene-wrap { position: relative; }

#scene {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
  user-select: none;
}

.sky { fill: url(#sky-gradient); }
.ground { fill: url(#ground-gradient); }
.ground-line { stroke: #428842; stroke-width: 3; }

.gravity-line {
  stroke: #db3347;
  stroke-width: 1.1;
  opacity: 0.13;
  marker-end: url(#gravity-arrow);
}

.gravity-label {
  fill: #c33646;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  opacity: 0.38;
}

#trajectory {
  fill: none;
  stroke: #4d6570;
  stroke-width: 2;
  stroke-dasharray: 7 8;
  opacity: 0.64;
}

#drag-target {
  fill: none;
  stroke: transparent;
  stroke-width: 38;
  cursor: ew-resize;
}

.vector-panel {
  fill: rgba(255, 255, 255, 0.72);
  stroke: rgba(84, 109, 119, 0.14);
  stroke-width: 1;
}

.diagram-title {
  fill: #6a7a82;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.vector, .velocity-arrow { fill: none; stroke-linecap: round; }
.vector { stroke-width: 4; }
.vector.vx { stroke: var(--blue); }
.vector.vy { stroke: var(--red); }
.vector.total { stroke: var(--ink); }
.velocity-arrow { stroke: var(--ink); stroke-width: 4; pointer-events: none; }

.right-angle {
  fill: none;
  stroke: #8b9aa1;
  stroke-width: 1.5;
  opacity: 0.72;
}

.vector-label {
  font-size: 13px;
  font-weight: 600;
  paint-order: stroke;
  stroke: rgba(255, 255, 255, 0.92);
  stroke-width: 5px;
  stroke-linejoin: round;
}

.vx-text { fill: var(--blue); }
.vy-text { fill: var(--red); }
.total-text { fill: var(--ink); }

.projectile { cursor: grab; outline: none; }
.projectile.dragging { cursor: grabbing; }
.drag-halo { fill: rgba(255, 255, 255, 0.01); stroke: rgba(23, 32, 42, 0); stroke-width: 2; }
.projectile:hover .drag-halo, .projectile:focus-visible .drag-halo { fill: rgba(255, 255, 255, 0.45); stroke: rgba(23, 32, 42, 0.18); }
.ball { fill: #f2a93b; stroke: #9d6016; stroke-width: 2; }
.ball-glint { fill: rgba(255, 255, 255, 0.72); pointer-events: none; }

.launch-marker line { stroke: #4a785d; stroke-width: 1.5; }
.launch-marker text { fill: #4e715f; font-size: 11px; font-weight: 600; letter-spacing: 0.12em; }

.drag-hint {
  position: absolute;
  left: 24px;
  top: 22px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid rgba(103, 126, 136, 0.18);
  border-radius: 999px;
  color: #536771;
  background: rgba(255, 255, 255, 0.74);
  backdrop-filter: blur(8px);
  font-size: 0.76rem;
  transition: opacity 220ms ease;
}

.drag-hint.hidden { opacity: 0; pointer-events: none; }
.hint-dot { width: 7px; height: 7px; border-radius: 50%; background: #e8a238; box-shadow: 0 0 0 4px rgba(232, 162, 56, 0.16); }

.readout {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border-top: 1px solid var(--line);
  background: #fff;
}

.readout > div { padding: 16px 20px 18px; }
.readout > div + div { border-left: 1px solid var(--line); }
.readout span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 0.72rem; }
.readout strong { font-size: clamp(0.9rem, 1.5vw, 1.08rem); font-weight: 600; font-variant-numeric: tabular-nums; }
.readout .blue strong { color: var(--blue); }
.readout .red strong { color: var(--red); }

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

@media (max-width: 1350px) {
  .topbar { align-items: flex-start; flex-direction: column; gap: 20px; }
  .controls { width: 100%; }
  .control { min-width: 0; flex: 1; }
}

@media (max-width: 900px) {
  .readout { grid-template-columns: repeat(3, 1fr); }
  .readout > div:nth-child(4) { border-left: 0; }
  .readout > div:nth-child(n+4) { border-top: 1px solid var(--line); }
}

@media (max-width: 600px) {
  .app-shell { padding: 16px 10px 24px; }
  .controls { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  .controls button { grid-column: 1 / -1; }
  .scene-card { border-radius: 12px; }
  .drag-hint { left: 10px; top: 10px; padding: 6px 9px; }
  .readout { grid-template-columns: repeat(2, 1fr); }
  .readout > div { padding: 13px 12px 15px; }
  .readout > div:nth-child(3), .readout > div:nth-child(5) { border-left: 0; }
  .readout > div:nth-child(4) { border-left: 1px solid var(--line); }
  .readout > div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .readout > div:last-child { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
