@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=Sora:wght@400;600;700&display=swap');

:root {
  /* Official Thinking Experiment Light Mode Tokens */
  --bg-950: #e9f4fb;
  --bg-900: #fff4dd;
  --bg-800: #f9fcfe;
  --text-100: #123140;
  --text-300: #4b6570;
  --text-500: #6c8691;
  --accent: #0f7e9b;
  --accent-strong: #095f76;
  --surface: #ffffff;
  --border: #b4d0db;
  --shadow-lg: 0 12px 24px rgba(12, 54, 68, 0.1);

  /* Functional UI Mappings */
  --panel: rgba(255, 255, 255, 0.94);
  --panel-edge: rgba(15, 126, 155, 0.12);
  --text: var(--text-100);
  --muted: var(--text-300);
  --accent-2: var(--accent-strong);
  --danger: #d94a38;
  --shadow: rgba(12, 54, 68, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  font-family: "Inter", "IBM Plex Sans", sans-serif;
  color: var(--text-100);
  background: #e9f4fb;
  line-height: 1.45;
}

.bg-shape {
  position: fixed;
  pointer-events: none;
  border-radius: 999px;
  filter: blur(40px);
  opacity: 0.2;
  z-index: 0;
}

.bg-shape-1 {
  width: 28rem;
  height: 28rem;
  top: -8rem;
  right: -6rem;
  background: var(--accent);
  opacity: 0.12;
}

.bg-shape-2 {
  width: 22rem;
  height: 22rem;
  bottom: -7rem;
  left: -4rem;
  background: var(--bg-900);
  opacity: 0.3;
}

.shell {
  width: min(1480px, calc(100% - 2rem));
  margin-inline: auto;
}

.hero {
  position: relative;
  z-index: 1;
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.2rem 1.4rem;
  background: linear-gradient(160deg, #ffffff, #f7fbfd);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 12px;
  border-radius: 14px 0 0 14px;
  background: var(--accent);
}

.hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.hero-top > :first-child {
  min-width: 0;
  padding-left: 0.4rem;
}

.kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.8rem;
  color: var(--accent-strong);
  font-weight: 700;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: -0.02em;
}

h1 {
  font-size: clamp(1.85rem, 2.8vw, 3rem);
  margin-top: 0.35rem;
  line-height: 1.05;
}

.subtitle {
  margin: 0.38rem 0 0;
  color: var(--text-300);
  font-size: 1rem;
  max-width: 76ch;
}

.layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(290px, 350px) minmax(0, 1fr) minmax(270px, 330px);
  gap: 1rem;
  padding: 0.8rem clamp(0.8rem, 2vw, 1.8rem) 0.9rem;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  background: var(--surface);
  box-shadow: 0 6px 16px rgba(12, 54, 68, 0.08);
}

.panel section {
  margin-bottom: 1rem;
}

.panel section:last-child {
  margin-bottom: 0;
}

.controls,
.guide {
  max-height: calc(100vh - 8.1rem);
  overflow: auto;
}

.controls {
  animation-delay: 0.05s;
}

.stage-panel {
  animation-delay: 0.12s;
}

.guide {
  animation-delay: 0.18s;
}

h2 {
  font-size: 0.92rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-strong);
  margin-bottom: 0.65rem;
  border-bottom: 1px solid var(--panel-edge);
  padding-bottom: 0.25rem;
}

h3 {
  font-size: 0.93rem;
  margin-bottom: 0.5rem;
}

.field {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
}

.field span {
  font-size: 0.84rem;
  color: var(--text-300);
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  font-weight: 600;
}

.field strong {
  color: var(--text);
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 500;
}

select,
button,
input,
textarea {
  font: inherit;
  color: var(--text-100);
}

select,
button,
textarea {
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-100);
}

select,
textarea {
  padding: 0.52rem 0.65rem;
  background: #ffffff;
  color: #123140 !important;
}

textarea {
  width: 100%;
  min-height: 8rem;
  resize: vertical;
  font-size: 0.9rem;
  line-height: 1.45;
}

.button-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

button {
  border-radius: 10px;
  background: linear-gradient(160deg, #0d839f, #0b5f77);
  color: #ffffff;
  font-weight: 700;
  border: 1px solid #095f76;
  padding: 0.58rem 0.82rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: rgba(247, 178, 103, 0.88);
}

button:active {
  transform: translateY(0);
}

#playBtn {
  background: var(--accent);
  color: #ffffff;
}

#clearBtn,
#resetBtn {
  background: var(--accent-strong);
  color: #ffffff;
}

#saveScreenshotBtn,
#saveReportBtn {
  background: var(--accent-strong);
  color: #ffffff;
}

#focusSourceBtn.is-active {
  background: var(--danger);
  border-color: var(--danger);
}

input[type='range'] {
  width: 100%;
  accent-color: var(--accent);
}

.toggle {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.52rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.toggle input {
  accent-color: var(--accent-2);
}

.metrics {
  border-top: 1px solid rgba(157, 228, 255, 0.17);
  padding-top: 0.8rem;
}

.metrics p {
  margin: 0.32rem 0;
  font-size: 0.84rem;
  color: var(--muted);
  font-family: 'IBM Plex Mono', monospace;
}

.canvas-wrap {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  background: #030f15;
  border: 1px solid rgba(183, 228, 238, 0.36);
  min-height: 52vh;
  height: calc(100vh - 11.4rem);
}

#tankCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.hud {
  position: absolute;
  left: 0.55rem;
  bottom: 0.55rem;
  background: rgba(3, 14, 20, 0.72);
  border: 1px solid rgba(189, 233, 243, 0.32);
  border-radius: 10px;
  padding: 0.33rem 0.52rem;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75rem;
  color: #ffffff;
  pointer-events: none;
}

.guide p,
.guide li,
.hint {
  font-size: 0.88rem;
  line-height: 1.44;
  color: var(--muted);
}

.guide ul {
  margin: 0;
  padding-left: 1.25rem;
}

.hint {
  margin-top: 0.45rem;
  font-family: 'IBM Plex Mono', monospace;
}

.worksheet-form {
  display: grid;
  gap: 0.65rem;
}

.worksheet-section {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.6rem;
  background: var(--bg-800);
}

.worksheet-section h4 {
  margin: 0 0 0.4rem;
  font-size: 0.84rem;
  color: var(--accent-strong);
  letter-spacing: 0.03em;
  font-weight: 700;
}

.worksheet-question {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.55rem;
}

.worksheet-question:last-child {
  margin-bottom: 0;
}

.worksheet-question label {
  font-size: 0.8rem;
  line-height: 1.35;
  color: var(--muted);
}

.worksheet-question textarea {
  min-height: 4.5rem;
  font-size: 0.83rem;
  border-radius: 8px;
}

.footer-note {
  position: relative;
  z-index: 1;
  margin: 0 0 0.9rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.76rem;
}

kbd {
  background: rgba(3, 20, 29, 0.92);
  border: 1px solid rgba(147, 204, 218, 0.4);
  border-radius: 6px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  padding: 0.08rem 0.36rem;
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1160px) {
  .layout {
    grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  }

  .guide {
    grid-column: 1 / -1;
    max-height: none;
  }

  .canvas-wrap {
    min-height: 46vh;
    height: 60vh;
  }
}

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

  .controls,
  .guide {
    max-height: none;
  }

  .canvas-wrap {
    min-height: 42vh;
    height: 52vh;
  }
}

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