:root {
  --bg-color: #f5f5f5;
  --text-color: #0f172a;
  --brand-h1: #111827;
  --brand-p: #6b7280;
  --card-bg: #ffffff;
  --card-shadow: 0 8px 24px rgba(15, 23, 42, 0.08), 0 0 0 1px rgba(148, 163, 184, 0.35);
  --card-h2: #111827;
  --card-subtitle: #6b7280;
  --label-color: #374151;
  --input-bg: #ffffff;
  --input-border: #e5e7eb;
  --input-color: #111827;
  --btn-primary-bg: #22c55e;
  --btn-primary-color: #ffffff;
  --btn-secondary-bg: #e5e7eb;
  --btn-secondary-color: #111827;
  --table-border: #e5e7eb;
  --table-bg: #ffffff;
  --table-thead-bg: #f3f4f6;
  --table-th-color: #111827;
  --table-td-color: #111827;
  --table-tr-even-bg: #f9fafb;
  --table-tr-hover-bg: #e5f3ff;
  --footer-color: #9ca3af;
  --modal-overlay-bg: rgba(15, 23, 42, 0.6);
  --info-section-bg: linear-gradient(135deg, #ffffff 0%, #f3f4f6 100%);
  --user-info-bg: #ffffff;
  --user-info-border: rgba(148, 163, 184, 0.5);
  --code-bg: #e5e7eb;
  --code-color: #111827;
  --tooltip-bg: rgba(15, 23, 42, 0.98);
  --tooltip-color: #ffffff;
}

.dark-mode {
  --bg-color: #0f172a;
  --text-color: #f1f5f9;
  --brand-h1: #f1f5f9;
  --brand-p: #94a3b8;
  --card-bg: #1e293b;
  --card-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);
  --card-h2: #f1f5f9;
  --card-subtitle: #94a3b8;
  --label-color: #94a3b8;
  --input-bg: #1e293b;
  --input-border: #334155;
  --input-color: #f1f5f9;
  --btn-secondary-bg: #334155;
  --btn-secondary-color: #f1f5f9;
  --table-border: #334155;
  --table-bg: #1e293b;
  --table-thead-bg: #334155;
  --table-th-color: #f1f5f9;
  --table-td-color: #cbd5e1;
  --table-tr-even-bg: #1e293b;
  --table-tr-hover-bg: #334155;
  --footer-color: #64748b;
  --modal-overlay-bg: rgba(0, 0, 0, 0.8);
  --info-section-bg: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  --user-info-bg: #1e293b;
  --user-info-border: rgba(255, 255, 255, 0.1);
  --code-bg: #334155;
  --code-color: #f1f5f9;
  --tooltip-bg: rgba(30, 41, 59, 0.98);
  --tooltip-color: #f1f5f9;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg-color);
  color: var(--text-color);
  transition: background 0.3s ease, color 0.3s ease;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: 1600px;
  margin: 0 auto;
  padding: 1.5rem;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.brand h1 {
  margin: 0;
  font-size: 1.9rem;
  letter-spacing: 0.04em;
  color: var(--brand-h1);
}

.brand p {
  margin: 0.25rem 0 0;
  color: var(--brand-p);
  font-size: 0.9rem;
}

.auth-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  background: var(--user-info-bg);
  box-shadow: 0 0 0 1px var(--user-info-border);
}

.user-info img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
}

.user-info span {
  font-size: 0.85rem;
  color: var(--text-color);
}

.badge {
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: #22c55e;
  color: #022c22;
  font-weight: 600;
  font-size: 0.75rem;
}

.hidden {
  display: none !important;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card {
  position: relative;
  background: var(--card-bg);
  border-radius: 1rem;
  padding: 1.4rem 1.6rem;
  box-shadow: var(--card-shadow);
  overflow: hidden;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.card h2 {
  margin-top: 0;
  margin-bottom: 0.4rem;
  font-size: 1.25rem;
  color: var(--card-h2);
}

.card-subtitle {
  margin: 0;
  color: var(--card-subtitle);
  font-size: 0.9rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem 1rem;
  margin-top: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.form-group.full {
  grid-column: 1 / -1;
}

label {
  font-size: 0.85rem;
  color: var(--label-color);
}

input[type="text"],
input[type="number"] {
  border-radius: 0.5rem;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  padding: 0.45rem 0.7rem;
  color: var(--input-color);
  font-size: 0.9rem;
  outline: none;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease;
}

input[type="text"]:focus,
input[type="number"]:focus {
  border-color: #22c55e;
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.7);
  background: var(--input-bg);
}

.form-actions {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.form-status {
  font-size: 0.85rem;
  color: #a0a7c5;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 0.45rem 1.2rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition:
    transform 0.11s ease,
    box-shadow 0.11s ease,
    background 0.16s ease,
    color 0.16s ease;
}

.btn.primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-color);
  box-shadow: 0 4px 10px rgba(34, 197, 94, 0.4);
}

.btn.secondary {
  background: var(--btn-secondary-bg);
  color: var(--btn-secondary-color);
  box-shadow: 0 4px 10px rgba(148, 163, 184, 0.4);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.18);
}

.btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.18);
}

.table-wrapper {
  margin-top: 1rem;
  border-radius: 0.9rem;
  overflow-x: auto;
  overflow-y: visible;
  border: 1px solid var(--table-border);
  background: var(--table-bg);
  box-shadow: var(--card-shadow);
  /* Allow tooltips to escape the container */
  position: relative;
  z-index: 5;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.table-controls {
  margin-top: 0.75rem;
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--card-subtitle);
}

.sort-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 0.75rem;
}

.sort-toggle input[type="checkbox"] {
  accent-color: #22c55e;
}

.table-controls select {
  border-radius: 999px;
  border: 1px solid var(--input-border);
  padding: 0.3rem 0.75rem;
  background: var(--input-bg);
  font-size: 0.85rem;
  color: var(--input-color);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 100%;
}

thead {
  background: var(--table-thead-bg);
}

th,
td {
  padding: 0.4rem 0.25rem;
  text-align: right;
  font-size: 0.75rem;
  border-bottom: 1px solid var(--table-border);
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  background: inherit;
  z-index: 10;
  width: 40px;
}

th:nth-child(2),
td:nth-child(2) {
  text-align: left;
  position: sticky;
  left: 40px;
  background: inherit;
  z-index: 10;
}

tbody tr:nth-child(odd) td:first-child,
tbody tr:nth-child(odd) td:nth-child(2) {
  background: var(--table-bg);
}

tbody tr:nth-child(even) td:first-child,
tbody tr:nth-child(even) td:nth-child(2) {
  background: var(--table-tr-even-bg);
}

thead th:first-child,
thead th:nth-child(2) {
  background: var(--table-thead-bg);
}

tbody tr:hover td:first-child,
tbody tr:hover td:nth-child(2) {
  background: #e5f3ff;
}

th {
  font-weight: 600;
  color: var(--table-th-color);
}

tbody tr:nth-child(odd) {
  background: var(--table-bg);
}

tbody tr:nth-child(even) {
  background: var(--table-tr-even-bg);
}

tbody tr:hover {
  background: #e5f3ff;
  z-index: 20;
  position: relative;
}

td {
  color: var(--table-td-color);
}

td.muted,
.muted {
  color: #9ca3af;
}

.player-cell {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.player-cell img {
  width: 28px;
  height: 28px;
  border-radius: 0.4rem;
  box-shadow: 0 0 0 1px rgba(148, 163, 184, 0.8);
}

.player-name {
  font-weight: 600;
}

tfoot tr {
  background: var(--table-thead-bg);
}

tfoot th,
tfoot td {
  font-weight: 600;
  color: var(--table-th-color);
}

.app-footer {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--footer-color);
}

@media (max-width: 768px) {
  .app {
    padding: 1rem;
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .auth-controls {
    align-self: stretch;
    justify-content: space-between;  }
}

/* Modal Overlay Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--modal-overlay-bg);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay .card {
  width: 100%;
  max-width: 420px;
  margin: 0;
}

.modal-overlay code {
  background: var(--code-bg);
  padding: 0.2rem 0.4rem;
  border-radius: 0.3rem;
  font-family: monospace;
  color: var(--code-color);
  font-size: 0.95em;
}

/* Info Section Styles */
.info-section {
  background: var(--info-section-bg);
  border-left: 4px solid #22c55e;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  margin-top: 1.5rem;
}

.info-item h3 {
  color: var(--card-h2);
  margin-bottom: 0.75rem;
  font-size: 1.25rem;
}

.info-item ul, .info-item ol {
  padding-left: 1.25rem;
  color: var(--card-subtitle);
  line-height: 1.6;
}

.info-item li {
  margin-bottom: 0.5rem;
}

.info-item strong {
  color: var(--card-h2);
}

/* Auth controls spacing */
/* UX Enhancements */
.copyable-ip {
  cursor: pointer;
  background: rgba(107, 114, 128, 0.1);
  padding: 0.1rem 0.4rem;
  border-radius: 0.25rem;
  transition: all 0.2s ease;
  border: 1px dashed #6b7280;
  display: inline-block;
  color: #3b82f6;
  font-weight: 500;
  position: relative;
}

.copyable-ip:hover {
  background: rgba(59, 130, 246, 0.1);
  border-color: #3b82f6;
}

.copyable-ip::after {
  content: "Kopieret!";
  position: absolute;
  top: -1.75rem;
  left: 50%;
  transform: translateX(-50%) translateY(5px);
  background: #1e293b;
  color: white;
  padding: 0.2rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.7rem;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none;
  white-space: nowrap;
}

.copyable-ip.copied::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.copy-toast {
  display: none; /* Removed in favor of element-specific feedback */
}

.player-cell {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Custom Tooltip */
.custom-tooltip {
  position: fixed;
  background: var(--tooltip-bg);
  backdrop-filter: blur(8px);
  color: var(--tooltip-color);
  padding: 0.6rem 0.9rem;
  border-radius: 0.6rem;
  font-size: 0.75rem;
  line-height: 1.5;
  white-space: pre-line;
  z-index: 10000;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
  pointer-events: none;
  min-width: 150px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: opacity 0.15s ease, transform 0.15s ease;
  opacity: 0;
  visibility: hidden;
  transform: translateY(5px);
}

.custom-tooltip.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.custom-tooltip.hidden {
  display: none;
}

/* Removed CSS hover triggers in favor of JS positioning */
/* .player-cell:hover .custom-tooltip { ... } */

/* Removed CSS hover triggers in favor of JS positioning */
/* .player-cell:hover .custom-tooltip { ... } */

.player-cell img {
  cursor: default; /* Remove the "help" cursor, let the tooltip be the guide */
  transition: transform 0.2s ease;
}

.player-cell.has-warp {
  cursor: pointer;
}

.player-cell.has-warp:hover {
  background: rgba(34, 197, 94, 0.08);
  border-radius: 0.5rem;
}

.player-cell.has-warp::after {
  content: "📍";
  font-size: 0.7rem;
  margin-left: -0.2rem;
  opacity: 0.7;
}

.custom-tooltip.success {
  background: #16a34a !important;
  color: #ffffff !important;
  border-color: #15803d !important;
}

.player-cell:hover img {
  transform: scale(1.1);
}

/* Theme Toggle Button Styles */
.theme-toggle {
  background: var(--btn-secondary-bg);
  color: var(--btn-secondary-color);
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.theme-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.theme-toggle:active {
  transform: scale(0.95);
}

.theme-toggle .sun-icon {
  display: none;
}

.dark-mode .theme-toggle .sun-icon {
  display: block;
}

.dark-mode .theme-toggle .moon-icon {
  display: none;
}

