:root {
  color-scheme: dark;
  --battlefield-inset-y: 1rem;
  --battlefield-inset-x: 1rem;
  --page-bg: #0d1117;
  --panel-bg: #151b23;
  --panel-border: #303946;
  --hex-size: 24px;
  --hex-width: calc(var(--hex-size) * 2);
  --hex-height: calc(var(--hex-size) * 1.732);
  --hex-step-x: calc(var(--hex-width) * 0.75);
  --hex-fill: #1f6f57;
  --hex-fill-alt: #245f78;
  --hex-stroke: #73cab0;
  --hex-selected: #f4c542;
  --red-team: #aa2929;
  --blue-team: #1525aa;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(52, 211, 153, 0.12), transparent 32rem),
    linear-gradient(135deg, #0d1117 0%, #111827 52%, #0c1018 100%);
  color: #e6edf3;
  overflow: hidden;
}

.login-screen,
.lobby-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 1rem;
  background:
    radial-gradient(circle at 18% 18%, rgba(250, 204, 21, 0.12), transparent 18rem),
    radial-gradient(circle at 82% 74%, rgba(56, 189, 248, 0.16), transparent 20rem),
    linear-gradient(135deg, #070b12 0%, #101827 54%, #05070b 100%);
  overflow: hidden;
}

.login-screen.is-hidden,
.lobby-screen.is-hidden {
  display: none;
}

.login-hex-field {
  position: absolute;
  inset: 0;
  opacity: 0.55;
  pointer-events: none;
}

.login-hex-field::before {
  content: "";
  position: absolute;
  inset: -4rem;
  background-image:
    linear-gradient(30deg, rgba(148, 163, 184, 0.14) 12%, transparent 12.5%, transparent 87%, rgba(148, 163, 184, 0.14) 87.5%, rgba(148, 163, 184, 0.14)),
    linear-gradient(150deg, rgba(148, 163, 184, 0.14) 12%, transparent 12.5%, transparent 87%, rgba(148, 163, 184, 0.14) 87.5%, rgba(148, 163, 184, 0.14)),
    linear-gradient(30deg, rgba(148, 163, 184, 0.14) 12%, transparent 12.5%, transparent 87%, rgba(148, 163, 184, 0.14) 87.5%, rgba(148, 163, 184, 0.14)),
    linear-gradient(150deg, rgba(148, 163, 184, 0.14) 12%, transparent 12.5%, transparent 87%, rgba(148, 163, 184, 0.14) 87.5%, rgba(148, 163, 184, 0.14)),
    linear-gradient(60deg, rgba(250, 204, 21, 0.08) 25%, transparent 25.5%, transparent 75%, rgba(250, 204, 21, 0.08) 75%, rgba(250, 204, 21, 0.08)),
    linear-gradient(60deg, rgba(250, 204, 21, 0.08) 25%, transparent 25.5%, transparent 75%, rgba(250, 204, 21, 0.08) 75%, rgba(250, 204, 21, 0.08));
  background-position: 0 0, 0 0, 2.75rem 4.8rem, 2.75rem 4.8rem, 0 0, 2.75rem 4.8rem;
  background-size: 5.5rem 9.6rem;
  mask-image: radial-gradient(circle at center, #000 0 48%, transparent 78%);
}

.login-hex-field span {
  position: absolute;
  width: clamp(4.25rem, 10vw, 7.5rem);
  aspect-ratio: 1 / 0.866;
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
  border: 1px solid rgba(250, 204, 21, 0.36);
  background: linear-gradient(135deg, rgba(170, 41, 41, 0.24), rgba(21, 37, 170, 0.22));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05), 0 1rem 3rem rgba(0, 0, 0, 0.28);
}

.login-hex-field span:nth-child(1) {
  top: 8%;
  left: 8%;
}

.login-hex-field span:nth-child(2) {
  top: 18%;
  right: 14%;
}

.login-hex-field span:nth-child(3) {
  bottom: 12%;
  left: 16%;
}

.login-hex-field span:nth-child(4) {
  right: 9%;
  bottom: 14%;
}

.login-hex-field span:nth-child(5) {
  top: 50%;
  left: 3%;
}

.login-hex-field span:nth-child(6) {
  top: 44%;
  right: 5%;
}

.login-card,
.lobby-card {
  position: relative;
  z-index: 1;
  width: min(100%, 27rem);
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(30, 41, 59, 0.9), rgba(15, 23, 42, 0.94)),
    rgba(15, 23, 42, 0.94);
  padding: clamp(1.25rem, 4vw, 2rem);
  box-shadow: 0 1.5rem 5rem rgba(0, 0, 0, 0.5);
}

.lobby-card {
  width: min(100%, 39rem);
}

.lobby-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.login-mark {
  display: grid;
  place-items: center;
  width: 4rem;
  aspect-ratio: 1 / 0.866;
  margin-bottom: 1rem;
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
  background: linear-gradient(135deg, var(--red-team), var(--blue-team));
}

.login-mark span {
  width: 2.3rem;
  aspect-ratio: 1 / 0.866;
  clip-path: inherit;
  background: #facc15;
  box-shadow: 0 0 1.8rem rgba(250, 204, 21, 0.55);
}

.login-kicker {
  margin: 0 0 0.35rem;
  color: #fde68a;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.login-card h1,
.lobby-card h1 {
  margin: 0;
  color: #f8fafc;
  font-size: clamp(2.1rem, 9vw, 3.4rem);
  font-weight: 950;
  line-height: 0.95;
}

.login-copy {
  margin: 0.8rem 0 1.35rem;
  color: #cbd5e1;
}

.login-form {
  display: grid;
  gap: 0.9rem;
}

.auth-toggle {
  margin: 1.1rem 0 0.95rem;
}

.login-form .form-control {
  border-color: rgba(148, 163, 184, 0.28);
  background: rgba(2, 6, 23, 0.64);
  color: #f8fafc;
}

.login-form .form-control:focus {
  border-color: rgba(250, 204, 21, 0.72);
  box-shadow: 0 0 0 0.25rem rgba(250, 204, 21, 0.12);
}

.login-form .btn-primary {
  border-color: rgba(250, 204, 21, 0.7);
  background: linear-gradient(135deg, #b91c1c, #1d4ed8);
  font-weight: 900;
}

.auth-message {
  margin: 0;
  border: 1px solid rgba(248, 113, 113, 0.38);
  border-radius: 6px;
  background: rgba(127, 29, 29, 0.22);
  color: #fecaca;
  padding: 0.5rem 0.65rem;
  font-size: 0.86rem;
}

.auth-message.success {
  border-color: rgba(74, 222, 128, 0.34);
  background: rgba(20, 83, 45, 0.22);
  color: #bbf7d0;
}

.lobby-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.lobby-actions .btn:first-child {
  grid-column: 1 / -1;
  border-color: rgba(250, 204, 21, 0.7);
  background: linear-gradient(135deg, #b91c1c, #1d4ed8);
  font-weight: 900;
}

.room-panel {
  display: grid;
  gap: 0.65rem;
  margin-top: 1rem;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 8px;
  background: rgba(2, 6, 23, 0.38);
  padding: 0.85rem;
}

.room-status {
  color: #fde68a;
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

.room-token-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.room-token-row span {
  color: #f8fafc;
  font-size: clamp(1.45rem, 7vw, 2.3rem);
  font-weight: 950;
  letter-spacing: 0;
}

.room-panel .form-control {
  border-color: rgba(148, 163, 184, 0.24);
  background: rgba(15, 23, 42, 0.72);
  color: #dbeafe;
}

.socket-status,
.ready-row,
.pregame-panel {
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.48);
  padding: 0.55rem 0.65rem;
}

.socket-status {
  color: #93c5fd;
  font-size: 0.82rem;
  font-weight: 800;
}

.ready-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.ready-row span,
.pregame-panel p {
  margin: 0;
  color: #cbd5e1;
  font-size: 0.88rem;
}

.roll-choice-buttons,
.army-choice-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin-top: 0.75rem;
}

.invite-modal .modal-content {
  border: 1px solid rgba(250, 204, 21, 0.25);
  background:
    linear-gradient(180deg, rgba(30, 41, 59, 0.96), rgba(15, 23, 42, 0.98)),
    #0f172a;
}

.invite-copy {
  color: #cbd5e1;
}

.invite-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.guest-form {
  margin-top: 1rem;
}

.guest-form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.65rem;
}

.guest-form .form-control {
  border-color: rgba(148, 163, 184, 0.28);
  background: rgba(2, 6, 23, 0.64);
  color: #f8fafc;
}

.app-shell {
  min-height: 100vh;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.navbar {
  background: rgba(13, 17, 23, 0.82);
  backdrop-filter: blur(10px);
}

.army-panel,
.action-strip,
.battlefield-bottom-panel,
.map-viewport {
  background: rgba(21, 27, 35, 0.92);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
}

.selected-tile {
  min-height: 3rem;
}

.legend-list {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.5rem 0.85rem;
  max-width: min(34rem, 42vw);
}

.legend-list span {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.legend-swatch {
  width: 1rem;
  height: 1rem;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.legend-swatch.obstacle {
  background: #3f454d;
}

.legend-swatch.cover {
  background:
    radial-gradient(circle at 50% 50%, rgba(31, 41, 55, 0.48) 0 14%, transparent 15%),
    #cbd5e1;
}

.legend-swatch.difficult {
  background:
    radial-gradient(circle at 32% 36%, rgba(31, 41, 55, 0.5) 0 12%, transparent 13%),
    radial-gradient(circle at 68% 64%, rgba(31, 41, 55, 0.42) 0 12%, transparent 13%),
    #8b5e34;
}

.legend-swatch.dangerous {
  background: #8f3d3d;
}

.legend-swatch.control {
  background:
    radial-gradient(circle, #facc15 0 35%, #0f172a 36% 55%, #facc15 56% 100%),
    #030712;
}

.battlefield-bottom-panel {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 0 0 auto;
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.55rem 0.75rem;
  min-width: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.map-legend-list {
  flex: 0 0 auto;
  justify-content: flex-end;
  max-width: none;
  margin-left: auto;
  gap: 0.45rem 0.7rem;
}

.battle-log-summary {
  flex: 1 1 auto;
  min-width: 0;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.56);
  color: #dbeafe;
  padding: 0.38rem 0.55rem;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.battle-log-summary:hover,
.battle-log-summary:focus-visible {
  border-color: rgba(147, 197, 253, 0.58);
  color: #eff6ff;
}

.battle-log-list {
  display: grid;
  gap: 0.55rem;
}

.battle-log-entry {
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.55);
  padding: 0.55rem 0.65rem;
  color: #e2e8f0;
  font-size: 0.9rem;
}

.army-status-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.88), rgba(30, 41, 59, 0.52));
  padding: 0.5rem;
  font-size: 0.76rem;
  font-weight: 800;
  min-width: 0;
}

.round-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.75rem;
  border: 1px solid rgba(250, 204, 21, 0.52);
  border-radius: 6px;
  background:
    linear-gradient(135deg, rgba(250, 204, 21, 0.22), rgba(113, 63, 18, 0.42)),
    rgba(15, 23, 42, 0.86);
  color: #fef3c7;
  padding: 0.18rem 0.55rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  white-space: nowrap;
}

.turn-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-height: 1.35rem;
  border-radius: 6px;
  padding: 0.18rem 0.62rem;
  color: #fff;
  font-weight: 800;
  font-size: 0.78rem;
}

.turn-indicator.your-turn {
  background: var(--red-team);
}

.turn-indicator.enemy-turn {
  background: var(--blue-team);
}

.turn-indicator.game-over {
  background: #facc15;
  color: #111827;
}

.score-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 1.75rem;
  border: 1px solid rgba(125, 211, 252, 0.34);
  border-radius: 6px;
  padding: 0.18rem 0.5rem;
  color: #dbeafe;
  background:
    linear-gradient(90deg, rgba(239, 68, 68, 0.18), rgba(56, 189, 248, 0.18)),
    rgba(15, 23, 42, 0.78);
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-strip {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex: 0 0 auto;
  min-width: 0;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background:
    linear-gradient(135deg, rgba(15, 23, 42, 0.86), rgba(30, 41, 59, 0.56)),
    rgba(15, 23, 42, 0.42);
  padding: 0.5rem 0.65rem;
  margin-bottom: 0.75rem;
  overflow: hidden;
  white-space: nowrap;
}

.action-path {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1 1 auto;
  min-width: 0;
  color: #f8fafc;
  font-size: 0.78rem;
  font-weight: 900;
  overflow: hidden;
}

.phase-chip {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  max-width: 16rem;
  min-height: 1.35rem;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.62);
  color: #cbd5e1;
  padding: 0.16rem 0.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.phase-chip.current {
  border-color: rgba(125, 211, 252, 0.4);
  background: rgba(8, 47, 73, 0.68);
  color: #e0f2fe;
}

.phase-separator {
  color: #64748b;
  font-size: 0.78rem;
  font-weight: 900;
}

.action-primary,
.action-secondary {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.action-primary {
  flex: 0 1 auto;
  color: #cbd5e1;
  font-size: 0.82rem;
  font-weight: 700;
}

.action-secondary {
  flex: 1 1 auto;
  color: #94a3b8;
  font-size: 0.78rem;
}

.action-primary::before,
.action-secondary::before {
  content: "/";
  margin-right: 0.65rem;
  color: rgba(148, 163, 184, 0.55);
}

.battlefield-section {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: var(--battlefield-inset-y) var(--battlefield-inset-x) calc(var(--battlefield-inset-y) + 0.35rem);
}

.battlefield-row,
.army-panel,
.battlefield-main {
  flex: 1;
  min-height: 0;
}

.army-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow: hidden;
  padding: 0.85rem;
}

.army-tabs {
  flex: 0 0 auto;
  gap: 0.35rem;
}

.army-tabs .nav-link {
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 6px;
  color: #cbd5e1;
  padding: 0.32rem 0.5rem;
  font-size: 0.78rem;
  font-weight: 800;
}

.army-tabs .nav-link.active {
  border-color: rgba(250, 204, 21, 0.55);
  background: rgba(113, 63, 18, 0.52);
  color: #fef3c7;
}

.army-tab-content {
  flex: 1 1 auto;
  min-height: 0;
}

.army-tab-content > .tab-pane {
  height: 100%;
  min-height: 0;
}

.army-tab-content > .tab-pane.active {
  display: flex;
  flex-direction: column;
}

.army-list {
  display: grid;
  gap: 0.65rem;
  flex: 1 1 auto;
  align-content: start;
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
  padding-right: 0.15rem;
}

.army-card {
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-left: 4px solid var(--red-team);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.68);
  padding: 0.7rem;
}

.army-card.blue {
  border-left-color: var(--blue-team);
}

.army-card.is-leader-card {
  box-shadow: 0 0 0 1px rgba(250, 204, 21, 0.42);
}

.army-card.is-leader-card .army-card-title::after {
  content: "\2654";
  border: 1px solid rgba(250, 204, 21, 0.58);
  border-radius: 999px;
  padding: 0.04rem 0.34rem;
  color: #fde68a;
  background: rgba(113, 63, 18, 0.5);
  font-size: 0.95rem;
  font-weight: 900;
  line-height: 1;
}

.army-card.is-eliminated {
  border-left-color: #64748b;
  color: #94a3b8;
  filter: grayscale(0.9);
  opacity: 0.68;
}

.army-card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
  font-weight: 800;
}

.army-card-name {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 0.4rem;
}

.army-card-unit-icon {
  flex: 0 0 auto;
  width: 1.72rem;
  height: 1.72rem;
  object-fit: contain;
  filter: invert(92%) sepia(17%) saturate(676%) hue-rotate(184deg) brightness(107%) contrast(96%);
  opacity: 0.95;
}

.army-card-skull {
  color: #cbd5e1;
  font-size: 1rem;
  line-height: 1;
}

.ability-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: -0.2rem 0 0.55rem;
}

.ability-badge {
  border: 1px solid rgba(226, 232, 240, 0.35);
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  background: rgba(30, 41, 59, 0.84);
  color: #f8fafc;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.2;
  text-transform: uppercase;
  cursor:pointer;
}

.ability-badge.fast {
  border-color: rgba(34, 197, 94, 0.72);
  color: #bbf7d0;
}

.ability-badge.slow {
  border-color: rgba(251, 191, 36, 0.72);
  color: #fde68a;
}

.ability-badge.leader {
  border-color: rgba(250, 204, 21, 0.76);
  color: #fef08a;
}

.army-profile-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.28rem;
}

.icon-stat {
  display: inline-grid;
  align-items: center;
  justify-content: center;
  gap: 0.12rem;
  min-width: 0;
  border-radius: 6px;
  background: rgba(30, 41, 59, 0.72);
  padding: 0.28rem 0.15rem;
  font-weight: 900;
  text-align: center;
}

.icon-stat-symbol {
  display: grid;
  place-items: center;
  line-height: 1;
  font-size: 1rem;
  margin-bottom: 0.18rem;
}

.icon-stat-value {
  line-height: 1;
  font-size: 0.82rem;
}

.icon-stat.star .icon-stat-symbol {
  color: #fde047;
}

.icon-stat.shield .icon-stat-symbol {
  color: #93c5fd;
}

.icon-stat.heart .icon-stat-symbol,
.member-token.alive {
  color: #fb7185;
}

.icon-stat.fist .icon-stat-symbol {
  color: #fdba74;
}

.icon-stat.gun .icon-stat-symbol {
  color: #c4b5fd;
}

.icon-stat.crosshair .icon-stat-symbol {
  color: #67e8f9;
}

.strength-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.22rem;
  margin-top: 0.55rem;
  min-height: 1.35rem;
  border-radius: 6px;
  background: rgba(30, 41, 59, 0.72);
  padding: 0.35rem 0.45rem;
}

.member-token {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 1.05rem;
  aspect-ratio: 1;
  color: #94a3b8;
  font-size: 1.05rem;
  line-height: 1;
}

.member-token.dead {
  color: #64748b;
}

.member-wound-count {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 0.58rem;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(15, 23, 42, 0.95);
}

.battlefield-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.map-viewport {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 2rem 2rem 0.85rem;
  min-height: 0;
  touch-action: manipulation;
}

.hex-map {
  position: relative;
  flex: 0 0 auto;
  width: calc(var(--hex-step-x) * 29 + var(--hex-width));
  height: calc(var(--hex-height) * 15 + var(--hex-height) / 2);
}

.hex {
  position: absolute;
  width: var(--hex-width);
  height: var(--hex-height);
  border: 0;
  padding: 0;
  color: #dff8ed;
  background: var(--hex-fill);
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
  cursor: pointer;
  transform: translate(-50%, -50%);
  transition: filter 140ms ease, outline-color 140ms ease, scale 140ms ease;
}

.hex.has-terrain {
  background: var(--hex-fill-alt);
}

.hex.terrain-obstacle {
  background: #3f454d;
}

.hex.terrain-cover {
  background:
    radial-gradient(circle at 50% 50%, rgba(31, 41, 55, 0.48) 0 14%, transparent 15%),
    #cbd5e1;
}

.hex.terrain-difficult {
  background:
    radial-gradient(circle at 32% 36%, rgba(31, 41, 55, 0.5) 0 12%, transparent 13%),
    radial-gradient(circle at 68% 64%, rgba(31, 41, 55, 0.42) 0 12%, transparent 13%),
    #8b5e34;
}

.hex.terrain-dangerous {
  background: #8f3d3d;
}

.hex.has-control-point {
  background: #030712;
  box-shadow: none;
}

.hex.has-control-point.control-home-red {
  background: var(--red-team);
}

.hex.has-control-point.control-home-blue {
  background: var(--blue-team);
}

.hex.has-control-point.controlled-red {
  background: var(--red-team);
}

.hex.has-control-point.controlled-blue {
  background: var(--blue-team);
}

.hex.has-control-point.control-home-red {
  color: var(--red-team);
}

.hex.has-control-point.control-home-blue {
  color: var(--blue-team);
}

.hex.has-control-point.is-contested {
  background:
    linear-gradient(90deg, var(--red-team) 0 50%, var(--blue-team) 50% 100%);
}

.hex.has-control-point::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  width: 32%;
  aspect-ratio: 1;
  border: 2px solid rgba(254, 240, 138, 0.95);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(250, 204, 21, 0.95) 0 28%, rgba(15, 23, 42, 0.82) 30% 48%, rgba(250, 204, 21, 0.85) 50% 100%);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.hex::after {
  content: "";
  position: absolute;
  inset: 3px;
  clip-path: inherit;
  border: 1px solid rgba(219, 255, 242, 0.55);
}

.hex.has-control-point::after {
  content: none;
}

.hex.has-control-point.control-home-red::after,
.hex.has-control-point.control-home-blue::after {
  content: "";
  inset: 0;
  z-index: 1;
  border: 0;
  padding: 1.5px;
  background: currentColor;
  clip-path: inherit;
  pointer-events: none;
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}

.hex:hover,
.hex:focus-visible {
  filter: brightness(1.14);
  outline: 2px solid var(--hex-stroke);
  outline-offset: 2px;
  z-index: 3;
}

.hex.is-selected {
  color: #14130a;
  background: var(--hex-selected);
  filter: drop-shadow(0 0 0.65rem rgba(244, 197, 66, 0.35));
}

.hex.is-move-range::before,
.hex.is-weapon-range::before {
  content: "";
  position: absolute;
  inset: 5px;
  z-index: 1;
  clip-path: inherit;
  pointer-events: none;
}

.hex.is-move-range::before {
  background: rgba(34, 197, 94, 0.38);
}

.hex.is-move-range {
  z-index: 8;
}

.hex.is-weapon-range::before {
  background: rgba(56, 189, 248, 0.26);
}

.hex.has-control-point.is-move-range,
.hex.has-control-point.is-weapon-range {
  box-shadow: inset 0 0 0 999px rgba(56, 189, 248, 0.14);
}

.hex.has-control-point.is-move-range::before,
.hex.has-control-point.is-weapon-range::before {
  left: 50%;
  top: 50%;
  inset: auto;
  z-index: 2;
  width: 32%;
  aspect-ratio: 1;
  border: 2px solid rgba(254, 240, 138, 0.95);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(250, 204, 21, 0.95) 0 28%, rgba(15, 23, 42, 0.82) 30% 48%, rgba(250, 204, 21, 0.85) 50% 100%);
  clip-path: none;
  transform: translate(-50%, -50%);
}

.hex.is-weapon-target {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
  z-index: 9;
}

.hex-label {
  position: relative;
  z-index: 1;
  display: none;
  place-items: center;
  width: 100%;
  height: 100%;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
}

.unit {
  position: absolute;
  z-index: 14;
  display: block;
  width: var(--hex-width);
  height: var(--hex-height);
  color: #fff;
  font-size: clamp(0.58rem, calc(var(--hex-size) * 0.44), 0.98rem);
  font-weight: 800;
  line-height: 1;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.unit-core {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  width: auto;
  aspect-ratio: auto;
  border: 0;
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
  box-shadow: 0 0 0.45rem rgba(0, 0, 0, 0.45);
}

.unit-core::after {
  content: "";
  position: absolute;
  inset: 1.5px;
  z-index: 2;
  background: var(--red-team);
  clip-path: inherit;
  pointer-events: none;
}

.unit-core-icon {
  position: relative;
  z-index: 3;
  width: 87%;
  height: 87%;
  object-fit: contain;
  filter: invert(100%);
  opacity: 0.96;
}

.unit-counter {
  position: absolute;
  z-index: 18;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 0.14rem;
  place-items: center;
  min-width: clamp(1.15rem, calc(var(--hex-size) * 1.08), 1.95rem);
  min-height: clamp(0.72rem, calc(var(--hex-size) * 0.66), 1.16rem);
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 3px;
  background: rgba(11, 18, 32, 0.94);
  color: #f8fafc;
  padding: 0 0.18rem;
  font-size: clamp(0.56rem, calc(var(--hex-size) * 0.34), 0.92rem);
  line-height: 1;
  box-shadow: 0 0.15rem 0.45rem rgba(0, 0, 0, 0.42);
}

.battlefield-tooltip {
  --bs-tooltip-max-width: 18rem;
  --bs-tooltip-bg: rgba(15, 23, 42, 0.98);
  --bs-tooltip-opacity: 1;
  pointer-events: none;
}

.battlefield-tooltip .tooltip-inner {
  border: 1px solid rgba(148, 163, 184, 0.28);
  padding: 0.45rem;
  color: #e2e8f0;
  text-align: left;
}

.unit-tooltip-card {
  display: grid;
  gap: 0.38rem;
  min-width: 13rem;
  border-left: 4px solid var(--red-team);
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.92);
  padding: 0.45rem;
}

.unit-tooltip-card.blue {
  border-left-color: var(--blue-team);
}

.unit-tooltip-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
}

.unit-tooltip-title img {
  width: 1rem;
  height: 1rem;
  object-fit: contain;
  filter: invert(92%) sepia(17%) saturate(676%) hue-rotate(184deg) brightness(107%) contrast(96%);
}

.unit-tooltip-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.tooltip-ability {
  border: 1px solid rgba(226, 232, 240, 0.28);
  border-radius: 999px;
  padding: 0.04rem 0.32rem;
  color: #f8fafc;
  background: rgba(30, 41, 59, 0.8);
  font-size: 0.62rem;
  font-weight: 800;
  text-transform: uppercase;
}

.unit-tooltip-stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.2rem;
}

.unit-tooltip-stats span {
  border-radius: 4px;
  background: rgba(30, 41, 59, 0.72);
  padding: 0.18rem 0.1rem;
  text-align: center;
  font-size: 0.68rem;
  font-weight: 900;
}

.unit-tooltip-strength {
  display: flex;
  gap: 0.16rem;
  border-radius: 4px;
  background: rgba(30, 41, 59, 0.72);
  padding: 0.22rem 0.32rem;
}

.tooltip-heart {
  color: #fb7185;
}

.tooltip-skull {
  color: #64748b;
}

.unit-counter-icon {
  font-size: 0.95em;
}

.unit-counter.quality .unit-counter-icon {
  color: #fde047;
}

.unit-counter.toughness .unit-counter-icon {
  color: #93c5fd;
}

.unit-counter.wounds .unit-counter-icon {
  color: #fb7185;
}

.unit-counter.models .unit-counter-icon {
  color: #cbd5e1;
}

.unit-counter-value {
  font-weight: 900;
}

.unit-counter.quality {
  left: -6%;
  top: -10%;
  transform: translateX(-50%);
}

.unit-counter.toughness {
  right: -6%;
  top: -10%;
  transform: translateX(50%);
}

.unit-counter.wounds {
  left: -6%;
  bottom: -10%;
  transform: translateX(-50%);
}

.unit-counter.models {
  right: -6%;
  bottom: -10%;
  transform: translateX(50%);
}

.unit.red .unit-core {
  background: rgba(255, 255, 255, 0.86);
}

.unit.blue .unit-core {
  background: rgba(255, 255, 255, 0.86);
}

.unit.blue .unit-core::after {
  background: var(--blue-team);
}

.unit.is-leader .unit-core {
  background: #facc15;
}

.unit.is-leader .unit-core::after {
  inset: 1.5px;
}

.unit.is-leader.blue .unit-core::after {
  background: var(--blue-team);
}

.unit.is-leader::after {
  content: none;
}

.hex.has-active-unit {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.unit.is-activated .unit-core {
  filter: grayscale(0.35) brightness(0.72);
  opacity: 0.72;
}

.unit.is-activated::before {
  content: "\2713";
  position: absolute;
  right: -0.15rem;
  top: -0.15rem;
  z-index: 6;
  display: grid;
  place-items: center;
  width: clamp(0.8rem, calc(var(--hex-size) * 0.48), 1.15rem);
  aspect-ratio: 1;
  border: 1px solid rgba(220, 252, 231, 0.85);
  border-radius: 50%;
  background: #16a34a;
  color: #f0fdf4;
  font-size: clamp(0.55rem, calc(var(--hex-size) * 0.28), 0.8rem);
  font-weight: 900;
  box-shadow: 0 0.2rem 0.55rem rgba(0, 0, 0, 0.4);
}

.dice-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(3, 7, 18, 0.7);
  backdrop-filter: blur(5px);
  animation: backdropIn 160ms ease-out both;
}

.dice-event {
  width: min(92vw, 680px);
  border: 1px solid rgba(226, 232, 240, 0.22);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.96);
  box-shadow: 0 1.5rem 4rem rgba(0, 0, 0, 0.45);
  padding: 1rem;
  animation: diceEventFromLeft 260ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.dice-backdrop.from-blue .dice-event {
  animation-name: diceEventFromRight;
}

.dice-title {
  margin-bottom: 0.2rem;
  font-weight: 800;
  font-size: 1.1rem;
}

.dice-subtitle {
  margin-bottom: 0.85rem;
  color: #cbd5e1;
  font-size: 0.95rem;
}

.dice-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.dice-columns.single {
  grid-template-columns: minmax(0, 1fr);
}

.dice-panel {
  min-width: 0;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 8px;
  padding: 0.75rem;
  background: rgba(30, 41, 59, 0.72);
}

.dice-panel h3 {
  margin: 0 0 0.5rem;
  color: #cbd5e1;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.dice-modifier {
  color: #bbf7d0;
  font-size: 0.72rem;
}

.dice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.die {
  display: grid;
  place-items: center;
  width: 1.65rem;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 5px;
  background: #e2e8f0;
  color: #0f172a;
  font-weight: 900;
  animation: diePop 380ms ease-out both;
  animation-delay: var(--delay);
}

.die.success {
  background: #22c55e;
  color: #052e16;
}

.die.fail {
  background: #ef4444;
  color: #fff;
}

.no-dice {
  color: #94a3b8;
  font-size: 0.85rem;
}

.dice-summary {
  margin-top: 0.85rem;
  color: #e2e8f0;
  font-weight: 700;
}

.dice-close {
  margin-top: 0.85rem;
}

.game-over-content {
  border: 1px solid rgba(250, 204, 21, 0.28);
  background: rgba(15, 23, 42, 0.98);
}

.game-over-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(239, 68, 68, 0.14), rgba(56, 189, 248, 0.14)),
    rgba(15, 23, 42, 0.72);
  padding: 1rem;
}

.game-over-kicker {
  color: #fde68a;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.game-over-hero h3 {
  margin: 0.15rem 0 0;
  font-weight: 900;
}

.final-score {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.final-score span {
  border: 1px solid rgba(125, 211, 252, 0.28);
  border-radius: 6px;
  background: rgba(30, 41, 59, 0.72);
  padding: 0.35rem 0.55rem;
  font-weight: 900;
}

.game-over-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin-top: 0.75rem;
}

.game-over-stat,
.game-over-vp {
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.58);
  padding: 0.75rem;
}

.game-over-stat.wide {
  grid-column: 1 / -1;
}

.game-over-stat h4,
.game-over-vp h4 {
  margin: 0 0 0.5rem;
  color: #cbd5e1;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.game-over-stat p {
  margin: -0.2rem 0 0.45rem;
  color: #94a3b8;
  font-size: 0.72rem;
}

.game-over-stat div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.18rem 0;
}

.game-over-vp {
  margin-top: 0.75rem;
}

.game-over-table {
  width: 100%;
  border-collapse: collapse;
  color: #e5e7eb;
}

.game-over-table th,
.game-over-table td {
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  padding: 0.42rem 0.35rem;
}

.game-over-table th {
  color: #94a3b8;
  font-size: 0.72rem;
  text-align: right;
  text-transform: uppercase;
}

.game-over-table th:first-child,
.game-over-table td:first-child {
  text-align: left;
}

.game-over-table td {
  text-align: right;
  font-weight: 850;
}

.game-over-table tbody tr:last-child td {
  border-bottom: 0;
}

.game-over-table .is-total td {
  border-top: 1px solid rgba(250, 204, 21, 0.38);
  color: #fef3c7;
  font-weight: 950;
}

.attack-step,
.defense-step,
.result-step {
  opacity: 0;
  transform: translateY(0.35rem);
  pointer-events: none;
  transition: opacity 220ms ease, transform 220ms ease;
}

.dice-backdrop.show-attack .attack-step,
.dice-backdrop.show-defense .attack-step,
.dice-backdrop.show-result .attack-step,
.dice-backdrop.show-defense .defense-step,
.dice-backdrop.show-result .defense-step,
.dice-backdrop.show-result .result-step {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

@keyframes backdropIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes diceEventFromLeft {
  from {
    opacity: 0;
    transform: translateX(-22vw) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes diceEventFromRight {
  from {
    opacity: 0;
    transform: translateX(22vw) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes diePop {
  0% {
    opacity: 0;
    transform: translateY(-0.65rem) rotate(-18deg) scale(0.7);
  }
  70% {
    opacity: 1;
    transform: translateY(0.08rem) rotate(6deg) scale(1.08);
  }
  100% {
    opacity: 1;
    transform: translateY(0) rotate(0) scale(1);
  }
}

@media (min-width: 1200px) {
  .battlefield-row {
    height: 100%;
    min-height: 0;
  }

  .army-panel-combined {
    flex: 0 0 30rem;
    max-width: 30rem;
    width: 30rem;
  }

  .battlefield-main {
    flex: 1 1 0;
    max-width: calc(100% - 30rem - var(--bs-gutter-x));
  }

  .army-panel {
    height: 100%;
    max-height: 100%;
  }
}

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

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

  .army-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-height: 18rem;
  }

  .map-viewport {
    height: calc(100dvh - 12rem);
    min-height: 420px;
  }

  .battlefield-bottom-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .map-legend-list {
    justify-content: flex-start;
    margin-left: 0;
  }
}

@media (max-width: 767.98px) {
  .army-list {
    grid-template-columns: 1fr;
  }
}

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

  .lobby-header,
  .room-token-row,
  .ready-row,
  .guest-form-row {
    align-items: stretch;
    flex-direction: column;
  }

  .lobby-actions,
  .invite-choice-grid,
  .roll-choice-buttons,
  .army-choice-buttons,
  .guest-form-row {
    grid-template-columns: 1fr;
  }

  .lobby-actions .btn:first-child {
    grid-column: auto;
  }

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

  .container-fluid {
    padding-inline: 0.75rem;
  }

  .map-viewport {
    height: calc(100dvh - 12rem);
    min-height: 320px;
    padding: 0.85rem;
  }

  .legend-list {
    justify-content: flex-start;
    max-width: none;
  }

  .action-strip {
    gap: 0.45rem;
    padding-inline: 0.55rem;
  }

  .hex-label {
    font-size: 0;
  }

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