@font-face {
  font-family: "Smooch Sans";
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  src: url("fonts/smooch-sans.woff2") format("woff2");
}

:root {
  color-scheme: dark;
  --bg: #0b1118;
  --panel: #111c27;
  --line: #2a3b49;
  --gold: #d5b66e;
  --gold-2: #f0d99c;
  --text: #f3f1e9;
  --muted: #a7b1b6;
  --blue: #4dd5e3;
  --red: #ed786e;
  --green: #80d9a2;
  --warn: #f3a64a;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: "Smooch Sans", "Arial Narrow", sans-serif;
  font-family: var(--font);
  font-size: 18px;
  font-weight: 500;
  line-height: 1.3;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100dvh;
  background: radial-gradient(ellipse at 50% -20%, #203342 0, var(--bg) 58%) fixed;
  color: var(--text);
  padding: var(--safe-top) 10px var(--safe-bottom);
  -webkit-tap-highlight-color: transparent;
}

button,
select,
input {
  font: inherit;
}

button {
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

.concealed {
  visibility: hidden;
}

.muted {
  color: var(--muted);
}

h1,
h2,
h3 {
  font-weight: 700;
  margin: 0;
  letter-spacing: 0.01em;
}

small {
  font-size: 13px;
  letter-spacing: 0.1em;
  color: var(--gold);
}

.app-shell {
  max-width: 760px;
  margin: 0 auto;
  padding: 6px 0 20px;
}

.topbar {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid #263541;
  padding: 0 2px 6px;
}

.brand {
  display: flex;
  gap: 6px;
  align-items: center;
  text-decoration: none;
  color: #dfe4e7;
  min-width: 0;
}

.brand-island {
  width: 64px;
  height: auto;
  flex: none;
}

.wordmark {
  display: flex;
  align-items: baseline;
  font-size: 34px;
  line-height: 1;
  letter-spacing: 0.01em;
}

.wordmark .wv {
  font-weight: 800;
}

.wordmark .olk {
  font-weight: 200;
}

.wordmark .arena {
  font-weight: 800;
  color: var(--gold);
  margin-left: 6px;
}

.match-info {
  text-align: right;
  display: grid;
  gap: 1px;
  min-width: 0;
  margin-left: auto;
}

.match-info strong {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.match-info span {
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--gold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-actions {
  display: flex;
  gap: 8px;
  flex: none;
}

.icon-button.account-button {
  border-radius: 50%;
  border-color: #42616a;
  background: #172b35;
  color: #b4f2ed;
  font-size: 21px;
}

.account-icon {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  vertical-align: middle;
}

.topbar.signed-in .account-icon,
.topbar:not(.signed-in) #accountInitial {
  display: none;
}

body:not(.game-mode) .match-info {
  display: none;
}

body.game-mode .account-button {
  display: none;
}

.icon-button {
  border: 1px solid var(--line);
  background: #15222d;
  border-radius: 12px;
  width: 44px;
  height: 44px;
  font-size: 22px;
  font-weight: 800;
  color: var(--gold-2);
  flex: none;
}

.view {
  display: grid;
  gap: 12px;
  padding-top: 12px;
}

.card,
.battlefield-card,
.orders-card,
.replay-panel {
  background: linear-gradient(145deg, #14222e, #101820);
  border: 1px solid #32414a;
  border-radius: var(--radius);
  box-shadow: 0 12px 30px #0004;
}

.card {
  padding: 16px;
}

.notice {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid #6a5730;
  background: #2a2312;
  color: var(--gold-2);
}

.mode-picker {
  display: grid;
  gap: 10px;
}

.mode-card {
  display: grid;
  grid-template-columns: 56px 1fr;
  align-items: center;
  gap: 12px;
  min-height: 88px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid #3a5260;
  background: linear-gradient(120deg, #173341, #112029);
  color: var(--text);
  text-decoration: none;
  text-align: left;
  font-size: 18px;
}

.mode-card.friend {
  border-color: #6a5730;
  background: linear-gradient(120deg, #33291a, #1a1812);
}

.mode-card b {
  display: block;
  font-size: 26px;
  font-weight: 700;
  line-height: 1.05;
}

.mode-card small {
  display: block;
  margin-top: 4px;
  font-size: 15px;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.mode-icon {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: #0d1a22;
  font-size: 30px;
  color: var(--blue);
}

.friend .mode-icon {
  color: var(--gold);
}

.auth-card {
  display: grid;
  gap: 12px;
}

.auth-card h1,
.lobby-head h1 {
  font-size: 28px;
}

.auth-card p {
  margin: 0;
  font-size: 16px;
}

.field {
  display: grid;
  gap: 6px;
  font-size: 14px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.field input,
.field select,
.field textarea,
.feedback-admin select,
.feedback-admin input,
.save-row input,
.invite-link {
  width: 100%;
  min-height: 48px;
  background: #0d1720;
  border: 1px solid #344550;
  border-radius: 12px;
  color: var(--text);
  padding: 10px 12px;
  font-family: system-ui, sans-serif;
  font-size: 16px;
}

.invite-link {
  margin: 0;
  overflow-wrap: anywhere;
  user-select: all;
  -webkit-user-select: all;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--text);
  font-size: 17px;
}

.check-row input {
  flex: none;
  width: 22px;
  height: 22px;
  accent-color: var(--gold);
}

.check-row small {
  color: var(--muted);
  font-size: 15px;
  letter-spacing: normal;
}

.form-error {
  margin: 0;
  min-height: 1em;
  color: var(--red);
}

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

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 14px;
  min-height: 52px;
  padding: 0 14px;
  font-size: 21px;
  font-weight: 700;
  text-decoration: none;
  text-align: center;
}

.primary-button {
  background: linear-gradient(105deg, #168f8c, #176e76);
  border: 1px solid #55d6cf;
  color: #fff;
  box-shadow: 0 7px 20px #08777a44;
}

.secondary-button {
  background: #17232d;
  border: 1px solid #65583d;
  color: #dfc98c;
}

.wide {
  width: 100%;
}

.text-button,
.link-button {
  border: 0;
  background: transparent;
  color: #d7c68f;
  font-size: 17px;
  padding: 10px 4px;
}

.link-button {
  padding: 0;
  text-decoration: underline;
}

.danger {
  color: var(--red) !important;
}

.chip-button {
  border: 1px solid #42616a;
  background: #172b35;
  color: #b4f2ed;
  border-radius: 999px;
  min-height: 34px;
  padding: 0 14px;
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
}

.lobby-card {
  display: grid;
  gap: 14px;
}

.lobby-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.lobby-head div {
  display: grid;
  gap: 2px;
}

.section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin: 0 3px;
}

.section-title div {
  display: grid;
  gap: 1px;
}

.duel-list,
.formation-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.duel-item {
  border: 1px solid #2d3d48;
  border-radius: 14px;
  background: #132029;
  overflow: hidden;
}

.duel-item a {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  align-items: center;
  padding: 10px 14px;
  color: var(--text);
  text-decoration: none;
  min-height: 56px;
}

.duel-opponent {
  font-weight: 700;
  font-size: 20px;
}

.duel-item small {
  grid-column: 1 / -1;
  letter-spacing: 0.04em;
  font-size: 14px;
}

.duel-actions {
  display: flex;
  gap: 8px;
  padding: 0 14px 12px;
}

.empty {
  padding: 8px 2px;
}

.badge {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #3a4a55;
  white-space: nowrap;
}

.badge.open {
  color: var(--gold-2);
  border-color: #6a5730;
}

.badge.action {
  color: #0b1118;
  background: var(--blue);
  border-color: var(--blue);
}

.badge.wait {
  color: var(--muted);
}

.badge.ready {
  color: #0b1118;
  background: var(--gold);
  border-color: var(--gold);
}

.badge.muted {
  color: #8d999e;
}

.home-footer {
  text-align: center;
  color: #66747a;
  font-size: 15px;
  padding: 16px 0 0;
}

.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 2px 0;
}

.player-chip {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
  flex: 1;
}

.player-chip b {
  display: block;
  font-size: 17px;
  letter-spacing: 0.06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 34vw;
}

.player-chip small {
  display: block;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.player-chip.opponent {
  justify-content: flex-end;
  text-align: right;
}

.player-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: none;
}

.player-dot.blue {
  background: var(--blue);
  box-shadow: 0 0 10px var(--blue);
}

.player-dot.red {
  background: var(--red);
  box-shadow: 0 0 10px var(--red);
}

.status-center {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #d6c89f;
  font-size: 15px;
  flex: none;
  padding: 0 6px;
}

.versus {
  border: 1px solid #5e5136;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  font-size: 13px;
  color: var(--gold);
}

.battlefield-card {
  overflow: hidden;
}

.map-label {
  height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 6px 0 12px;
  color: var(--gold-2);
  font-size: 15px;
  letter-spacing: 0.08em;
}

.map-label code {
  font-size: 11px;
  color: #c7d0c9;
  margin-left: auto;
}

.canvas-wrap {
  position: relative;
  aspect-ratio: 1 / 0.92;
  background: #121c22;
  overflow: hidden;
}

.canvas-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.map-hint {
  position: absolute;
  left: 50%;
  top: 8px;
  transform: translateX(-50%);
  max-width: calc(100% - 16px);
  padding: 5px 12px;
  border-radius: 99px;
  background: #0b151de6;
  color: #f0e5c8;
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  border: 1px solid #9e895244;
}

.result-banner {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  transform: translate(-50%, -50%) rotate(-4deg);
  padding: 8px 20px;
  border: 3px solid currentColor;
  border-radius: 12px;
  background: #101820e8;
  color: var(--gold-2);
  font-size: clamp(38px, 15vw, 72px);
  font-weight: 800;
  line-height: 0.9;
  letter-spacing: 0.04em;
  text-shadow: 0 3px 0 #000;
  white-space: nowrap;
  pointer-events: none;
}

.result-banner.win {
  color: #9df0b8;
}

.result-banner.loss {
  color: #ff9d94;
}

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

.orders-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 8px;
  row-gap: 2px;
}

.orders-heading small,
.orders-heading b {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.orders-heading b {
  font-size: 24px;
  line-height: 1.05;
}

.orders-heading .budget {
  justify-self: end;
}

.unit-actions {
  display: flex;
  gap: 6px;
}

.orders-heading .text-button {
  font-size: 16px;
  padding: 6px 4px;
}

.command-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 6px;
}

.command {
  background: #172430;
  border: 1px solid #354652;
  border-radius: 12px;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #d6dcdb;
}

.command span {
  font-size: 18px;
  color: #b2c2c2;
}

.command b {
  font-size: 17px;
}

.command.active {
  border-color: #47d3de;
  background: #12333a;
  box-shadow: inset 0 0 0 1px #47d3de55;
  color: #d8fbfb;
}

.command.active span {
  color: var(--blue);
}

.target-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 6px;
  color: var(--muted);
  font-size: 14px;
  letter-spacing: 0.1em;
}

.target-row select {
  background: #14222c;
  border: 1px solid #344550;
  border-radius: 10px;
  color: #eee;
  min-height: 36px;
  padding: 0 12px;
  font-size: 18px;
  flex: 1;
  max-width: 70%;
}

.order-help {
  margin: 4px 1px 0;
  min-height: 2.1em;
  color: #94a2a5;
  font-size: 13px;
  line-height: 1.05;
}

.units-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 8px 3px 6px;
}

.budget {
  font-size: 16px;
  color: #e3c774;
  padding: 2px 10px;
  border: 1px solid #594d33;
  border-radius: 99px;
  flex: none;
  white-space: nowrap;
}

.unit-picker {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  z-index: 2;
  max-width: 440px;
  margin: 0 auto;
  padding: 4px 6px 6px;
  border: 1px solid #53616a;
  border-radius: 14px;
  background: #0b151df0;
  box-shadow: 0 10px 24px #0008;
}

.canvas-wrap:has(.unit-picker:not(.hidden)) .map-hint {
  visibility: hidden;
}

.picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 4px;
}

.picker-close {
  width: 36px;
  height: 32px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #d7dfdf;
  font-size: 20px;
  line-height: 1;
}

.picker-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
}

.unit-card {
  min-width: 0;
  min-height: 58px;
  background: linear-gradient(160deg, #1b2a35, #14202a);
  border: 1px solid #354550;
  border-radius: 12px;
  padding: 4px 2px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 0;
}

.unit-card.selected {
  border-color: var(--blue);
  box-shadow: 0 0 0 1px #4dd5e355, inset 0 0 18px #30cad022;
}

.unit-icon {
  width: 42px;
  height: 34px;
}

.unit-card b {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  line-height: 1;
}

.unit-card small {
  display: none;
}

.setup-panel {
  display: grid;
  gap: 6px;
}

.footer-actions {
  display: grid;
  grid-template-columns: 0.8fr 1.7fr;
  gap: 8px;
  margin-top: 0;
}

.waiting-panel {
  display: grid;
  gap: 10px;
}

.waiting-panel h2 {
  font-size: 26px;
}

.waiting-panel p {
  margin: 0;
}

.replay-panel {
  padding: 10px 12px;
}

.replay-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.replay-head div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.replay-head b {
  font-size: 22px;
}

.result-badge {
  padding: 4px 14px;
  border-radius: 999px;
  border: 1px solid #5e5136;
  color: var(--gold-2);
  white-space: nowrap;
}

.result-badge[data-outcome="win"] {
  background: #1d4a3a;
  border-color: var(--green);
  color: #c9f6d8;
}

.result-badge[data-outcome="loss"] {
  background: #4a1f22;
  border-color: var(--red);
  color: #ffd2cc;
}

.timeline {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
}

.timeline button {
  height: 44px;
  background: #172b35;
  border: 1px solid #42616a;
  border-radius: 11px;
  color: #b4f2ed;
  font-size: 19px;
  font-weight: 700;
}

.timeline input {
  width: 100%;
  accent-color: #4dd5de;
  height: 32px;
}

.event-log {
  list-style: none;
  margin: 0 0 10px;
  padding: 6px 0 0;
  height: 96px;
  overflow: auto;
  font-size: 16px;
  color: #93a1a4;
  border-top: 1px solid #263844;
}

.event-log li {
  padding: 3px 0;
  border-bottom: 1px solid #1f303b;
}

.event-log li.current {
  color: #e3ecea;
}

body.game-mode {
  overflow: hidden;
}

body.game-mode .app-shell {
  height: calc(100dvh - var(--safe-top) - var(--safe-bottom));
  display: flex;
  flex-direction: column;
  padding-bottom: 0;
}

body.game-mode .topbar {
  min-height: 42px;
  padding-bottom: 2px;
}

body.game-mode .brand-island,
body.game-mode .match-info {
  display: none;
}

body.game-mode .wordmark {
  font-size: 27px;
}

body.game-mode .icon-button {
  width: 36px;
  height: 36px;
}

body.game-mode .statusbar {
  min-height: 28px;
  padding: 0 2px;
}

body.game-mode .player-chip {
  gap: 5px;
}

body.game-mode .player-chip b {
  font-size: 14px;
  max-width: 31vw;
}

body.game-mode .player-chip small,
body.game-mode .status-center span:last-child {
  display: none;
}

body.game-mode .player-dot {
  width: 9px;
  height: 9px;
}

body.game-mode .status-center {
  padding: 0 4px;
}

body.game-mode .versus {
  width: 24px;
  height: 24px;
  font-size: 11px;
}

body.game-mode .home-footer {
  display: none;
}

.game-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 0;
}

.game-view .battlefield-card {
  flex: 1;
  min-height: 260px;
  display: flex;
  flex-direction: column;
}

.game-view .canvas-wrap {
  flex: 1;
  min-height: 0;
  aspect-ratio: auto;
}

.game-panel {
  flex: none;
}

dialog {
  width: min(560px, calc(100vw - 24px));
  inset: var(--safe-top) 0 var(--safe-bottom);
  margin: auto;
  max-height: calc(100vh - var(--safe-top) - var(--safe-bottom) - 24px);
  max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 24px);
  padding: 0;
  border: 1px solid #3a4b56;
  border-radius: var(--radius);
  background: #111c27;
  color: var(--text);
  box-shadow: 0 30px 80px #000a;
}

dialog::backdrop {
  background: #04080bcc;
}

.dialog-body {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.dialog-body h2 {
  font-size: 28px;
}

.dialog-body p {
  margin: 0;
}

.save-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.formation-list li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid #22323d;
}

.formation-list li div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.formation-list small {
  letter-spacing: 0.02em;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scroll-dialog {
  height: calc(100vh - var(--safe-top) - var(--safe-bottom) - 24px);
  height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 24px);
  overflow: hidden;
}

.dialog-frame {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
}

.dialog-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px 10px;
  padding: 14px 16px 10px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.dialog-head h2 {
  font-size: 26px;
  line-height: 1.05;
}

.chapter-nav {
  grid-column: 1 / -1;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.chapter-nav::-webkit-scrollbar {
  display: none;
}

.chapter-nav button {
  flex: none;
  border: 1px solid #42616a;
  background: #172b35;
  color: #b4f2ed;
  border-radius: 999px;
  padding: 5px 11px;
  font: inherit;
  font-size: 16px;
}

.dialog-scroll {
  position: relative;
  display: grid;
  grid-auto-rows: max-content;
  align-content: start;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 30px 22px 18px;
  scrollbar-width: none;
}

.dialog-scroll::-webkit-scrollbar {
  display: none;
}

.dialog-scroll p {
  margin: 0;
}

.scroll-rail {
  position: absolute;
  right: 6px;
  bottom: 10px;
  width: 12px;
  border-radius: 999px;
  background: #1d2c38;
  touch-action: none;
}

.scroll-thumb {
  position: absolute;
  left: 2px;
  right: 2px;
  top: 0;
  min-height: 36px;
  border-radius: 999px;
  background: var(--gold);
  cursor: grab;
}

.rules .counter-table th,
.rules .counter-table td {
  white-space: normal;
  vertical-align: top;
}

.rules .counter-table td:first-child {
  color: var(--gold-2);
  white-space: nowrap;
}

.steps {
  margin: 0;
  padding-left: 22px;
  display: grid;
  gap: 8px;
}

.field textarea {
  resize: vertical;
  min-height: 110px;
  line-height: 1.4;
}

.field input[type="file"] {
  min-height: 0;
  padding: 8px;
}

.feedback-form {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #0f1923;
}

.feedback-list {
  display: grid;
  gap: 10px;
}

.feedback-list h3 {
  font-size: 21px;
  color: var(--gold-2);
  margin: 8px 0 0;
}

.feedback-card {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #0f1923;
}

.feedback-card.finished {
  opacity: 0.78;
}

.feedback-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.feedback-meta small {
  color: var(--muted);
}

.feedback-badge {
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 14px;
  letter-spacing: 0.04em;
  border: 1px solid #42616a;
  color: #b4f2ed;
}

.feedback-badge.kind-bug {
  border-color: #7a3f3a;
  color: #ffb2a6;
}

.feedback-badge.kind-feature {
  border-color: #65583d;
  color: var(--gold-2);
}

.feedback-badge.status-done {
  border-color: #3c6b4d;
  color: var(--green);
}

.feedback-badge.status-rejected {
  border-color: #4a4f55;
  color: #8d999e;
}

.feedback-body {
  margin: 0;
  white-space: pre-line;
  overflow-wrap: anywhere;
  color: #d9dcd6;
}

.feedback-answer {
  margin: 0;
  padding: 6px 10px;
  border-left: 3px solid var(--gold);
  background: #17222c;
  color: var(--gold-2);
}

.feedback-shot {
  width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.feedback-card .text-button {
  justify-self: start;
  padding: 4px 0;
}

.feedback-admin {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px;
  align-items: center;
  padding-top: 6px;
  border-top: 1px dashed var(--line);
}

.feedback-admin select,
.feedback-admin input {
  min-height: 38px;
  padding: 6px 8px;
}

.rules h3 {
  font-size: 21px;
  color: var(--gold-2);
  margin-top: 4px;
}

.rules ul {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 5px;
}

.table-wrap {
  overflow-x: auto;
}

.rules table {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
}

.rules th,
.rules td {
  text-align: left;
  padding: 5px 6px;
  border-bottom: 1px solid #22323d;
  white-space: nowrap;
}

.rules th {
  color: var(--gold);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.08em;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + var(--safe-bottom));
  transform: translate(-50%, 20px);
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: 14px;
  background: #0f2a2f;
  border: 1px solid #3fb7bf;
  color: #e5fbfb;
  font-size: 18px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 20;
}

.toast[data-tone="warn"] {
  background: #2e1f12;
  border-color: var(--warn);
  color: #ffe6c6;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.update-button {
  position: fixed;
  right: 12px;
  top: calc(12px + var(--safe-top));
  z-index: 30;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid #f0d99c;
  border-radius: 999px;
  background: #fff;
  color: #172430;
  font-weight: 700;
  box-shadow: 0 8px 20px #0006;
}

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

.mode-option {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid #2f414c;
  background: #111d26;
  color: var(--muted);
  text-align: left;
}

.mode-option b {
  font-size: 21px;
  color: var(--text);
}

.mode-option small {
  font-size: 15px;
  line-height: 1.1;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.mode-option[aria-checked="true"] {
  border-color: var(--gold);
  background: linear-gradient(120deg, #2d2715, #16150f);
  box-shadow: inset 0 0 0 1px #d5b66e55;
}

.mode-option[aria-checked="true"] b {
  color: var(--gold-2);
}

.push-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid #2d3d48;
  background: #132029;
}

.push-row span {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.push-row small {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.1;
  letter-spacing: 0.02em;
}

.chip-button.active {
  border-color: #6a5730;
  background: #2a2312;
  color: var(--gold-2);
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 17px;
}

.stats-table th,
.stats-table td {
  padding: 6px 4px;
  border-bottom: 1px solid #22323d;
  text-align: left;
}

.stats-table thead th {
  color: var(--gold);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.stats-table tbody th {
  font-weight: 700;
  max-width: 9em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-table .number {
  text-align: center;
  width: 2.4em;
}

.stats-table td.win {
  color: var(--green);
}

.stats-table td.loss {
  color: var(--red);
}

.stats-table td:last-child {
  text-align: right;
}

.stats-table .chip-button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 15px;
}

.command-row.with-flag {
  grid-template-columns: repeat(4, 1fr);
}

.command-row.with-flag .command {
  flex-direction: column;
  gap: 0;
  min-height: 46px;
  line-height: 1;
}

.command-row.with-flag .command b {
  font-size: 15px;
}

.flag-card small {
  color: var(--gold);
}

.countdown {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  transform: translate(-50%, -50%);
  display: grid;
  justify-items: center;
  padding: 12px 26px 6px;
  border-radius: 20px;
  border: 1px solid #9e8952;
  background: #0b151de8;
  pointer-events: none;
}

.countdown small {
  color: var(--gold);
  letter-spacing: 0.14em;
  font-size: 13px;
}

.countdown b {
  font-size: 72px;
  line-height: 1;
  color: var(--gold-2);
}

.pepi {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: calc(12px + var(--safe-bottom));
  z-index: 15;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  max-width: 460px;
  margin: 0 auto;
  pointer-events: none;
}

.pepi.hidden {
  display: none;
}

.pepi-figure {
  flex: none;
  width: 64px;
  height: auto;
  filter: drop-shadow(0 6px 10px #0008);
}

.pepi-bubble {
  position: relative;
  flex: 1;
  margin-bottom: 18px;
  padding: 10px 12px 8px;
  border-radius: 16px;
  border: 1px solid #d5b66e;
  background: #fbf6e6;
  color: #1b2630;
  box-shadow: 0 12px 30px #000a;
  pointer-events: auto;
}

.pepi-bubble::before {
  content: "";
  position: absolute;
  left: -8px;
  bottom: 18px;
  width: 14px;
  height: 14px;
  background: #fbf6e6;
  border-left: 1px solid #d5b66e;
  border-bottom: 1px solid #d5b66e;
  transform: rotate(45deg);
}

.pepi-bubble p {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
}

.pepi-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.pepi-actions .text-button {
  color: #6b5a33;
}

.pepi-actions .chip-button {
  border-color: #1d7e9e;
  background: #1d7e9e;
  color: #fff;
}

@media (min-width: 640px) {
  body {
    padding-left: 18px;
    padding-right: 18px;
  }

  .mode-picker {
    grid-template-columns: 1fr 1fr;
  }

  .unit-icon {
    width: 46px;
    height: 38px;
  }

  .unit-card {
    min-height: 64px;
  }
}

@media (min-width: 960px) and (min-aspect-ratio: 4 / 3) {
  body.game-mode .app-shell {
    max-width: 1280px;
  }

  .game-view {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    grid-template-rows: auto minmax(0, 1fr);
    column-gap: 14px;
  }

  .game-view .statusbar {
    grid-column: 1 / -1;
  }

  .game-view .battlefield-card {
    grid-row: 2;
  }

  .game-panel {
    grid-column: 2;
    grid-row: 2;
    overflow: auto;
    align-self: start;
    max-height: 100%;
  }

  .event-log {
    height: 240px;
  }
}

@media (max-height: 760px) {
  .order-help {
    display: none;
  }

  .topbar {
    min-height: 50px;
  }

  .brand-island {
    width: 52px;
  }

  .wordmark {
    font-size: 30px;
  }
}

@media (max-width: 380px) {
  body {
    padding-left: 6px;
    padding-right: 6px;
  }

  .map-label code {
    display: none;
  }

  .map-label .chip-button {
    margin-left: auto;
  }

  .unit-list {
    gap: 4px;
  }

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

  .unit-card b {
    font-size: 13px;
  }

  .match-info {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    transition: none;
  }
}
