:root {
  --bg: #f4f1ea;
  --panel: #fffdf8;
  --panel-2: #ebe6d9;
  --ink: #211f1a;
  --muted: #6d665c;
  --line: #d8d0c0;
  --green: #4d7a64;
  --red: #b85f4d;
  --blue: #3d6f91;
  --yellow: #d7aa3f;
  --shadow: 0 16px 42px rgba(33, 31, 26, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(120deg, rgba(77, 122, 100, 0.18), transparent 40%),
    linear-gradient(300deg, rgba(184, 95, 77, 0.15), transparent 36%),
    var(--bg);
  color: var(--ink);
  font-family: "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}

button,
a {
  font: inherit;
}

.app-shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 78px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.6rem, 1.1rem + 1.5vw, 2.55rem);
  line-height: 1.1;
  letter-spacing: 0;
}

.docs-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  text-decoration: none;
}

.workspace {
  margin-top: 14px;
}

.game-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.tab {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.74);
  color: var(--muted);
  cursor: pointer;
}

.tab.is-active {
  background: var(--ink);
  color: #fffdf8;
  border-color: var(--ink);
}

.mock-frame {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr) 230px;
  gap: 12px;
  min-height: 680px;
}

.panel {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.88);
  box-shadow: var(--shadow);
}

.panel-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.8rem;
}

.panel-heading strong {
  color: var(--ink);
  font-size: 0.9rem;
}

.stat-grid {
  display: grid;
  gap: 8px;
}

.stat {
  display: grid;
  gap: 2px;
  min-height: 56px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf0;
}

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

.stat strong {
  font-size: 1.05rem;
}

.control-stack {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.control-stack button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  cursor: pointer;
}

.stage-wrap {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #11100d;
  box-shadow: var(--shadow);
}

.stage {
  display: none;
  min-height: 680px;
  padding: 18px;
}

.stage.is-active {
  display: block;
}

.rogue-stage {
  background: #181611;
  color: #f7f1df;
}

.rogue-map {
  display: grid;
  grid-template-columns: repeat(14, 1fr);
  gap: 4px;
  width: min(100%, 620px);
  margin: 0 auto;
}

.tile {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: #29251c;
  color: #e9dfc7;
  font-weight: 800;
}

.tile.wall {
  background: #4a4438;
}

.tile.floor {
  background: #242017;
}

.tile.player {
  background: var(--green);
  color: #fff;
}

.tile.enemy {
  background: var(--red);
  color: #fff;
}

.tile.item {
  background: var(--yellow);
  color: #271f10;
}

.message-log {
  display: grid;
  gap: 8px;
  width: min(100%, 620px);
  margin: 18px auto 0;
}

.message-log p {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #514735;
  border-radius: 8px;
  background: #211d15;
  color: #e9dfc7;
}

.stg-stage {
  position: relative;
  overflow: hidden;
  background: #091019;
}

.stg-hud,
.katana-hud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
  color: #f8fbff;
  font-weight: 800;
}

.stg-hud span,
.katana-hud span {
  min-height: 32px;
  padding: 5px 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.stg-field {
  position: relative;
  height: 590px;
  margin-top: 16px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    #0b1420;
  background-size: 24px 24px;
}

.bullet,
.ship,
.boss {
  position: absolute;
  display: block;
  border-radius: 999px;
}

.bullet {
  width: 9px;
  height: 9px;
  background: #f06464;
  box-shadow: 0 0 12px rgba(240, 100, 100, 0.7);
}

.ship {
  width: 26px;
  height: 26px;
  clip-path: polygon(50% 0, 100% 100%, 50% 78%, 0 100%);
  background: #7fd1ff;
  border-radius: 0;
}

.boss {
  width: 68px;
  height: 68px;
  background: #d7aa3f;
  box-shadow: 0 0 26px rgba(215, 170, 63, 0.5);
}

.katana-stage {
  position: relative;
  overflow: hidden;
  background: linear-gradient(#cadce5, #eef0df 46%, #3a4d3e 47%, #21251f);
}

.skyline {
  height: 230px;
  margin: 70px -18px 0;
  background:
    linear-gradient(90deg, transparent 0 8%, rgba(40, 61, 55, 0.28) 8% 15%, transparent 15% 22%, rgba(40, 61, 55, 0.32) 22% 35%, transparent 35% 47%, rgba(40, 61, 55, 0.26) 47% 61%, transparent 61%),
    linear-gradient(transparent 44%, rgba(30, 42, 34, 0.5) 45% 100%);
}

.dash-track {
  position: relative;
  height: 220px;
  margin-top: 28px;
  border-top: 4px solid rgba(255, 255, 255, 0.18);
}

.checkpoint,
.runner,
.gate {
  position: absolute;
  bottom: 34px;
  display: block;
}

.checkpoint {
  width: 12px;
  height: 76px;
  border-radius: 8px;
  background: #f6f2d8;
}

.checkpoint-a {
  left: 18%;
}

.checkpoint-b {
  left: 48%;
}

.checkpoint-c {
  left: 76%;
}

.runner {
  left: 36%;
  width: 34px;
  height: 58px;
  border-radius: 18px 18px 8px 8px;
  background: var(--red);
  box-shadow: 54px 4px 0 -18px rgba(255, 255, 255, 0.9);
}

.gate {
  right: 7%;
  width: 74px;
  height: 96px;
  border: 8px solid #d7aa3f;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
}

.score-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 24px;
}

.score-list li {
  min-height: 38px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf0;
}

.sync-card {
  display: grid;
  gap: 4px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.sync-card span {
  color: var(--muted);
  font-size: 0.78rem;
}

@media (max-width: 980px) {
  .mock-frame {
    grid-template-columns: 1fr;
  }

  .stage,
  .mock-frame {
    min-height: auto;
  }

  .panel-left,
  .panel-right {
    order: 2;
  }

  .stage-wrap {
    order: 1;
  }

  .stg-field {
    height: 420px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1280px);
    padding-top: 14px;
  }

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

  .game-tabs {
    grid-template-columns: 1fr;
  }

  .rogue-map {
    gap: 2px;
  }

  .tile {
    font-size: 0.68rem;
  }
}
