:root {
  color-scheme: dark;
  --text: #edf2f7;
  --muted: #9aa7b7;
  --panel: rgba(12, 16, 20, 0.82);
  --line: rgba(255, 255, 255, 0.15);
  --blue: #58c7ff;
  --gold: #e1b95a;
  --violet: #b58cff;
  --red: #ff5d57;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: auto;
  background:
    radial-gradient(circle at 72% 18%, rgba(225, 185, 90, 0.15), transparent 30%),
    radial-gradient(circle at 28% 76%, rgba(181, 140, 255, 0.16), transparent 32%),
    linear-gradient(180deg, #12171b 0%, #07090d 78%);
  color: var(--text);
  font-family: Inter, "Microsoft YaHei", system-ui, sans-serif;
}

button,
a {
  color: inherit;
  font: inherit;
}

button {
  border: 0;
}

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

.tutorial-topbar,
.page-tabs,
.lesson-tabs,
.lesson-panel,
.board-stage,
.info-card,
.diagram-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(14px);
}

.tutorial-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 16px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1;
}

.tutorial-topbar p,
.lesson-copy p,
.effect-box p,
.lesson-log {
  color: var(--muted);
}

.tutorial-topbar p {
  margin-top: 6px;
  font-size: 13px;
}

.top-actions a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.07);
  text-decoration: none;
}

.top-actions a:hover,
.page-tab:hover,
.lesson-tab:hover,
.lesson-controls button:hover {
  background: rgba(255, 255, 255, 0.13);
}

.page-tabs,
.lesson-tabs {
  display: flex;
  gap: 10px;
  padding: 10px;
}

.page-tab,
.lesson-tab {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.07);
  cursor: pointer;
}

.page-tab.active,
.lesson-tab.active {
  background: color-mix(in srgb, var(--accent) 30%, rgba(255, 255, 255, 0.08));
  box-shadow: inset 0 -3px 0 var(--accent);
}

.tutorial-page {
  display: grid;
  min-height: 0;
  gap: 14px;
}

.tutorial-page[hidden] {
  display: none;
}

.info-page {
  grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
}

.info-card {
  padding: 22px;
}

.info-card h2 {
  margin-bottom: 12px;
  font-size: 24px;
}

.info-card p,
.info-card li {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.65;
}

.info-card ul {
  display: grid;
  gap: 10px;
  margin: 18px 0 0;
  padding-left: 20px;
}

.diagram-card {
  display: grid;
  place-items: center;
  min-height: 460px;
  padding: 24px;
}

.lesson-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 0;
  gap: 14px;
}

.frontline-demo,
.demolish-demo {
  grid-template-columns: repeat(3, minmax(86px, 150px));
  gap: 24px;
}

.mini-hex {
  display: grid;
  width: 118px;
  height: 102px;
  place-items: center;
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(62, 66, 70, 0.7);
  color: var(--text);
  font-weight: 700;
}

.mini-hex.player {
  background: rgba(36, 102, 142, 0.78);
  border-color: rgba(99, 203, 255, 0.8);
}

.mini-hex.valid {
  background: rgba(225, 185, 90, 0.24);
  border-color: var(--gold);
  box-shadow: 0 0 28px rgba(225, 185, 90, 0.3);
}

.mini-hex.invalid {
  opacity: 0.52;
}

.building-token,
.card-token {
  display: grid;
  width: 150px;
  min-height: 190px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font-weight: 700;
}

.building-token {
  border-color: rgba(225, 185, 90, 0.5);
}

.card-token {
  border-color: rgba(88, 199, 255, 0.5);
}

.arrow {
  color: var(--muted);
  font-size: 32px;
}

.lesson-panel {
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  gap: 14px;
  min-height: 0;
  padding: 14px;
}

.lesson-panel img {
  width: 150px;
  height: 201px;
  justify-self: center;
  border-radius: 8px;
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.42);
  object-fit: cover;
}

.lesson-copy span {
  color: var(--accent);
  font-size: 12px;
}

.lesson-copy h2 {
  margin: 5px 0 8px;
  font-size: 20px;
}

.lesson-copy p,
.effect-box p {
  font-size: 14px;
  line-height: 1.6;
}

.effect-box {
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, rgba(255, 255, 255, 0.12));
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.effect-box strong {
  display: block;
  margin-bottom: 7px;
  color: var(--accent);
}

.lesson-controls {
  display: grid;
  align-content: end;
  gap: 10px;
}

.lesson-controls button {
  min-height: 42px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
}

.board-stage {
  position: relative;
  overflow: hidden;
}

.demo-board {
  position: absolute;
  inset: 0;
}

.hex {
  position: absolute;
  display: grid;
  place-items: center;
  width: var(--hex-width, 84px);
  height: var(--hex-height, 72px);
  border: 1px solid rgba(255, 255, 255, 0.17);
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
  background: rgba(62, 66, 70, 0.7);
  color: rgba(255, 255, 255, 0.72);
  cursor: default;
  transform: translate(-50%, -50%);
  transition:
    background 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.hex.player {
  background: rgba(36, 102, 142, 0.76);
  border-color: rgba(99, 203, 255, 0.8);
}

.hex.target {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent), 0 0 28px color-mix(in srgb, var(--accent) 62%, transparent);
  cursor: pointer;
}

.hex.done {
  background: color-mix(in srgb, var(--accent) 64%, #182028);
  border-color: var(--accent);
}

.hex.result {
  animation: claim 520ms ease both;
}

.hex small {
  font-size: 12px;
  font-weight: 700;
  pointer-events: none;
}

.lesson-log {
  position: absolute;
  left: 50%;
  bottom: 18px;
  width: min(680px, calc(100% - 36px));
  padding: 12px 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(7, 9, 13, 0.8);
  text-align: center;
  transform: translateX(-50%);
}

@keyframes claim {
  from {
    opacity: 0.35;
    transform: translate(-50%, -50%) scale(0.74);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@media (max-width: 860px) {
  body {
    overflow: auto;
  }

  .tutorial-shell {
    height: auto;
    min-height: 100vh;
  }

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

  .lesson-tabs {
    overflow-x: auto;
  }

  .lesson-layout {
    grid-template-columns: 1fr;
  }

  .info-page {
    grid-template-columns: 1fr;
  }

  .lesson-panel {
    grid-template-columns: 120px 1fr;
    grid-template-rows: auto auto;
  }

  .lesson-panel img {
    width: 108px;
    height: 145px;
    grid-row: span 2;
  }

  .lesson-controls {
    grid-column: 1 / -1;
    grid-template-columns: 1fr 1fr;
  }

  .board-stage {
    min-height: 520px;
  }
}

@media (max-width: 560px) {
  .page-tabs,
  .lesson-tabs {
    overflow-x: auto;
  }

  .frontline-demo,
  .demolish-demo {
    grid-template-columns: 1fr;
  }
}
