@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@500;600;700;800&family=Rajdhani:wght@500;600;700&display=swap');

:root {
  --ink: #d9f7ec;
  --muted: #7d9d99;
  --panel: rgba(7, 22, 28, .86);
  --panel-solid: #0a1d24;
  --line: rgba(143, 221, 192, .19);
  --cyan: #52edcf;
  --cyan-bright: #b6ffea;
  --orange: #ff9d55;
  --red: #ff6275;
  --yellow: #ffd166;
  --font-display: "Barlow Condensed", Impact, "Arial Narrow", sans-serif;
  --font-ui: Rajdhani, "Trebuchet MS", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #07131a; }
body { color: var(--ink); font-family: var(--font-ui); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 2px solid var(--yellow); outline-offset: 3px; }

#gameShell { position: relative; width: 100%; height: 100%; min-height: 100dvh; overflow: hidden; isolation: isolate; }
#gameCanvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; background: #07131a; }
.game-ui { position: absolute; z-index: 3; transition: opacity .2s ease, transform .2s ease; }

.topbar {
  left: max(14px, env(safe-area-inset-left)); right: max(14px, env(safe-area-inset-right)); top: max(12px, env(safe-area-inset-top));
  min-height: 62px; display: flex; align-items: stretch; justify-content: space-between; gap: 12px;
  pointer-events: none;
}
.brand, .icon-button { pointer-events: auto; border: 1px solid var(--line); background: linear-gradient(135deg, rgba(13, 40, 46, .93), rgba(4, 14, 19, .86)); }
.brand { display: flex; align-items: center; gap: 8px; padding: 0 13px 0 9px; border-radius: 8px; color: #c5f9e8; font: 700 22px/1 var(--font-display); letter-spacing: 1px; box-shadow: 0 8px 24px #02090d66; }
.brand:hover { border-color: #55e5c488; background: #123139; }
.brand > span:last-child span { color: var(--orange); }
.brand-mark { color: var(--cyan); font-size: 30px; line-height: .5; text-shadow: 0 0 16px #52edcf88; }
.readouts { display: flex; min-width: 0; align-items: stretch; justify-content: center; background: rgba(5, 16, 21, .75); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; box-shadow: 0 8px 24px #02090d44; }
.readout { min-width: 84px; padding: 7px 12px 5px; display: flex; flex-direction: column; border-right: 1px solid var(--line); text-align: center; }
.readout:last-child { border: 0; }
.label, .panel-eyebrow, .eyebrow { color: var(--muted); font: 700 10px/1.1 var(--font-display); letter-spacing: 1.5px; }
.readout strong { color: var(--cyan-bright); font: 700 21px/.95 var(--font-display); letter-spacing: .8px; white-space: nowrap; }
.objective-readout strong { color: #ffe1ad; font-size: 16px; padding-top: 3px; }
.icon-button { width: 62px; border-radius: 8px; color: var(--cyan-bright); font: 700 26px/1 var(--font-display); box-shadow: 0 8px 24px #02090d66; }
.icon-button:hover { color: var(--orange); border-color: #ff9d5588; }

.tactical-panel { top: 92px; left: max(16px, env(safe-area-inset-left)); width: 218px; padding: 12px 13px 11px; border: 1px solid var(--line); border-radius: 8px; background: linear-gradient(135deg, rgba(7, 25, 31, .9), rgba(7, 17, 24, .73)); box-shadow: 0 10px 30px #02080c44; pointer-events: none; }
.panel-eyebrow { display: flex; align-items: center; gap: 7px; }
.live-dot { width: 6px; height: 6px; background: var(--cyan); box-shadow: 0 0 9px var(--cyan); border-radius: 50%; animation: blink 1.5s infinite; }
.unit-name { margin-top: 7px; color: #e4fff5; font: 700 17px/1 var(--font-display); letter-spacing: .65px; }
.unit-stats { min-height: 18px; margin-top: 4px; color: #a1bbb8; font-size: 13px; line-height: 1.1; }
.legend-row { margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--line); display: flex; gap: 14px; color: #82a09c; font: 700 10px/1 var(--font-display); letter-spacing: .8px; }
.legend-dot { width: 7px; height: 7px; display: inline-block; margin: 0 4px 1px 0; border-radius: 50%; }
.legend-dot.move { background: var(--cyan); box-shadow: 0 0 7px var(--cyan); }
.legend-dot.attack { background: var(--orange); box-shadow: 0 0 7px var(--orange); }

.toast { left: 50%; top: 82px; max-width: min(440px, calc(100vw - 32px)); padding: 8px 13px; border-radius: 5px; border: 1px solid rgba(127, 219, 192, .32); background: rgba(5, 21, 27, .9); color: #ddfff3; text-align: center; font: 700 13px/1.2 var(--font-display); letter-spacing: .8px; transform: translate(-50%, -12px); opacity: 0; pointer-events: none; box-shadow: 0 10px 25px #01090d55; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.warning { border-color: #ffad6b88; color: #ffd7a4; }
.toast.danger { border-color: #ff667788; color: #ffc2ca; }

.command-dock { left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; gap: 7px; align-items: stretch; pointer-events: auto; }
.dock-button { border: 1px solid rgba(137, 220, 193, .24); background: linear-gradient(145deg, rgba(13, 37, 43, .96), rgba(5, 18, 23, .96)); min-height: 57px; border-radius: 8px; color: #b4d6cd; box-shadow: 0 8px 25px #02090d66; transition: .15s ease; }
.dock-button:hover:not(:disabled) { transform: translateY(-2px); border-color: #72f2d488; background: #12363d; color: #eefff9; }
.dock-button:active:not(:disabled) { transform: translateY(1px) scale(.98); }
.dock-button:disabled { opacity: .42; cursor: default; }
.dock-button.small { width: 66px; padding: 3px 6px; display: flex; align-items: center; justify-content: center; gap: 3px; color: var(--cyan); font: 700 27px/.8 var(--font-display); }
.dock-button.small span { color: #8da9a6; font-size: 9px; letter-spacing: .7px; }
.dock-button.primary { min-width: 155px; padding: 5px 16px; border-color: #50d8bc99; background: linear-gradient(135deg, #1a625b, #0c3439); color: #e5fff6; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.dock-button.primary b { font: 800 18px/.9 var(--font-display); letter-spacing: 1px; }
.dock-button.primary small { margin-top: 3px; color: #99d5c7; font: 700 9px/1 var(--font-display); letter-spacing: 1px; }

.screen { position: absolute; z-index: 10; inset: 0; display: grid; place-items: center; padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom)); background: radial-gradient(circle at 50% 37%, rgba(7, 38, 45, .64), rgba(2, 10, 14, .9) 72%); opacity: 0; pointer-events: none; transition: opacity .25s ease; }
.screen.active { opacity: 1; pointer-events: auto; }
.card { position: relative; overflow: hidden; width: min(510px, 100%); border: 1px solid rgba(129, 229, 199, .3); border-radius: 12px; padding: clamp(21px, 5vw, 35px); background: linear-gradient(145deg, rgba(11, 39, 45, .96), rgba(5, 17, 23, .97)); box-shadow: 0 25px 90px #000b0fbb, inset 0 1px #b2ffe51c; }
.card:before, .card:after { content: ""; position: absolute; pointer-events: none; }
.card:before { width: 210px; height: 210px; right: -95px; top: -110px; border: 1px solid #72f2d422; border-radius: 50%; box-shadow: 0 0 0 18px #72f2d409, 0 0 0 44px #72f2d405; }
.card:after { left: 0; right: 0; top: 0; height: 3px; background: linear-gradient(90deg, transparent, var(--cyan), var(--orange), transparent); opacity: .85; }
.menu-card { max-height: calc(100dvh - 36px); overflow: auto; scrollbar-width: thin; }
.signal-line { display: flex; align-items: center; gap: 9px; color: #638784; font: 700 10px/1 var(--font-display); letter-spacing: 1px; white-space: nowrap; }
.signal-line span { height: 1px; flex: 1; background: #6adfc236; }
.title-lockup { margin: 15px 0 0; display: flex; align-items: center; gap: 11px; }
.title-glyph { color: var(--cyan); font: 400 54px/.75 Arial, sans-serif; text-shadow: 0 0 24px #52edcf77; }
h1, h2 { margin: 0; color: #effff9; font-family: var(--font-display); font-weight: 800; letter-spacing: 1.4px; }
h1 { font-size: clamp(48px, 11vw, 72px); line-height: .83; }
h1 span { color: var(--orange); }
h2 { font-size: clamp(42px, 10vw, 58px); line-height: .9; }
.tagline { margin: 14px 0 18px; color: #a9c7c0; font-size: 17px; line-height: 1.15; }
.briefing { position: relative; display: grid; grid-template-columns: 36px 1fr; gap: 12px; padding: 13px; border-radius: 7px; border: 1px solid #7ae2c322; background: #061b21b0; }
.briefing-icon { color: var(--orange); font-size: 28px; line-height: 1; text-shadow: 0 0 10px #ff9d5566; }
.briefing b { color: #e4fff6; font: 700 14px/1 var(--font-display); letter-spacing: .8px; }
.briefing p { margin: 5px 0 0; color: #8faeaa; font-size: 13px; line-height: 1.25; }
.action-button, .outline-button, .text-button { border-radius: 7px; transition: .15s ease; }
.action-button { position: relative; overflow: hidden; width: 100%; margin-top: 17px; min-height: 52px; padding: 8px 13px; display: flex; align-items: center; justify-content: space-between; border: 1px solid #78f3d0bb; background: linear-gradient(110deg, #237c70, #0f4549); color: #edfff8; box-shadow: 0 8px 24px #010a0c88, inset 0 1px #d3fff533; font: 800 19px/1 var(--font-display); letter-spacing: 1px; }
.action-button:before { content:""; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 20%, #c4ffed33 48%, transparent 72%); transform: translateX(-110%); transition: transform .5s ease; }
.action-button:hover:before { transform: translateX(110%); }
.action-button:hover { transform: translateY(-2px); filter: brightness(1.15); }
.action-button:active { transform: translateY(1px) scale(.99); }
kbd { position: relative; padding: 3px 6px; border: 1px solid #c3fff177; border-bottom-width: 2px; border-radius: 3px; color: #d6fff3; background: #062e32; font: 700 10px/1 var(--font-ui); letter-spacing: .4px; }
.howto { margin: 18px 0 15px; display: grid; gap: 8px; color: #7e9e9b; font-size: 12px; }
.howto > div { display: flex; align-items: center; gap: 5px; min-height: 19px; }
.howto p { margin: 0 0 0 4px; }
.keycap { padding: 3px 5px; border: 1px solid #80cbbb50; border-radius: 3px; color: #b6dcd3; background: #0a2830; font: 700 9px/1 var(--font-display); letter-spacing: .55px; }
.keycap.wide { font-size: 8px; }
.leaderboard { border-top: 1px solid var(--line); padding-top: 11px; }
.leaderboard-head { display: flex; justify-content: space-between; color: #97b7b1; font: 700 11px/1 var(--font-display); letter-spacing: 1px; }
.leaderboard-head small { color: #66847f; font: inherit; }
ol { padding: 0; margin: 8px 0 0; list-style: none; counter-reset: rank; }
ol li { counter-increment: rank; padding: 3px 3px; display: grid; grid-template-columns: 24px 1fr auto; align-items: center; color: #a4c3bc; font: 600 13px/1.1 var(--font-ui); border-bottom: 1px solid #8dcfbd10; }
ol li:before { content: "0" counter(rank); color: #53726f; font: 700 10px/1 var(--font-display); }
ol li b { color: #d7f8ed; font: 700 14px/1 var(--font-display); letter-spacing: .6px; }
ol li.you { border-radius: 3px; background: #3fdbbc16; color: #ccfff0; }
ol li.you:after { content: "NEW"; margin-left: 8px; color: var(--yellow); font: 700 9px/1 var(--font-display); letter-spacing: .6px; }
.footer-copy { position: absolute; bottom: max(13px, env(safe-area-inset-bottom)); margin: 0; color: #66847f; text-align: center; font: 700 10px/1 var(--font-display); letter-spacing: 1px; }

.compact-card { width: min(400px, 100%); text-align: center; }
.compact-card p { margin: 13px 0 20px; color: #99b8b2; font-size: 16px; }
.eyebrow { margin-bottom: 9px; color: var(--cyan); }
.button-stack { display: grid; gap: 9px; }
.outline-button { min-height: 42px; border: 1px solid #86cdbb66; background: #0b2930; color: #c6e9df; font: 700 15px/1 var(--font-display); letter-spacing: .8px; }
.outline-button:hover { border-color: #80f0d1; color: #f1fff9; background: #12373d; }
.text-button { min-height: 32px; border: 0; background: transparent; color: #71928d; font: 700 12px/1 var(--font-display); letter-spacing: .7px; }
.text-button:hover { color: #c7eee4; }
.gameover-card { width: min(430px, 100%); text-align: center; }
.gameover-card > p { margin: 11px auto 15px; color: #9cb9b3; font-size: 15px; line-height: 1.2; }
.final-score { margin: 12px 0 16px; padding: 12px 13px; border: 1px solid #76e9ca44; border-radius: 7px; background: #061d22aa; display: grid; gap: 2px; }
.final-score span, .final-score small { color: #7f9e99; font: 700 10px/1 var(--font-display); letter-spacing: 1px; }
.final-score strong { color: #fff0bf; font: 800 46px/.9 var(--font-display); letter-spacing: 2px; text-shadow: 0 0 20px #ffd16644; }
.final-score small { color: #8cbab0; }
.result-board { margin: 0 0 16px; text-align: left; }
.button-stack.horizontal { grid-template-columns: 1fr 1fr; align-items: stretch; }
.button-stack.horizontal .action-button { min-height: 44px; margin: 0; font-size: 16px; }

body:not(.in-game) .game-ui { opacity: 0; pointer-events: none; transform: translateY(-8px); }
body:not(.in-game) .command-dock { transform: translate(-50%, 10px); }
body.paused .game-ui, body.game-ended .game-ui { opacity: .16; pointer-events: none; }

@keyframes blink { 50% { opacity: .25; box-shadow: none; } }

@media (max-width: 650px) {
  .topbar { min-height: 48px; gap: 7px; top: max(8px, env(safe-area-inset-top)); left: max(9px, env(safe-area-inset-left)); right: max(9px, env(safe-area-inset-right)); }
  .brand { padding: 0 8px; font-size: 18px; border-radius: 6px; }
  .brand-mark { font-size: 24px; }
  .readout { min-width: 51px; padding: 5px 7px 3px; }
  .readout strong { font-size: 18px; }
  .objective-readout { display: none; }
  .icon-button { width: 47px; border-radius: 6px; font-size: 21px; }
  .tactical-panel { top: 64px; left: max(9px, env(safe-area-inset-left)); width: 185px; padding: 8px 10px; border-radius: 6px; }
  .unit-name { margin-top: 5px; font-size: 15px; }
  .unit-stats { font-size: 11px; }
  .legend-row { display: none; }
  .toast { top: 64px; font-size: 12px; }
  .command-dock { bottom: max(8px, env(safe-area-inset-bottom)); gap: 5px; }
  .dock-button { min-height: 49px; border-radius: 7px; }
  .dock-button.small { width: 53px; font-size: 24px; }
  .dock-button.small span { font-size: 8px; }
  .dock-button.primary { min-width: 141px; }
  .dock-button.primary b { font-size: 17px; }
  .card { padding: 22px; border-radius: 10px; }
  .menu-card { width: min(460px, 100%); }
  .signal-line { font-size: 8px; }
  .title-lockup { margin-top: 13px; }
  .tagline { font-size: 15px; margin: 12px 0 14px; }
  .briefing { padding: 10px; }
  .howto { margin: 14px 0 12px; gap: 5px; }
  .footer-copy { display: none; }
}
@media (max-height: 660px) and (min-width: 651px) {
  .tactical-panel { top: 80px; transform: scale(.88); transform-origin: top left; }
  .topbar { min-height: 50px; }
  .command-dock { bottom: 8px; transform: translateX(-50%) scale(.9); transform-origin: bottom center; }
}
@media (max-width: 370px) {
  .brand > span:last-child { display: none; }
  .readout { min-width: 48px; }
  .tactical-panel { width: 166px; }
  .dock-button.primary { min-width: 127px; }
  .dock-button.primary small { font-size: 8px; }
}
