/* ===== CSS Variables - Retro OLED Theme ===== */
:root {
  /* OLED Black */
  --bg-primary: #000000;
  --bg-secondary: #000000;
  --bg-card: #000000;
  --bg-elevated: #0a0a0a;
  
  /* Neon Green */
  --accent-primary: #00ff41;
  --accent-glow: #00ff41;
  --accent-dim: #00cc33;
  
  /* Whites */
  --text-primary: #ffffff;
  --text-secondary: #cccccc;
  --text-muted: #666666;
  
  /* Functional */
  --accent-success: #00ff41;
  --accent-warning: #ffffff;
  --accent-danger: #ff0040;
  
  /* Borders */
  --border-primary: 1px solid #00ff41;
  --border-subtle: 1px solid #333333;
  
  /* Shadows */
  --shadow-glow: 0 0 20px rgba(0, 255, 65, 0.3);
  --shadow-glow-strong: 0 0 30px rgba(0, 255, 65, 0.5);
  
  /* Radius - Minimal */
  --radius-sm: 0;
  --radius-md: 0;
  --radius-lg: 0;
  --radius-xl: 0;
  --radius-full: 0;
}

/* ===== Reset & Base ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Courier New', 'Consolas', monospace;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Scanline effect */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.1) 2px,
    rgba(0, 0, 0, 0.1) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

#app {
  min-height: 100vh;
  position: relative;
}

.view {
  display: none;
  min-height: 100vh;
  padding: 2rem;
}

.view.active {
  display: block;
  animation: fadeIn 0.2s linear;
}

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

/* ===== Lobby View ===== */
#lobby {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  padding: 2rem;
}

#lobby.active {
  display: flex;
}

.logo-container {
  text-align: center;
  margin-bottom: 3rem;
}

.logo {
  font-size: 4rem;
  filter: grayscale(1) brightness(2);
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.8; }
}

.logo-container h1 {
  font-size: 2.5rem;
  font-weight: 400;
  color: var(--accent-primary);
  letter-spacing: 8px;
  text-transform: uppercase;
  text-shadow: 0 0 10px var(--accent-primary);
  font-family: 'Courier New', monospace;
}

.subtitle {
  color: var(--text-muted);
  font-size: 1rem;
  margin-top: 0.5rem;
  letter-spacing: 4px;
  text-transform: uppercase;
}

.form-card {
  background: var(--bg-card);
  padding: 2rem;
  border: var(--border-primary);
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-glow);
}

.input-group {
  margin-bottom: 1.5rem;
}

.input-group label {
  display: block;
  font-size: 0.75rem;
  color: var(--accent-primary);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.input-group input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-primary);
  border: var(--border-primary);
  color: var(--text-primary);
  font-size: 1rem;
  font-family: 'Courier New', monospace;
  transition: all 0.1s linear;
}

.input-group input:focus {
  outline: none;
  box-shadow: var(--shadow-glow);
  background: #001100;
}

.input-group input::placeholder {
  color: var(--text-muted);
}

#roomCode {
  text-transform: uppercase;
  letter-spacing: 6px;
  text-align: center;
  font-weight: 700;
}

.button-group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ===== Buttons ===== */
.btn {
  padding: 0.75rem 1.5rem;
  border: var(--border-primary);
  background: var(--bg-primary);
  font-size: 0.9rem;
  font-weight: 400;
  font-family: 'Courier New', monospace;
  cursor: pointer;
  transition: all 0.1s linear;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--accent-primary);
}

.btn:hover {
  background: var(--accent-primary);
  color: var(--bg-primary);
  box-shadow: var(--shadow-glow);
}

.btn:active {
  opacity: 0.8;
}

.btn-primary {
  background: var(--accent-primary);
  color: var(--bg-primary);
}

.btn-primary:hover {
  background: var(--bg-primary);
  color: var(--accent-primary);
}

.btn-secondary {
  background: var(--bg-primary);
  color: var(--text-primary);
  border-color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--text-primary);
  color: var(--bg-primary);
}

.btn-success {
  border-color: var(--accent-success);
  color: var(--accent-success);
}

.btn-success:hover {
  background: var(--accent-success);
  color: var(--bg-primary);
}

.btn-warning {
  border-color: var(--text-primary);
  color: var(--text-primary);
}

.btn-warning:hover {
  background: var(--text-primary);
  color: var(--bg-primary);
}

.btn-large {
  padding: 1rem 2rem;
  font-size: 1rem;
}

.btn-icon {
  background: transparent;
  border: var(--border-subtle);
  padding: 0.5rem;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text-primary);
  transition: all 0.1s linear;
}

.btn-icon:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.divider {
  display: flex;
  align-items: center;
  margin: 1rem 0;
}

.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--text-muted);
}

.divider span {
  padding: 0 1rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.error-msg {
  color: var(--accent-danger);
  font-size: 0.8rem;
  margin-top: 1rem;
  text-align: center;
  padding: 0.5rem;
  border: 1px solid var(--accent-danger);
}

.error-msg:empty {
  display: none;
}

/* ===== Waiting Room ===== */
#waitingRoom {
  max-width: 600px;
  margin: 0 auto;
}

.room-header {
  text-align: center;
  margin-bottom: 2rem;
}

.room-header h2 {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  color: var(--accent-primary);
  font-weight: 400;
  letter-spacing: 4px;
  text-transform: uppercase;
  text-shadow: 0 0 10px var(--accent-primary);
}

.room-code-display {
  display: inline-flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg-card);
  padding: 1rem 1.5rem;
  border: var(--border-primary);
}

.room-code-display .code {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 6px;
  color: var(--accent-primary);
  text-shadow: 0 0 5px var(--accent-primary);
}

.teams-panel {
  background: var(--bg-card);
  padding: 1.5rem;
  border: var(--border-subtle);
  margin-bottom: 2rem;
}

.teams-panel h3 {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.team-list {
  list-style: none;
}

.team-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem;
  border-bottom: var(--border-subtle);
  transition: all 0.1s linear;
}

.team-list li:last-child {
  border-bottom: none;
}

.team-list li:hover {
  background: #0a0a0a;
}

.team-list li.you {
  border-left: 2px solid var(--accent-primary);
  padding-left: calc(0.75rem - 2px);
}

.team-list li.host::after {
  content: '[HOST]';
  color: var(--accent-primary);
  font-size: 0.7rem;
  letter-spacing: 1px;
}

.team-list .team-name {
  font-weight: 400;
  color: var(--text-primary);
}

.team-list .team-budget {
  color: var(--accent-primary);
  font-weight: 400;
  font-family: 'Courier New', monospace;
}

.host-controls {
  text-align: center;
}

.host-controls .hint {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 1rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Settings Panel */
.settings-panel {
  background: var(--bg-primary);
  border: var(--border-primary);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  text-align: left;
}

.settings-panel h4 {
  font-size: 0.8rem;
  color: var(--accent-primary);
  margin-bottom: 1.25rem;
  letter-spacing: 2px;
  font-weight: 400;
  text-shadow: 0 0 5px var(--accent-primary);
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: var(--border-subtle);
}

.setting-row:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.setting-row label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.setting-select {
  background: var(--bg-primary);
  color: var(--accent-primary);
  border: var(--border-primary);
  padding: 0.5rem 1rem;
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  cursor: pointer;
  min-width: 120px;
}

.setting-select:focus {
  outline: none;
  box-shadow: var(--shadow-glow);
}

.setting-select option {
  background: var(--bg-primary);
  color: var(--text-primary);
}

.setting-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-right: 0.75rem;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

.settings-display {
  display: flex;
  justify-content: center;
  gap: 2rem;
  padding: 1rem;
  border: var(--border-subtle);
  margin-top: 1.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.settings-display strong {
  color: var(--accent-primary);
}

.waiting-msg {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 1rem;
  border: var(--border-subtle);
  animation: blink 1.5s step-end infinite;
}

.hidden {
  display: none !important;
}

/* ===== Auction View ===== */
#auction {
  display: none;
  grid-template-columns: 1fr 280px;
  grid-template-rows: auto 1fr;
  gap: 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
}

#auction.active {
  display: grid;
}

.auction-header {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  padding: 1rem 1.5rem;
  border: var(--border-subtle);
}

.players-remaining {
  font-size: 0.9rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.players-remaining span {
  font-weight: 700;
  color: var(--accent-primary);
  text-shadow: 0 0 5px var(--accent-primary);
}

.timer-bar-container {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 1rem;
  border: var(--border-subtle);
  min-width: 160px;
}

.timer-bar {
  flex: 1;
  height: 4px;
  background: var(--accent-primary);
  box-shadow: 0 0 5px var(--accent-primary);
  transition: width 0.3s linear;
}

.timer-bar.warning {
  background: var(--text-primary);
  box-shadow: 0 0 5px var(--text-primary);
}

.timer-bar.danger {
  background: var(--accent-danger);
  box-shadow: 0 0 5px var(--accent-danger);
  animation: timerBlink 0.3s step-end infinite;
}

@keyframes timerBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

#timerText {
  font-weight: 700;
  font-size: 1.2rem;
  min-width: 30px;
  text-align: right;
  font-family: 'Courier New', monospace;
}

.auction-main {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Player Card */
.player-card {
  background: var(--bg-card);
  border: var(--border-primary);
  padding: 2rem;
  text-align: center;
  box-shadow: var(--shadow-glow);
  position: relative;
}

.player-avatar {
  width: 80px;
  height: 80px;
  margin: 0 auto 1.5rem;
  border: 2px solid var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-primary);
  font-family: 'Courier New', monospace;
}

.role-badge {
  display: inline-block;
  padding: 0.4rem 1rem;
  font-size: 0.7rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 1rem;
  border: 1px solid currentColor;
}

.role-badge.Batsman { color: var(--text-primary); }
.role-badge.Bowler { color: var(--accent-primary); }
.role-badge.Allrounder { color: var(--text-secondary); }
.role-badge.Wicketkeeper { color: var(--accent-primary); }

.player-info h2 {
  font-size: 1.5rem;
  font-weight: 400;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.country {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.price-section {
  display: flex;
  justify-content: center;
  gap: 3rem;
  margin-top: 2rem;
  flex-wrap: wrap;
}

.base-price, .current-bid {
  text-align: center;
  padding: 1rem;
  min-width: 120px;
}

.current-bid {
  border: var(--border-primary);
  box-shadow: var(--shadow-glow);
}

.price-section .label {
  display: block;
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 0.5rem;
}

.price-section .value {
  font-size: 1.25rem;
  font-weight: 700;
  font-family: 'Courier New', monospace;
}

.price-section .highlight {
  color: var(--accent-primary);
  text-shadow: 0 0 5px var(--accent-primary);
  font-size: 1.5rem;
}

.bidder-name {
  color: var(--text-muted);
  margin-top: 1.5rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.bidder-name.leading {
  color: var(--accent-primary);
  text-shadow: 0 0 5px var(--accent-primary);
}

/* Bid Controls */
.bid-controls {
  background: var(--bg-card);
  padding: 1.5rem;
  border: var(--border-subtle);
}

.bid-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}

.btn-bid {
  padding: 0.75rem 0.5rem;
  background: var(--bg-primary);
  color: var(--accent-primary);
  border: var(--border-primary);
  font-size: 0.85rem;
  font-family: 'Courier New', monospace;
}

.btn-bid:hover {
  background: var(--accent-primary);
  color: var(--bg-primary);
  box-shadow: var(--shadow-glow);
}

.host-only {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 1rem;
}

.host-only .btn {
  min-width: 140px;
}

/* Teams Sidebar */
.teams-sidebar {
  background: var(--bg-card);
  padding: 1rem;
  border: var(--border-subtle);
  height: fit-content;
  max-height: calc(100vh - 180px);
  overflow-y: auto;
}

.teams-sidebar::-webkit-scrollbar {
  width: 4px;
}

.teams-sidebar::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

.teams-sidebar::-webkit-scrollbar-thumb {
  background: var(--accent-primary);
}

.teams-sidebar h3 {
  font-size: 0.75rem;
  margin-bottom: 1rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 2px;
}

.teams-sidebar .team-list li {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  padding: 0.75rem;
}

.teams-sidebar .team-players {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Budget Bar */
.budget-bar {
  width: 100%;
  height: 2px;
  background: var(--text-muted);
  margin-top: 0.5rem;
}

.budget-bar-fill {
  height: 100%;
  background: var(--accent-primary);
  box-shadow: 0 0 3px var(--accent-primary);
  transition: width 0.3s linear;
}

.budget-bar-fill.low {
  background: var(--accent-danger);
  box-shadow: 0 0 3px var(--accent-danger);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-primary);
  border: var(--border-primary);
  padding: 1rem 2rem;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 1rem;
  opacity: 0;
  transition: all 0.2s linear;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.success { 
  border-color: var(--accent-success);
  box-shadow: var(--shadow-glow);
}

.toast.warning { 
  border-color: var(--text-primary);
}

.toast-icon {
  font-size: 1.2rem;
  filter: grayscale(1);
}

/* Confetti Canvas */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 999;
}

/* ===== Results View ===== */
#results {
  text-align: center;
  padding-top: 3rem;
}

#results h1 {
  font-size: 2rem;
  margin-bottom: 2rem;
  color: var(--accent-primary);
  font-weight: 400;
  letter-spacing: 4px;
  text-transform: uppercase;
  text-shadow: 0 0 10px var(--accent-primary);
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  max-width: 1000px;
  margin: 0 auto 2rem;
}

.result-card {
  background: var(--bg-card);
  padding: 1.5rem;
  border: var(--border-subtle);
  text-align: left;
  transition: all 0.1s linear;
}

.result-card:hover {
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-glow);
}

.result-card h3 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.result-card .budget-left {
  color: var(--accent-primary);
  font-weight: 400;
  font-size: 0.85rem;
  margin-bottom: 1rem;
  font-family: 'Courier New', monospace;
}

.result-card .player-list {
  list-style: none;
}

.result-card .player-list li {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: var(--border-subtle);
  font-size: 0.85rem;
}

.result-card .player-list li:last-child {
  border-bottom: none;
}

.result-card .player-list li span:last-child {
  color: var(--accent-primary);
}

/* Bid History */
.bid-history {
  background: var(--bg-card);
  padding: 1rem;
  border: var(--border-subtle);
  margin-top: 1rem;
  max-height: 180px;
  overflow-y: auto;
}

.bid-history h4 {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 400;
}

.bid-history-list {
  list-style: none;
}

.bid-history-list li {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  font-size: 0.8rem;
  border-bottom: var(--border-subtle);
}

.bid-history-list li:first-child {
  color: var(--accent-primary);
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  #auction.active {
    grid-template-columns: 1fr;
  }
  
  .teams-sidebar {
    order: -1;
    max-height: none;
  }
  
  .bid-buttons {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .view {
    padding: 1rem;
  }
  
  .logo-container h1 {
    font-size: 1.5rem;
    letter-spacing: 4px;
  }
  
  .form-card {
    padding: 1.5rem;
  }
  
  .price-section {
    gap: 1rem;
  }
  
  .player-info h2 {
    font-size: 1.2rem;
  }
  
  .host-only {
    flex-direction: column;
  }
  
  .host-only .btn {
    width: 100%;
  }
}

/* ===== Utility ===== */
.shake {
  animation: shake 0.2s linear;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

.new-bid {
  animation: newBid 0.3s linear;
}

@keyframes newBid {
  0%, 100% { box-shadow: var(--shadow-glow); }
  50% { box-shadow: var(--shadow-glow-strong); }
}

/* ===== Footer Credit ===== */
.credit-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  padding: 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-primary);
  border-top: var(--border-subtle);
  letter-spacing: 1px;
  text-transform: uppercase;
  z-index: 100;
}

.credit-footer a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: all 0.2s ease;
}

.credit-footer a:hover {
  text-shadow: 0 0 5px var(--accent-primary);
}
