* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; background: #0b0f14; color: #e8edf2; font-family: 'Segoe UI', Roboto, Arial, sans-serif; overflow: hidden; }

.screen { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.hidden { display: none !important; }

.panel { background: #121923; border: 1px solid #243244; border-radius: 10px; padding: 32px; width: 420px; max-width: 92vw; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
h1 { margin: 0 0 4px; letter-spacing: 3px; font-size: 32px; color: #4fc3f7; text-align: center; }
h2 { margin-top: 0; text-align: center; }
.subtitle { text-align: center; color: #8aa0b4; margin-bottom: 24px; }

input[type=text], input[type=password] { width: 100%; padding: 10px 12px; margin-bottom: 10px; border-radius: 6px; border: 1px solid #2c3b4e; background: #0e141c; color: #e8edf2; font-size: 14px; }
.btn { width: 100%; padding: 11px; border-radius: 6px; border: none; background: #233247; color: #e8edf2; font-size: 14px; cursor: pointer; margin-bottom: 8px; transition: background .15s; }
.btn:hover { background: #2d4259; }
.btn-primary { background: #2066d1; font-weight: 600; }
.btn-primary:hover { background: #2a7bf0; }
.btn-small { width: auto; padding: 8px 14px; }
.or { text-align: center; color: #5b7084; margin: 14px 0; font-size: 12px; text-transform: uppercase; }
.error { color: #ff6b6b; min-height: 18px; font-size: 13px; text-align: center; margin: 8px 0 0; }

.account-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; color: #8aa0b4; font-size: 14px; }
.btn-link { background: none; border: none; color: #4fc3f7; cursor: pointer; font-size: 13px; padding: 0; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #8aa0b4; margin: -2px 0 10px; cursor: pointer; }
.checkbox-row input { margin: 0; }
.public-rooms-list { max-height: 160px; overflow-y: auto; margin-bottom: 10px; }
.public-room-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; background: #0e141c; border-radius: 6px; margin-bottom: 6px; font-size: 13px; }
.public-room-row button { padding: 5px 12px; font-size: 12px; margin: 0; width: auto; }
.public-rooms-empty { color: #5b7084; font-size: 12px; text-align: center; padding: 10px; }

.invite-row { display: flex; gap: 8px; margin-bottom: 18px; }
.invite-row input { margin-bottom: 0; }

.player-list { margin-bottom: 18px; }
.player-row { display: flex; justify-content: space-between; padding: 8px 10px; background: #0e141c; border-radius: 6px; margin-bottom: 6px; font-size: 14px; }
.player-row .faction-tag { color: #8aa0b4; font-size: 12px; }

.faction-pick { display: flex; gap: 12px; margin-bottom: 18px; }
.faction-card { flex: 1; border: 2px solid #243244; border-radius: 8px; padding: 10px; text-align: center; cursor: pointer; transition: border-color .15s; }
.faction-card img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; margin-bottom: 6px; }
.faction-card.selected { border-color: #4fc3f7; }

#screen-game { display: block; position: relative; width: 100%; height: 100%; }
#canvas { display: block; background: #15200f; width: 100%; height: 100%; cursor: crosshair; }
#hud-top { position: absolute; top: 0; left: 0; right: 0; padding: 10px 16px; display: flex; justify-content: space-between; align-items: center; background: linear-gradient(to bottom, rgba(0,0,0,.6), transparent); pointer-events: none; z-index: 5; }
#credits { font-size: 18px; font-weight: 700; color: #ffd34d; text-shadow: 0 1px 3px #000; }
#winBanner { pointer-events: all; background: rgba(10,14,20,.9); padding: 20px 28px; border-radius: 10px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
#winText { font-size: 28px; font-weight: 800; color: #4fc3f7; text-shadow: 0 2px 6px #000; }
#winBanner .btn-small { width: auto; padding: 10px 24px; }

#gameToast { position: absolute; top: 60px; left: 50%; transform: translateX(-50%); background: rgba(180,30,30,.9); color: #fff; padding: 8px 16px; border-radius: 6px; font-size: 13px; z-index: 6; pointer-events: none; }

#hud-bottom { position: absolute; bottom: 0; left: 0; right: 0; padding: 10px 16px; background: linear-gradient(to top, rgba(0,0,0,.75), transparent); z-index: 5; }
#buildPanel { display: flex; gap: 8px; flex-wrap: wrap; }
.build-btn { background: #16222f; border: 1px solid #2c3b4e; color: #e8edf2; padding: 6px 10px; border-radius: 6px; cursor: pointer; font-size: 12px; min-width: 76px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.build-btn:hover { background: #1e3148; }
.build-btn img { width: 44px; height: 44px; object-fit: cover; border-radius: 5px; }
.build-btn .build-label { line-height: 1.2; }
.build-btn .cost { color: #ffd34d; font-size: 11px; }
.build-btn:disabled { opacity: .4; cursor: not-allowed; }
.build-hint { color: #8aa0b4; font-size: 13px; padding: 8px; }

#minimapWrap { position: absolute; bottom: 110px; right: 16px; z-index: 5; border: 2px solid #2c3b4e; border-radius: 6px; overflow: hidden; background: #05080a; box-shadow: 0 4px 16px rgba(0,0,0,.5); }
#minimap { display: block; cursor: pointer; }

#groupBar { display: flex; gap: 4px; justify-content: center; margin-bottom: 8px; }
.group-slot { width: 42px; height: 42px; border-radius: 6px; border: 1px solid #2c3b4e; background: rgba(14,20,28,.85); position: relative; cursor: pointer; overflow: hidden; }
.group-slot.empty { opacity: .35; cursor: default; }
.group-slot.active { border-color: #4fc3f7; border-width: 2px; box-shadow: 0 0 6px rgba(79,195,247,.7); }
.group-slot img { width: 100%; height: 100%; object-fit: cover; }
.group-slot .g-num { position: absolute; top: 1px; left: 3px; font-size: 10px; color: #fff; text-shadow: 0 1px 2px #000; }
.group-slot .g-count { position: absolute; bottom: 1px; right: 3px; font-size: 11px; font-weight: 700; color: #ffd34d; text-shadow: 0 1px 2px #000; }

#unitActions { display: flex; gap: 8px; margin-bottom: 8px; }
.toggle-btn { background: #16222f; border: 1px solid #2c3b4e; color: #e8edf2; padding: 8px 14px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.toggle-btn.on { border-color: #5fd36b; color: #5fd36b; }
.toggle-btn.off { border-color: #ff4d4d; color: #ff4d4d; }

#queueStrip { display: flex; gap: 6px; margin-bottom: 8px; min-height: 0; }
.queue-item { position: relative; width: 36px; height: 36px; border-radius: 5px; overflow: hidden; border: 1px solid #2c3b4e; background: #0e141c; }
.queue-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.queue-item .q-progress { position: absolute; left: 0; bottom: 0; width: 100%; height: 4px; background: #000; }
.queue-item .q-progress-fill { height: 100%; background: #5fd36b; }
.queue-item .q-pos { position: absolute; top: 1px; right: 2px; font-size: 9px; color: #fff; text-shadow: 0 1px 2px #000; }
.queue-item.waiting { opacity: .55; }

.build-option { display: flex; }
#buildTooltip { position: fixed; z-index: 11000; max-width: min(330px, calc(100vw - 32px)); padding: 12px 14px; border: 1px solid #58728a; border-radius: 8px; background: rgba(10,20,30,.97); color: #e8edf2; font: 13px/1.55 sans-serif; white-space: pre-line; pointer-events: none; box-shadow: 0 5px 22px #0008; }
