:root {
  --bg-top: #f4f1e8;
  --bg-bottom: #d9e9ef;
  --ink: #172127;
  --ink-soft: #4f5e69;
  --panel: #fdfdfc;
  --line: #d8dee2;
  --accent: #0f766e;
  --accent-strong: #0d5f59;
  --warning: #8f4d11;
  --shadow: 0 16px 36px rgba(23, 33, 39, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "IBM Plex Sans", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 10%, rgba(255, 236, 205, 0.75), transparent 40%),
    radial-gradient(circle at 100% 100%, rgba(176, 222, 225, 0.75), transparent 30%),
    linear-gradient(160deg, var(--bg-top), var(--bg-bottom));
}

body.is-loading {
  overflow: hidden;
}

.page-shell {
  width: min(1320px, 95vw);
  margin: 2rem auto 2.5rem;
}

.hero {
  margin-bottom: 1rem;
}

.eyebrow {
  margin: 0;
  color: var(--ink-soft);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.75rem;
  font-weight: 600;
}

.hero h1 {
  margin: 0.35rem 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(1.9rem, 2.5vw, 2.7rem);
  line-height: 1.05;
}

.subtitle {
  margin: 0;
  color: var(--ink-soft);
  max-width: 70ch;
}

.layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 1rem;
  align-items: start;
}

.panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(249, 251, 252, 0.94));
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.panel-input {
  padding: 1rem;
  position: sticky;
  top: 1rem;
}

.panel-input h2,
.panel-output h2 {
  margin: 0 0 0.45rem;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.15rem;
}

.help {
  margin: 0 0 0.8rem;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.88rem;
  color: var(--ink-soft);
}

textarea,
input[type="text"],
input[type="email"],
input[type="number"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.72rem 0.8rem;
  font: inherit;
  color: var(--ink);
  background: #fff;
}

textarea {
  min-height: 300px;
  resize: vertical;
}

textarea:focus,
input:focus {
  outline: 2px solid rgba(15, 118, 110, 0.25);
  border-color: var(--accent);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 150px;
  gap: 0.7rem;
  margin-top: 0.7rem;
}

.field {
  margin-top: 0.7rem;
}

.switches {
  margin-top: 0.9rem;
  display: grid;
  gap: 0.45rem;
}

.switch {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0;
  color: var(--ink);
  font-size: 0.92rem;
}

.switch input {
  width: auto;
}

.actions {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

button {
  border: 0;
  border-radius: 10px;
  padding: 0.68rem 0.9rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  transition: transform 140ms ease, background-color 160ms ease;
}

button:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.6;
  cursor: wait;
  transform: none;
}

.button-muted {
  background: #ecf1f4;
  color: var(--ink);
}

.button-muted:hover {
  background: #dbe5ea;
}

.error-box {
  margin-top: 0.9rem;
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  background: #fff2e7;
  border: 1px solid #f5cfad;
  color: #8d3f00;
}

.panel-output {
  padding: 0.95rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
}

.summary-card {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.75rem;
  background: #fff;
}

.summary-label {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.summary-value {
  margin: 0.2rem 0 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.3rem;
  line-height: 1;
}

.route-map {
  margin-top: 0.7rem;
  height: 420px;
  border-radius: 12px;
  border: 1px solid var(--line);
  overflow: hidden;
}

.panel-subsection {
  margin-top: 0.95rem;
}

.chunk-list {
  display: grid;
  gap: 0.55rem;
}

.chunk-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem 0.7rem;
  background: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.7rem;
}

.chunk-meta {
  font-size: 0.92rem;
}

.chunk-meta p {
  margin: 0;
}

.chunk-link {
  white-space: nowrap;
  color: var(--accent-strong);
  text-decoration: none;
  font-weight: 600;
}

.chunk-link:hover {
  text-decoration: underline;
}

.table-wrap {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  overflow: auto;
  max-height: 460px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.89rem;
}

th,
td {
  border-bottom: 1px solid #ecf1f4;
  padding: 0.56rem 0.58rem;
  text-align: left;
  vertical-align: top;
}

thead th {
  position: sticky;
  top: 0;
  background: #f4f8fa;
  z-index: 1;
}

tbody tr:hover {
  background: #f8fcfd;
}

.placeholder,
.placeholder-cell {
  color: var(--ink-soft);
}

.marker-badge {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  border: 2px solid #fff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.marker-stop {
  background: #155e75;
  color: #fff;
}

.marker-start {
  background: #1d8f58;
  color: #fff;
}

.marker-end {
  background: #b45309;
  color: #fff;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 5000;
  background: rgba(13, 21, 25, 0.62);
  backdrop-filter: blur(7px);
  display: grid;
  place-items: center;
  padding: 1rem;
}

.loading-overlay[hidden] {
  display: none !important;
}

.loading-card {
  width: min(860px, 98vw);
  max-height: 94vh;
  overflow: auto;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: linear-gradient(180deg, rgba(245, 251, 250, 0.97), rgba(252, 251, 248, 0.97));
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.3);
  padding: 1rem;
}

.loading-heading {
  display: flex;
  gap: 0.9rem;
  align-items: center;
}

.loading-kicker {
  margin: 0;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-size: 0.72rem;
  font-weight: 700;
}

.loading-heading h2 {
  margin: 0.22rem 0 0.2rem;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.38rem;
}

.loading-elapsed {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.loading-spinner {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 5px solid #dcefed;
  border-top-color: #0f766e;
  animation: spin 0.9s linear infinite;
  flex: 0 0 auto;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.trivia-box {
  margin-top: 0.95rem;
  background: #fff;
  border: 1px solid #d8e6e4;
  border-radius: 12px;
  padding: 0.8rem 0.9rem;
}

.trivia-label {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #1b5f66;
  font-weight: 700;
}

.trivia-text {
  margin: 0.38rem 0 0;
  font-size: 1rem;
  line-height: 1.35;
  min-height: 2.7em;
}

.loading-controls {
  margin-top: 0.9rem;
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.loader-cancel {
  background: #b42318;
  color: #fff;
}

.loader-cancel:hover {
  background: #9d1f14;
}

.loader-game-wrap {
  margin-top: 0.8rem;
  border: 1px solid #d2dde3;
  border-radius: 12px;
  background: #fff;
  padding: 0.8rem;
}

.loader-game-head {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.loader-game-stat {
  margin: 0;
  font-size: 0.92rem;
  color: var(--ink-soft);
}

#loaderGameCanvas {
  margin-top: 0.55rem;
  width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid #d9e3e8;
  background: radial-gradient(circle at 20% 0%, #1c2d39, #0f1b24 65%, #0a1319 100%);
}

.loader-game-help {
  margin: 0.45rem 0 0;
  color: var(--ink-soft);
  font-size: 0.86rem;
}

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

  .panel-input {
    position: static;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .page-shell {
    width: 96vw;
    margin: 1rem auto 1.3rem;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .summary-grid {
    grid-template-columns: 1fr 1fr;
  }

  .route-map {
    height: 340px;
  }

  .chunk-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .loading-heading {
    align-items: flex-start;
  }

  .loading-spinner {
    width: 44px;
    height: 44px;
  }

  .loading-heading h2 {
    font-size: 1.18rem;
  }

  #loaderGameToggle,
  #loaderGameWrap {
    display: none !important;
  }
}
