/* Base styling configuration - Minimal Dark Premium Theme */
:root {
  --bg-app: #0c0d0f;
  --bg-card: #141619;
  --border-card: #25282e;
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #4b5563;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --accent-amber: #f59e0b;
  --accent-blue: #3b82f6;
  
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;
  
  --transition-smooth: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-sans);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.app-container {
  width: 100%;
  max-width: 740px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 24px 20px;
  position: relative;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.logo {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-accent {
  color: var(--accent-green);
  font-family: var(--font-mono);
}

.live-badge {
  font-size: 0.65rem;
  font-weight: 800;
  background-color: rgba(239, 68, 68, 0.15);
  color: var(--accent-red);
  border: 1px solid var(--accent-red);
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.05em;
}

.header-stats {
  display: flex;
  gap: 12px;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-card);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 500;
}

.timer-alert {
  border-color: rgba(245, 158, 11, 0.3);
}

/* LIVE ROAST TICKER OVERLAY */
.roast-ticker-overlay {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  background-color: rgba(239, 68, 68, 0.95);
  color: #fff;
  padding: 10px 24px;
  border-radius: 99px;
  box-shadow: 0 10px 30px rgba(239, 68, 68, 0.4);
  animation: slideDown 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes slideDown {
  from { opacity: 0; transform: translate(-50%, -20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.roast-ticker-content {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  font-weight: 700;
}

/* Main workspace panel views */
.main-content {
  flex-grow: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

.view-panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: fadeIn 0.3s ease-out;
}

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

/* Cards Base */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 16px;
  width: 100%;
  padding: 28px 32px;
  box-shadow: 0 10px 40px -15px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.card.shake {
  animation: shake 0.35s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* SETUP CARD & MULTIPLAYER CONTROLS */
.setup-header h2 {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.setup-header p {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.setup-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

#candidate-name {
  background-color: var(--bg-app);
  border: 1px solid var(--border-card);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.95rem;
  color: var(--text-primary);
  outline: none;
  font-family: var(--font-sans);
}

/* Photo Upload Box Styling */
.photo-upload-container {
  background-color: var(--bg-app);
  border: 1px dashed var(--border-card);
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
}

.photo-preview-box {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #1e222a;
  border: 1px solid #374151;
  display: flex;
  justify-content: center;
  align-items: center;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
}

.upload-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}

.upload-sub {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

/* Mode select switcher */
.mode-select-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mode-tab {
  background-color: var(--bg-app);
  border: 1px solid var(--border-card);
  color: var(--text-secondary);
  padding: 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.mode-tab.active {
  border-color: var(--accent-blue);
  color: var(--text-primary);
  background-color: rgba(59, 130, 246, 0.08);
}

/* Multiplayer Room Controls Box */
.multiplayer-box {
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-card);
  padding: 16px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.room-action-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.join-room-group {
  display: flex;
  gap: 6px;
  flex-grow: 1;
}

#join-room-code {
  background-color: var(--bg-app);
  border: 1px solid var(--border-card);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--text-primary);
  font-family: var(--font-mono);
  width: 100%;
}

.room-lobby-box {
  background-color: var(--bg-app);
  border: 1px solid var(--border-card);
  padding: 12px 14px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lobby-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lobby-title {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.room-code-badge {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--accent-green);
  background-color: rgba(16, 185, 129, 0.1);
  padding: 2px 8px;
  border-radius: 4px;
}

.copy-code-btn {
  background: none;
  border: none;
  color: var(--accent-blue);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  margin-left: auto;
}

.lobby-players {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.players-label {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.players-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.player-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background-color: #1e222a;
  border: 1px solid var(--border-card);
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
}

.player-chip.is-host::after {
  content: 'HOST';
  font-size: 0.6rem;
  background-color: var(--accent-amber);
  color: #000;
  padding: 1px 4px;
  border-radius: 3px;
  margin-left: 4px;
}

.tier-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.tier-card {
  background-color: var(--bg-app);
  border: 1px solid var(--border-card);
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.tier-card h3 {
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.tier-card p {
  font-size: 0.68rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

.tier-card.active {
  border-color: var(--accent-green);
  background-color: rgba(16, 185, 129, 0.05);
}

/* LIVE TEAMMATES HUD */
.teammates-hud {
  width: 100%;
  background-color: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hud-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.teammates-progress-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.teammate-progress-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tm-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 600;
}

.tm-bar-outer {
  background-color: #1e222a;
  height: 6px;
  border-radius: 99px;
  overflow: hidden;
}

.tm-bar-inner {
  height: 100%;
  background-color: var(--accent-green);
  width: 0%;
  transition: width 0.3s ease;
}

/* ACTIVE ASSESSMENT CARD */
.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.category-badge {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  background-color: rgba(255, 255, 255, 0.05);
  padding: 4px 10px;
  border-radius: 6px;
}

.test-indicators {
  display: flex;
  align-items: center;
  gap: 16px;
}

.strike-count {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-amber);
  font-family: var(--font-mono);
}

.progress-text {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.card-prompt {
  font-size: 1.15rem;
  font-weight: 500;
  line-height: 1.6;
}

.typing-container {
  position: relative;
  min-height: 52px;
  border-bottom: 2px solid var(--border-card);
  padding-bottom: 10px;
  display: flex;
  align-items: center;
  cursor: text;
}

#keyboard-gate {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  z-index: 1;
}

.char-display-line {
  font-family: var(--font-mono);
  font-size: 1.3rem;
  font-weight: 500;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  pointer-events: none;
  white-space: pre-wrap;
  word-break: break-all;
  width: 100%;
}

.char {
  position: relative;
  height: 1.8rem;
  display: inline-flex;
  align-items: center;
}

.char.caret::before {
  content: '';
  position: absolute;
  left: 0;
  bottom: 2px;
  width: 2px;
  height: 1.2rem;
  background-color: var(--accent-green);
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  from, to { background-color: transparent }
  50% { background-color: var(--accent-green) }
}

.char.correct {
  color: var(--text-primary);
}

.char.incorrect {
  color: var(--accent-red);
  text-decoration: underline wavy var(--accent-red);
}

.char.placeholder {
  color: var(--text-muted);
}

.card-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid rgba(255, 255, 255, 0.03);
  padding-top: 16px;
}

.helper-text {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.key-indicator {
  font-family: var(--font-mono);
  background-color: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-card);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.7rem;
}

/* LEADERBOARD SHOWDOWN STYLING */
.showdown-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.showdown-header {
  text-align: center;
}

.showdown-header h2 {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.showdown-header p {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.leaderboard-card {
  width: 100%;
  background-color: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 14px;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.leaderboard-card h3 {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.standings-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.standing-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--bg-app);
  border: 1px solid var(--border-card);
  padding: 10px 16px;
  border-radius: 8px;
}

.st-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.rank-badge {
  font-weight: 800;
  font-size: 0.9rem;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #1e222a;
}

.rank-1 { background-color: var(--accent-amber); color: #000; }
.rank-2 { background-color: #94a3b8; color: #000; }
.rank-3 { background-color: #b45309; color: #fff; }

.st-name {
  font-weight: 700;
  font-size: 0.9rem;
}

.st-right {
  display: flex;
  gap: 16px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
}

/* BRUTAL MEME CARD SECTION */
.meme-section {
  width: 100%;
  background-color: #101215;
  border: 1px solid var(--border-card);
  border-radius: 16px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.meme-card-header {
  text-align: center;
}

.meme-card-header h3 {
  font-size: 1.25rem;
  font-weight: 800;
}

.meme-card-header p {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.canvas-wrapper {
  max-width: 100%;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.6);
  background-color: #050505;
  border: 1px solid var(--border-card);
}

#meme-canvas {
  width: 100%;
  height: auto;
  max-width: 500px;
  display: block;
}

.meme-actions {
  width: 100%;
  display: flex;
  justify-content: center;
}

.meme-dl-btn {
  background-color: var(--accent-amber);
  color: #000;
  font-weight: 700;
}

.meme-dl-btn:hover {
  background-color: #f59e0b;
  opacity: 0.95;
}

.action-buttons {
  margin-top: 12px;
  display: flex;
  gap: 12px;
  width: 100%;
  justify-content: center;
}

/* Common Buttons */
.primary-btn {
  background-color: var(--text-primary);
  color: var(--bg-app);
  border: none;
  border-radius: 8px;
  padding: 12px 24px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.primary-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.secondary-btn {
  background-color: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-card);
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.secondary-btn:hover {
  background-color: rgba(255, 255, 255, 0.03);
  border-color: var(--text-secondary);
}

.text-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.text-btn:hover {
  color: var(--text-primary);
}

.wide-btn {
  width: 100%;
}

.progress-bar-container {
  width: 100%;
  height: 4px;
  background-color: #1e222a;
  border-radius: 99px;
  overflow: hidden;
  margin-top: 20px;
}

.progress-bar {
  height: 100%;
  background-color: var(--accent-green);
  width: 0%;
  transition: width 0.3s ease;
}

.hidden {
  display: none !important;
}
