.rules-badge {
  display: inline-block;
  padding: 5px 10px;
  border: 1px solid #647575;
  border-radius: 30px;
  color: #b9e7ce;
  background: #182922;
  font-size: 11px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.simple-rules {
  list-style: none;
  counter-reset: rules;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 0;
  margin: 22px 0;
}
.simple-rules li {
  counter-increment: rules;
  background: #171f2a;
  border: 1px solid #34424f;
  border-radius: 12px;
  padding: 16px;
  line-height: 1.55;
}
.simple-rules strong {
  display: block;
  color: #ffd1a4;
  font-size: 15px;
  margin-bottom: 8px;
}
.simple-rules strong:before {
  content: counter(rules) " · ";
}
.simple-rules span {
  color: #d0d8e0;
  font-size: 13px;
}
.setup-section {
  border-top: 1px solid #36414d;
  padding-top: 18px;
  margin-top: 24px;
}
.setup-section h3 {
  font-size: 18px;
  margin: 0 0 8px;
}
.setup-section h3 small {
  color: #abd4c0;
  margin-left: 12px;
}
.setup-section > p,
.strategy-tip {
  font-size: 13px;
  line-height: 1.65;
}
.setup-grid,
.settings-grid,
.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}
.setup-grid label {
  display: grid;
  gap: 8px;
  font-size: 13px;
}
.setup-grid select {
  width: 100%;
}
.formation-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.formation-option {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: left;
  padding: 12px;
  border-radius: 12px;
  white-space: normal;
}
.formation-option small {
  font-size: 12px;
  line-height: 1.5;
  color: #b7c7d5;
  margin-top: 8px;
}
.formation-option.selected,
.hero-option.selected {
  border-color: #efba81;
  background: #352b22;
  box-shadow: inset 0 0 0 1px #efba81;
}
.formation-diagram {
  width: 100%;
  height: 90px;
  color: #aac5cc;
  margin-bottom: 8px;
}
.formation-diagram circle {
  fill: #efbd8d;
}
.formation-diagram text {
  font: 7px sans-serif;
  fill: #bacbd7;
  letter-spacing: 0.06em;
}
.formation-diagram .slot-number {
  font: bold 8px sans-serif;
  fill: #18222b;
  letter-spacing: 0;
}
.hero-option {
  position: relative;
}
.selection-order {
  position: absolute;
  right: 10px;
  top: 9px;
  color: #efbd8d;
}
.strategy-tip,
.admin-note {
  border-left: 3px solid #7da9a7;
  padding: 10px 14px;
  background: #15272c;
  color: #c8e4e4;
}
.settings-grid section,
.admin-section {
  min-width: 0;
}
.settings-grid h3,
.admin-section h3 {
  color: #ffd1a4;
}
.setting {
  gap: 14px;
}
.setting span small {
  display: block;
  font-size: 12px;
  line-height: 1.5;
  color: #abbccb;
  font-weight: normal;
  margin-top: 5px;
  max-width: 340px;
}
.setting select {
  max-width: 48%;
}
.setting input[type="range"] {
  width: 125px;
  flex-shrink: 0;
}
.setting input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  accent-color: #e8b180;
}
.admin-section {
  border: 1px solid #354451;
  border-radius: 12px;
  padding: 16px;
}
.admin-section .setting input[type="number"] {
  width: 80px;
}
input[type="password"],
input[type="number"] {
  background: #141e29;
  color: #edf4fa;
  border: 1px solid #536574;
  border-radius: 7px;
  padding: 10px;
  max-width: 100%;
}
.admin-form {
  display: grid;
  gap: 14px;
  max-width: 550px;
}
.admin-form label {
  display: grid;
  gap: 8px;
}
.admin-form input {
  width: 100%;
}
.inline-error {
  color: #ffb7ab;
  line-height: 1.6;
  min-height: 1em;
}
.inline-success {
  color: #b9e7ce;
}
details {
  margin: 16px 0;
  border: 1px solid #34424e;
  border-radius: 10px;
  padding: 12px 16px;
}
summary {
  cursor: pointer;
  color: #e0eaf2;
  font-weight: 600;
}
details p,
details li {
  font-size: 13px;
  line-height: 1.7;
  color: #c3d0db;
}
.handbook-modes .simple-rules {
  margin-top: 10px;
}
.handbook-modes h3 {
  margin-top: 24px;
}
.sticky-actions {
  position: sticky;
  bottom: 0;
  background: #101721;
  padding: 18px 0;
  margin-bottom: -12px;
  border-top: 1px solid #35434e;
  z-index: 3;
}
.tactics-toolbar {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  margin: 10px 0;
}
.tactics-toolbar label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 11px;
  flex: 1;
  min-width: 135px;
}
.tactics-toolbar select {
  width: 100%;
  font-size: 12px;
  padding: 8px;
}
.strategy-panel {
  margin: 10px 0;
  font-size: 12px;
  line-height: 1.6;
}
.strategy-panel p {
  margin: 6px 0;
}
.strategy-panel select {
  max-width: 100%;
}
.strategy-panel button {
  margin-top: 7px;
}
.bottom-panel {
  max-height: 43vh;
  overflow-y: auto;
  scrollbar-width: thin;
}
.bottom-panel details {
  margin: 7px 0;
  padding: 8px 12px;
}
.bottom-panel summary {
  font-size: 12px;
}
.menu-bottom {
  flex-wrap: wrap;
  row-gap: 14px;
}
.menu-bottom .rules-badge {
  margin-left: auto;
}
.large-text #modal p,
.large-text #modal label,
.large-text .simple-rules span,
.large-text details li {
  font-size: 16px;
}
.large-text button,
.large-text select {
  font-size: 15px;
}
.large-text .hud-heading p,
.large-text .hud-right p,
.large-text .strategy-panel {
  font-size: 14px;
}
.high-contrast .panel,
.high-contrast .bottom-panel,
.high-contrast #modal {
  background: #090e14;
  border-color: #a5bfcc;
}
.high-contrast .muted,
.high-contrast small,
.high-contrast p {
  color: #dbe5ed;
}
.high-contrast button {
  border-color: #93a8b8;
}
.high-contrast button:focus-visible,
.high-contrast .selected {
  outline: 3px solid #ffca87;
  outline-offset: 2px;
}
button:focus-visible,
select:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 2px solid #ffcc93;
  outline-offset: 3px;
}
@media (max-width: 800px) {
  .simple-rules,
  .settings-grid,
  .admin-grid {
    grid-template-columns: 1fr;
  }
  .formation-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .simple-rules {
    gap: 8px;
  }
  .simple-rules li {
    padding: 12px;
  }
  .simple-rules strong {
    margin-bottom: 4px;
  }
  .menu-bottom .rules-badge {
    margin-left: 0;
  }
  .setup-grid {
    gap: 12px;
  }
  .bottom-panel {
    max-height: 45vh;
  }
  .sticky-actions {
    bottom: 0;
  }
  .settings-grid {
    gap: 0;
  }
}
@media (max-height: 780px) and (min-width: 801px) {
  .bottom-panel {
    max-height: 39vh;
  }
  .hud-heading,
  .hud-right {
    max-height: calc(54vh - 85px);
    overflow-y: auto;
  }
  .hud-heading h2 {
    font-size: 23px;
  }
  .hud-heading p,
  .hud-right p {
    font-size: 11px;
  }
  .strategy-panel {
    margin: 6px 0;
  }
  .strategy-panel p {
    font-size: 11px;
  }
  .mode-card {
    min-height: 235px;
  }
  .menu h1 {
    font-size: 48px;
  }
}

select {
  background: #172331;
  color: #ecf1f7;
  border: 1px solid #536574;
  border-radius: 7px;
  padding: 9px;
}
.bottom-panel .split {
  flex-wrap: wrap;
}
.bottom-panel .split .row {
  flex-wrap: wrap;
}
.turn-controls.strategy-panel {
  display: block;
}
.turn-controls.strategy-panel .tactics-toolbar {
  justify-content: center;
}
@media (max-width: 800px) {
  .bottom-panel .shop-row {
    flex-wrap: wrap;
  }
  .bottom-panel .shop-row > button {
    min-width: 140px;
  }
  .dialog-actions {
    flex-wrap: wrap;
  }
  .timeline {
    flex-wrap: wrap;
  }
  .setup-grid {
    grid-template-columns: 1fr;
  }
  .setting select {
    max-width: 52%;
  }
}

.camera-dragging {
  cursor: grabbing;
}
.camera-hint {
  position: fixed;
  right: 25px;
  bottom: 3px;
  z-index: 8;
  color: #c2ceda;
  font-size: 10px;
  pointer-events: none;
  padding: 2px 8px;
  border-radius: 5px;
  background: #0c142bd9;
}
.camera-hint[hidden] {
  display: none;
}
.camera-help {
  font-size: 12px;
  line-height: 1.7;
  border-left: 2px solid #8caaab;
  padding-left: 12px;
}
.codex-detail .stats-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}
.codex-detail .stat {
  min-width: 0;
}
.codex-detail .stat strong {
  font-size: 22px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.animation-preview {
  flex-wrap: wrap;
}
.movement-test-panel {
  position: absolute;
  top: 22px;
  left: 24px;
  width: 340px;
  max-height: calc(100% - 44px);
  overflow: auto;
  padding: 20px;
  pointer-events: auto;
}
.movement-test-panel h2 {
  margin: 8px 0;
}
.movement-test-panel label {
  display: block;
  margin: 10px 0;
  font-size: 12px;
}
.movement-test-panel select {
  display: block;
  width: 100%;
  margin-top: 5px;
}
.movement-test-panel .row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.movement-test-panel button {
  padding: 8px 10px;
}
.movement-step-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin: 12px 0;
}
.movement-debug {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #081019;
  padding: 12px;
  font-size: 11px;
  line-height: 1.6;
  max-height: 180px;
  overflow: auto;
  border-radius: 8px;
}
.movement-test-caption {
  position: absolute;
  bottom: 38px;
  left: 400px;
  right: 24px;
  max-width: 680px;
  padding: 18px;
  pointer-events: auto;
}
.movement-test-caption strong,
.movement-test-caption span {
  display: block;
}
.movement-test-caption span {
  font-size: 12px;
  margin-top: 6px;
  line-height: 1.5;
}
.menu-bottom {
  flex-wrap: wrap;
}
@media (max-width: 850px) {
  .movement-test-panel {
    left: 12px;
    top: 12px;
    width: 270px;
    max-height: calc(100% - 42px);
    padding: 12px;
  }
  .movement-test-caption {
    left: 300px;
    right: 12px;
    bottom: 24px;
    padding: 10px;
  }
}
@media (max-width: 800px) {
  .camera-hint {
    max-width: 95%;
    font-size: 9px;
    right: 8px;
  }
  .topbar nav {
    gap: 4px;
  }
  .topbar nav button {
    padding: 8px;
  }
}
