:root {
  --bg-primary: #0a0c10;
  --bg-surface: #161b22;
  --bg-card: rgba(22, 27, 34, 0.75);
  --border-color: #30363d;
  --accent-cyan: #00f0f0;
  --accent-blue: #0088ff;
  --accent-green: #2ea043;
  --accent-red: #da3633;
  --accent-yellow: #f0f000;
  --accent-purple: #a000f0;
  --text-main: #f0f6fc;
  --text-muted: #8b949e;
  --font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  --glass-border: rgba(255, 255, 255, 0.1);
  --shadow-glow: 0 0 20px rgba(0, 240, 240, 0.15);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-family);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  padding: 16px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  backdrop-filter: blur(10px);
  margin-bottom: 20px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--text-main);
}

.header-title span {
  color: var(--accent-cyan);
  text-shadow: 0 0 8px rgba(0, 240, 240, 0.5);
}

.badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.room-badge {
  background: rgba(0, 240, 240, 0.1);
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 240, 240, 0.3);
}

.player-badge {
  background: rgba(46, 160, 67, 0.2);
  color: var(--accent-green);
  border: 1px solid var(--accent-green);
}

.opponent-badge {
  background: rgba(218, 54, 51, 0.2);
  color: var(--accent-red);
  border: 1px solid var(--accent-red);
}

/* Status Indicator */
.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.status-indicator.connected .status-dot {
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}

.status-indicator.connected {
  color: var(--accent-green);
  border-color: rgba(46, 160, 67, 0.3);
}

.status-indicator.disconnected .status-dot {
  background: var(--accent-red);
}

.status-indicator.disconnected {
  color: var(--accent-red);
  border-color: rgba(218, 54, 51, 0.3);
}

/* Modal Overlay & Cards */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 16, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 20px;
}

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

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5), var(--shadow-glow);
}

.modal-title {
  font-size: 1.3rem;
  margin-bottom: 24px;
  text-align: center;
  color: var(--accent-cyan);
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 500;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(0, 240, 240, 0.2);
}

.button-group {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

/* Buttons */
.btn {
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  flex: 1;
}

.btn-primary {
  background: var(--accent-cyan);
  color: #000;
}

.btn-primary:hover {
  background: #33f3f3;
  box-shadow: 0 0 15px rgba(0, 240, 240, 0.4);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

.btn-success {
  background: var(--accent-green);
  color: #fff;
}

.btn-success:hover {
  background: #38b852;
  box-shadow: 0 0 15px rgba(46, 160, 67, 0.4);
}

.btn-danger {
  background: var(--accent-red);
  color: #fff;
}

.btn-danger:hover {
  background: #e54845;
}

.error-banner {
  margin-top: 16px;
  padding: 10px;
  border-radius: 6px;
  background: rgba(218, 54, 51, 0.15);
  border: 1px solid var(--accent-red);
  color: #ff7b72;
  font-size: 0.85rem;
  text-align: center;
}

/* Roster Section */
.roster-section {
  margin-bottom: 24px;
}

.roster-section h3 {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.player-roster {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-roster li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-weight: 500;
}

.player-roster .host-badge {
  background: rgba(240, 240, 0, 0.15);
  color: var(--accent-yellow);
  border: 1px solid rgba(240, 240, 0, 0.3);
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 700;
}

.waiting-msg {
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.9rem;
  margin-bottom: 16px;
}

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

/* Game Stage */
.game-stage {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  flex: 1;
  align-items: start;
}

.game-stage.hidden {
  display: none !important;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 20px;
  backdrop-filter: blur(10px);
}

.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.player-header, .opponent-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.stage-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 130px;
}

.panel-box {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.panel-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 8px;
  letter-spacing: 1px;
}

/* Canvas Containers */
.canvas-container {
  position: relative;
  background: #000;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8);
}

.player-canvas-container {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 15px rgba(0, 240, 240, 0.15);
}

.opponent-canvas-container {
  border-color: rgba(255, 255, 255, 0.2);
}

canvas {
  display: block;
}

/* Stats Box */
.stats-box {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stat-item {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--accent-cyan);
  font-family: monospace;
}

/* Opponent Section */
.opponent-stage-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.opponent-stats .stat-value {
  color: var(--accent-red);
}

/* Overlays */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 12, 16, 0.9);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
  z-index: 10;
  padding: 16px;
  text-align: center;
}

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

.game-over-overlay h2 {
  font-size: 1.8rem;
  color: var(--accent-red);
  font-weight: 900;
  letter-spacing: 2px;
}

.game-over-overlay p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.ko-overlay {
  background: rgba(218, 54, 51, 0.4);
  backdrop-filter: blur(3px);
}

.ko-badge {
  font-size: 2.5rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
  letter-spacing: 2px;
}

/* Footer Controls Guide */
.controls-footer {
  margin-top: auto;
  padding-top: 20px;
}

.controls-guide {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px 24px;
  padding: 14px 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  font-size: 0.85rem;
}

.key-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
}

kbd {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-cyan);
  font-family: monospace;
  box-shadow: 0 2px 0 var(--border-color);
}

.hidden {
  display: none !important;
}

/* Responsive Breakpoints */
@media (max-width: 900px) {
  .game-stage {
    grid-template-columns: 1fr;
  }
}
