:root {
  color-scheme: dark;
  font-family: Inter, ui-rounded, "Segoe UI", sans-serif;
  background: #0e0d19;
  color: #f7f5ff;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 15% 10%, #403074 0, transparent 35%),
    radial-gradient(circle at 85% 85%, #0d6766 0, transparent 30%),
    #0e0d19;
}

.shell { width: min(1400px, calc(100% - 32px)); margin: 0 auto; padding: 72px 0; }
.hero { margin-bottom: 32px; }
.eyebrow { color: #89f0db; font-weight: 800; letter-spacing: .18em; font-size: .75rem; }
h1 { max-width: 650px; margin: 8px 0; font-size: clamp(2.8rem, 10vw, 5.8rem); line-height: .94; letter-spacing: -.055em; }
.intro { color: #c9c4dd; font-size: 1.15rem; }
.hero, .card { max-width: 720px; }
.card { padding: 28px; border: 1px solid #ffffff20; border-radius: 22px; background: #17152be8; box-shadow: 0 22px 70px #0006; backdrop-filter: blur(12px); }
label, h3 { display: block; margin-bottom: 8px; color: #c9c4dd; font-weight: 700; }
input, button, select { min-height: 48px; border-radius: 12px; font: inherit; }
input { width: 100%; border: 1px solid #ffffff24; padding: 0 14px; background: #0e0d19; color: white; outline: none; }
select { width: 100%; border: 1px solid #ffffff24; padding: 0 40px 0 14px; background: #0e0d19; color: white; }
input:focus { border-color: #89f0db; box-shadow: 0 0 0 3px #89f0db25; }
button { cursor: pointer; border: 0; padding: 0 18px; background: #89f0db; color: #112522; font-weight: 800; }
button:hover { filter: brightness(1.08); }
button.secondary { background: #403074; color: white; }
button.quiet { min-height: 38px; background: transparent; color: #89f0db; border: 1px solid #89f0db55; }
.actions { display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 12px; margin-top: 16px; }
.join-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.join-row input { text-transform: uppercase; letter-spacing: .12em; }
.message { min-height: 1.4em; color: #ffadad; margin-bottom: 0; }
.hidden { display: none; }
.room-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.room-heading h2 { margin: 0 0 16px; font-size: 2.5rem; letter-spacing: .18em; }
#players { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; padding: 0; list-style: none; }
#players li { padding: 12px; border-radius: 10px; background: #ffffff0c; }
.game-placeholder { margin: 24px 0; padding: 32px 18px; border: 1px dashed #ffffff38; border-radius: 14px; text-align: center; color: #c9c4dd; }
.game-placeholder p { margin-top: 0; color: white; font-weight: 750; }
.launch-panel { display: grid; gap: 10px; margin: 24px 0; padding: 20px; border-radius: 14px; background: #ffffff08; }
.muted, #host-hint { color: #a9a3bf; }

body.playing .hero, body.playing #join-card, body.playing #room-card { display: none; }
.game { width: 100%; }
.mission-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.mission-header h2 { margin: 4px 0 0; font-size: clamp(1.6rem, 4vw, 2.8rem); }
.mission-meta { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.mission-meta span { padding: 8px 11px; border: 1px solid #ffffff22; border-radius: 999px; color: #c9c4dd; font-size: .78rem; font-weight: 800; letter-spacing: .08em; }
.planning-splash { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: #080713e8; backdrop-filter: blur(14px); }
.planning-splash.hidden { display: none; }
.planning-splash-card { width: min(520px, 100%); padding: 36px; border: 1px solid #89f0db55; border-radius: 22px; background: #17152b; box-shadow: 0 28px 90px #000b; text-align: center; }
.planning-splash-card h2 { margin: 8px 0; font-size: clamp(2rem, 8vw, 4rem); line-height: .95; }
.planning-splash-card button { margin-top: 14px; }
.active-banner { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; margin-bottom: 14px; padding: 12px 16px; border: 1px solid #89f0db44; border-radius: 14px; background: #101d27; }
.active-banner > span { color: #89f0db; font-size: .72rem; font-weight: 850; letter-spacing: .12em; }
.active-banner strong { font-size: 1.08rem; }
.active-banner > i { grid-column: 1 / -1; height: 4px; overflow: hidden; border-radius: 99px; background: #ffffff12; }
.active-banner > i b { display: block; width: 0; height: 100%; border-radius: inherit; background: #89f0db; transition: width .1s linear; }
.game-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; align-items: start; }
.map-panel, .command-panel { border: 1px solid #ffffff1d; border-radius: 18px; background: #11101ee8; box-shadow: 0 18px 60px #0005; }
.map-panel { min-width: 0; overflow: hidden; }
.map-scroll { width: 100%; max-height: calc(100vh - 220px); overflow: auto; background: #070710; overscroll-behavior: contain; }
#map { display: block; width: 864px; height: 864px; image-rendering: auto; touch-action: pan-x pan-y; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; padding: 12px 16px; color: #aaa5be; font-size: .78rem; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { display: inline-block; width: 11px; height: 11px; border-radius: 3px; }
.legend-swatch.unknown { background: #080812; border: 1px solid #29263a; }
.legend-swatch.hazard { background: #143a58; }
.legend-swatch.resource { background: #8ffff1; transform: rotate(45deg); }
.legend-swatch.simulation { width: 18px; height: 3px; border-radius: 99px; background: #75f4ff; }
.command-panel { display: grid; gap: 20px; padding: 20px; max-height: calc(100vh - 150px); overflow-y: auto; }
.command-panel section { min-width: 0; }
.section-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.section-heading h3 { margin-top: 0; }
#queue-count { color: #89f0db; font-size: .78rem; font-weight: 800; }
.operator-list, .command-queue, .mission-log ol { padding: 0; margin: 0; list-style: none; }
.operator-list { display: grid; gap: 6px; }
.operator-list li { display: grid; grid-template-columns: 12px 1fr auto; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 9px; background: #ffffff08; }
.operator-list li.active { outline: 1px solid #89f0db88; }
.operator-dot { width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 12px currentColor; }
.operator-stats { color: #aaa5be; font-size: .72rem; }
.command-queue { counter-reset: commands; display: grid; gap: 6px; margin-bottom: 10px; }
.command-queue li { counter-increment: commands; display: grid; grid-template-columns: 24px 38px 1fr auto; align-items: center; gap: 8px; min-height: 50px; padding: 6px 10px; border: 1px solid #ffffff15; border-radius: 9px; background: #090815; color: #d7d3e5; font-size: .84rem; }
.command-queue li::before { content: counter(commands, decimal-leading-zero); color: #716b86; }
.command-queue li:first-child { border-color: #89f0db66; }
.command-queue li.empty { color: #716b86; border-style: dashed; }
.command-queue img { width: 36px; height: 36px; object-fit: contain; transition: transform .15s ease; }
.command-queue .queue-remove { min-height: 32px; padding: 0 9px; background: transparent; color: #ff9c9c; border: 1px solid #ff9c9c55; font-size: .7rem; }
button:disabled { cursor: not-allowed; opacity: .38; filter: none; }
button.execute { width: 100%; background: #ffcf67; color: #2d2108; }
.direction-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin: 10px 0; }
.direction-pad button { background: #403074; color: white; }
.direction-pad button[data-direction="north"] { grid-column: 2; }
.direction-pad button[data-direction="west"] { grid-column: 1; grid-row: 2; }
.direction-pad button[data-direction="south"] { grid-column: 2; grid-row: 2; }
.direction-pad button[data-direction="east"] { grid-column: 3; grid-row: 2; }
button.scan { width: 100%; background: #174e5e; color: #b9f7ff; }
.ready-section { padding: 14px; border: 1px solid #89f0db2c; border-radius: 13px; background: #89f0db08; }
#ready-owner-hint { color: #89f0db; font-size: .7rem; font-weight: 800; }
.ready-slot { min-height: 104px; display: grid; place-items: center; border: 2px dashed #89f0db55; border-radius: 12px; color: #777189; text-align: center; }
.ready-slot.drag-over { border-color: #89f0db; background: #89f0db10; }
.ready-card { display: grid; grid-template-columns: 64px 1fr; align-items: center; gap: 12px; width: 100%; padding: 10px; text-align: left; }
.ready-card img { width: 62px; height: 62px; object-fit: contain; transition: transform .15s ease; }
.ready-card strong, .ready-card small { display: block; }
.ready-card small { margin-top: 4px; color: #aaa5be; }
.ready-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 8px; }
.ready-actions button { min-height: 40px; padding: 0 10px; font-size: .78rem; }
#clear-ready { grid-column: 1 / -1; }
.command-deck { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.deck-card { position: relative; min-width: 0; min-height: 108px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 8px 4px; border: 1px solid #ffffff18; background: #e8e2cf; color: #39362f; }
.deck-card:hover { filter: brightness(1.06); }
.deck-card img { width: 54px; height: 54px; object-fit: contain; }
.deck-card strong { max-width: 100%; overflow: hidden; font-size: .66rem; line-height: 1.05; text-overflow: ellipsis; white-space: nowrap; }
.deck-card em { position: absolute; right: 5px; bottom: 5px; display: grid; place-items: center; min-width: 20px; height: 20px; padding: 0 4px; border-radius: 99px; background: #29263a; color: white; font-size: .68rem; font-style: normal; }
.deck-card:disabled { opacity: .25; }
.mission-log { border-top: 1px solid #ffffff18; padding-top: 14px; }
.mission-log summary { cursor: pointer; color: #c9c4dd; font-weight: 800; }
.mission-log ol { display: grid; gap: 6px; margin-top: 10px; }
.mission-log li { color: #918ba7; font-size: .76rem; line-height: 1.35; }

@media (max-width: 600px) {
  .shell { padding: 40px 0; }
  .actions { grid-template-columns: 1fr; }
  .actions > span { text-align: center; }
}

@media (max-width: 900px) {
  body.playing .shell { width: min(100% - 16px, 900px); padding: 16px 0; }
  .mission-header { align-items: flex-start; flex-direction: column; }
  .mission-meta { justify-content: flex-start; }
  .game-grid { grid-template-columns: 1fr; }
  .map-scroll { max-height: 58vh; }
  .command-panel { max-height: none; }
  .active-banner { grid-template-columns: 1fr auto; }
  .active-banner > span:first-child { grid-column: 1 / -1; }
}
