:root {
  color-scheme: light dark;

  /* Color System */
  --bg-color: light-dark(#f4f6f8, #121316);
  --card-bg: light-dark(#ffffff, #1e2025);
  --card-active: light-dark(#e9ecef, #2a2d34);
  --text-main: light-dark(#1a1a1e, #e6e8ec);
  --border-color: light-dark(#d0d5dd, #333742);
  --accent-role: light-dark(#9b111e, #e63946);
  --villager-role: light-dark(#006633, #39ff14);
  --eliminated-bg: light-dark(#e5e7eb, #18191c);
}

html,
body {
  overflow-x: hidden;
  touch-action: manipulation;
}

html {
  scrollbar-gutter: stable both-edges;
  box-sizing: border-box;
  scrollbar-color: var(--border-color) transparent;
  scrollbar-width: thin;
}

body {
  background: var(--bg-color);
  color: var(--text-main);
  font-family: system-ui, -apple-system, sans-serif;
  margin: 0;
  padding: 20px;
  min-height: 100vh;
  padding-bottom: calc(90px + env(safe-area-inset-bottom));
}

*,
*::before,
*::after {
  box-sizing: inherit;
}

::-webkit-scrollbar {
  width: 8px;
}

/* Transparent background track */
::-webkit-scrollbar-track {
  background: transparent;
}

/* Adaptive, nice-looking draggable bar */
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 10px; /* Matches your card-border radius smoothness */
}

/* Slight opacity boost on hover */
::-webkit-scrollbar-thumb:hover {
  filter: brightness(0.8);
}


#setup_div {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

#playerList {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 10px;
  padding: 0;
  margin: 20px 0;
}

/* Card Component */
.player-card {
  display: flex;
  min-height: 54px;
  max-height: 54px;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    transform 0.05s ease;
  gap: 8px;
}

.player-card h1 {
  font-size: 1rem;
  font-weight: 500;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-card:active {
  background-color: var(--card-active);
  transform: scale(0.98);
}

/* Visibility States */
.hiddenInfo {
  visibility: hidden;
  user-select: none;
  -webkit-user-select: none;
  font-weight: 600;
  color: var(--accent-role);
}

.hiddenInfo.revealed {
  visibility: visible;
}

/* Role & Card States */
.player-card[data-role="eliminated"] {
  cursor: not-allowed;
  filter: grayscale(100%);
  opacity: 0.45;
  border-color: transparent;
  background-color: var(--eliminated-bg);
  pointer-events: none; /* Prevents clicks on eliminated cards */
}

.player-card.selected {
  border: 2px dashed var(--accent-role);
  color: var(--accent-role);
}

.player-card[data-role="none"] span {
  color: var(--villager-role);
}

.player-card.targeted {
  border: 2px solid var(--accent-role);
  background-color: light-dark(rgba(155, 17, 30, 0.1), rgba(230, 57, 70, 0.2));
}

.delete-btn {
  background: transparent;
  border: none;
  color: var(--accent-role);
  font-size: 1.2rem;
  font-weight: bold;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Fixed Bottom Controls */
/* Fixed Bottom Controls Container */
#bottom_controls {
    position: fixed;
    bottom: calc(8px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);

  /* Use flexbox instead of fixed 3-column grid */
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 8px;

  /* Responsive Width & Centering */
  width: calc(100% - 16px);
  max-width: 500px;

  padding: 8px;
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 10;
}

#bottom_controls button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 16px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background-color: var(--bg-color);
  color: var(--text-main);
  font-weight: 500;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.05s ease;
  min-width: 0;
  box-sizing: border-box;
}

/* Allow middle/action buttons to fill available space evenly */
#btn_add_player,
#btn_edit_toggle,
#btn_show_log {
  flex: 1;
}

#bottom_controls button svg {
  width: 24px;
  height: 24px;
  display: block;
  flex-shrink: 0;
}

#bottom_controls button:active {
  background-color: var(--card-active);
  transform: scale(0.98);
}
