/* ==========================================
   CSS DESIGN SYSTEM: TANK ARENA ONLINE
   Futuristic Neon Glassmorphism Theme
   ========================================== */

/* Variables and Theme Tokens */
:root {
  --bg-dark: #07070c;
  --bg-panel: rgba(15, 15, 30, 0.45);
  --bg-inset: rgba(5, 5, 10, 0.6);
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-neon-primary: #39ff14; /* Cyberpunk Green */
  --border-neon-secondary: #ff007f; /* Neon Hot Pink */
  
  --primary-color: #39ff14;
  --secondary-color: #ff007f;
  --accent-blue: #00f0ff;
  --accent-yellow: #ffff00;
  
  --text-primary: #f0f0ff;
  --text-muted: #8c8cbe;
  
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
  --neon-glow-primary: 0 0 15px rgba(57, 255, 20, 0.3);
  --neon-glow-secondary: 0 0 15px rgba(255, 0, 127, 0.3);
  --neon-glow-blue: 0 0 15px rgba(0, 240, 255, 0.3);
}

/* Global Reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

/* Scrollbar customizations */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.1);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary-color);
}

/* Animated Background Canvas */
#lobby-bg-animation {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  background: radial-gradient(circle at center, #141432 0%, #05050c 100%);
  pointer-events: none;
  opacity: 0.8;
}

/* Custom Cursor */
#custom-cursor {
  position: fixed;
  width: 16px;
  height: 16px;
  border: 2px solid var(--accent-blue);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 9999;
  transition: width 0.1s, height 0.1s, background-color 0.1s;
  box-shadow: 0 0 8px var(--accent-blue);
  display: none; /* activated on screen-game */
}

/* App Main Grid */
#app-container {
  position: relative;
  z-index: 10;
  width: 95vw;
  max-width: 1300px;
  height: 90vh;
  max-height: 800px;
  display: flex;
  flex-direction: column;
}

/* APP HEADER */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  margin-bottom: 15px;
}

.game-logo {
  font-family: 'Orbitron', sans-serif;
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: 5px;
  color: #fff;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.2), 0 0 20px var(--accent-blue);
}

.game-logo span {
  color: var(--primary-color);
  text-shadow: 0 0 10px rgba(57, 255, 20, 0.5), 0 0 25px var(--primary-color);
}

.audio-control-btn {
  background: var(--bg-panel);
  border: 1px solid var(--border-glass);
  padding: 10px 14px;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: transform 0.2s, background-color 0.2s;
}

.audio-control-btn:hover {
  transform: scale(1.1);
  background: rgba(255,255,255,0.1);
  border-color: var(--accent-blue);
}

/* SCREENS LAYOUT */
.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  gap: 20px;
  animation: fadeIn 0.4s ease-out forwards;
}

.screen.active {
  display: flex;
}

/* Glassmorphism Panel styles */
.glass-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-glass);
  box-shadow: var(--glass-shadow);
  border-radius: 16px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 24px;
  transition: border-color 0.3s;
}

.glass-panel:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

.glass-inset {
  background: var(--bg-inset);
  border: 1px solid rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.5);
}

/* Section Headings */
.section-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.6rem;
  letter-spacing: 2px;
  color: #fff;
  text-transform: uppercase;
}

.section-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 5px;
  margin-bottom: 25px;
}

/* Buttons style */
.btn {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  padding: 14px 28px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 1px;
  font-size: 0.85rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-color) 0%, #1fcc00 100%);
  color: #000;
}

.btn-secondary {
  background: var(--bg-panel);
  border: 1px solid var(--border-glass);
  color: #fff;
}

.btn-danger {
  background: linear-gradient(135deg, var(--secondary-color) 0%, #cc0066 100%);
  color: #fff;
}

.btn-small {
  padding: 8px 16px;
  font-size: 0.75rem;
  border-radius: 6px;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #4fff30 0%, #26eb00 100%);
}

.btn-secondary:hover {
  border-color: var(--accent-blue);
  color: var(--accent-blue);
  box-shadow: var(--neon-glow-blue);
}

.btn-danger:hover {
  background: linear-gradient(135deg, #ff3399 0%, #eb0075 100%);
  box-shadow: 0 0 15px rgba(255, 0, 127, 0.4);
}

/* Neon buttons glowing effect */
.neon-btn {
  box-shadow: var(--neon-glow-primary);
  border: 1px solid var(--primary-color);
}

.neon-btn:hover {
  box-shadow: 0 0 25px var(--primary-color);
}

.btn.disabled, .btn:disabled {
  opacity: 0.3;
  pointer-events: none;
  transform: none;
  box-shadow: none;
}

.flex-btn {
  flex: 1;
}

/* Lobby input forms */
.lobby-form {
  display: flex;
  flex-direction: column;
  gap: 25px;
}

/* Floating labels inputs */
.input-group {
  position: relative;
  width: 100%;
}

.input-group input {
  width: 100%;
  padding: 16px;
  background: var(--bg-inset);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  color: #fff;
  font-size: 1rem;
  outline: none;
  transition: all 0.3s;
}

.input-group label {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  transition: all 0.3s;
}

.input-group input:focus, 
.input-group input:not(:placeholder-shown) {
  border-color: var(--accent-blue);
  box-shadow: var(--neon-glow-blue);
}

.input-group input:focus + label,
.input-group input:not(:placeholder-shown) + label {
  top: 0;
  font-size: 0.75rem;
  background-color: #111124;
  padding: 2px 8px;
  border-radius: 4px;
  color: var(--accent-blue);
}

/* Color select options */
.color-picker-container {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.color-label {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.color-options {
  display: flex;
  gap: 12px;
}

.color-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.2);
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
}

.color-btn:hover {
  transform: scale(1.15);
  border-color: #fff;
}

.color-btn.active {
  border-color: #fff;
  transform: scale(1.2);
}

/* Action Rows */
.action-buttons-row {
  display: flex;
  gap: 20px;
  width: 100%;
}

.action-buttons-row > button {
  flex: 1;
}

.join-action-group {
  display: flex;
  flex: 1.2;
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-inset);
}

.join-action-group input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 0 16px;
  color: #fff;
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  letter-spacing: 2px;
  outline: none;
  font-size: 1rem;
}

.join-action-group button {
  border-radius: 0;
  border: none;
  border-left: 1px solid var(--border-glass);
}

/* Public rooms table list */
.screen-lobby {
  display: flex;
  flex-direction: row !important;
}

#screen-lobby > div {
  flex: 1;
}

.public-rooms-panel {
  display: flex;
  flex-direction: column;
}

.panel-subtitle {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.1rem;
  letter-spacing: 1.5px;
  color: #fff;
  margin-bottom: 15px;
}

.rooms-list-wrapper {
  flex: 1;
  overflow-y: auto;
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  background: var(--bg-inset);
  margin-bottom: 15px;
}

.rooms-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.rooms-table th, .rooms-table td {
  padding: 12px 16px;
  font-size: 0.85rem;
}

.rooms-table th {
  background: rgba(255,255,255,0.03);
  color: var(--text-muted);
  font-weight: 500;
  border-bottom: 1px solid var(--border-glass);
}

.rooms-table td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}

.rooms-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.empty-list-row {
  text-align: center;
  color: var(--text-muted);
}

.empty-list-row td {
  padding: 40px !important;
}

/* ==========================================
   SCREEN 2: IN-ROOM LOBBY DESIGN
   ========================================== */
.room-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.room-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-glass);
  padding-bottom: 15px;
  margin-bottom: 20px;
}

.room-title-info {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.room-code-badge {
  background: var(--bg-inset);
  border: 1px solid var(--border-glass);
  padding: 6px 14px;
  border-radius: 20px;
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 8px;
}

#btn-copy-code {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  transition: transform 0.2s;
}

#btn-copy-code:hover {
  transform: scale(1.2);
}

.room-lobby-layout {
  display: flex;
  flex: 1;
  gap: 20px;
  min-height: 0; /* allows children to scroll properly */
}

/* Room Lobby Left: Player List */
.player-list-section {
  flex: 1.2;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.lobby-section-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 1rem;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.player-cards-container {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 5px;
}

/* Animated Player Card */
.player-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-glass);
  border-radius: 10px;
  animation: cardSlideIn 0.3s ease-out forwards;
}

.player-card-info {
  display: flex;
  align-items: center;
  gap: 15px;
}

.player-tank-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  position: relative;
  box-shadow: 0 0 10px currentColor;
}

.player-tank-icon::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 4px;
  background: currentColor;
  transform: translateY(-50%);
  border-radius: 2px;
}

.player-card-name {
  font-weight: 700;
  font-size: 0.95rem;
}

.player-host-tag {
  background: rgba(255, 153, 0, 0.15);
  border: 1px solid #ff9900;
  color: #ff9900;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 8px;
  font-family: 'Orbitron', sans-serif;
}

.player-status-badge {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.player-status-badge.ready {
  background: rgba(57, 255, 20, 0.15);
  color: var(--primary-color);
  border: 1px solid var(--primary-color);
}

.player-status-badge.waiting {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: 1px solid var(--border-glass);
}

/* Room Lobby Right: Chat and controls */
.chat-controls-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 12px;
  min-height: 250px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  margin-bottom: 10px;
}

.chat-bubble {
  font-size: 0.85rem;
  line-height: 1.4;
  word-break: break-all;
}

.chat-bubble .sender {
  font-weight: 700;
  color: var(--accent-blue);
  margin-right: 5px;
}

.chat-bubble.system {
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}

.chat-input-row {
  display: flex;
  gap: 10px;
}

.chat-input-row input {
  flex: 1;
  background: var(--bg-dark);
  border: 1px solid var(--border-glass);
  border-radius: 6px;
  color: #fff;
  padding: 10px 14px;
  outline: none;
  font-size: 0.85rem;
}

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

.chat-input-row button {
  padding: 10px 20px;
}

.lobby-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lobby-tip {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.controls-row {
  display: flex;
  gap: 15px;
}

/* ==========================================
   SCREEN 3: GAME ARENA LAYOUT & HUD
   ========================================== */
.game-layout {
  display: flex;
  flex: 1;
  gap: 20px;
  align-items: stretch;
  min-height: 0;
}

.canvas-wrapper {
  flex: 1;
  position: relative;
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  overflow: hidden;
  background-color: #0c0d16;
  box-shadow: 0 10px 30px rgba(0,0,0,0.8);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  background-color: transparent;
}

/* Kill Feed */
#kill-feed-container {
  position: absolute;
  top: 155px;
  left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
  z-index: 100;
}

.kill-msg {
  background: rgba(0, 0, 0, 0.75);
  border-left: 3px solid var(--secondary-color);
  padding: 6px 12px;
  border-radius: 0 6px 6px 0;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  animation: killMsgIn 0.3s ease-out forwards, fadeOut 0.4s ease-in 3.5s forwards;
}

/* Pre-Game Countdowns */
#game-countdown-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(5, 5, 10, 0.75);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 150;
  backdrop-filter: blur(4px);
}

.countdown-number {
  font-family: 'Orbitron', sans-serif;
  font-size: 6rem;
  font-weight: 900;
  color: var(--primary-color);
  text-shadow: 0 0 30px var(--primary-color);
  animation: pulse 1s ease-in-out infinite;
}

/* HUD Panels */
.game-hud {
  width: 280px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.hud-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 16px;
}

.hud-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.85rem;
  letter-spacing: 1px;
  color: var(--text-muted);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  padding-bottom: 8px;
  margin-bottom: 10px;
}

/* Leaderboard inside HUD */
.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.leader-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  padding: 6px 10px;
  background: rgba(255,255,255,0.02);
  border-radius: 4px;
  border-left: 3px solid transparent;
}

.leader-item.myself {
  background: rgba(0, 240, 255, 0.08);
  border-left-color: var(--accent-blue);
}

.leader-item .rank-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.leader-item .score {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  color: var(--primary-color);
}

/* Active buffs details */
.powerup-buffs {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.buff-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  padding: 8px 12px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border-glass);
  border-radius: 6px;
  opacity: 0.25;
  transition: opacity 0.3s, border-color 0.3s;
}

.buff-item.active {
  opacity: 1;
}

.buff-item.triple.active {
  border-color: var(--accent-yellow);
  color: var(--accent-yellow);
  box-shadow: 0 0 10px rgba(255,255,0,0.15);
}

.buff-item.speed.active {
  border-color: var(--primary-color);
  color: var(--primary-color);
  box-shadow: 0 0 10px rgba(57,255,20,0.15);
}

.buff-item.shield.active {
  border-color: var(--accent-blue);
  color: var(--accent-blue);
  box-shadow: 0 0 10px rgba(0,240,255,0.15);
}

/* Controls guide HUD */
.guide-list {
  list-style: none;
  font-size: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text-muted);
}

.key-badge {
  display: inline-block;
  background: var(--bg-inset);
  border: 1px solid var(--border-glass);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
  color: #fff;
  font-family: 'Orbitron', sans-serif;
}

/* ==========================================
   GAME OVER MODAL SCREEN
   ========================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(5,5,10,0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: none;
  justify-content: center;
  align-items: center;
}

.modal-overlay.active {
  display: flex;
}

.modal-panel {
  width: 90%;
  max-width: 550px;
  padding: 35px !important;
  text-align: center;
  border-color: var(--border-neon-secondary);
  box-shadow: 0 15px 40px rgba(255,0,127,0.25);
  animation: modalScaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.modal-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.8rem;
  font-weight: 900;
  letter-spacing: 2px;
}

.neon-text {
  color: var(--secondary-color);
  text-shadow: 0 0 10px rgba(255,0,127,0.3), 0 0 25px var(--secondary-color);
}

.modal-subtitle {
  color: var(--text-primary);
  font-size: 0.95rem;
  margin-top: 8px;
  margin-bottom: 25px;
  font-weight: 500;
}

.game-stats-table-wrapper {
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  background: var(--bg-inset);
  max-height: 250px;
  overflow-y: auto;
  margin-bottom: 30px;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.stats-table th, .stats-table td {
  padding: 10px 14px;
  font-size: 0.85rem;
}

.stats-table th {
  background: rgba(255,255,255,0.03);
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-glass);
}

.stats-table td {
  border-bottom: 1px solid rgba(255,255,255,0.02);
}

.stats-table tbody tr:first-child td {
  color: var(--primary-color);
  font-weight: 700;
}

.modal-actions {
  display: flex;
  justify-content: center;
}

/* Helpers */
.hidden {
  display: none !important;
}

/* ==========================================
   ANIMATIONS KEYFRAMES
   ========================================== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes cardSlideIn {
  from { opacity: 0; transform: translateX(-15px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes killMsgIn {
  from { opacity: 0; transform: translateX(-30px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

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

@keyframes modalScaleIn {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}
