:root {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-light: #60a5fa;
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  --dark: #1f2937;
  --light: #f3f4f6;
  --border: #d1d5db;
}

/* Light Mode Variables */
body {
  --bg-gradient-start: #667eea;
  --bg-gradient-end: #764ba2;
  --card-bg: rgba(255, 255, 255, 0.95);
  --text-color: #1f2937;
  --heading-color: #3b82f6;
  --border-color: #d1d5db;
  --input-bg: white;
  --input-border: #d1d5db;
  --secondary-bg: #f9fafb;
  --log-bg: #1f2937;
  --log-text: #d1d5db;
  --console-bg: #1f2937;
  --console-border: #374151;
  --preview-bg: #f0f9ff;
  --info-bg: #f9fafb;
  --group-bg: #f9fafb;
  --bet-section-bg: #f9fafb;
  --shadow: rgba(0, 0, 0, 0.1);
  --shadow-hover: rgba(0, 0, 0, 0.15);
  --tab-bg: white;
  --tab-active-bg: #3b82f6;
  --tab-text: #1f2937;
  --tab-active-text: white;
  --bg-light: #f9fafb;
  --text-light: #1f2937;
  --bg-dark: #111827;
  --card-dark: #1f2937;
  --text-dark: #f3f4f6;
  --border-dark: #374151;
}

/* Dark Mode Variables */
body.dark-mode {
  --bg-gradient-start: #1a1a2e;
  --bg-gradient-end: #16213e;
  --card-bg: rgba(31, 41, 55, 0.95);
  --text-color: #f3f4f6;
  --heading-color: #60a5fa;
  --border-color: #374151;
  --input-bg: #374151;
  --input-border: #4b5563;
  --secondary-bg: #1f2937;
  --log-bg: #111827;
  --log-text: #d1d5db;
  --console-bg: #111827;
  --console-border: #1f2937;
  --preview-bg: rgba(59, 130, 246, 0.1);
  --info-bg: #1f2937;
  --group-bg: #1f2937;
  --bet-section-bg: #1f2937;
  --shadow: rgba(0, 0, 0, 0.3);
  --shadow-hover: rgba(0, 0, 0, 0.4);
  --tab-bg: #1f2937;
  --tab-active-bg: #3b82f6;
  --tab-text: #f3f4f6;
  --tab-active-text: white;
}

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

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(
    135deg,
    var(--bg-gradient-start) 0%,
    var(--bg-gradient-end) 100%
  );
  min-height: 100vh;
  padding: 1rem;
  color: white;
  transition: all 0.3s ease;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  position: relative;
}

.theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1000;
  background: var(--card-bg);
  border: 2px solid var(--primary);
  color: var(--text-color);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.5rem;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px var(--shadow);
}

.theme-toggle:hover {
  transform: scale(1.1) rotate(20deg);
  box-shadow: 0 6px 20px var(--shadow-hover);
}

h1 {
  text-align: center;
  font-size: 2.5rem;
  margin-bottom: 1rem;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
  padding-top: 1rem;
}

.landing-container {
  min-height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
}

.landing-subtitle {
  text-align: center;
  color: rgba(255, 255, 255, 0.9);
  font-size: 1.1rem;
  margin-top: -0.5rem;
}

.landing-options {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
  max-width: 900px;
  padding: 0 1rem 2rem;
}

.landing-card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 2rem;
  text-align: center;
  text-decoration: none;
  color: var(--text-color);
  box-shadow: 0 12px 30px var(--shadow);
  border: 1px solid var(--border-color);
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.landing-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 18px 36px var(--shadow-hover);
  border-color: var(--primary-light);
}

.landing-card-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

.landing-card h2 {
  margin-bottom: 0.5rem;
  color: var(--heading-color);
}

.landing-card p {
  color: var(--text-color);
  opacity: 0.85;
  margin-bottom: 1.25rem;
}

.landing-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.5rem;
  border-radius: 999px;
  background: var(--primary);
  color: white;
  font-weight: 600;
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.35);
}

.tab-container {
  display: flex;
  justify-content: center;
  margin-bottom: 2rem;
  background: var(--card-bg);
  border-radius: 12px;
  padding: 0.5rem;
  box-shadow: 0 4px 16px var(--shadow);
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

.tab-button {
  padding: 0.8rem 1.5rem;
  background: var(--tab-bg);
  color: var(--tab-text);
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  flex: 1;
  margin: 0 0.25rem;
}

.tab-button.active {
  background: var(--tab-active-bg);
  color: var(--tab-active-text);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

.tab-button:hover:not(.active) {
  background: var(--primary-light);
  color: white;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

/* Single Player Styles */
.container-singleplayer {
  max-width: 60%;
  margin: 0 auto;
}
.single-section {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: 0 8px 32px var(--shadow);
  color: var(--text-color);
  transition: all 0.3s ease;
}

.single-section h2 {
  margin-bottom: 1.5rem;
  color: var(--heading-color);
}

.single-section input,
.single-section select,
.single-section textarea {
  width: 100%;
  padding: 0.8rem;
  border: 1px solid var(--input-border);
  border-radius: 4px;
  font-size: 1rem;
  margin-bottom: 1rem;
  transition: all 0.3s ease;
  background-color: var(--input-bg);
  color: var(--text-color);
}

.single-section input:focus,
.single-section select:focus,
.single-section textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

#gameDropdown {
  height: 10rem;
}

#logContainer {
  height: 350px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 1rem;
  background-color: var(--log-bg);
  font-family: monospace;
  font-size: 0.9rem;
  transition: all 0.3s ease;
  color: var(--log-text);
}

#logContainer div {
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--console-border);
}

#logContainer div:last-child {
  border-bottom: none;
}

#statusText {
  font-weight: bold;
  color: var(--error);
}

#statusText.connected {
  color: var(--success);
}

#gameTokenDisplay {
  background-color: var(--preview-bg);
  border-left: 4px solid var(--primary);
  padding: 1rem;
  margin-bottom: 2rem;
  border-radius: 4px;
  transition: all 0.3s ease;
}

#gameToken {
  font-family: monospace;
  word-break: break-all;
  display: inline-block;
  padding: 0.2rem 0.5rem;
  background-color: rgba(59, 130, 246, 0.2);
  border-radius: 3px;
  transition: all 0.3s ease;
  cursor: pointer;
}

.progress-bar {
  width: 100%;
  height: 4px;
  background-color: var(--border-color);
  border-radius: 2px;
  margin-top: 0.5rem;
  overflow: hidden;
  position: relative;
}

.progress-bar::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 30%;
  background-color: var(--primary);
  animation: progress 1s infinite ease-in-out;
  border-radius: 2px;
}

@keyframes progress {
  0% {
    left: -30%;
  }
  100% {
    left: 100%;
  }
}

/* Multi Player Styles */
.setup-section {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: 0 8px 32px var(--shadow);
  color: var(--text-color);
  transition: all 0.3s ease;
}

.setup-section h2 {
  margin-bottom: 1.5rem;
  color: var(--heading-color);
}

.upload-section {
  margin-bottom: 1.5rem;
}

.input-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 1rem;
}

label {
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-color);
}

input[type="file"] {
  padding: 0.6rem;
  cursor: pointer;
  background: var(--input-bg);
  color: var(--text-color);
  border: 1px solid var(--input-border);
  border-radius: 4px;
  transition: all 0.3s ease;
}

input[type="file"]::file-selector-button {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  margin-right: 1rem;
  transition: all 0.3s;
}

input[type="file"]::file-selector-button:hover {
  background: var(--primary-dark);
}

.file-info {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--info-bg);
  border-radius: 6px;
  border-left: 4px solid var(--primary);
  transition: all 0.3s ease;
}

.file-info pre {
  background: var(--log-bg);
  color: var(--log-text);
  padding: 1rem;
  border-radius: 4px;
  overflow-x: auto;
  margin-top: 0.5rem;
  font-size: 0.85rem;
}

.preview-box {
  padding: 1rem;
  background: var(--preview-bg);
  border-radius: 6px;
  border-left: 4px solid var(--success);
  transition: all 0.3s ease;
}

.preview-box p {
  margin: 0.5rem 0;
  color: var(--text-color);
}

.preview-box span {
  font-weight: 600;
  color: var(--primary);
}

button {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.8rem 1.5rem;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

button:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

button:disabled {
  background: #9ca3af;
  cursor: not-allowed;
  transform: none;
}

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

.global-actions {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: 0 4px 16px var(--shadow);
  color: var(--text-color);
  transition: all 0.3s ease;
}

.global-actions h2 {
  margin-bottom: 1rem;
  color: var(--heading-color);
}

.action-buttons {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.btn-success {
  background: var(--success);
}

.btn-success:hover {
  background: #059669;
}

.btn-danger {
  background: var(--error);
}

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

.group-betting-section {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: 0 4px 16px var(--shadow);
  color: var(--text-color);
  transition: all 0.3s ease;
}

.group-betting-section h2 {
  margin-bottom: 1.5rem;
  color: var(--heading-color);
}

.groups-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.group-card {
  background: var(--group-bg);
  border-radius: 8px;
  padding: 1.5rem;
  border: 2px solid var(--border-color);
  transition: all 0.3s;
}

.group-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--border-color);
}

.group-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
}

.group-member-count {
  background: var(--primary);
  color: white;
  padding: 0.3rem 0.8rem;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
}

.group-members {
  margin-bottom: 1rem;
  padding: 0.8rem;
  background: var(--input-bg);
  border-radius: 6px;
  max-height: 120px;
  overflow-y: auto;
  transition: all 0.3s ease;
}

.group-members p {
  font-size: 0.9rem;
  color: var(--text-color);
  margin: 0.3rem 0;
}

.group-bet-input {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.group-bet-input input,
.group-bet-input select,
.group-bet-input textarea {
  padding: 0.6rem;
  border: 1px solid var(--input-border);
  border-radius: 4px;
  font-size: 0.9rem;
  background: var(--input-bg);
  color: var(--text-color);
  transition: all 0.3s ease;
}

.group-bet-input select {
  cursor: pointer;
}

.group-bet-input textarea {
  min-height: 100px;
  font-family: monospace;
  resize: vertical;
}

.group-bet-input label {
  font-size: 0.85rem;
  color: var(--text-color);
  font-weight: 600;
}

.group-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.btn-small {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  flex: 1;
}

.btn-remove {
  background: var(--error);
  padding: 0.5rem 0.8rem;
}

.btn-remove:hover {
  background: #dc2626;
}

.add-group-btn {
  background: var(--success);
  margin-top: 1rem;
}

.add-group-btn:hover {
  background: #059669;
}

.player-assignment-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.player-assignment-label {
  font-size: 0.85rem;
  color: var(--text-color);
  font-weight: 600;
  margin-bottom: 0.5rem;
  display: block;
}

.player-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 0.4rem;
}

.player-btn {
  padding: 0.4rem;
  font-size: 0.8rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.player-btn:hover:not(:disabled) {
  transform: translateY(-2px);
}

.player-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.global-console-section {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: 0 4px 16px var(--shadow);
  color: var(--text-color);
  transition: all 0.3s ease;
}

.global-console-section h2 {
  margin-bottom: 1rem;
  color: var(--heading-color);
}

.global-console {
  background: var(--console-bg);
  border-radius: 8px;
  padding: 1rem;
  max-height: 300px;
  overflow-y: auto;
  font-family: monospace;
  font-size: 0.85rem;
  transition: all 0.3s ease;
}

.console-entry {
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--console-border);
  display: flex;
  gap: 0.5rem;
}

.console-entry:last-child {
  border-bottom: none;
}

.console-player-badge {
  background: var(--primary);
  color: white;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 600;
  min-width: 50px;
  text-align: center;
  flex-shrink: 0;
}

.console-message {
  flex: 1;
  word-break: break-word;
}

.console-info {
  color: #60a5fa;
}

.console-success {
  color: #34d399;
}

.console-error {
  color: #f87171;
}

.console-warning {
  color: #fbbf24;
}

.players-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

.player-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 4px 16px var(--shadow);
  color: var(--text-color);
  transition: all 0.3s;
}

.player-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px var(--shadow-hover);
}

.player-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--border-color);
}

.player-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: 0.5rem;
  background: #dbeafe;
  color: #1e40af;
}

.dark-mode .badge {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
}

.player-status {
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
}

.status-connected {
  background: #d1fae5;
  color: #065f46;
}

.dark-mode .status-connected {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.status-disconnected {
  background: #fee2e2;
  color: #991b1b;
}

.dark-mode .status-disconnected {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

.status-logged-out {
  background: #e5e7eb;
  color: #374151;
}

.dark-mode .status-logged-out {
  background: rgba(156, 163, 175, 0.2);
  color: #9ca3af;
}

.player-info {
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.info-row {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border-color);
}

.info-label {
  font-weight: 600;
  color: #6b7280;
}

.dark-mode .info-label {
  color: #9ca3af;
}

.info-value {
  color: var(--text-color);
  font-family: monospace;
  word-break: break-all;
}

.player-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.bet-section {
  background: var(--bet-section-bg);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  border-left: 4px solid var(--warning);
  transition: all 0.3s ease;
}

.bet-section h3 {
  margin-bottom: 0.8rem;
  color: var(--text-color);
  font-size: 0.95rem;
}

.bet-input-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.bet-input-group input,
.bet-input-group select,
.bet-input-group textarea {
  padding: 0.5rem;
  border: 1px solid var(--input-border);
  border-radius: 4px;
  font-size: 0.9rem;
  background: var(--input-bg);
  color: var(--text-color);
  transition: all 0.3s ease;
}

.bet-input-group select {
  cursor: pointer;
}

.bet-input-group textarea {
  min-height: 80px;
  font-family: monospace;
  resize: vertical;
}

.bet-input-group button {
  padding: 0.5rem;
  font-size: 0.9rem;
}

.player-logs {
  max-height: 200px;
  overflow-y: auto;
  background: var(--log-bg);
  border-radius: 6px;
  padding: 0.8rem;
  font-family: monospace;
  font-size: 0.8rem;
  color: var(--log-text);
  transition: all 0.3s ease;
}

.log-entry {
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--console-border);
}

.log-info {
  color: #60a5fa;
}

.log-success {
  color: #34d399;
}

.log-error {
  color: #f87171;
}

.log-warning {
  color: #fbbf24;
}

.scrollbar-thin::-webkit-scrollbar {
  width: 6px;
}

.scrollbar-thin::-webkit-scrollbar-track {
  background: var(--console-bg);
  border-radius: 3px;
}

.scrollbar-thin::-webkit-scrollbar-thumb {
  background: #4b5563;
  border-radius: 3px;
}

.scrollbar-thin::-webkit-scrollbar-thumb:hover {
  background: #6b7280;
}

.group-members.scrollbar-thin::-webkit-scrollbar-track {
  background: var(--secondary-bg);
  border-radius: 3px;
}

.group-members.scrollbar-thin::-webkit-scrollbar-thumb {
  background: #9ca3af;
  border-radius: 3px;
}

/* Log types - Light theme */
.log-info {
  color: #3b82f6;
}

.log-error {
  color: #ef4444;
}

.log-success {
  color: #10b981;
}

.log-received {
  color: #8b5cf6;
}

.log-sent {
  color: #f59e0b;
}

/* Log types - Dark theme */
.dark-mode .log-info {
  color: #60a5fa;
}

.dark-mode .log-error {
  color: #f87171;
}

.dark-mode .log-success {
  color: #34d399;
}

.dark-mode .log-received {
  color: #a78bfa;
}

.dark-mode .log-sent {
  color: #fbbf24;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.3s ease;
}

@media (max-width: 600px) {
  body {
    padding: 0.5rem;
  }

  .players-grid {
    grid-template-columns: 1fr;
  }

  .groups-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 1.8rem;
  }

  .theme-toggle {
    top: 0.5rem;
    right: 0.5rem;
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
  }

  .tab-button {
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
  }
  .container-singleplayer {
    max-width: 100%;
  }
}
