:root {
  --bg-color: #0b0f19;
  --card-bg: #161e2e;
  --card-border: #233044;
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.4);
  --accent: #ec4899;
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.4);
  --success: #10b981;
  --warning: #f59e0b;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: stretch;
  overflow-x: hidden;
}

.app-container {
  width: 100%;
  max-width: 500px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  position: relative;
}

/* Header */
.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--card-border);
  margin-bottom: 1rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo-icon {
  font-size: 1.6rem;
}

.logo-text {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 2px;
  background: linear-gradient(135deg, #a5b4fc, #ec4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
}

.icon-btn {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--text-main);
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.icon-btn:active {
  transform: scale(0.95);
  background: var(--card-border);
}

/* Screens */
.screen {
  display: none;
  flex-direction: column;
  gap: 1rem;
  animation: fadeIn 0.25s ease-out;
}

.screen.active {
  display: flex;
}

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

/* Cards */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 1.2rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.card h2, .card h3 {
  margin-bottom: 0.5rem;
  font-weight: 700;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.2rem;
}

/* Inputs & Form Elements */
.input-group {
  margin-bottom: 1rem;
  text-align: left;
}

.input-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
  font-weight: 600;
}

input[type="text"], select {
  width: 100%;
  padding: 0.8rem 1rem;
  background: #0f172a;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  color: #fff;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
  user-select: auto;
}

input[type="text"]:focus, select:focus {
  border-color: var(--primary);
}

/* Buttons */
.primary-btn {
  width: 100%;
  padding: 0.9rem;
  background: linear-gradient(135deg, var(--primary), #818cf8);
  border: none;
  border-radius: 12px;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px var(--primary-glow);
  transition: all 0.2s;
}

.primary-btn:active {
  transform: scale(0.98);
}

.secondary-btn {
  width: 100%;
  padding: 0.75rem;
  background: #1f293d;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.danger-btn {
  background: linear-gradient(135deg, var(--danger), #f87171);
  box-shadow: 0 4px 12px var(--danger-glow);
}

.danger-outline-btn {
  background: rgba(239, 68, 68, 0.12) !important;
  border: 1px solid rgba(239, 68, 68, 0.6) !important;
  color: #fca5a5 !important;
  transition: all 0.2s ease;
}

.danger-outline-btn:hover,
.danger-outline-btn:active {
  background: var(--danger) !important;
  color: #ffffff !important;
}

.glow-btn {
  box-shadow: 0 0 20px var(--primary-glow);
}

.pulse {
  animation: pulseAnim 2s infinite;
}

@keyframes pulseAnim {
  0%, 100% { box-shadow: 0 0 10px var(--primary-glow); }
  50% { box-shadow: 0 0 25px rgba(99, 102, 241, 0.8); }
}

/* Badges & Pills */
.badge {
  display: inline-block;
  background: #1e293b;
  border: 1px solid var(--card-border);
  padding: 0.3rem 0.6rem;
  border-radius: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.badge b {
  color: #fff;
}

.host-pill {
  background: var(--accent);
  color: #fff;
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 6px;
  vertical-align: middle;
}

/* Lobby */
.lobby-header-card {
  padding: 0.8rem;
}

.room-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.player-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.7rem;
  margin-top: 0.8rem;
}

.player-card {
  background: #0f172a;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 0.8rem;
  text-align: center;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}

.player-card.is-me {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.1);
}

.player-card.is-offline {
  opacity: 0.65;
  border-style: dashed;
}

.player-status-tag {
  font-size: 0.65rem;
  color: #94a3b8;
  background: rgba(148, 163, 184, 0.15);
  padding: 1px 5px;
  border-radius: 4px;
}

.kick-btn {
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid var(--danger);
  color: #fca5a5;
  font-size: 0.65rem;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 1;
}

.kick-btn:hover {
  background: var(--danger);
  color: #fff;
}

.make-host-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(245, 158, 11, 0.2);
  border: 1px solid var(--warning);
  color: #fbbf24;
  font-size: 0.7rem;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 1;
  transition: all 0.2s ease;
  z-index: 5;
}

.make-host-btn:hover {
  background: var(--warning);
  color: #0f172a;
  transform: scale(1.15);
}

.host-transfer-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
}

.host-transfer-row select {
  flex: 1;
  min-width: 0;
}

.host-transfer-row button {
  width: auto;
  white-space: nowrap;
  padding: 0.6rem 0.85rem;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.player-avatar {
  font-size: 2rem;
}

.player-name {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.player-score {
  font-size: 0.75rem;
  color: var(--warning);
}

.player-badge-host {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 0.65rem;
  background: var(--accent);
  color: #fff;
  padding: 1px 4px;
  border-radius: 4px;
}

/* Host Settings */
.setting-item {
  margin-bottom: 0.9rem;
}

.setting-item label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.toggle-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.toggle-item input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Secret Reveal Card */
.reveal-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  text-align: center;
}

.reveal-title {
  font-size: 1.4rem;
}

.reveal-hint {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.secret-card {
  background: linear-gradient(145deg, #1e293b, #0f172a);
  border: 2px dashed #374151;
  border-radius: 20px;
  padding: 2.5rem 1.5rem;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  transition: all 0.25s ease;
  position: relative;
}

.secret-card:active {
  transform: scale(0.98);
}

.secret-card.revealed {
  border: 2px solid var(--primary);
  background: linear-gradient(145deg, #1e1b4b, #0f172a);
  box-shadow: 0 0 30px var(--primary-glow);
}

.secret-card.is-impostor.revealed {
  border-color: var(--danger);
  background: linear-gradient(145deg, #450a0a, #0f172a);
  box-shadow: 0 0 30px var(--danger-glow);
}

.card-front {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
}

.lock-icon {
  font-size: 3rem;
}

.tap-label {
  font-size: 1rem;
  font-weight: 600;
  color: #cbd5e1;
}

.card-back {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.secret-card.revealed .card-front {
  display: none;
}

.secret-card.revealed .card-back {
  display: flex;
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}

.role-badge {
  padding: 0.3rem 0.9rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 1px;
  background: var(--success);
  color: #fff;
}

.secret-card.is-impostor .role-badge {
  background: var(--danger);
}

.secret-card.is-undercover .role-badge {
  background: #8b5cf6;
  color: #fff;
}

.secret-card.is-mrwhite .role-badge {
  background: #f1f5f9;
  color: #0f172a;
}

.role-pill {
  font-size: 0.72rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-weight: 700;
  display: inline-block;
  margin-left: 0.4rem;
}
.role-pill.civilian {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.4);
}
.role-pill.undercover {
  background: rgba(168, 85, 247, 0.2);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.4);
}
.role-pill.mr_white {
  background: rgba(241, 245, 249, 0.2);
  color: #f1f5f9;
  border: 1px solid rgba(241, 245, 249, 0.4);
}
.role-pill.impostor {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.secret-word-hidden {
  opacity: 0.7;
  font-style: italic;
  color: #94a3b8 !important;
}

.waiting-guess-card {
  text-align: center;
  border-color: #3b82f6;
  background: rgba(30, 58, 138, 0.25);
  padding: 1.2rem;
}

.secret-word-title {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 1px;
}

.secret-word-display {
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: 1px;
  color: #67e8f9;
  text-shadow: 0 0 15px rgba(103, 232, 249, 0.5);
}

.secret-card.is-impostor .secret-word-display {
  color: #f87171;
  text-shadow: 0 0 15px rgba(248, 113, 113, 0.6);
}

.category-hint {
  font-size: 0.9rem;
  color: var(--warning);
  font-weight: 600;
}

.role-desc {
  font-size: 0.85rem;
  color: #94a3b8;
  max-width: 280px;
}

/* Starter Card */
.starter-card {
  background: #1e1b4b;
  border-color: #3730a3;
  text-align: center;
  padding: 1rem;
}

.starter-label {
  font-size: 0.75rem;
  color: #a5b4fc;
  font-weight: 800;
  letter-spacing: 1px;
}

.starter-name {
  font-size: 1.3rem;
  font-weight: 800;
  color: #fff;
  margin: 0.3rem 0;
}

.starter-sub {
  font-size: 0.8rem;
  color: #c7d2fe;
}

/* Discussion */
.timer-card {
  text-align: center;
  padding: 1.5rem 1rem;
}

.timer-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.timer-digits {
  font-size: 3.5rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: #fff;
  margin: 0.5rem 0;
}

.timer-bar-wrapper {
  width: 100%;
  height: 8px;
  background: #1e293b;
  border-radius: 4px;
  overflow: hidden;
}

.timer-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  width: 100%;
  transition: width 1s linear;
}

.info-banner {
  font-size: 0.9rem;
  line-height: 1.4;
  border-left: 4px solid var(--primary);
}

.starter-reminder {
  text-align: center;
  font-size: 0.95rem;
  color: #cbd5e1;
}

/* Voting Grid */
.vote-title {
  text-align: center;
  font-size: 1.3rem;
}

.vote-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 0.8rem;
}

.voting-grid {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.vote-btn {
  background: #1e293b;
  border: 2px solid var(--card-border);
  border-radius: 14px;
  padding: 1rem 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  transition: all 0.2s;
}

.vote-btn:active {
  transform: scale(0.97);
  border-color: var(--primary);
}

.vote-btn.selected {
  border-color: var(--accent);
  background: rgba(236, 72, 153, 0.15);
}

.vote-player-info {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.vote-avatar {
  font-size: 1.8rem;
}

.confirmed-vote-card {
  text-align: center;
  margin-top: 1rem;
  background: rgba(16, 185, 129, 0.1);
  border-color: var(--success);
}

.check-icon {
  font-size: 2.2rem;
  margin-bottom: 0.3rem;
}

/* Results */
.result-banner {
  text-align: center;
  padding: 1.5rem 1rem;
  border-radius: 16px;
  background: linear-gradient(135deg, #065f46, #047857);
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.3);
}

.result-banner.impostor-won {
  background: linear-gradient(135deg, #991b1b, #b91c1c);
  box-shadow: 0 4px 20px rgba(239, 68, 68, 0.4);
}

.result-title {
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: 1px;
}

.result-subtitle {
  font-size: 0.95rem;
  opacity: 0.9;
  margin-top: 0.3rem;
}

.reveal-truth-card {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.truth-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.truth-label {
  color: var(--text-muted);
  font-weight: 600;
}

.truth-val {
  font-weight: 800;
  font-size: 1.15rem;
}

.impostor-text {
  color: #f87171;
}

.word-text {
  color: #67e8f9;
}

.undercover-text {
  color: #f472b6;
}

/* Guess Box */
.guess-box {
  background: #31135e;
  border-color: #6d28d9;
}

.guess-box h4 {
  color: #c084fc;
  margin-bottom: 0.3rem;
}

.guess-box p {
  font-size: 0.85rem;
  color: #e9d5ff;
  margin-bottom: 0.8rem;
}

.guess-input-group {
  display: flex;
  gap: 0.5rem;
}

.guess-result-card {
  text-align: center;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 1rem;
}

/* Lists */
.vote-results-list, .leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.8rem;
  background: #0f172a;
  border-radius: 8px;
  font-size: 0.9rem;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem;
  z-index: 100;
}

.modal-content {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 1.5rem;
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.qr-wrapper {
  margin: 1rem auto;
  padding: 0.5rem;
  background: #111827;
  border-radius: 12px;
  display: inline-block;
}

.qr-wrapper img {
  max-width: 220px;
  height: auto;
  display: block;
}

.join-url {
  font-family: monospace;
  background: #0f172a;
  padding: 0.5rem;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  word-break: break-all;
}

/* Utility */
.lobby-settings-preview {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: rgba(15, 23, 42, 0.6);
  padding: 0.8rem;
  border-radius: 12px;
  border: 1px dashed rgba(255, 255, 255, 0.15);
  text-align: left;
  font-size: 0.85rem;
}

.lobby-preview-badge {
  color: #cbd5e1;
}

.hidden {
  display: none !important;
}

.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0.8rem auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.toast {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  border: 1px solid var(--primary);
  color: #fff;
  padding: 0.6rem 1.2rem;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 200;
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
  animation: fadeIn 0.2s ease-out;
}

/* Lobby erstellen / beitreten */
.invite-banner {
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid var(--primary);
  border-radius: 12px;
  padding: 0.7rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  text-align: center;
}

.divider {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 1.2rem 0 0.8rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--card-border);
}

.code-join-row {
  display: flex;
  gap: 0.5rem;
}

.code-join-row input {
  flex: 1;
  min-width: 0;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-weight: 700;
  text-align: center;
}

.code-join-row .secondary-btn {
  width: auto;
  white-space: nowrap;
}

.link-btn {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-decoration: underline;
  padding: 0.4rem;
  cursor: pointer;
}
