:root {
  --bg: #090a0c;
  --bg-2: #0d0f13;
  --ink: #e8e4d8;
  --ink-dim: #8c8b84;
  --ink-faint: #55565a;
  --line: #23262c;
  --line-soft: #171a1f;
  --enemy: #ff6b52;
  --enemy-dim: #a34737;
  --panel: rgba(10, 11, 13, 0.82);
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --pad: clamp(20px, 4vw, 54px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
}

body {
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

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

button {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  letter-spacing: inherit;
}

button:disabled {
  cursor: default;
}

::selection {
  background: var(--ink);
  color: var(--bg);
}

:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 3px;
}

.hidden {
  display: none !important;
}

#ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 60% at 62% 40%, rgba(232, 228, 216, 0.045), transparent 70%),
    radial-gradient(ellipse 60% 60% at 15% 90%, rgba(255, 107, 82, 0.028), transparent 70%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='80' viewBox='0 0 160 80'%3E%3Cg fill='none' stroke='%23e8e4d8' stroke-opacity='.05' stroke-width='1'%3E%3Cpath d='M0 40L80 0L160 40L80 80Z'/%3E%3Cpath d='M-80 0L0 40L80 0'/%3E%3Cpath d='M80 80L160 40L240 80'/%3E%3C/g%3E%3C/svg%3E");
  background-size: auto, auto, 160px 80px;
}

#ambient::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(9, 10, 12, 0.1), rgba(9, 10, 12, 0.72) 78%);
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  display: none;
}

body.in-game #stage {
  display: block;
}

body.in-game #ambient {
  opacity: 0;
}

#ui {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

#ui button,
#ui input,
#ui a {
  pointer-events: auto;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: var(--pad);
}

.eyebrow {
  display: block;
  color: var(--ink-dim);
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

/* ---------- Main menu ---------- */

#screen-menu {
  justify-content: space-between;
}

.menu-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--ink-dim);
  font-size: 9px;
  letter-spacing: 0.16em;
}

.mark-diamond {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 8px;
  border: 1px solid var(--ink);
  transform: rotate(45deg) scaleX(0.7);
  vertical-align: 0;
}

.meta-left {
  display: flex;
  align-items: center;
}

.menu-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(350px, 440px);
  align-items: end;
  gap: clamp(32px, 7vw, 120px);
  padding-bottom: clamp(40px, 8vh, 110px);
}

.brand h1 {
  margin: 0 0 18px;
  font-size: clamp(58px, 12.5vw, 178px);
  font-weight: 400;
  line-height: 0.78;
  letter-spacing: 0.12em;
  text-indent: 0.06em;
  color: var(--ink);
}

.brand .tagline {
  margin: 0;
  color: var(--ink-dim);
  font-size: 10px;
  letter-spacing: 0.32em;
}

.menu-nav {
  border-top: 1px solid var(--line);
}

.nav-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto 18px;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 17px 6px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  transition: background 120ms ease, color 120ms ease, padding 160ms ease;
}

.nav-index {
  color: var(--ink-faint);
  font-size: 9px;
  letter-spacing: 0.08em;
  transition: color 120ms ease;
}

.nav-label {
  font-size: 13px;
  letter-spacing: 0.2em;
}

.nav-note {
  color: var(--ink-faint);
  font-size: 8px;
  letter-spacing: 0.14em;
  transition: color 120ms ease;
}

.nav-arrow {
  font-size: 14px;
  opacity: 0.5;
  transition: transform 160ms ease, opacity 160ms ease;
}

.nav-row:hover {
  background: var(--ink);
  color: var(--bg);
  padding-left: 12px;
  padding-right: 6px;
}

.nav-row:hover .nav-index,
.nav-row:hover .nav-note {
  color: rgba(9, 10, 12, 0.55);
}

.nav-row:hover .nav-arrow {
  opacity: 1;
  transform: translateX(3px);
}

.menu-foot {
  display: flex;
  justify-content: space-between;
  color: var(--ink-faint);
  font-size: 8px;
  letter-spacing: 0.18em;
}

/* ---------- Interior pages ---------- */

.page {
  background: linear-gradient(180deg, rgba(9, 10, 12, 0.82), rgba(9, 10, 12, 0.94));
}

.page-head {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) auto;
  align-items: center;
  gap: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.back,
.link {
  color: var(--ink-dim);
  font-size: 9px;
  letter-spacing: 0.16em;
  text-align: left;
  transition: color 120ms ease;
}

.back:hover,
.link:hover {
  color: var(--ink);
}

.page-title {
  text-align: center;
}

.page-title h2 {
  margin: 3px 0 0;
  font-size: clamp(24px, 3.6vw, 44px);
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.22em;
  text-indent: 0.11em;
}

.page-meta {
  color: var(--ink-dim);
  font-size: 9px;
  letter-spacing: 0.16em;
  text-align: right;
}

.page-body {
  flex: 1;
  overflow-y: auto;
  padding: clamp(26px, 5vh, 56px) 0;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
  pointer-events: auto;
}

.page-body::-webkit-scrollbar {
  width: 4px;
}

.page-body::-webkit-scrollbar-thumb {
  background: var(--line);
}

.lede {
  max-width: 620px;
  margin: 0 0 clamp(26px, 4vh, 44px);
  color: var(--ink-dim);
  font-size: 11px;
  line-height: 1.75;
  letter-spacing: 0.04em;
}

.page-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--ink-faint);
  font-size: 8px;
  letter-spacing: 0.16em;
}

.level-list {
  border-top: 1px solid var(--line);
  max-width: 940px;
}

.level-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 94px 62px 64px 22px;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 19px 6px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  transition: background 120ms ease, padding 160ms ease;
}

.level-row:hover:not(.locked) {
  background: rgba(232, 228, 216, 0.035);
  padding-left: 12px;
}

.level-row.locked {
  cursor: default;
  color: var(--ink-faint);
}

.level-index {
  color: var(--ink-faint);
  font-size: 10px;
  letter-spacing: 0.12em;
}

.level-name {
  font-size: 13px;
  letter-spacing: 0.18em;
}

.level-name small {
  display: block;
  margin-top: 4px;
  color: var(--ink-faint);
  font-size: 9px;
  letter-spacing: 0.04em;
  line-height: 1.45;
  text-transform: none;
}

.level-row.locked .level-name small {
  color: rgba(85, 86, 90, 0.6);
}

.level-brief {
  color: var(--ink-dim);
  font-size: 9px;
  letter-spacing: 0.1em;
}

.tier {
  display: flex;
  gap: 3px;
  justify-content: flex-end;
}

.tier i {
  display: block;
  width: 5px;
  height: 5px;
  border: 1px solid var(--ink-faint);
  transform: rotate(45deg) scaleY(0.78);
}

.tier i.on {
  background: var(--ink-dim);
  border-color: var(--ink-dim);
}

.level-row.locked .tier i.on {
  background: var(--ink-faint);
  border-color: var(--ink-faint);
}

.level-state {
  font-size: 8px;
  letter-spacing: 0.14em;
  text-align: right;
  color: var(--ink-faint);
}

.level-row.cleared .level-state {
  color: var(--ink);
}

.level-row.open .level-state {
  color: var(--ink-dim);
}

.level-arrow {
  text-align: right;
  color: var(--ink-faint);
  font-size: 12px;
}

.level-row:hover:not(.locked) .level-arrow {
  color: var(--ink);
}

.fineprint {
  max-width: 620px;
  margin: 28px 0 0;
  color: var(--ink-faint);
  font-size: 9px;
  line-height: 1.7;
  letter-spacing: 0.04em;
}

/* ---------- Online ---------- */

.online-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  max-width: 940px;
}

.panel {
  min-height: 220px;
  padding: 26px;
  border: 1px solid var(--line);
  background: rgba(14, 16, 20, 0.42);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.panel h3 {
  margin: 10px 0 8px;
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0.18em;
}

.panel p {
  margin: 0 0 24px;
  color: var(--ink-dim);
  font-size: 10px;
  line-height: 1.7;
}

.panel .btn {
  margin-top: auto;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 38px;
  padding: 9px 16px;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
  background: transparent;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.btn:hover {
  border-color: var(--ink-dim);
  background: rgba(232, 228, 216, 0.06);
}

.btn.primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

.btn.primary:hover {
  background: transparent;
  color: var(--ink);
}

.btn span {
  color: var(--ink-faint);
  font-size: 8px;
}

.btn.primary span {
  color: rgba(9, 10, 12, 0.55);
}

.btn.primary:hover span {
  color: var(--ink-faint);
}

.btn:disabled {
  opacity: 0.35;
}

.join-form {
  display: flex;
  gap: 8px;
  margin-top: auto;
  width: 100%;
}

.code-input {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: transparent;
  font-size: 15px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  outline: none;
}

.code-input::placeholder {
  color: var(--ink-faint);
  letter-spacing: 0.28em;
}

.code-input:focus {
  border-color: var(--ink-dim);
}

.resume-row {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--ink-faint);
  font-size: 8px;
  letter-spacing: 0.16em;
}

.rules-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: clamp(30px, 6vh, 60px);
  color: var(--ink-faint);
  font-size: 8px;
  letter-spacing: 0.18em;
}

.rules-strip i {
  font-style: normal;
  opacity: 0.4;
}

.wait-panel {
  max-width: 580px;
  margin: 3vh auto 0;
  text-align: center;
}

.room-code {
  margin: 12px 0 18px;
  font-size: clamp(48px, 8vw, 82px);
  line-height: 1;
  letter-spacing: 0.3em;
  text-indent: 0.15em;
}

.wait-status {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 9px;
  color: var(--ink-dim);
  font-size: 9px;
  letter-spacing: 0.18em;
}

.pulse-dot {
  width: 5px;
  height: 5px;
  background: var(--ink);
  border-radius: 50%;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.25;
    transform: scale(0.8);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

.wait-copy {
  margin: 36px 0 8px;
  color: var(--ink-faint);
  font-size: 9px;
  letter-spacing: 0.08em;
}

.copy-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  max-width: 100%;
}

.copy-row code {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid var(--line);
  color: var(--ink-dim);
  font-family: var(--mono);
  font-size: 9px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}

.wait-panel .link {
  display: inline-block;
  margin-top: 32px;
}

/* ---------- Game HUD ---------- */

#screen-game {
  pointer-events: none;
}

#screen-game button {
  pointer-events: auto;
}

.game-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto minmax(180px, 1fr);
  align-items: start;
  gap: 16px;
  padding: 20px 24px;
}

.game-left,
.game-right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.game-right {
  justify-content: flex-end;
}

.icon-btn {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: rgba(9, 10, 12, 0.55);
  color: var(--ink-dim);
  font-size: 9px;
  letter-spacing: 0.02em;
  transition: color 120ms ease, border-color 120ms ease;
}

.icon-btn:hover {
  color: var(--ink);
  border-color: var(--ink-dim);
}

.icon-btn.off {
  color: var(--ink-faint);
  text-decoration: line-through;
}

.btn.danger {
  border-color: var(--enemy-dim);
  color: var(--enemy);
}

.btn.danger:hover {
  background: rgba(255, 107, 82, 0.08);
  border-color: var(--enemy);
}

.result-note {
  margin: 0;
  color: var(--ink-faint);
  font-size: 9px;
  line-height: 1.7;
  letter-spacing: 0.04em;
}

.game-id {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.game-id .eyebrow {
  font-size: 8px;
}

.game-name {
  color: var(--ink);
  font-size: 10px;
  letter-spacing: 0.12em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.turn {
  text-align: center;
  padding-top: 2px;
  min-width: 190px;
}

.turn-round {
  display: block;
  color: var(--ink-faint);
  font-size: 8px;
  letter-spacing: 0.2em;
}

.turn-side {
  display: block;
  margin-top: 3px;
  color: var(--ink);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.22em;
  transition: color 200ms ease;
}

.turn-node {
  display: none;
}

.turn.enemy .turn-side {
  color: var(--enemy);
}

.turn.waiting .turn-side {
  color: var(--ink-dim);
}

.turn-note {
  position: absolute;
  left: 50%;
  top: 74px;
  transform: translateX(-50%);
  color: var(--ink-faint);
  font-size: 8px;
  letter-spacing: 0.16em;
  white-space: nowrap;
}

.score {
  display: grid;
  grid-template-columns: auto auto;
  column-gap: 12px;
  row-gap: 2px;
  padding: 0 2px;
}

.score-title {
  grid-column: 1 / -1;
  color: var(--ink-faint);
  font-size: 8px;
  letter-spacing: 0.18em;
  text-align: right;
}

.score-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  font-size: 8px;
  color: var(--ink-dim);
}

.score-row em {
  font-style: normal;
  letter-spacing: 0.12em;
  font-size: 8px;
}

.score-row b {
  min-width: 9px;
  color: var(--ink);
  font-size: 10px;
  font-weight: 400;
  text-align: right;
}

.score-row.enemy b {
  color: var(--enemy);
}

.pips {
  display: flex;
  gap: 4px;
}

.pips i {
  display: block;
  width: 6px;
  height: 6px;
  border: 1px solid var(--ink-faint);
  transform: rotate(45deg) scaleY(0.76);
}

.pips i.on {
  background: var(--ink);
  border-color: var(--ink);
}

.score-row.enemy .pips i.on {
  background: var(--enemy);
  border-color: var(--enemy);
}

.game-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: 276px minmax(0, 1fr) auto;
  align-items: end;
  gap: 20px;
  padding: 18px 24px calc(18px + env(safe-area-inset-bottom));
}

.unit-card {
  min-height: 72px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(10px);
}

.unit-empty {
  color: var(--ink-faint);
  font-size: 8px;
  letter-spacing: 0.18em;
  padding: 12px 0 14px;
}

.unit-head {
  display: flex;
  align-items: center;
  gap: 9px;
}

.unit-glyph {
  display: block;
  width: 15px;
  height: 12px;
  position: relative;
  flex: 0 0 auto;
}

.unit-glyph::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 1px;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 9px solid var(--ink);
}

.unit-glyph.arc::before {
  width: 9px;
  height: 9px;
  left: 2px;
  top: 1px;
  border: 1px solid var(--ink);
  border-radius: 50%;
  background: transparent;
  border-left-width: 1px;
  border-right-width: 1px;
  border-top-width: 1px;
  border-bottom-width: 1px;
}

.unit-glyph.bastion::before {
  width: 9px;
  height: 9px;
  left: 2px;
  top: 1px;
  border: 1px solid var(--ink);
  background: transparent;
  border-left-width: 1px;
  border-right-width: 1px;
  border-top-width: 1px;
  border-bottom-width: 1px;
}

.unit-name {
  font-size: 10px;
  letter-spacing: 0.2em;
}

.unit-hp {
  display: flex;
  gap: 3px;
  margin-left: auto;
}

.unit-hp i {
  display: block;
  width: 8px;
  height: 3px;
  background: var(--ink);
}

.unit-hp i.off {
  background: var(--line);
}

.unit-stats {
  display: flex;
  gap: 22px;
  margin-top: 9px;
}

.unit-stats span {
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.unit-stats b {
  font-size: 12px;
  font-weight: 400;
  color: var(--ink);
}

.unit-stats em {
  font-style: normal;
  color: var(--ink-faint);
  font-size: 7px;
  letter-spacing: 0.12em;
}

.log {
  justify-self: center;
  align-self: center;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--ink-faint);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding-bottom: 10px;
}

.log.alert {
  color: var(--enemy);
}

.action-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding-bottom: 2px;
}

.action-bar .btn {
  background: var(--panel);
  backdrop-filter: blur(10px);
}

.action-bar .btn.primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
  backdrop-filter: none;
}

.action-bar .btn.primary:hover {
  background: transparent;
  color: var(--ink);
}

.action-bar .btn.primary span {
  color: rgba(9, 10, 12, 0.55);
}

.action-bar .btn.primary:hover span {
  color: var(--ink-faint);
}

/* ---------- Modal ---------- */

#modal-root {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 6, 8, 0.76);
  backdrop-filter: blur(3px);
}

.modal-card {
  position: relative;
  width: min(580px, 100%);
  max-height: min(86vh, 760px);
  display: flex;
  flex-direction: column;
  padding: 0;
  border: 1px solid var(--line);
  background: #0c0e12;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  animation: rise 220ms ease both;
}

#modal-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: clamp(26px, 4vw, 42px);
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

#modal-content::-webkit-scrollbar {
  width: 4px;
}

#modal-content::-webkit-scrollbar-thumb {
  background: var(--line);
}

.modal-close {
  position: absolute;
  z-index: 2;
  top: 12px;
  right: 14px;
  width: 28px;
  height: 28px;
  color: var(--ink-faint);
  font-size: 17px;
  line-height: 1;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 28px;
  height: 28px;
  color: var(--ink-faint);
  font-size: 17px;
  line-height: 1;
}

.modal-close:hover {
  color: var(--ink);
}

.modal-kicker {
  display: block;
  color: var(--ink-faint);
  font-size: 8px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.modal-title {
  margin: 8px 0 18px;
  font-size: clamp(24px, 4vw, 36px);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: 0.18em;
  text-indent: 0.09em;
  text-transform: uppercase;
}

.modal-sub {
  margin: -8px 0 20px;
  color: var(--ink-dim);
  font-size: 10px;
  letter-spacing: 0.1em;
}

.modal-body {
  color: var(--ink-dim);
  font-size: 11px;
  line-height: 1.75;
}

.modal-body p {
  margin: 0 0 16px;
}

.modal-body strong {
  color: var(--ink);
  font-weight: 400;
}

.brief-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 22px 0;
  padding: 16px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.brief-cell .eyebrow {
  margin-bottom: 7px;
}

.brief-cell span {
  color: var(--ink);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.roster {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

.roster-item {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--ink-dim);
  font-size: 8px;
  letter-spacing: 0.1em;
}

.roster-item i {
  width: 7px;
  height: 7px;
  border: 1px solid var(--ink-dim);
  transform: rotate(45deg) scaleY(0.65);
}

.roster-item.arc i {
  border-radius: 50%;
  transform: none;
}

.roster-item.bastion i {
  transform: none;
}

.hint-box {
  margin: 18px 0 0;
  padding: 12px 14px;
  border-left: 1px solid var(--line);
  color: var(--ink-dim);
  font-size: 9px;
  line-height: 1.65;
  letter-spacing: 0.04em;
}

.hint-box b {
  display: block;
  margin-bottom: 2px;
  color: var(--ink-faint);
  font-size: 7px;
  font-weight: 400;
  letter-spacing: 0.2em;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 28px;
}

.result-title {
  margin: 6px 0 2px;
  font-size: clamp(34px, 6vw, 58px);
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.18em;
  text-indent: 0.09em;
}

.result-title.win {
  color: var(--ink);
}

.result-title.loss {
  color: var(--enemy);
}

.result-title.draw {
  color: var(--ink-dim);
}

.result-reason {
  color: var(--ink-faint);
  font-size: 9px;
  letter-spacing: 0.2em;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 28px 0;
  padding: 18px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.result-stats span {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.result-stats b {
  color: var(--ink);
  font-size: 18px;
  font-weight: 400;
}

.result-stats em {
  color: var(--ink-faint);
  font-size: 8px;
  font-style: normal;
  letter-spacing: 0.14em;
}

.manual h3 {
  margin: 24px 0 8px;
  color: var(--ink);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.18em;
}

.manual h3:first-child {
  margin-top: 0;
}

.manual p,
.manual li {
  color: var(--ink-dim);
  font-size: 10px;
  line-height: 1.7;
}

.manual ul {
  margin: 0;
  padding-left: 18px;
}

.manual table {
  width: 100%;
  border-collapse: collapse;
  font-size: 9px;
}

.manual th,
.manual td {
  padding: 8px 4px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  font-weight: 400;
  letter-spacing: 0.06em;
}

.manual th {
  color: var(--ink-faint);
  font-size: 7px;
  letter-spacing: 0.16em;
}

.manual td {
  color: var(--ink-dim);
}

.manual td:first-child {
  color: var(--ink);
}

.manual .muted {
  color: var(--ink-faint);
  font-size: 9px;
}

.manual kbd {
  display: inline-block;
  padding: 1px 5px;
  border: 1px solid var(--line);
  color: var(--ink-dim);
  font-family: var(--mono);
  font-size: 8px;
  line-height: 1.4;
}

/* ---------- Toast and misc ---------- */

.toast {
  position: fixed;
  z-index: 30;
  top: 132px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(90vw, 440px);
  padding: 9px 14px;
  border: 1px solid var(--line);
  background: #0d0f13;
  color: var(--ink-dim);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
  pointer-events: none;
  animation: toast-in 180ms ease both;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, -4px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .menu-grid {
    grid-template-columns: 1fr;
    gap: 44px;
  }

  .brand h1 {
    font-size: clamp(56px, 16vw, 120px);
  }

  .menu-nav {
    max-width: 560px;
  }

  .level-row {
    grid-template-columns: 42px minmax(0, 1fr) 70px 54px 54px 16px;
    gap: 10px;
  }

  .level-name small {
    display: none;
  }

  .game-top {
    grid-template-columns: 1fr auto 1fr;
    padding: 14px 14px;
  }

  .game-id .eyebrow {
    display: none;
  }

  .game-name {
    font-size: 9px;
  }

  .turn {
    min-width: 150px;
  }

  .turn-node {
    display: block;
    margin-top: 2px;
    color: var(--ink-faint);
    font-size: 8px;
    letter-spacing: 0.16em;
  }

  .score {
    display: none;
  }

  .game-bottom {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "log log"
      "unit actions";
    gap: 10px 12px;
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  }

  .unit-card {
    grid-area: unit;
    min-height: 0;
  }

  .log {
    grid-area: log;
    padding: 0;
    font-size: 8px;
    justify-self: start;
  }

  .action-bar {
    grid-area: actions;
  }

  .unit-card {
    padding: 10px 12px;
  }

  .unit-empty {
    padding: 4px 0;
  }

  .unit-stats {
    gap: 14px;
    margin-top: 6px;
  }

  .unit-stats em {
    display: none;
  }

  .unit-stats b {
    font-size: 11px;
  }

  .turn-note {
    top: 66px;
  }
}

@media (max-width: 620px) {
  :root {
    --pad: 16px;
  }

  .menu-meta {
    font-size: 8px;
  }

  .meta-right {
    display: none;
  }

  .menu-grid {
    padding-bottom: 24px;
  }

  .brand h1 {
    font-size: clamp(48px, 17vw, 78px);
    letter-spacing: 0.09em;
  }

  .brand .tagline {
    font-size: 8px;
    letter-spacing: 0.22em;
  }

  .nav-row {
    grid-template-columns: 28px minmax(0, 1fr) 16px;
    padding: 14px 4px;
  }

  .nav-note {
    display: none;
  }

  .menu-foot span:last-child {
    display: none;
  }

  .page-head {
    grid-template-columns: 1fr auto;
    gap: 10px;
  }

  .page-head .back {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
  }

  .page-title {
    grid-column: 1 / -1;
    grid-row: 2;
    text-align: left;
    margin-top: 8px;
  }

  .page-title h2 {
    letter-spacing: 0.16em;
  }

  .page-meta {
    grid-column: 2;
    grid-row: 1;
  }

  .level-row {
    grid-template-columns: 30px minmax(0, 1fr) 44px;
    gap: 8px;
    padding: 15px 2px;
  }

  .level-brief,
  .tier,
  .level-arrow {
    display: none;
  }
  .level-name {
    font-size: 11px;
  }

  .level-state {
    font-size: 7px;
  }

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

  .panel {
    min-height: 0;
    padding: 20px;
  }

  .panel .btn {
    margin-top: 8px;
  }

  .join-form {
    margin-top: 8px;
  }

  .rules-strip {
    display: none;
  }

  .wait-panel {
    margin-top: 0;
  }

  .copy-row {
    flex-direction: column;
  }

  .copy-row .btn {
    min-height: 32px;
    justify-content: center;
  }

  .game-top {
    grid-template-columns: auto 1fr auto;
    gap: 6px;
    padding: 10px 10px;
  }

  .game-left {
    gap: 8px;
  }

  .game-id {
    display: none;
  }

  .game-right {
    gap: 6px;
  }

  .icon-btn {
    width: 26px;
    height: 26px;
    font-size: 8px;
  }

  .turn {
    min-width: 0;
    justify-self: center;
  }

  .turn-side {
    font-size: 9px;
    letter-spacing: 0.16em;
  }

  .game-bottom {
    grid-template-columns: 1fr;
    grid-template-areas:
      "log"
      "unit"
      "actions";
    gap: 8px;
  }

  .log {
    display: block;
    padding: 0;
    font-size: 8px;
  }

  .action-bar {
    justify-content: stretch;
  }

  .action-bar .btn {
    flex: 1;
    justify-content: center;
    letter-spacing: 0.12em;
  }

  .action-bar .btn span {
    display: none;
  }

  .unit-head {
    gap: 7px;
  }

  .unit-stats {
    gap: 12px;
  }

  .unit-stats em {
    display: inline;
    font-size: 6px;
  }

  .modal-card {
    padding: 0;
  }

  #modal-content {
    padding: 28px 22px;
  }

  .brief-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .result-stats {
    margin: 22px 0;
  }
}

@media (max-height: 640px) and (min-width: 901px) {
  .menu-grid {
    padding-bottom: 20px;
  }

  .menu-foot {
    display: none;
  }

  .page-body {
    padding: 24px 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
