/* CSS Custom Properties for Theme Management */
:root {
  /* Light theme colors (default) */
  --bg-primary: #f7f7fa;
  --bg-secondary: #fff;
  --bg-tertiary: #f0f4f8;
  --bg-accent: rgba(0, 116, 217, 0.1);
  --text-primary: #2d2d2d;
  --text-secondary: #666;
  --text-accent: #0074d9;
  --border-primary: #ccc;
  --border-accent: #0074d9;
  --button-primary: #0074d9;
  --button-primary-hover: #005fa3;
  --button-danger: #ff4136;
  --button-danger-hover: #c12b1e;
  --shadow-light: rgba(0, 0, 0, 0.05);
  --shadow-medium: rgba(0, 0, 0, 0.07);
  --shadow-heavy: rgba(0, 0, 0, 0.15);
}

/* Dark theme colors */
[data-theme="dark"] {
  --bg-primary: #1a1a1a;
  --bg-secondary: #2d2d2d;
  --bg-tertiary: #3a3a3a;
  --bg-accent: rgba(100, 149, 237, 0.2);
  --text-primary: #e5e5e5;
  --text-secondary: #b0b0b0;
  --text-accent: #6495ed;
  --border-primary: #555;
  --border-accent: #6495ed;
  --button-primary: #6495ed;
  --button-primary-hover: #4169e1;
  --button-danger: #ff6b6b;
  --button-danger-hover: #ff5252;
  --shadow-light: rgba(0, 0, 0, 0.2);
  --shadow-medium: rgba(0, 0, 0, 0.3);
  --shadow-heavy: rgba(0, 0, 0, 0.4);
}

body {
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  margin: 0;
  padding: 0;
  transition:
    background-color 0.3s ease,
    color 0.3s ease;
}

h1,
h2,
h3 {
  color: var(--text-primary);
  margin-top: 1.5em;
  margin-bottom: 0.5em;
}

form {
  margin: 1em 0;
  padding: 1em;
  background: var(--bg-secondary);
  border-radius: 8px;
  box-shadow: 0 2px 8px var(--shadow-light);
  max-width: 400px;
}

label {
  display: block;
  margin-bottom: 0.5em;
  font-weight: 500;
}

input[type="text"] {
  width: 100%;
  padding: 0.5em;
  margin-bottom: 1em;
  border: 1px solid var(--border-primary);
  border-radius: 4px;
  background: var(--bg-secondary);
  color: var(--text-primary);
}

form input,
form button {
  display: block;
  width: 100%;
  margin-bottom: 1em;
}

button {
  background: var(--button-primary);
  color: #fff;
  border: none;
  padding: 0.6em 1.2em;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1em;
  margin-right: 0;
  transition: background 0.2s;
}

button:hover {
  background: var(--button-primary-hover);
}

ul {
  list-style: none;
  padding: 0;
}

li {
  background: var(--bg-tertiary);
  margin-bottom: 0.5em;
  padding: 0.5em 1em;
  border-radius: 4px;
  color: var(--text-primary);
}

input[type="hidden"] {
  display: none;
}

p {
  color: var(--text-accent);
  font-weight: 500;
  margin-top: 1em;
}

.center-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.game-title {
  font-size: 2.5em;
  font-weight: bold;
  color: var(--text-accent);
  margin-bottom: 0.5em;
  margin-top: 2em;
  letter-spacing: 2px;
}

.login-box {
  background: var(--bg-secondary);
  padding: 2em 2.5em;
  border-radius: 10px;
  box-shadow: 0 2px 16px var(--shadow-medium);
  min-width: 320px;
  text-align: center;
}

.login-box h2 {
  margin-bottom: 1em;
  color: var(--text-primary);
}

.admin-btn {
  position: absolute;
  top: 24px;
  right: 32px;
  background: var(--button-danger);
  color: #fff;
  border: none;
  padding: 0.5em 1.2em;
  border-radius: 4px;
  text-decoration: none;
  font-size: 1em;
  font-weight: 500;
  box-shadow: 0 2px 8px var(--shadow-medium);
  transition: background 0.2s;
  z-index: 100;
}

.admin-btn:hover {
  background: var(--button-danger-hover);
}

.home-btn {
  position: absolute;
  top: 24px;
  left: 32px;
  background: var(--button-primary);
  color: #fff;
  border: none;
  padding: 0.5em 1.2em;
  border-radius: 4px;
  text-decoration: none;
  font-size: 1em;
  font-weight: 500;
  box-shadow: 0 2px 8px var(--shadow-medium);
  transition: background 0.2s;
  z-index: 100;
}

.home-btn:hover {
  background: var(--button-primary-hover);
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1em;
}

th,
td {
  border: 1px solid var(--border-primary);
  padding: 0.5em 1em;
  text-align: left;
}

th {
  background: var(--bg-tertiary);
  font-weight: 600;
}

/* Card styling */
.card {
  display: inline-block;
  width: 140px;
  height: 200px;
  margin: 8px;
  padding: 12px;
  border-radius: 12px;
  border: 2px solid #333;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  transition:
    transform 0.2s,
    box-shadow 0.2s;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #fff 0%, #f8f8f8 100%);
}

/* Only apply pointer cursor and hover effect to interactive cards */
.card--interactive {
  cursor: pointer;
}

.card--interactive:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.card-header {
  font-size: 10px;
  font-weight: bold;
  text-transform: uppercase;
  margin-bottom: 8px;
  text-align: center;
}

.card-name {
  font-size: 12px;
  font-weight: bold;
  text-align: center;
  margin-bottom: 8px;
  line-height: 1.3;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-description {
  font-size: 10px;
  line-height: 1.3;
  text-align: center;
  margin-top: 6px;
  color: inherit;
  padding: 0 4px;
}

.card-value {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
}

.card-type-icon {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 18px;
}

/* Card type specific styling */
.card-money {
  background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
  color: white;
  border-color: #27ae60;
}

.card-property {
  background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
  color: white;
  border-color: #2980b9;
}

.card-action {
  background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
  color: white;
  border-color: #c0392b;
}

.card-wild {
  background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%);
  color: white;
  border-color: #8e44ad;
}

.card-rent {
  background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
  color: white;
  border-color: #e67e22;
}

/* Hand container styling */
.hand-container {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 20px 0;
  padding: 20px;
  background: var(--bg-accent);
  border-radius: 12px;
  border: 2px dashed var(--border-primary);
  min-height: 120px;
}

.hand-container.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-style: italic;
}

.card-container {
  position: relative;
  display: inline-block;
}

.card-button {
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--button-primary);
  color: white;
  border: none;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 10px;
  cursor: pointer;
  z-index: 10;
  transition: background 0.2s;
}

.card-button:hover {
  background: var(--button-primary-hover);
}

/* Properties section styling */
.properties-container {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 20px 0;
  padding: 20px;
  background: var(--bg-accent);
  border-radius: 12px;
  border: 2px solid var(--border-accent);
  min-height: 80px;
}

.properties-container.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-style: italic;
}

.property-card {
  width: 100px;
  height: 140px;
  font-size: 10px;
  padding: 8px;
}

.property-card .card-name {
  font-size: 10px;
  min-height: 24px;
}

/* Theme Toggle Dropdown */
.theme-toggle {
  position: absolute;
  top: 24px;
  right: 120px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-primary);
  padding: 0.5em 0.8em;
  border-radius: 4px;
  font-size: 1em;
  cursor: pointer;
  box-shadow: 0 2px 8px var(--shadow-medium);
  transition:
    background 0.2s,
    border-color 0.2s;
  z-index: 100;
  min-width: 120px;
  text-align: left;
  font-family: inherit;
}

/* Header actions container for admin and theme toggle buttons */
.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px; /* Space between buttons */
  position: relative;
  top: 24px;
  right: 24px;
}

.theme-toggle:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-accent);
}

/* System theme preference detection */
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #3a3a3a;
    --bg-accent: rgba(100, 149, 237, 0.2);
    --text-primary: #e5e5e5;
    --text-secondary: #b0b0b0;
    --text-accent: #6495ed;
    --border-primary: #555;
    --border-accent: #6495ed;
    --button-primary: #6495ed;
    --button-primary-hover: #4169e1;
    --button-danger: #ff6b6b;
    --button-danger-hover: #ff5252;
    --shadow-light: rgba(0, 0, 0, 0.2);
    --shadow-medium: rgba(0, 0, 0, 0.3);
    --shadow-heavy: rgba(0, 0, 0, 0.4);
  }
}

/* Input password field styling */
input[type="password"] {
  width: 100%;
  padding: 0.5em;
  margin-bottom: 1em;
  border: 1px solid var(--border-primary);
  border-radius: 4px;
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* Lobby-specific styles */
.lobby-box {
  background: var(--bg-secondary);
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 4px 12px var(--shadow-medium);
  border: 1px solid var(--border-primary);
  max-width: 600px;
  margin: 0 auto;
}

.lobby-actions {
  display: grid;
  gap: 2rem;
  margin: 2rem 0;
}

.action-section {
  background: var(--bg-tertiary);
  padding: 1.5rem;
  border-radius: 6px;
  border: 1px solid var(--border-primary);
}

.action-section h3 {
  margin-top: 0;
  color: var(--text-accent);
}

.current-session {
  background: var(--bg-accent);
  padding: 1.5rem;
  border-radius: 6px;
  border: 1px solid var(--border-accent);
  margin: 1rem 0;
}

.session-info {
  margin: 1rem 0;
}

.session-code {
  font-family: "Courier New", monospace;
  font-weight: bold;
  font-size: 1.2em;
  color: var(--text-accent);
  background: var(--bg-secondary);
  padding: 0.3em 0.6em;
  border-radius: 4px;
  border: 1px solid var(--border-accent);
}

.players-list {
  margin: 0.5rem 0;
}

.player-tag {
  display: inline-block;
  background: var(--button-primary);
  color: white;
  padding: 0.3em 0.8em;
  margin: 0.2em;
  border-radius: 20px;
  font-size: 0.9em;
}

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

.inline-form {
  display: inline-block;
}

.btn-primary {
  background: var(--button-primary);
  color: white;
  border: none;
  padding: 0.8em 1.5em;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1em;
  font-weight: 500;
  text-decoration: none;
  display: inline-block;
  transition: background 0.2s;
}

.btn-primary:hover {
  background: var(--button-primary-hover);
}

.btn-danger {
  background: var(--button-danger);
  color: white;
  border: none;
  padding: 0.8em 1.5em;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1em;
  font-weight: 500;
  transition: background 0.2s;
}

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

.form-group {
  margin: 1rem 0;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.form-group input {
  width: 100%;
  padding: 0.8em;
  border: 1px solid var(--border-primary);
  border-radius: 4px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 1em;
}

.lobby-info {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-primary);
}

.lobby-info h4 {
  margin-top: 0;
  color: var(--text-accent);
}

.lobby-info ul {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

.lobby-info li {
  margin: 0.5rem 0;
  color: var(--text-secondary);
}

.message {
  padding: 1rem;
  border-radius: 4px;
  margin: 1rem 0;
  border: 1px solid;
}

.message.success {
  background: rgba(40, 167, 69, 0.1);
  border-color: #28a745;
  color: #155724;
}

.message.error {
  background: rgba(220, 53, 69, 0.1);
  border-color: #dc3545;
  color: #721c24;
}

[data-theme="dark"] .message.success {
  background: rgba(40, 167, 69, 0.2);
  color: #d4edda;
}

[data-theme="dark"] .message.error {
  background: rgba(220, 53, 69, 0.2);
  color: #f8d7da;
}

/* Mobile Responsive Design */
@media (max-width: 768px) {
  /* Hide original positioned buttons on mobile */
  body > .admin-btn,
  body > .home-btn,
  body > .theme-toggle {
    display: none;
  }

  /* Show mobile header */
  .mobile-header {
    display: flex;
  }

  /* Adjust main title for mobile */
  .game-title {
    font-size: 2em;
    margin-top: 1em;
    letter-spacing: 1px;
  }

  /* Make login box more mobile-friendly */
  .login-box,
  .lobby-box {
    padding: 1.5em 1em;
    min-width: auto;
    width: 90%;
    max-width: 400px;
    margin: 0 1em;
  }

  /* Center container adjustments for mobile */
  .center-container {
    padding: 1em;
    min-height: 100vh;
  }

  /* Mobile header button layout */
  .mobile-header {
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.5em;
    padding: 1em;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
  }

  /* Reposition admin and home buttons for mobile */
  .mobile-header .admin-btn,
  .mobile-header .home-btn {
    position: static;
    margin: 0;
    padding: 0.6em 1em;
    font-size: 0.9em;
    min-height: 44px; /* Touch-friendly minimum size */
  }

  /* Reposition theme toggle for mobile */
  .mobile-header .theme-toggle {
    position: static;
    margin: 0;
    padding: 0.6em;
    font-size: 0.9em;
    min-height: 44px; /* Touch-friendly minimum size */
    min-width: 100px;
  }

  /* Improve form elements for touch */
  input[type="text"],
  input[type="password"] {
    padding: 0.8em;
    font-size: 16px; /* Prevents zoom on iOS */
    min-height: 44px;
  }

  button,
  .btn-primary,
  .btn-danger {
    padding: 0.8em 1.2em;
    font-size: 1em;
    min-height: 44px; /* Touch-friendly minimum size */
    width: 100%;
    margin: 0.5em 0;
  }

  /* Adjust game elements for mobile */
  .card {
    width: 120px;
    height: 170px;
    margin: 4px;
    padding: 8px;
  }

  .card-name {
    font-size: 10px;
    min-height: 24px;
  }

  .card-value {
    width: 20px;
    height: 20px;
    font-size: 10px;
  }

  /* Mobile-friendly session actions */
  .session-actions {
    flex-direction: column;
    gap: 0.5rem;
  }

  .session-actions .btn-primary,
  .session-actions .btn-danger {
    width: 100%;
  }

  /* Improve action sections for mobile */
  .action-section {
    margin: 1rem 0;
    padding: 1rem;
  }

  /* Better spacing for mobile */
  .players-list {
    margin: 1rem 0;
  }

  .player-tag {
    margin: 0.2em;
    padding: 0.4em 0.6em;
  }

  /* Table responsiveness */
  table {
    font-size: 0.9em;
    overflow-x: auto;
    display: block;
    white-space: nowrap;
  }

  th,
  td {
    padding: 0.4em 0.6em;
  }
}

/* Desktop styles - hide mobile header */
@media (min-width: 769px) {
  .mobile-header {
    display: none;
  }
}

/* Extra small mobile devices */
@media (max-width: 480px) {
  .game-title {
    font-size: 1.8em;
  }

  .login-box,
  .lobby-box {
    padding: 1em 0.8em;
    width: 95%;
  }

  .card {
    width: 100px;
    height: 140px;
    margin: 2px;
    padding: 6px;
  }

  .card-name {
    font-size: 9px;
    min-height: 20px;
  }

  /* Stack elements more aggressively on very small screens */
  .mobile-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5em;
    padding: 0.8em;
  }

  .admin-btn,
  .home-btn,
  .theme-toggle {
    width: 100%;
    text-align: center;
  }
}

.role-badge {
  display: inline-block;
  font-size: 0.6em;
  font-weight: 600;
  padding: 0.2em 0.7em;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 0.5em;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.role-admin {
  background: var(--button-danger);
  color: #fff;
}

.role-user {
  background: var(--button-primary);
  color: #fff;
}
