:root {
  --bg-color: #0b141d;
  --panel-bg: rgba(18, 30, 49, 0.88);
  --panel-border: #2c4465;
  --gold: #f5a623;
  --blue: #4a90e2;
  --green: #48bb78;
  --red: #f56565;
  --orange: #ed8936;
  --text-main: #e2e8f0;
  --text-dim: #94a3b8;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-color);
  color: var(--text-main);
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#canvas-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* TOP HEADER */
#top-bar {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 6px 14px;
  z-index: 10;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

.lord-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar-ring {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  overflow: visible;
}

.avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.vip-badge {
  position: absolute;
  bottom: -4px;
  right: -6px;
  background: linear-gradient(135deg, #e53e3e, #c53030);
  font-size: 9px;
  font-weight: bold;
  padding: 1px 4px;
  border-radius: 6px;
  color: white;
  border: 1px solid #ffd700;
}

.lord-meta {
  display: flex;
  flex-direction: column;
}

.lord-name {
  font-size: 13px;
  font-weight: bold;
  color: #fff;
}

.lord-power {
  font-size: 11px;
  color: var(--gold);
}

.resource-bar {
  display: flex;
  gap: 14px;
  align-items: center;
}

.res-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(0,0,0,0.3);
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.08);
}

.res-icon-img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.soldier-thumb-img {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  object-fit: cover;
  background: #111c2a;
}

.hero-avatar-box img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.res-item.gold {
  border-color: rgba(245, 166, 35, 0.4);
}

.btn-icon {
  background: rgba(255,255,255,0.1);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: rgba(255,255,255,0.2);
}

/* ASIDE WIDGET */
#furnace-widget {
  position: absolute;
  top: 74px;
  left: 10px;
  width: 220px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
}

.temp-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 6px 10px;
  backdrop-filter: blur(8px);
}

.temp-text {
  font-weight: bold;
  color: #63b3ed;
  font-size: 14px;
}

.weather-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: auto;
}

.weather-badge.blizzard {
  background: #3182ce;
  color: white;
  animation: pulse 2s infinite;
}

.furnace-card, .survivor-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 10px;
  backdrop-filter: blur(8px);
}

.furnace-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.furnace-title {
  font-size: 12px;
  font-weight: bold;
}

.furnace-stats {
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 8px;
}

.f-good {
  color: var(--gold);
  font-weight: bold;
}

.btn-overdrive {
  width: 100%;
  background: linear-gradient(135deg, #dd6b20, #c05621);
  border: none;
  border-radius: 6px;
  color: white;
  padding: 6px 0;
  font-size: 10px;
  font-weight: bold;
  cursor: pointer;
}

.survivor-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 6px;
}

.mini-bar-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.mini-label {
  font-size: 10px;
  color: var(--text-dim);
  width: 55px;
}

.progress-bar {
  flex: 1;
  height: 6px;
  background: rgba(0,0,0,0.4);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar .fill {
  height: 100%;
  border-radius: 3px;
}

.fill.green { background: var(--green); }
.fill.orange { background: var(--orange); }

/* BOTTOM NAVIGATION */
#bottom-nav {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 6px 12px;
  z-index: 10;
  backdrop-filter: blur(8px);
}

.nav-tab {
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 14px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text-dim);
  transition: all 0.2s;
}

.nav-tab.active {
  background: rgba(74, 144, 226, 0.2);
  color: #fff;
  border: 1px solid var(--blue);
}

.tab-icon {
  font-size: 18px;
}

.tab-label {
  font-size: 11px;
  font-weight: 600;
}

/* MODALS */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-overlay.hidden {
  display: none !important;
}

.modal-card {
  background: #111c2a;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  width: 90%;
  max-width: 440px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,0.8);
}

.modal-card.modal-large {
  max-width: 680px;
}

.modal-header {
  padding: 12px 16px;
  background: #172436;
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 15px;
  color: #fff;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 22px;
  cursor: pointer;
}

.modal-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 12px 16px;
  background: #172436;
  border-top: 1px solid var(--panel-border);
  display: flex;
  justify-content: flex-end;
}

.btn-primary {
  background: linear-gradient(135deg, #3182ce, #2b6cb0);
  border: none;
  color: white;
  padding: 8px 18px;
  border-radius: 8px;
  font-weight: bold;
  cursor: pointer;
}

.btn-gold {
  background: linear-gradient(135deg, #d69e2e, #b7791f);
  border: none;
  color: white;
  padding: 8px 18px;
  border-radius: 8px;
  font-weight: bold;
  cursor: pointer;
}

/* HERO GRID */
.hero-roster-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.filter-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--panel-border);
  color: var(--text-dim);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
}

.filter-btn.active {
  background: var(--blue);
  color: white;
}

.hero-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}

.hero-card {
  background: #18283d;
  border: 1px solid #2e4a6d;
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  cursor: pointer;
  transition: transform 0.2s;
}

.hero-card:hover {
  transform: translateY(-2px);
  border-color: var(--gold);
}

.hero-card.quality-5 {
  border-color: #f6ad55;
  background: linear-gradient(180deg, rgba(221,107,32,0.15), #18283d);
}

.hero-card.quality-4 {
  border-color: #b794f4;
  background: linear-gradient(180deg, rgba(128,90,213,0.15), #18283d);
}

.hero-avatar-box {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: #2a3d54;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin-bottom: 6px;
  border: 2px solid rgba(255,255,255,0.2);
}

.hero-name {
  font-size: 12px;
  font-weight: bold;
  text-align: center;
}

.hero-type {
  font-size: 10px;
  color: var(--text-dim);
}

.hero-level {
  font-size: 10px;
  color: var(--gold);
  margin-top: 4px;
}

/* SOLDIER LIST */
.soldier-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.soldier-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #18283d;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid #2e4a6d;
}

/* BATTLE ARENA */
.explore-arena {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.battle-stage-info {
  display: flex;
  justify-content: space-between;
  background: rgba(0,0,0,0.3);
  padding: 8px 12px;
  border-radius: 8px;
}

.battlefield-canvas-box {
  height: 200px;
  background: linear-gradient(180deg, #10243b, #091523);
  border: 1px solid #2d4566;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  position: relative;
}

.team-side {
  display: flex;
  gap: 8px;
}

.fighter-slot {
  width: 48px;
  height: 70px;
  background: rgba(255,255,255,0.05);
  border: 1px dashed rgba(255,255,255,0.2);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.vs-divider {
  font-size: 20px;
  font-weight: 900;
  color: var(--red);
}

.battle-log {
  background: rgba(0,0,0,0.4);
  padding: 10px;
  border-radius: 6px;
  font-size: 11px;
  height: 70px;
  overflow-y: auto;
  color: var(--text-dim);
}

/* JOB ASSIGNMENT & TECH & ALLIANCE */
.job-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #18283d;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid #2e4a6d;
  margin-bottom: 8px;
}

.job-meta {
  display: flex;
  flex-direction: column;
}

.job-meta strong {
  font-size: 13px;
  color: #fff;
}

.job-meta span {
  font-size: 10px;
  color: var(--text-dim);
}

.job-counter {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-job {
  width: 26px;
  height: 26px;
  background: #2b4461;
  border: 1px solid #4a6c94;
  color: white;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
}

.btn-job:hover {
  background: var(--blue);
}

.tech-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tech-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #18283d;
  border: 1px solid #2e4a6d;
  padding: 12px;
  border-radius: 8px;
}

.tech-card.researched {
  border-color: var(--green);
  background: linear-gradient(135deg, rgba(72,187,120,0.1), #18283d);
}

.alliance-header-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #18283d;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--gold);
  margin-bottom: 14px;
}

.alliance-badge {
  font-size: 36px;
}

.alliance-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.action-card {
  background: #18283d;
  border: 1px solid #2e4a6d;
  padding: 14px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
}

.action-icon {
  font-size: 28px;
}

/* STATUS PILL & CHAT MODAL */
.status-pill {
  font-size: 11px;
  font-weight: bold;
  padding: 3px 8px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.status-pill.online {
  background: rgba(72, 187, 120, 0.2);
  color: #48bb78;
  border: 1px solid rgba(72, 187, 120, 0.4);
}

.status-pill.offline {
  background: rgba(245, 101, 101, 0.2);
  color: #f56565;
  border: 1px solid rgba(245, 101, 101, 0.4);
}

.chat-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 280px;
  overflow-y: auto;
  background: #0d1722;
  border-radius: 8px;
  padding: 10px;
  border: 1px solid var(--panel-border);
}

.chat-msg {
  font-size: 12px;
  line-height: 1.4;
  padding: 6px 10px;
  border-radius: 6px;
  background: #172436;
}

.chat-msg.system {
  background: rgba(245, 166, 35, 0.15);
  border-left: 3px solid var(--gold);
  color: #fbd38d;
}

.chat-msg strong {
  color: #63b3ed;
  margin-right: 4px;
}

.chat-input-bar {
  display: flex;
  gap: 8px;
  width: 100%;
}

.chat-input-bar input {
  flex: 1;
  background: #0d1722;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 8px 12px;
  color: #fff;
  font-size: 12px;
  outline: none;
}

.chat-input-bar input:focus {
  border-color: var(--blue);
}

.gm-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-cheat {
  background: #23374e;
  border: 1px solid #3c5b82;
  color: white;
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}

.btn-cheat:hover {
  background: #2b4461;
}

/* SWITCH TOGGLE */
.switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 20px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #4a5568;
  transition: .3s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
}

input:checked + .slider {
  background-color: #dd6b20;
}

input:checked + .slider:before {
  transform: translateX(18px);
}

.slider.round {
  border-radius: 20px;
}

.slider.round:before {
  border-radius: 50%;
}

@keyframes pulse {
  0% { opacity: 0.8; }
  50% { opacity: 1; transform: scale(1.02); }
  100% { opacity: 0.8; }
}
