:root {
  color-scheme: light;
  --paper: #f7f3e8;
  --ink: #1c2630;
  --muted: #65727e;
  --line: #d9d0be;
  --panel: #fffdf7;
  --accent: #0f8b8d;
  --accent-dark: #0a6062;
  --gold: #f2b84b;
  --coral: #e66a5d;
  --leaf: #4f9f67;
  --violet: #6f64c8;
  --shadow: 0 16px 48px rgba(30, 42, 54, 0.18);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(15, 139, 141, 0.11), transparent 32%),
    linear-gradient(225deg, rgba(242, 184, 75, 0.18), transparent 32%),
    var(--paper);
  color: var(--ink);
}

button,
a {
  font: inherit;
}

button {
  border: 0;
}

.game-shell {
  width: min(1480px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 14px;
}

.topbar,
.bottom-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(255, 253, 247, 0.82);
  border: 1px solid rgba(217, 208, 190, 0.82);
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: 0 6px 24px rgba(48, 54, 59, 0.08);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 240px;
}

.logo-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: var(--gold);
  font-weight: 900;
  letter-spacing: 0;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 2px;
  color: var(--accent-dark);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.22rem, 2.6vw, 2rem);
  line-height: 1.05;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(72px, 1fr));
  gap: 8px;
  width: min(680px, 62vw);
}

.stat {
  min-height: 58px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid var(--line);
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.stat strong {
  display: block;
  margin-top: 3px;
  font-size: 1.35rem;
  line-height: 1;
}

.stage-wrap {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 318px;
  gap: 14px;
}

#gameCanvas {
  width: 100%;
  height: 100%;
  min-height: 520px;
  display: block;
  background: #fdf7ed;
  border: 1px solid rgba(92, 86, 74, 0.25);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.side-panel {
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 12px;
  min-width: 0;
}

.panel-section {
  background: rgba(255, 253, 247, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 8px 22px rgba(48, 54, 59, 0.08);
}

.panel-section.compact h2 {
  min-height: 32px;
  font-size: 1.12rem;
  overflow-wrap: anywhere;
}

.file-meter {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.file-meter span,
.file-meter strong {
  padding: 6px 8px;
  border-radius: 8px;
  background: #f2eadb;
  min-width: 72px;
  text-align: center;
}

.limit-bar {
  height: 12px;
  margin-top: 10px;
  border-radius: 999px;
  background: #e5dccc;
  overflow: hidden;
}

#limitBarFill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--leaf), var(--gold), var(--coral));
  transition: width 160ms ease;
}

.lanes {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-content: start;
}

.lane-button {
  min-height: 70px;
  display: grid;
  grid-template-columns: 42px 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 10px;
  padding: 10px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.lane-button:hover,
.lane-button:focus-visible {
  outline: 3px solid rgba(15, 139, 141, 0.22);
}

.lane-button.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 139, 141, 0.18);
}

.lane-icon {
  grid-row: 1 / 3;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: #ffffff;
  font-weight: 900;
}

.lane-button span:not(.lane-icon) {
  font-weight: 850;
}

.lane-button small {
  color: var(--muted);
  font-weight: 700;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.primary-button,
.secondary-button {
  min-height: 44px;
  border-radius: 8px;
  padding: 10px 12px;
  font-weight: 850;
  cursor: pointer;
}

.primary-button {
  background: var(--accent);
  color: #ffffff;
}

.primary-button:hover,
.primary-button:focus-visible {
  background: var(--accent-dark);
}

.secondary-button {
  background: #ffffff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.controls .primary-button {
  grid-column: 1 / -1;
}

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

.bottom-strip {
  min-height: 64px;
}

.bottom-strip div {
  display: grid;
  gap: 3px;
}

.bottom-strip span {
  color: var(--muted);
  font-size: 0.9rem;
}

.bottom-strip a {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  border-radius: 8px;
  padding: 9px 12px;
  background: var(--ink);
  color: #ffffff;
  text-decoration: none;
  font-weight: 800;
}

.platform-crazygames .external-tool-link,
.platform-yandex .external-tool-link {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(28, 38, 48, 0.62);
  z-index: 10;
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(480px, 100%);
  border-radius: 8px;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.modal-card h2 {
  font-size: 1.55rem;
}

.modal-card p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.45;
}

.modal-stats {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.modal-stats div {
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #ffffff;
  padding: 10px;
  text-align: center;
}

.modal-stats span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.modal-stats strong {
  display: block;
  margin-top: 3px;
  font-size: 1.1rem;
}

.modal-actions {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 920px) {
  .game-shell {
    padding: 10px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .stat-grid {
    width: 100%;
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .stage-wrap {
    grid-template-columns: 1fr;
  }

  #gameCanvas {
    min-height: 48vh;
  }

  .side-panel {
    grid-template-rows: auto auto auto auto;
  }

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

  .lane-button {
    min-height: 86px;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    text-align: center;
  }

  .lane-icon {
    grid-row: auto;
    margin: 0 auto;
  }
}

@media (max-width: 620px) {
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .bottom-strip {
    flex-direction: column;
    align-items: stretch;
  }

  .bottom-strip a {
    width: 100%;
  }
}
