:root {
  --ui-scale: 1.0;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #313338;
  font-family: 'Ubuntu', 'Segoe UI', sans-serif;
  color: #f2f3f5;
}

#gameCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  z-index: 1;
}

#ui-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 10;
  pointer-events: none;
}

/* Toast Warning Banner */
.toast-banner {
  position: fixed;
  top: calc(70px * var(--ui-scale));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(200, 52, 54, 0.95);
  border: 2px solid #d93838;
  color: #fff;
  font-size: calc(11px * var(--ui-scale));
  font-weight: 900;
  letter-spacing: 1.5px;
  padding: calc(8px * var(--ui-scale)) calc(16px * var(--ui-scale));
  border-radius: 6px;
  z-index: 200;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.35);
  transition: opacity 0.4s ease-out, transform 0.4s ease-out;
  opacity: 1;
}

.toast-banner.hidden {
  display: block !important;
  opacity: 0;
  transform: translate(-50%, -15px);
  pointer-events: none;
}

/* HUD Panels */
.hud-panel {
  background: rgba(43, 45, 49, 0.90);
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: calc(8px * var(--ui-scale)) calc(12px * var(--ui-scale));
  backdrop-filter: blur(6px);
  pointer-events: auto;
}

.hud-row {
  display: flex;
  gap: calc(8px * var(--ui-scale));
  font-size: calc(13px * var(--ui-scale));
  font-weight: 600;
  font-family: monospace;
}

.hud-label { color: #949ba4; }
.hud-val { color: #359bb5; }

.center-top {
  position: fixed;
  top: calc(16px * var(--ui-scale));
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  min-width: calc(180px * var(--ui-scale));
}

.wave-title {
  font-size: calc(12px * var(--ui-scale));
  font-weight: 900;
  letter-spacing: 1.5px;
  color: #359bb5;
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
}

.wave-timer {
  font-size: calc(13px * var(--ui-scale));
  font-weight: bold;
}

/* Diep.io Evolution Upgrade Panel */
#diep-upgrade-panel {
  position: fixed;
  top: calc(16px * var(--ui-scale));
  left: calc(16px * var(--ui-scale));
  display: flex;
  flex-direction: column;
  gap: calc(6px * var(--ui-scale));
  pointer-events: auto;
  z-index: 50;
  transition: opacity 0.18s ease, transform 0.18s ease;
  opacity: 1;
  transform: translateX(0);
}

#diep-upgrade-panel.hidden {
  display: flex !important;
  opacity: 0;
  transform: translateX(-20px);
  pointer-events: none;
}

.diep-panel-header {
  font-size: calc(15px * var(--ui-scale));
  font-weight: 900;
  letter-spacing: 0.5px;
  color: #ffffff;
  text-shadow: -1.5px -1.5px 0 #000, 1.5px -1.5px 0 #000, -1.5px 1.5px 0 #000, 1.5px 1.5px 0 #000;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 2px;
}

.diep-upgrade-grid {
  display: grid;
  grid-template-columns: repeat(2, calc(82px * var(--ui-scale)));
  gap: calc(8px * var(--ui-scale));
}

.diep-card {
  position: relative;
  width: calc(82px * var(--ui-scale));
  height: calc(82px * var(--ui-scale));
  background-color: #333333;
  border: calc(3.5px * var(--ui-scale)) solid #3d3d3d;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding: calc(4px * var(--ui-scale));
  transition: transform 0.12s ease, filter 0.15s ease, background-color 0.2s ease;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.15), 0 4px 10px rgba(0, 0, 0, 0.35);
  overflow: visible !important;
}

.diep-card:hover {
  transform: translateY(-3px) scale(1.03);
  filter: brightness(1.08);
}

.diep-card.active {
  border-color: #00b2e1 !important;
}

.diep-card.locked-shop {
  border-color: #e03838 !important;
  filter: grayscale(0.2) opacity(0.9);
}

.diep-card-canvas {
  position: absolute;
  top: 44%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: calc(110px * var(--ui-scale));
  height: calc(110px * var(--ui-scale));
  pointer-events: none;
  overflow: visible;
}

.card-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  font-size: calc(8px * var(--ui-scale));
  font-weight: 900;
  padding: 2px 4px;
  border-radius: 3px;
  color: #fff;
  z-index: 10;
}

.card-badge.shop { background: #d93838; }

.diep-card-name {
  font-size: calc(10px * var(--ui-scale));
  font-weight: 900;
  text-align: center;
  color: #ffffff;
  text-shadow: -1.5px -1.5px 0 #000, 1.5px -1.5px 0 #000, -1.5px 1.5px 0 #000, 1.5px 1.5px 0 #000, 0 2px 4px rgba(0,0,0,0.8);
  margin-bottom: calc(2px * var(--ui-scale));
  z-index: 2;
  white-space: nowrap;
}

.diep-ignore-btn {
  margin-top: calc(2px * var(--ui-scale));
  background: #a0a0a0;
  border: calc(2.5px * var(--ui-scale)) solid #3d3d3d;
  border-radius: 6px;
  color: #ffffff;
  font-weight: 900;
  font-size: calc(11px * var(--ui-scale));
  padding: calc(4px * var(--ui-scale)) calc(12px * var(--ui-scale));
  cursor: pointer;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25), 0 3px 6px rgba(0, 0, 0, 0.2);
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
  transition: all 0.1s ease;
  width: 100%;
}

.diep-ignore-btn:hover {
  background: #b5b5b5;
  transform: translateY(-1px);
}

/* 8-Stat Upgrade Panel */
.bottom-left-panel {
  position: fixed;
  bottom: calc(16px * var(--ui-scale));
  left: calc(16px * var(--ui-scale));
  width: calc(260px * var(--ui-scale));
  display: flex;
  flex-direction: column;
  gap: calc(4px * var(--ui-scale));
  padding: calc(8px * var(--ui-scale)) calc(10px * var(--ui-scale));
  transition: opacity 0.18s ease, transform 0.18s ease;
  opacity: 1;
  transform: translateY(0);
  z-index: 50;
  pointer-events: auto;
}

.bottom-left-panel.hidden {
  display: flex !important;
  opacity: 0;
  transform: translateY(18px);
  pointer-events: none;
}

.stat-badge {
  font-size: calc(10px * var(--ui-scale));
  font-weight: 900;
  color: #359bb5;
  letter-spacing: 0.5px;
  margin-bottom: calc(4px * var(--ui-scale));
  text-align: center;
  text-transform: uppercase;
  animation: flashAlert 0.5s infinite alternate;
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
  white-space: nowrap;
}

.stat-list {
  display: flex;
  flex-direction: column;
  gap: calc(3px * var(--ui-scale));
}

.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: calc(6px * var(--ui-scale));
}

.stat-name {
  font-size: calc(10px * var(--ui-scale));
  font-weight: 800;
  width: calc(125px * var(--ui-scale));
  color: #dbdee1;
  white-space: nowrap;
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
}

.stat-bar-track {
  flex: 1;
  height: calc(9px * var(--ui-scale));
  background: #1e1f22;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,0.08);
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  width: 0%;
  transition: width 0.15s ease;
}

.stat-add-btn {
  width: calc(15px * var(--ui-scale));
  height: calc(15px * var(--ui-scale));
  background: #359bb5;
  border: none;
  border-radius: 3px;
  color: #fff;
  font-weight: bold;
  font-size: calc(11px * var(--ui-scale));
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
}

.stat-add-btn.disabled {
  background: #383a40;
  color: #6d6f78;
  cursor: default;
  text-shadow: none;
}

/* Bottom HUD Layout */
#bottom-hud-wrapper {
  position: fixed;
  bottom: calc(16px * var(--ui-scale));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(4px * var(--ui-scale));
  pointer-events: auto;
}

.hud-player-name {
  font-size: calc(20px * var(--ui-scale));
  font-weight: 900;
  color: #ffffff;
  text-shadow: -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000, 2px 2px 0 #000;
  text-align: center;
  margin-bottom: calc(1px * var(--ui-scale));
  font-family: 'Ubuntu', 'Segoe UI', sans-serif;
}

.hud-bar-wrapper {
  position: relative;
  height: calc(14px * var(--ui-scale));
  background: #383a40;
  border: 2.5px solid #202225;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}

.score-bar-wrapper {
  width: calc(250px * var(--ui-scale));
  justify-content: flex-start;
  padding-left: calc(6px * var(--ui-scale));
}

.level-bar-wrapper {
  width: calc(320px * var(--ui-scale));
}

.score-pip {
  width: calc(10px * var(--ui-scale));
  height: calc(10px * var(--ui-scale));
  background: #57e385;
  border: 1.5px solid #1c1d20;
  border-radius: 50%;
  position: absolute;
  left: calc(6px * var(--ui-scale));
  z-index: 3;
}

.xp-bar-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  background: #ffe869;
  border-radius: 10px;
  transition: width 0.1s ease;
}

.hud-bar-text {
  position: relative;
  z-index: 2;
  font-size: calc(11.5px * var(--ui-scale));
  font-weight: 900;
  color: #ffffff;
  text-shadow: -1.5px -1.5px 0 #000, 1.5px -1.5px 0 #000, -1.5px 1.5px 0 #000, 1.5px 1.5px 0 #000;
  width: 100%;
  text-align: center;
  letter-spacing: 0.2px;
}

.center-hud {
  min-width: calc(280px * var(--ui-scale));
  text-align: center;
  margin-top: calc(2px * var(--ui-scale));
}

.weapon-title {
  font-size: calc(11px * var(--ui-scale));
  font-weight: 800;
  letter-spacing: 1px;
  color: #949ba4;
  margin-bottom: calc(6px * var(--ui-scale));
}

.rack-container {
  display: flex;
  justify-content: center;
  gap: calc(8px * var(--ui-scale));
}

.shell-pip {
  width: calc(18px * var(--ui-scale));
  height: calc(28px * var(--ui-scale));
  background: #1e1f22;
  border: 2px solid #359bb5;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.shell-pip.loaded {
  background: #359bb5;
  box-shadow: 0 0 8px rgba(53, 155, 181, 0.4);
}

.shell-pip.reloading {
  background: rgba(53, 155, 181, 0.2);
  animation: pulseReload 0.6s infinite alternate;
}

@keyframes pulseReload {
  from { opacity: 0.3; }
  to { opacity: 0.9; }
}

.gauge-bar-wrapper {
  position: relative;
  width: 100%;
  height: calc(18px * var(--ui-scale));
  background: #1e1f22;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  overflow: hidden;
}

.gauge-bar-fill {
  height: 100%;
  width: 0%;
  background: #359bb5;
  transition: width 0.05s linear;
}

.gauge-bar-fill.heat-high { background: #c4702b; }
.gauge-bar-fill.heat-critical { background: #d93838; }
.gauge-bar-fill.energy { background: #c2942c; }

.gauge-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: calc(10px * var(--ui-scale));
  font-weight: 800;
  color: #ffffff;
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
}

.overheat-banner {
  color: #d93838;
  font-size: calc(11px * var(--ui-scale));
  font-weight: 900;
  letter-spacing: 1px;
  margin-top: 4px;
  animation: flashAlert 0.4s infinite alternate;
}

@keyframes flashAlert {
  from { opacity: 0.3; }
  to { opacity: 1; }
}

/* Authentication & Profile Status - Fixed Bottom Right */
.auth-status-container {
  position: absolute;
  bottom: calc(20px * var(--ui-scale));
  right: calc(20px * var(--ui-scale));
  display: flex;
  align-items: center;
  gap: calc(10px * var(--ui-scale));
  background: rgba(30, 31, 34, 0.95);
  border: 2px solid rgba(255, 255, 255, 0.12);
  padding: calc(8px * var(--ui-scale)) calc(16px * var(--ui-scale));
  border-radius: 8px;
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  z-index: 105;
  font-size: calc(11px * var(--ui-scale));
  font-weight: 800;
  transition: all 0.2s ease;
}

.auth-status-label {
  color: #359bb5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(200px * var(--ui-scale));
  letter-spacing: 0.5px;
}

.auth-action-link {
  background: #359bb5;
  border: none;
  color: #ffffff;
  padding: calc(5px * var(--ui-scale)) calc(12px * var(--ui-scale));
  border-radius: 5px;
  font-weight: 900;
  font-size: calc(10.5px * var(--ui-scale));
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25);
  letter-spacing: 0.5px;
}

.auth-action-link:hover {
  background: #44a8c2;
  transform: translateY(-1px);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25), 0 2px 8px rgba(53, 155, 181, 0.4);
}

.auth-action-link:active {
  transform: translateY(1px);
  box-shadow: none;
}

.auth-divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: #949ba4;
  font-size: calc(10px * var(--ui-scale));
  font-weight: 800;
  margin: 4px 0;
}

.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.auth-divider span {
  padding: 0 8px;
}

.google-btn {
  background: #ffffff !important;
  color: #3c4043 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #dadce0 !important;
  text-shadow: none !important;
}

.google-btn:hover {
  background: #f8f9fa !important;
  transform: scale(1.01);
}

.auth-error-msg {
  background: rgba(217, 56, 56, 0.2);
  border: 1px solid #d93838;
  color: #ff7e80;
  padding: 8px;
  border-radius: 4px;
  font-size: calc(11px * var(--ui-scale));
  font-weight: bold;
  text-align: center;
  margin-bottom: 8px;
}

.modal-sub {
  font-size: calc(11px * var(--ui-scale));
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #949ba4;
  margin-top: -6px;
  margin-bottom: 14px;
}

/* Modals & Main Menu */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(18, 19, 22, 0.88);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

.main-menu-box {
  background: #2b2d31;
  border: 3px solid #359bb5;
  border-radius: 12px;
  padding: calc(36px * var(--ui-scale)) calc(40px * var(--ui-scale));
  text-align: center;
  box-shadow: 0 0 25px rgba(53, 155, 181, 0.2);
  min-width: calc(360px * var(--ui-scale));
}

.main-menu-title {
  font-size: calc(28px * var(--ui-scale));
  font-weight: 900;
  letter-spacing: 3px;
  color: #359bb5;
  text-shadow: -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000, 2px 2px 0 #000;
}

.main-menu-sub {
  font-size: calc(12px * var(--ui-scale));
  font-weight: 800;
  letter-spacing: 2px;
  color: #949ba4;
  margin-top: 4px;
  margin-bottom: calc(18px * var(--ui-scale));
}

/* Main Menu Player Name Input (Diep.io Classic Style) */
.player-name-wrapper {
  margin-bottom: calc(16px * var(--ui-scale));
  width: 100%;
}

.player-name-main-input {
  width: 100%;
  background: #1e1f22;
  border: calc(2.5px * var(--ui-scale)) solid #3d3f44;
  border-radius: 6px;
  padding: calc(11px * var(--ui-scale)) calc(14px * var(--ui-scale));
  font-size: calc(14px * var(--ui-scale));
  font-weight: 900;
  color: #ffffff;
  text-align: center;
  outline: none;
  letter-spacing: 1px;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  font-family: 'Ubuntu', 'Segoe UI', sans-serif;
}

.player-name-main-input::placeholder {
  color: #6c727a;
  font-weight: 700;
}

.player-name-main-input:focus {
  border-color: #359bb5;
  background: #25272c;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.4), 0 0 12px rgba(53, 155, 181, 0.4);
}

.main-menu-actions {
  display: flex;
  flex-direction: column;
  gap: calc(12px * var(--ui-scale));
}

.menu-btn {
  padding: calc(12px * var(--ui-scale));
  border-radius: 6px;
  border: none;
  font-weight: 800;
  font-size: calc(13px * var(--ui-scale));
  cursor: pointer;
  transition: all 0.15s ease;
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25), 0 3px 8px rgba(0, 0, 0, 0.25);
}

.menu-btn.primary { background: #359bb5; color: #fff; }
.menu-btn.primary:hover { background: #44a8c2; transform: scale(1.02); }

.menu-btn.secondary { background: #1e1f22; color: #fff; border: 1px solid rgba(255,255,255,0.15); }
.menu-btn.secondary:hover { background: #313338; transform: scale(1.02); }

/* Modal Buttons General & Tactical Overhauls */
.modal-actions {
  display: flex;
  gap: calc(10px * var(--ui-scale));
  justify-content: center;
  width: 100%;
}

.modal-btn {
  padding: calc(10px * var(--ui-scale)) calc(20px * var(--ui-scale));
  border-radius: 6px;
  border: none;
  font-weight: 900;
  font-size: calc(12px * var(--ui-scale));
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25), 0 3px 8px rgba(0, 0, 0, 0.25);
  font-family: 'Ubuntu', 'Segoe UI', sans-serif;
}

.modal-btn.primary {
  background: #359bb5;
  color: #ffffff;
}

.modal-btn.primary:hover {
  background: #44a8c2;
  transform: translateY(-2px);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25), 0 5px 12px rgba(53, 155, 181, 0.35);
}

.modal-btn.primary:active {
  transform: translateY(1px);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.modal-btn.secondary {
  background: #1e1f22;
  color: #dbdee1;
  border: 1.5px solid rgba(255, 255, 255, 0.15);
}

.modal-btn.secondary:hover {
  background: #313338;
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25), 0 5px 12px rgba(0, 0, 0, 0.35);
}

.modal-btn.secondary:active {
  transform: translateY(1px);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Custom Tactical Styling for "SAVE & CLOSE" */
#close-settings-btn {
  width: 100%;
  background: linear-gradient(180deg, #3bb576 0%, #298d5a 100%);
  border: calc(2px * var(--ui-scale)) solid #23734a;
  color: #ffffff;
  font-size: calc(13px * var(--ui-scale));
  font-weight: 900;
  letter-spacing: 1.5px;
  padding: calc(11px * var(--ui-scale)) calc(24px * var(--ui-scale));
  border-radius: 8px;
  box-shadow: inset 0 -3px 0 #1b5b3a, 0 4px 14px rgba(41, 141, 90, 0.4);
}

#close-settings-btn:hover {
  background: linear-gradient(180deg, #44cc86 0%, #30a368 100%);
  transform: translateY(-2px);
  box-shadow: inset 0 -3px 0 #1b5b3a, 0 6px 18px rgba(41, 141, 90, 0.55);
}

#close-settings-btn:active {
  transform: translateY(1px);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.35);
}

/* Custom Tactical Styling for "CLOSE SHOP" */
#close-armory-btn {
  width: 100%;
  background: linear-gradient(180deg, #2b2e35 0%, #1e2025 100%);
  border: calc(2px * var(--ui-scale)) solid #359bb5;
  color: #359bb5;
  font-size: calc(13px * var(--ui-scale));
  font-weight: 900;
  letter-spacing: 1.5px;
  padding: calc(11px * var(--ui-scale)) calc(24px * var(--ui-scale));
  border-radius: 8px;
  box-shadow: inset 0 -3px 0 #121417, 0 4px 14px rgba(53, 155, 181, 0.25);
}

#close-armory-btn:hover {
  background: linear-gradient(180deg, #359bb5 0%, #28778b 100%);
  color: #ffffff;
  border-color: #4bb3ce;
  transform: translateY(-2px);
  box-shadow: inset 0 -3px 0 #1c5665, 0 6px 18px rgba(53, 155, 181, 0.45);
}

#close-armory-btn:active {
  transform: translateY(1px);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.35);
}

.modal-box {
  background: #2b2d31;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  padding: calc(24px * var(--ui-scale));
  width: calc(380px * var(--ui-scale));
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.modal-box.wide {
  width: calc(520px * var(--ui-scale));
}

/* Smooth Game Over Modal Transitions */
#game-over-modal {
  animation: gameOverFadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

#game-over-modal .modal-box {
  animation: gameOverBoxPopIn 0.55s cubic-bezier(0.2, 0.9, 0.3, 1.08) forwards;
  will-change: transform, opacity;
}

#game-over-modal .modal-title {
  animation: gameOverTitleGlow 0.5s ease-out forwards;
}

#game-over-modal .modal-stats {
  animation: gameOverItemFade 0.6s cubic-bezier(0.16, 1, 0.3, 1) backwards;
  animation-delay: 0.1s;
}

#game-over-modal .modal-actions {
  animation: gameOverItemFade 0.65s cubic-bezier(0.16, 1, 0.3, 1) backwards;
  animation-delay: 0.22s;
}

@keyframes gameOverFadeIn {
  0% {
    opacity: 0;
    backdrop-filter: blur(0px);
  }
  100% {
    opacity: 1;
    backdrop-filter: blur(8px);
  }
}

@keyframes gameOverBoxPopIn {
  0% {
    opacity: 0;
    transform: translateY(22px) scale(0.90);
  }
  65% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes gameOverTitleGlow {
  0% {
    opacity: 0;
    transform: scale(0.92);
    filter: drop-shadow(0 0 16px rgba(217, 56, 56, 0.8));
  }
  100% {
    opacity: 1;
    transform: scale(1);
    filter: drop-shadow(0 0 4px rgba(217, 56, 56, 0.2));
  }
}

@keyframes gameOverItemFade {
  0% {
    opacity: 0;
    transform: translateY(12px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-title {
  font-size: calc(20px * var(--ui-scale));
  font-weight: 900;
  color: #359bb5;
  letter-spacing: 2px;
  margin-bottom: calc(12px * var(--ui-scale));
  text-shadow: -1.5px -1.5px 0 #000, 1.5px -1.5px 0 #000, -1.5px 1.5px 0 #000, 1.5px 1.5px 0 #000;
}

.modal-title.alert { color: #d93838; }

.modal-stats {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
  background: #1e1f22;
  padding: 12px;
  border-radius: 6px;
}

.stat-box {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: bold;
}

.stat-box .lbl { color: #949ba4; }
.stat-box .val { color: #fff; }
.stat-box .val.gold { color: #c2942c; }

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: calc(14px * var(--ui-scale));
  font-size: calc(12px * var(--ui-scale));
  font-weight: bold;
  color: #f2f3f5;
}

.setting-input {
  background: #1e1f22;
  color: #359bb5;
  border: 1px solid rgba(255,255,255,0.2);
  padding: 6px 10px;
  border-radius: 4px;
  font-weight: bold;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.admin-btn {
  background: #1e1f22;
  border: 1px solid #359bb5;
  color: #359bb5;
  padding: 8px;
  border-radius: 4px;
  font-size: calc(11px * var(--ui-scale));
  font-weight: bold;
  cursor: pointer;
}

.admin-btn.alert { border-color: #d93838; color: #d93838; }
.admin-btn:hover { background: #313338; }

.admin-checkbox-row {
  font-size: calc(11px * var(--ui-scale));
  font-weight: bold;
  color: #949ba4;
  text-align: left;
}

.admin-log-title {
  font-size: calc(10px * var(--ui-scale));
  font-weight: 800;
  color: #949ba4;
  text-align: left;
  margin-top: 10px;
  margin-bottom: 4px;
  letter-spacing: 1px;
}

.debug-log-console {
  width: 100%;
  height: calc(110px * var(--ui-scale));
  background: #1e1f22;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 8px;
  font-family: monospace;
  font-size: calc(10px * var(--ui-scale));
  overflow-y: auto;
  text-align: left;
  color: #dbdee1;
}

input[type="color"] {
  appearance: none;
  border: 2px solid #359bb5;
  width: calc(32px * var(--ui-scale));
  height: calc(32px * var(--ui-scale));
  border-radius: 50%;
  cursor: pointer;
  background: transparent;
}

input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 50%; }

.armory-currency {
  font-size: calc(13px * var(--ui-scale));
  font-weight: bold;
  margin-bottom: calc(12px * var(--ui-scale));
  color: #f2f3f5;
}

.armory-currency .gold { color: #e9b439; }

.shop-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: calc(14px * var(--ui-scale));
}

.shop-tab-btn {
  flex: 1;
  padding: calc(8px * var(--ui-scale));
  background: #1e1f22;
  border: 1px solid rgba(255,255,255,0.15);
  color: #949ba4;
  font-weight: 800;
  font-size: calc(11px * var(--ui-scale));
  border-radius: 4px;
  cursor: pointer;
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
}

.shop-tab-btn.active {
  background: #287294;
  color: #ffffff;
  border-color: #287294;
}

.shop-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(260px * var(--ui-scale));
  overflow-y: auto;
  padding-right: 4px;
}

.shop-card {
  background: #1e1f22;
  border: 2px solid #359bb5;
  border-radius: 6px;
  padding: calc(10px * var(--ui-scale)) calc(14px * var(--ui-scale));
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-align: left;
  color: #f2f3f5;
}

.shop-title { font-size: calc(12px * var(--ui-scale)); font-weight: 900; }
.shop-desc { font-size: calc(10px * var(--ui-scale)); color: #949ba4; margin-top: 2px; }

.shop-status.unlocked {
  font-size: calc(10px * var(--ui-scale));
  font-weight: 900;
  color: #57a857;
  letter-spacing: 1px;
}

.shop-buy-btn {
  background: #359bb5;
  border: none;
  border-radius: 4px;
  padding: calc(6px * var(--ui-scale)) calc(12px * var(--ui-scale));
  font-weight: bold;
  font-size: calc(10px * var(--ui-scale));
  cursor: pointer;
  color: #fff;
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
}

.shop-buy-btn.active-equip {
  background: #313338;
  color: #359bb5;
  border: 1px solid #359bb5;
}

.shop-buy-btn.disabled { background: #383a40; color: #6d6f78; cursor: default; text-shadow: none; }

.hidden { display: none !important; }

/* Light Theme Overrides */
body.theme-light {
  background-color: #b5b9bc;
  color: #2b2e31;
}

body.theme-light .hud-panel {
  background: rgba(222, 225, 228, 0.92);
  border-color: #a2a6aa;
  color: #2b2e31;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
}

body.theme-light .hud-label { color: #5a5d62; }
body.theme-light .hud-val { color: #287294; }

body.theme-light .wave-title { color: #287294; text-shadow: none; }
body.theme-light .wave-timer { color: #2b2e31; }

body.theme-light .diep-panel-header {
  color: #2b2e31;
  text-shadow: none;
}

body.theme-light .diep-card {
  background-color: #e6e9ed;
  border-color: #a0a5aa;
  color: #2b2e31;
}

body.theme-light .diep-ignore-btn {
  background: #9fa3a7;
  border-color: #55585c;
  color: #ffffff;
  text-shadow: -1px -1px 0 #333, 1px -1px 0 #333, -1px 1px 0 #333, 1px 1px 0 #333;
}

body.theme-light .diep-ignore-btn:hover {
  background: #b0b4b8;
}

body.theme-light .stat-badge {
  color: #287294;
  text-shadow: 0 0 6px rgba(40, 114, 148, 0.3);
}

body.theme-light .stat-name { color: #33363a; text-shadow: none; }
body.theme-light .stat-bar-track { background: #c2c6c9; border-color: #a6aaad; }
body.theme-light .stat-add-btn { background: #287294; color: #ffffff; text-shadow: none; }
body.theme-light .stat-add-btn.disabled { background: #a8acad; color: #6e7275; }

body.theme-light .xp-bar-wrapper,
body.theme-light .gauge-bar-wrapper,
body.theme-light .shell-pip,
body.theme-light .auth-status-container {
  background: #c8cbce;
  border-color: #9ea2a6;
}

body.theme-light .hud-bar-text,
body.theme-light .gauge-text {
  color: #ffffff;
  text-shadow: -1.5px -1.5px 0 #000, 1.5px -1.5px 0 #000, -1.5px 1.5px 0 #000, 1.5px 1.5px 0 #000;
  font-weight: 900;
}

body.theme-light .weapon-title { color: #5a5d62; }

body.theme-light .toast-banner {
  background: rgba(195, 60, 62, 0.92);
  border-color: #b03234;
}

body.theme-light .modal-overlay {
  background: rgba(182, 186, 189, 0.82);
}

body.theme-light .main-menu-box,
body.theme-light .modal-box {
  background: #d5d8db;
  color: #2b2e31;
  border-color: #287294;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
}

body.theme-light .main-menu-title { color: #287294; text-shadow: none; }
body.theme-light .main-menu-sub { color: #5a5d62; }

body.theme-light .menu-btn.primary,
body.theme-light .modal-btn.primary {
  background: #287294;
  color: #ffffff;
  text-shadow: none;
}

body.theme-light .menu-btn.primary:hover,
body.theme-light .modal-btn.primary:hover {
  background: #3284b3;
}

body.theme-light .menu-btn.secondary,
body.theme-light .modal-btn.secondary {
  background: #c8cbce;
  color: #2b2e31;
  border-color: #9ea2a6;
  text-shadow: none;
}

body.theme-light .menu-btn.secondary:hover,
body.theme-light .modal-btn.secondary:hover {
  background: #b0b4b7;
}

body.theme-light .modal-stats { background: #c8cbce; }
body.theme-light .modal-stats .lbl { color: #5a5d62; }
body.theme-light .modal-stats .val { color: #2b2e31; }
body.theme-light .modal-stats .val.gold { color: #b86e00; }

body.theme-light .setting-row { color: #2b2e31; }
body.theme-light .setting-input {
  background: #e8ebee;
  color: #287294;
  border-color: #a2a6aa;
}

body.theme-light .armory-currency { color: #2b2e31; }

body.theme-light .shop-tab-btn {
  background: #c8cbce;
  color: #5a5d62;
  border-color: #9ea2a6;
  text-shadow: none;
}

body.theme-light .shop-tab-btn.active {
  background: #287294;
  color: #ffffff;
  border-color: #287294;
}

body.theme-light .shop-card {
  background: #c8cbce;
  border-color: #287294;
  color: #2b2e31;
}

body.theme-light .shop-desc { color: #5a5d62; }

body.theme-light .admin-btn {
  background: #c8cbce;
  color: #287294;
  border-color: #287294;
}

body.theme-light .admin-btn:hover { background: #b6babb; }
body.theme-light .admin-checkbox-row { color: #33363a; }
body.theme-light .admin-log-title { color: #5a5d62; }

body.theme-light .debug-log-console {
  background: #c8cbce;
  border-color: #9ea2a6;
  color: #2b2e31;
}

body.theme-light .player-name-main-input {
  background: #e4e7ea;
  border-color: #a8adb3;
  color: #2b2e31;
}

body.theme-light .player-name-main-input:focus {
  border-color: #287294;
  background: #f0f3f6;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.1), 0 0 10px rgba(40, 114, 148, 0.25);
}

body.theme-light .auth-status-container {
  background: #d5d8db;
  border-color: #9ea2a6;
}

body.theme-light .auth-action-link {
  background: #287294;
  color: #ffffff;
  text-shadow: none;
}

body.theme-light .auth-action-link:hover {
  background: #3284b3;
}

body.theme-light #close-settings-btn {
  background: linear-gradient(180deg, #34a86b 0%, #2b8c58 100%);
  border-color: #206d44;
  color: #ffffff;
  box-shadow: inset 0 -3px 0 #1b5b3a, 0 3px 8px rgba(0, 0, 0, 0.15);
}

body.theme-light #close-settings-btn:hover {
  background: linear-gradient(180deg, #3dbd7a 0%, #309b63 100%);
}

body.theme-light #close-armory-btn {
  background: linear-gradient(180deg, #e4e7ea 0%, #d0d4d8 100%);
  border-color: #287294;
  color: #287294;
  box-shadow: inset 0 -3px 0 #b0b4b8, 0 3px 8px rgba(0, 0, 0, 0.1);
}

body.theme-light #close-armory-btn:hover {
  background: linear-gradient(180deg, #287294 0%, #1e5a75 100%);
  color: #ffffff;
  border-color: #1e5a75;
}