:root {
  color-scheme: dark;
  --bg: #071019;
  --bg-2: #0b1320;
  --console: #132235;
  --console-2: #1b2b40;
  --panel: #101a28;
  --panel-2: #16263a;
  --info: #102a3d;
  --text: #e6f1ff;
  --muted: #b8d0ea;
  --cyan: #64d2ff;
  --teal: #5ef2c2;
  --amber: #ffb35c;
  --orange: #ff884d;
  --danger: #ff5c5c;
  --danger-bg: #351722;
  --border: #4a7ba7;
  --border-soft: #2f4c6a;
  --focus: #ffdf7a;
  --shadow: rgba(3, 10, 18, 0.62);
  --glow-cyan: rgba(100, 210, 255, 0.38);
  --glow-teal: rgba(94, 242, 194, 0.28);
  --glow-amber: rgba(255, 179, 92, 0.35);
  --glow-red: rgba(255, 92, 92, 0.42);
  --lcars-cream: #e6dfad;
  --lcars-blue: #3f84e5;
  --lcars-sky: #8bd7f1;
  --lcars-gold: #f6b217;
  --lcars-orange-soft: #ffd16d;
  --button-dark-text: #06101a;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 8%, rgba(100, 210, 255, 0.14), transparent 28rem),
    radial-gradient(circle at 88% 18%, rgba(94, 242, 194, 0.09), transparent 24rem),
    linear-gradient(135deg, var(--bg), var(--bg-2) 52%, #101a28);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, Helvetica, sans-serif;
  font-size: 17px;
  line-height: 1.5;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(100, 210, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(100, 210, 255, 0.035) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent 85%);
}

body.large-text {
  font-size: 20px;
}

body.high-contrast {
  --border: #7abfff;
  --border-soft: #5a93c2;
  --text: #f0f8ff;
  --muted: #d1e4f7;
  --cyan: #80ddff;
  --teal: #7effd4;
  --focus: #ffe27a;
}

body.reduced-motion *,
body.reduced-motion *::before,
body.reduced-motion *::after {
  scroll-behavior: auto;
  transition: none !important;
  animation: none !important;
}

button,
input {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1.5px solid var(--border);
  border-radius: 4px 14px 4px 14px;
  background:
    linear-gradient(180deg, rgba(100, 210, 255, 0.18), rgba(94, 242, 194, 0.08)),
    #102235;
  color: var(--text);
  padding: 0.48rem 0.78rem;
  cursor: pointer;
  font-weight: 800;
  letter-spacing: 0;
  box-shadow: inset 0 0 0 1px rgba(230, 241, 255, 0.04), 0 0 16px rgba(100, 210, 255, 0.08);
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

button:hover {
  border-color: var(--cyan);
  background:
    linear-gradient(180deg, rgba(100, 210, 255, 0.28), rgba(94, 242, 194, 0.13)),
    #142b42;
  box-shadow: 0 0 18px var(--glow-cyan);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  box-shadow: none;
}

button:focus-visible,
input:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: 0.5rem;
  z-index: 20;
  transform: translateY(-150%);
  background: #142235;
  color: var(--text);
  border: 2px solid var(--focus);
  padding: 0.75rem 1rem;
  font-weight: 800;
}

.skip-link:focus {
  transform: translateY(0);
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1,
h2,
h3,
legend,
.eyebrow {
  font-family: Rajdhani, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

h1 {
  margin-bottom: 0;
  color: #f0f8ff;
  font-size: clamp(2.15rem, 4vw, 4rem);
  line-height: 1;
  text-shadow: 0 0 22px rgba(100, 210, 255, 0.34);
}

h2 {
  font-size: 1.65rem;
}

h3 {
  font-size: 1.2rem;
}

.eyebrow {
  color: var(--teal);
  font-weight: 900;
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

.site-header {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-soft);
  background:
    linear-gradient(90deg, rgba(100, 210, 255, 0.12), transparent 45%),
    rgba(11, 19, 32, 0.94);
  box-shadow: 0 18px 42px var(--shadow);
}

.header-actions,
.button-grid,
.tab-strip,
.setup-actions,
.ending-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.home-page,
.setup-page,
.ending-page {
  min-height: 100vh;
  display: grid;
  place-items: start center;
  padding: 1.25rem;
}

.home-card,
.setup-card,
.ending-card,
.mission-console,
.board-panel,
.hand-panel,
.gameplay-actions,
.log-card,
.action-card,
.info-panel,
.tab-panel {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 8px 24px 8px 24px;
  background:
    linear-gradient(135deg, rgba(100, 210, 255, 0.08), transparent 34%),
    linear-gradient(180deg, var(--console), var(--panel));
  box-shadow: 0 18px 48px var(--shadow), inset 0 0 0 1px rgba(230, 241, 255, 0.035);
}

.home-card::before,
.setup-card::before,
.ending-card::before,
.mission-console::before,
.board-panel::before,
.hand-panel::before,
.gameplay-actions::before {
  content: "";
  position: absolute;
  left: 1rem;
  right: 1rem;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), var(--teal), transparent);
  opacity: 0.7;
}

.home-card,
.setup-card,
.ending-card {
  padding: 1.35rem;
}

.home-card,
.setup-card {
  width: min(1500px, calc(100vw - 32px));
}

.ending-card {
  width: min(1180px, 100%);
}

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

.home-card > .eyebrow,
.home-card > h1,
.home-card > .tagline,
.home-card > p:not(.tagline):not(.eyebrow),
.home-card > .setup-actions {
  grid-column: 1 / -1;
}

.intro-text,
.tagline {
  max-width: 1120px;
  font-size: 1.12rem;
}

.tagline {
  color: var(--cyan);
  font-weight: 900;
}

.home-section {
  margin-top: 0;
  padding: 1rem;
  border: 1px solid var(--border-soft);
  border-radius: 6px 18px 6px 18px;
  background: rgba(16, 42, 61, 0.55);
}

.setup-actions {
  margin: 1rem 0;
}

.setup-actions button:first-child,
.ending-actions button:first-child,
#home-play-button {
  border-color: var(--teal);
  background:
    linear-gradient(180deg, rgba(94, 242, 194, 0.28), rgba(100, 210, 255, 0.1)),
    #123345;
  color: #f4fffb;
}

.ending-actions {
  margin-top: 1rem;
}

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

.ending-stats div,
fieldset,
.hand-card,
.role-card {
  border: 1px solid var(--border-soft);
  border-radius: 6px 18px 6px 18px;
  background: rgba(16, 26, 40, 0.78);
  padding: 0.75rem;
}

.ending-stats dt,
dt,
legend {
  color: var(--cyan);
  font-weight: 900;
}

.ending-stats dd,
dd {
  margin: 0.2rem 0 0;
  font-weight: 800;
  color: var(--text);
}

.gameplay-shell {
  width: calc(100vw - 32px);
  max-width: 1780px;
  margin: 0 auto;
  padding: 0.9rem 0;
  display: grid;
  grid-template-columns: minmax(380px, 0.82fr) minmax(680px, 1.35fr);
  gap: 1rem;
  align-items: stretch;
}

.left-column,
.right-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
}

.right-column {
  align-self: stretch;
}

.alert-banner {
  width: calc(100vw - 32px);
  max-width: 1780px;
  margin: 0.75rem auto 0;
  border: 1px solid var(--orange);
  border-left: 8px solid var(--danger);
  border-radius: 6px 18px 6px 18px;
  background: linear-gradient(90deg, rgba(255, 92, 92, 0.22), rgba(255, 179, 92, 0.08));
  color: #ffe4d1;
  padding: 0.7rem 0.95rem;
  font-weight: 900;
  box-shadow: 0 0 22px var(--glow-red);
}

.alert-banner.critical {
  animation: alertPulse 1.8s ease-in-out infinite;
}

.setup-panel {
  padding: 1rem 0 0;
}

.setup-grid {
  display: grid;
  grid-template-columns: minmax(240px, 0.72fr) minmax(360px, 1.1fr) minmax(240px, 0.78fr);
  grid-template-areas:
    "players difficulty ship"
    "access access rules"
    "player1 player1 player2";
  gap: 1rem;
  align-items: stretch;
}

.setup-grid fieldset {
  min-width: 0;
  margin: 0;
}

.setup-players {
  grid-area: players;
}

.setup-difficulty {
  grid-area: difficulty;
}

.setup-ship {
  grid-area: ship;
}

.setup-player-one {
  grid-area: player1;
}

.setup-player-two {
  grid-area: player2;
}

.setup-accessibility {
  grid-area: access;
}

.setup-rules {
  grid-area: rules;
}

.setup-quick,
.setup-system-card {
  display: flex;
  flex-direction: column;
}

.setup-quick label,
.setup-system-card label {
  min-height: 44px;
  display: flex;
  gap: 0.45rem;
  align-items: flex-start;
  padding: 0.42rem 0.5rem;
  border: 1px solid rgba(74, 123, 167, 0.45);
  border-radius: 4px 14px 4px 14px;
  background: rgba(7, 16, 25, 0.36);
}

.setup-panel label {
  display: block;
  margin: 0.65rem 0;
}

.setup-panel input,
.task-row input {
  margin-right: 0.5rem;
}

.setup-panel input[type="text"] {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: #0e1a29;
  color: var(--text);
  padding: 0.48rem 0.58rem;
}

.role-card-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.setup-player-card .role-card {
  min-height: 96px;
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  margin: 0;
  border-radius: 4px 20px 4px 20px;
  background:
    linear-gradient(135deg, rgba(100, 210, 255, 0.1), transparent 62%),
    rgba(7, 16, 25, 0.56);
}

.setup-player-card {
  margin-top: 0.5rem;
}

.role-card:has(input:checked),
.role-card:focus-within {
  border-color: var(--teal);
  box-shadow: 0 0 20px var(--glow-teal);
}

#setup-summary,
#role-help,
#difficulty-help,
#ship-size-help,
#shortcut-help,
#map-summary,
.latest-update-line,
.tile-state,
.tile-situation {
  color: var(--muted);
}

.mission-console,
.board-panel,
.hand-panel,
.gameplay-actions {
  padding: 1rem;
}

.board-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.mission-console h2,
.board-panel h2,
.hand-panel h2,
.gameplay-actions h2 {
  color: var(--cyan);
  margin-bottom: 0.6rem;
}

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

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

.card-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.55rem;
}

.hand-card {
  background:
    linear-gradient(90deg, rgba(94, 242, 194, 0.08), transparent),
    rgba(11, 25, 39, 0.9);
}

.hand-card strong {
  color: var(--teal);
}

.hand-card p {
  margin: 0.25rem 0 0.45rem;
}

.hand-card button,
#read-inventory-button {
  min-height: 34px;
  padding: 0.32rem 0.55rem;
}

.tab-strip {
  margin: 0.5rem 0 0.75rem;
}

.tab-button {
  border-radius: 4px 18px 4px 18px;
}

.tab-button[aria-selected="true"] {
  border-color: var(--amber);
  background: linear-gradient(180deg, rgba(255, 179, 92, 0.36), rgba(100, 210, 255, 0.12)), #16263a;
  color: #fff2dd;
  box-shadow: 0 0 20px var(--glow-amber);
}

.tab-panel {
  background: rgba(10, 20, 32, 0.72);
}

.log-card,
.action-card,
.info-panel {
  padding: 0.8rem;
  margin-bottom: 0.75rem;
}

.game-log {
  max-height: min(360px, 42vh);
  overflow-y: auto;
  margin: 0;
  padding: 0 0.2rem 0 0;
  list-style: none;
  scrollbar-color: var(--cyan) #0b1320;
}

.game-log li {
  padding: 0.8rem 0.9rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border-soft);
  border-left: 5px solid var(--cyan);
  border-radius: 6px 18px 6px 18px;
  background:
    linear-gradient(90deg, rgba(100, 210, 255, 0.12), transparent 70%),
    rgba(14, 28, 43, 0.95);
  box-shadow: inset 0 0 18px rgba(100, 210, 255, 0.035);
}

.game-log li:last-child {
  border-left-color: var(--teal);
  box-shadow: 0 0 20px rgba(94, 242, 194, 0.14), inset 0 0 18px rgba(94, 242, 194, 0.05);
}

.game-log li p {
  margin: 0;
}

.gameplay-actions {
  margin-bottom: 0;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.32), transparent 18%, transparent 82%, rgba(0, 0, 0, 0.28)),
    linear-gradient(180deg, #0c1624, #101d2e);
}

.button-grid {
  margin-top: 0.55rem;
}

.button-grid button,
.danger-action,
.round-controls button,
.help-controls button {
  --command-bg: var(--lcars-sky);
  --command-bg-2: #65bfe0;
  --command-text: var(--text);
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--command-bg) 70%, transparent) 0 7px, transparent 7px),
    linear-gradient(180deg, rgba(100, 210, 255, 0.12), rgba(3, 10, 18, 0.1)),
    #101d2e;
  color: var(--command-text);
  border: 1px solid color-mix(in srgb, var(--command-bg) 64%, #203248);
  border-radius: 4px 18px 4px 18px;
  box-shadow: inset 0 0 0 1px rgba(230, 241, 255, 0.035), 0 0 14px rgba(100, 210, 255, 0.08);
  text-transform: none;
  font-family: Rajdhani, "Segoe UI", Arial, sans-serif;
  font-weight: 950;
  line-height: 1.05;
}

.button-grid button:hover,
.danger-action:hover,
.round-controls button:hover,
.help-controls button:hover {
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--command-bg-2) 80%, transparent) 0 9px, transparent 9px),
    linear-gradient(180deg, rgba(100, 210, 255, 0.2), rgba(94, 242, 194, 0.08)),
    #142b42;
  border-color: var(--command-bg-2);
  box-shadow: 0 0 18px color-mix(in srgb, var(--command-bg-2) 34%, transparent), inset 0 0 18px rgba(100, 210, 255, 0.04);
}

.button-grid button:focus-visible,
.danger-action:focus-visible,
.round-controls button:focus-visible,
.help-controls button:focus-visible {
  outline-offset: 4px;
}

.danger-action {
  --command-bg: var(--lcars-gold);
  --command-bg-2: var(--lcars-orange-soft);
  margin-top: 0;
}

.move-button-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: minmax(54px, 1fr);
  gap: 0.42rem;
  padding: 0.35rem;
  border: 1px solid rgba(100, 210, 255, 0.12);
  border-radius: 6px 18px 6px 18px;
  background: rgba(3, 7, 13, 0.64);
}

.basic-button-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  grid-auto-rows: minmax(58px, 1fr);
  gap: 0.42rem;
  padding: 0.35rem;
  border: 1px solid rgba(100, 210, 255, 0.12);
  border-radius: 6px 18px 6px 18px;
  background: rgba(3, 7, 13, 0.64);
}

.round-controls,
.help-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  grid-auto-rows: minmax(50px, 1fr);
  gap: 0.42rem;
  margin-top: 0.5rem;
  padding: 0.35rem;
  border: 1px solid rgba(100, 210, 255, 0.12);
  border-radius: 6px 18px 6px 18px;
  background: rgba(3, 7, 13, 0.64);
}

.move-button-grid button,
.basic-button-grid button,
.round-controls button,
.help-controls button {
  width: 100%;
  min-height: 50px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: normal;
  font-size: clamp(0.82rem, 1.35vw, 0.98rem);
  padding: 0.42rem 0.62rem;
  text-align: center;
  overflow-wrap: anywhere;
}

.choice-move,
.choice-discover,
#summary-button,
#replay-button {
  --command-bg: var(--lcars-blue);
  --command-bg-2: #5b9bf0;
}

.choice-stabilize,
.choice-stabilizeAdjacent,
.choice-resolve,
.choice-useItem,
.choice-chargeSuit,
#read-inventory-button {
  --command-bg: var(--lcars-gold);
  --command-bg-2: var(--lcars-orange-soft);
}

.choice-talk,
.choice-assist,
.choice-escort,
.choice-roleAbility,
.help-controls button {
  --command-bg: var(--lcars-sky);
  --command-bg-2: #a7e5f8;
}

.choice-escape {
  --command-bg: var(--teal);
  --command-bg-2: #8dffd9;
}

.help-controls button {
  border-radius: 4px 16px 4px 16px;
}

.button-grid button:disabled,
.round-controls button:disabled,
.help-controls button:disabled {
  background:
    linear-gradient(90deg, rgba(184, 208, 234, 0.28) 0 7px, transparent 7px),
    linear-gradient(180deg, rgba(184, 208, 234, 0.08), rgba(0, 0, 0, 0.1)),
    #1c2735;
  color: #b9c7d5;
  border-color: #2b3c50;
  opacity: 0.72;
  box-shadow: none;
}

.goal-line {
  font-weight: 900;
  color: var(--teal);
  margin-bottom: 0.5rem;
  text-shadow: 0 0 14px rgba(94, 242, 194, 0.26);
}

.status-bar-line,
.dice-guide,
.suit-power-meter,
.known-leads-line {
  border: 1px solid var(--border-soft);
  border-radius: 6px 18px 6px 18px;
  background: rgba(16, 42, 61, 0.75);
  padding: 0.48rem 0.75rem;
  font-weight: 800;
}

.status-bar-line {
  margin-top: 0;
  margin-bottom: 0.65rem;
  font-size: 0.95rem;
}

.known-leads-line {
  margin: 0 0 0.65rem;
  border-left: 5px solid var(--amber);
  background:
    linear-gradient(90deg, rgba(255, 179, 92, 0.14), transparent 72%),
    rgba(16, 42, 61, 0.62);
  color: #ffe2b8;
}

.action-group-title {
  margin: 0.85rem 0 0.35rem;
  color: var(--muted);
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.task-row label {
  display: inline-grid;
  gap: 0.18rem;
}

.task-next-step {
  color: var(--muted);
  font-weight: 800;
}

.dice-guide {
  border-left: 5px solid var(--amber);
  margin-bottom: 0.45rem;
  color: #ffe1b7;
}

.suit-power-meter {
  position: relative;
  overflow: hidden;
  margin-bottom: 0.5rem;
  color: #f2fbff;
}

.suit-power-meter::before {
  content: "";
  position: absolute;
  inset: 0;
  width: var(--power, 100%);
  background: linear-gradient(90deg, rgba(100, 210, 255, 0.42), rgba(94, 242, 194, 0.32));
  z-index: 0;
}

.suit-power-meter.low::before {
  background: linear-gradient(90deg, rgba(255, 179, 92, 0.48), rgba(255, 136, 77, 0.3));
}

.suit-power-meter.critical::before {
  background: linear-gradient(90deg, rgba(255, 92, 92, 0.52), rgba(255, 136, 77, 0.34));
}

.suit-power-meter {
  isolation: isolate;
}

.suit-power-meter::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(230, 241, 255, 0.08), transparent);
  z-index: 1;
}

.suit-power-meter {
  text-shadow: 0 1px 2px #071019;
}

.state-pill {
  display: inline-block;
  border: 1.5px solid var(--cyan);
  border-radius: 4px 14px 4px 14px;
  padding: 0.22rem 0.55rem;
  font-weight: 900;
  background: rgba(100, 210, 255, 0.1);
}

.situation {
  margin-top: 1rem;
  border-top: 1px solid var(--border-soft);
  padding-top: 0.8rem;
}

.ship-map {
  display: grid;
  grid-template-columns: repeat(var(--ship-cols, 5), 1fr);
  grid-template-rows: repeat(var(--ship-rows, 5), minmax(140px, 1fr));
  grid-auto-rows: minmax(140px, 1fr);
  flex: 1;
  gap: 0.65rem;
  padding: 1rem;
  list-style: none;
  border: 1px solid rgba(100, 210, 255, 0.16);
  border-radius: 8px 24px 8px 24px;
  background:
    radial-gradient(circle at center, rgba(100, 210, 255, 0.11), transparent 58%),
    linear-gradient(rgba(100, 210, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(100, 210, 255, 0.035) 1px, transparent 1px),
    rgba(7, 16, 25, 0.48);
  background-size: auto, 28px 28px, 28px 28px, auto;
}

.ship-map li {
  min-width: 0;
  display: flex;
  min-height: 140px;
}

.ship-map .current {
  filter: drop-shadow(0 0 14px var(--glow-cyan));
}

.ship-tile {
  width: 100%;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid var(--border-soft);
  border-radius: 4px 16px 4px 16px;
  background:
    linear-gradient(135deg, rgba(100, 210, 255, 0.16), transparent 50%),
    #0e1c2b;
  color: var(--text);
  text-align: left;
  padding: 0.58rem;
  font-weight: 500;
  overflow-wrap: anywhere;
  box-shadow: inset 0 0 16px rgba(100, 210, 255, 0.05);
}

button.ship-tile {
  border: 2px solid var(--cyan);
  cursor: pointer;
}

button.ship-tile:hover {
  background:
    linear-gradient(135deg, rgba(94, 242, 194, 0.2), transparent 55%),
    #112941;
}

.ship-tile[aria-disabled="true"],
.ship-tile.unreachable {
  background:
    linear-gradient(135deg, rgba(184, 208, 234, 0.05), transparent),
    #0d1724;
  border-color: rgba(74, 123, 167, 0.55);
}

.ship-map .current .ship-tile {
  border-color: var(--teal);
  box-shadow: 0 0 20px var(--glow-teal), inset 0 0 18px rgba(94, 242, 194, 0.08);
}

.tile-name {
  display: block;
  font-weight: 900;
  font-size: 0.95rem;
  color: #f1f8ff;
}

.tile-state {
  display: inline-block;
  margin-top: 0.25rem;
  font-size: 0.82rem;
  font-weight: 900;
  color: var(--cyan);
}

.tile-state:has(+ .tile-situation) {
  margin-bottom: 0.1rem;
}

.ship-tile:has(.tile-state:nth-child(2)) {
  /* structural hook for modern browsers; fallback remains readable */
}

.ship-tile .tile-state {
  text-transform: uppercase;
}

.ship-tile:has(.tile-state) .tile-state {
  text-shadow: 0 0 10px rgba(100, 210, 255, 0.25);
}

.ship-tile:has(.tile-state):has(span:nth-child(2)) {
  /* no-op hook keeps state text visible without relying on color */
}

.tile-situation {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.82rem;
  font-style: italic;
}

.tile-status {
  display: block;
  margin-top: 0.45rem;
  padding-top: 0.35rem;
  border-top: 1px solid rgba(100, 210, 255, 0.18);
  font-size: 0.82rem;
  font-weight: 900;
  color: var(--teal);
}

.ship-tile:has(.tile-state) {
  position: relative;
}

.ship-tile:has(.tile-state)::after {
  content: "";
  position: absolute;
  left: 0.4rem;
  right: 0.4rem;
  bottom: 0.35rem;
  height: 2px;
  background: linear-gradient(90deg, var(--cyan), transparent);
  opacity: 0.55;
}

.ship-tile:has(.tile-state:nth-child(2)) .tile-state {
  color: var(--cyan);
}

.ship-tile.damaged {
  border-color: var(--amber);
  background:
    linear-gradient(135deg, rgba(255, 179, 92, 0.22), transparent 55%),
    #221a14;
  box-shadow: 0 0 18px rgba(255, 179, 92, 0.14), inset 0 0 18px rgba(255, 179, 92, 0.06);
}

.ship-tile.damaged .tile-state,
.ship-tile.damaged .tile-status {
  color: var(--amber);
}

.ship-tile.critical {
  border-color: var(--danger);
  background:
    repeating-linear-gradient(135deg, rgba(255, 92, 92, 0.16) 0 8px, transparent 8px 18px),
    linear-gradient(135deg, rgba(255, 92, 92, 0.2), transparent 50%),
    #23121a;
  box-shadow: 0 0 20px var(--glow-red), inset 0 0 18px rgba(255, 92, 92, 0.08);
}

.ship-tile.critical .tile-state,
.ship-tile.critical .tile-status {
  color: #ffb1b1;
}

.ship-tile.critical .tile-status {
  font-size: 0.78rem;
}

.tile-region {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ship-tile.destroyed {
  border-color: var(--danger);
  background:
    repeating-linear-gradient(135deg, rgba(255, 92, 92, 0.24) 0 8px, rgba(8, 12, 20, 0.78) 8px 18px),
    #100b10;
  box-shadow: 0 0 24px rgba(255, 92, 92, 0.28), inset 0 0 22px rgba(0, 0, 0, 0.42);
  opacity: 0.82;
}

.ship-tile.destroyed .tile-state,
.ship-tile.destroyed .tile-status {
  color: #ffd0d0;
}

.ship-tile.operational {
  border-color: rgba(100, 210, 255, 0.78);
}

.warning-box {
  margin-top: 0.75rem;
  border: 1.5px solid var(--danger);
  border-radius: 6px 18px 6px 18px;
  background: var(--danger-bg);
  color: #ffd4d4;
  padding: 0.75rem;
  font-weight: 900;
}

.task-row {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  padding: 0.45rem 0;
}

.secondary-action {
  margin-top: 0.25rem;
}

.latest-update-line {
  font-size: 0.9rem;
  margin: 0.45rem 0 0;
  padding-top: 0.4rem;
  border-top: 1px solid var(--border-soft);
}

.latest-update {
  color: var(--text);
  font-weight: 700;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes alertPulse {
  0%, 100% {
    box-shadow: 0 0 14px rgba(255, 92, 92, 0.22);
  }
  50% {
    box-shadow: 0 0 26px rgba(255, 92, 92, 0.5);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}

@media (max-width: 1060px) {
  .gameplay-shell {
    display: block;
  }

  .setup-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      "players difficulty"
      "ship access"
      "rules rules"
      "player1 player1"
      "player2 player2";
  }

  .left-column,
  .right-column,
  .board-panel,
  .hand-panel {
    margin-top: 1rem;
    height: auto;
    min-height: 0;
  }

  .ship-map {
    flex: initial;
  }
}

@media (max-width: 900px) {
  .site-header,
  .setup-panel form,
  .hand-grid,
  .home-card {
    display: block;
  }

  .home-card,
  .setup-card {
    width: min(100%, calc(100vw - 24px));
  }

  .role-card-list {
    grid-template-columns: 1fr;
  }

  .header-actions,
  .setup-panel fieldset {
    margin-top: 1rem;
  }

  .ship-map {
    grid-template-columns: repeat(var(--ship-cols, 5), minmax(80px, 1fr));
    grid-template-rows: repeat(var(--ship-rows, 5), minmax(118px, 1fr));
  }
}
