/* style.css — Werewolf Game Mobile-First Theme */

:root {
  /* Sizing */
  --radius: 12px;
  --gap: 12px;
  --max-width: 480px;

  /* Constant colors */
  --accent: #ffd700;
  --danger: #cc0000;
  --success: #2e7d32;
  --werewolf: #8b0000;
  --village: #1565c0;
}

/* Night (dark) theme — default on body */
body {
  --bg: #0f0f1a;
  --bg-card: #1a1a2e;
  --bg-card-hover: #252545;
  --text: #e0e0e0;
  --text-muted: #888;
  --border: #333;
  --shadow: rgba(0,0,0,0.5);
}

/* Day theme override on body */
body.day-theme {
  --bg: #f5e6ca;
  --bg-card: #fff8ee;
  --bg-card-hover: #f0e0c8;
  --text: #2d2d2d;
  --text-muted: #666;
  --border: #ccc;
  --shadow: rgba(0,0,0,0.15);
}

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

html, body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
}

/* === SCREEN SYSTEM === */
.screen {
  display: none;
  flex-direction: column;
  min-height: 100vh;
  padding: 16px;
  animation: fadeIn 0.3s ease;
}
.screen.active {
  display: flex;
}

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

/* === TYPOGRAPHY === */
h1 {
  font-size: 1.8rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 8px;
}
h2 {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 12px;
}
h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 8px;
}

/* === BUTTONS === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 48px;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
}
.btn:active {
  transform: scale(0.97);
}
.btn-primary {
  background: var(--accent);
  color: #000;
}
.btn-primary:hover {
  background: #ffe44d;
}
.btn-primary:disabled {
  background: #555;
  color: #888;
  cursor: not-allowed;
  transform: none;
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background: #e02020;
}
.btn-secondary {
  background: var(--bg-card);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--bg-card-hover);
}
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 8px 16px;
}
.btn-block {
  width: 100%;
}
.btn-lg {
  padding: 18px 32px;
  font-size: 1.2rem;
}
.btn-sm {
  padding: 8px 16px;
  font-size: 0.85rem;
  min-height: 36px;
}
.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  font-size: 1.2rem;
}

/* === INPUTS === */
.input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}
.input:focus {
  border-color: var(--accent);
}
.input-row {
  display: flex;
  gap: 8px;
}
.input-row .input {
  flex: 1;
}

/* === CARDS === */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  transition: background 0.2s;
}
.card:hover {
  background: var(--bg-card-hover);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* === PLAYER LIST === */
.player-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 8px 0;
}
.player-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.player-item .name {
  flex: 1;
  font-weight: 500;
}
.player-item .order-btns {
  display: flex;
  gap: 4px;
}
.player-item .number {
  width: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* === ROLE CONFIG === */
.role-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0;
}
.role-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.role-card.disabled {
  opacity: 0.4;
}
.role-card .role-icon {
  font-size: 1.5rem;
  width: 36px;
  text-align: center;
}
.role-card .role-info {
  flex: 1;
}
.role-card .role-name {
  font-weight: 600;
  font-size: 0.95rem;
}
.role-card .role-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.role-card .role-team {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}
.role-card .role-team.ww {
  background: var(--werewolf);
  color: #fff;
}
.role-card .role-team.village {
  background: var(--village);
  color: #fff;
}
.role-card .role-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}
.role-count {
  width: 28px;
  text-align: center;
  font-weight: 700;
  font-size: 1.1rem;
}

/* === TOGGLE SWITCH === */
.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.toggle:last-child {
  border-bottom: none;
}
.toggle-label {
  flex: 1;
}
.toggle-label .label {
  font-weight: 500;
  font-size: 0.95rem;
}
.toggle-label .desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.switch {
  position: relative;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch .slider {
  position: absolute;
  inset: 0;
  background: #555;
  border-radius: 28px;
  cursor: pointer;
  transition: 0.3s;
}
.switch .slider:before {
  content: '';
  position: absolute;
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.3s;
}
.switch input:checked + .slider {
  background: var(--accent);
}
.switch input:checked + .slider:before {
  transform: translateX(20px);
}

/* === SELECT === */
.select-wrap {
  display: flex;
  gap: 4px;
}
.select-option {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}
.select-option.active {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* === PLAYER GRID (for night/vote actions) === */
.player-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 12px 0;
}
.player-grid-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}
.player-grid-item:hover {
  background: var(--bg-card-hover);
}
.player-grid-item.selected {
  border-color: var(--accent);
  background: rgba(255, 215, 0, 0.1);
}
.player-grid-item.dead {
  opacity: 0.3;
  pointer-events: none;
  text-decoration: line-through;
}

/* === PRIVACY / SHIELD SCREEN === */
.shield-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  text-align: center;
  gap: 24px;
  padding: 32px;
}
.shield-screen .shield-icon {
  font-size: 4rem;
}
.shield-screen .shield-text {
  font-size: 1.5rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
}
.shield-screen .shield-sub {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* === CONFIRM IDENTITY === */
.confirm-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
  gap: 20px;
  padding: 32px;
}
.confirm-name {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
}

/* === ROLE REVEAL === */
.reveal-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
  gap: 16px;
  padding: 32px;
}
.reveal-icon {
  font-size: 5rem;
}
.reveal-role {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
}
.reveal-desc {
  color: var(--text-muted);
  font-size: 0.95rem;
  max-width: 320px;
  line-height: 1.5;
}
.reveal-extra {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 0.9rem;
  margin-top: 8px;
}

/* === NIGHT ACTION === */
.night-action {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px 0;
}
.night-action .role-header {
  text-align: center;
  margin-bottom: 8px;
}
.night-action .role-header .icon {
  font-size: 3rem;
}

/* === DAY ANNOUNCEMENT === */
.announcement {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
  gap: 16px;
  padding: 32px;
}
.announcement .narration {
  font-size: 1.1rem;
  line-height: 1.6;
  max-width: 360px;
  font-style: italic;
}
.death-card {
  background: var(--bg-card);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  margin: 6px 0;
}
.death-card .death-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--danger);
}

/* === DISCUSSION === */
.discussion {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
  gap: 20px;
  padding: 32px;
}
.timer-display {
  font-size: 4rem;
  font-weight: 700;
  font-family: 'Courier New', monospace;
  color: var(--accent);
}
.timer-display.warning {
  color: var(--danger);
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.discussion .starter-name {
  font-size: 1.2rem;
  font-weight: 600;
}

/* === VOTE RESULT === */
.vote-result {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
}
.vote-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-card);
  border-radius: var(--radius);
}
.vote-bar .vote-name {
  width: 80px;
  font-weight: 600;
  font-size: 0.9rem;
}
.vote-bar .vote-fill {
  flex: 1;
  height: 24px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.vote-bar .vote-fill-inner {
  height: 100%;
  background: var(--accent);
  transition: width 0.5s ease;
}
.vote-bar .vote-count {
  width: 30px;
  text-align: right;
  font-weight: 700;
}

/* === GAME OVER === */
.game-over {
  text-align: center;
  padding: 24px 16px;
}
.game-over .winner-banner {
  font-size: 2rem;
  font-weight: 700;
  margin: 16px 0;
  padding: 20px;
  border-radius: var(--radius);
}
.game-over .winner-banner.village {
  background: rgba(21, 101, 192, 0.2);
  color: #42a5f5;
}
.game-over .winner-banner.werewolf {
  background: rgba(139, 0, 0, 0.2);
  color: #ef5350;
}
.reveal-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 0.85rem;
}
.reveal-table th, .reveal-table td {
  padding: 8px 6px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.reveal-table th {
  font-weight: 600;
  color: var(--text-muted);
}
.reveal-table .dead-row {
  opacity: 0.5;
  text-decoration: line-through;
}

/* === LEADERBOARD === */
.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.leaderboard-table th, .leaderboard-table td {
  padding: 8px 6px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.leaderboard-table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.75rem;
}
.leaderboard-filters {
  display: flex;
  gap: 6px;
  margin: 12px 0;
}

/* === TABS === */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
}
.tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tab-content {
  display: none;
}
.tab-content.active {
  display: block;
}

/* === UTILITY === */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
.mt-auto { margin-top: auto; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.flex-col { display: flex; flex-direction: column; }
.flex-row { display: flex; flex-direction: row; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-1 { flex: 1; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* === VALIDATION === */
.validation-msg {
  font-size: 0.8rem;
  padding: 8px 12px;
  border-radius: 8px;
  margin: 4px 0;
}
.validation-msg.error {
  background: rgba(204, 0, 0, 0.15);
  color: #ff6b6b;
}
.validation-msg.warning {
  background: rgba(255, 215, 0, 0.15);
  color: #ffd700;
}
.validation-msg.success {
  background: rgba(46, 125, 50, 0.15);
  color: #66bb6a;
}

/* === NUMBER INPUT === */
.num-input {
  display: flex;
  align-items: center;
  gap: 2px;
}
.num-input .input {
  width: 48px;
  text-align: center;
  padding: 6px 4px;
  font-weight: 700;
}

/* === MUTE BUTTON (fixed) === */
.mute-btn {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 100;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mute-btn.muted {
  color: var(--danger);
}

/* === INSTALL BANNER (floating card) === */
.install-banner {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px 24px;
  width: calc(100% - 32px);
  max-width: 360px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  text-align: center;
  animation: slideUp 0.4s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.install-banner .install-title {
  font-size: 1rem;
  font-weight: 600;
}
.install-banner .install-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}
.install-banner-btns {
  display: flex;
  gap: 8px;
  width: 100%;
}
.install-banner-btns .btn {
  flex: 1;
}

/* Scrollable sections */
.scrollable {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Footer actions */
.screen-footer {
  padding: 16px 0;
  margin-top: auto;
}
