/* =========================================================
   Smashi.app — Design System & Styles
   ========================================================= */

:root {
  --bg-dark: #090b10;
  --bg-card: rgba(18, 23, 34, 0.75);
  --bg-card-solid: #121722;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.16);
  
  --flame-primary: #ff4d3b;
  --flame-gradient: linear-gradient(135deg, #ff4d3b 0%, #ff7847 50%, #ff9f43 100%);
  --violet-gradient: linear-gradient(135deg, #8a5cf6 0%, #d946ef 100%);
  
  --color-smash: #10b981;
  --color-smash-glow: rgba(16, 185, 129, 0.35);
  --color-pass: #ef4444;
  --color-pass-glow: rgba(239, 68, 68, 0.35);
  --color-accent: #ff5722;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --shadow-card: 0 20px 40px -15px rgba(0, 0, 0, 0.5);
  --shadow-neon: 0 0 25px rgba(255, 77, 59, 0.4);
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Ambient glow backgrounds */
.ambient-glow {
  position: fixed;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.18;
}
.glow-1 {
  top: -100px;
  right: -100px;
  background: radial-gradient(circle, #ff4d3b, #d946ef);
}
.glow-2 {
  bottom: -150px;
  left: -150px;
  background: radial-gradient(circle, #6366f1, #06b6d4);
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(16px);
  background: rgba(9, 11, 16, 0.7);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 20px;
}

.header-container {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.brand-icon {
  font-size: 24px;
  animation: flame-pulse 2s infinite ease-in-out;
}

.brand-name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #fff;
}

.brand-dot {
  color: var(--flame-primary);
}

.icon-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 18px;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* Main Layout & Views */
.app-main {
  flex: 1;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 16px 40px;
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
}

.view {
  display: none;
  width: 100%;
  animation: fadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.view.active {
  display: flex;
  flex-direction: column;
}

/* Reusable Glass Card */
.card-glass {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
}

/* Typography & Hero */
.hero-section {
  text-align: center;
  margin-bottom: 24px;
  padding: 10px 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(255, 77, 59, 0.12);
  border: 1px solid rgba(255, 77, 59, 0.3);
  color: #ff7847;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: 20px;
  margin-bottom: 14px;
}

.badge-accent {
  background: rgba(138, 92, 246, 0.15);
  border-color: rgba(138, 92, 246, 0.35);
  color: #c084fc;
}

.hero-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 32px;
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 12px;
}

.gradient-text {
  background: var(--flame-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-muted);
  max-width: 440px;
  margin: 0 auto;
}

/* Mode Selector Tabs */
.mode-tabs {
  display: flex;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  padding: 4px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
}

.mode-tab {
  flex: 1;
  padding: 12px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 600;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-tab.active {
  background: var(--flame-gradient);
  color: #fff;
  box-shadow: 0 4px 15px rgba(255, 77, 59, 0.3);
}

.tab-pane {
  display: none;
}
.tab-pane.active {
  display: block;
}

/* Forms */
.form-group {
  margin-bottom: 20px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

input[type="text"] {
  width: 100%;
  padding: 14px 16px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: all 0.2s ease;
}

input[type="text"]:focus {
  border-color: var(--flame-primary);
  box-shadow: 0 0 0 3px rgba(255, 77, 59, 0.2);
}

.input-code {
  font-family: 'Space Grotesk', monospace;
  font-size: 28px !important;
  font-weight: 800;
  letter-spacing: 8px;
  text-align: center;
  text-transform: uppercase;
}

/* Deck Grid */
.deck-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.deck-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.deck-card:hover {
  border-color: var(--border-hover);
  background: rgba(255, 255, 255, 0.06);
}

.deck-card.selected {
  border-color: var(--flame-primary);
  background: rgba(255, 77, 59, 0.08);
  box-shadow: 0 0 15px rgba(255, 77, 59, 0.2);
}

.deck-icon {
  font-size: 26px;
}

.deck-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.deck-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
}

/* Custom Deck Area */
.custom-deck-area {
  margin-top: 15px;
  margin-bottom: 20px;
  padding: 14px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-color);
}
.custom-deck-area.hidden {
  display: none;
}
.custom-items-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

/* Buttons */
.btn-primary {
  width: 100%;
  padding: 16px;
  background: var(--flame-gradient);
  border: none;
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  box-shadow: var(--shadow-neon);
}

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

.btn-secondary {
  flex: 1;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-ghost {
  padding: 10px 14px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-ghost:hover {
  color: var(--text-main);
  border-color: var(--border-hover);
}

.btn-ghost-sm {
  background: transparent;
  border: none;
  color: var(--flame-primary);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  padding: 6px 0;
}

/* LOBBY VIEW */
.lobby-card {
  text-align: center;
}

.lobby-header {
  margin-bottom: 20px;
}

.lobby-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 26px;
  font-weight: 800;
  margin-top: 10px;
  margin-bottom: 12px;
}

.room-code-box {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.4);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.room-code-label {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 600;
}

.room-code-display {
  font-family: 'Space Grotesk', monospace;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 4px;
  color: #ff9f43;
}

.share-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.qr-container {
  margin-bottom: 24px;
  padding: 16px;
  background: #fff;
  border-radius: var(--radius-md);
  display: inline-block;
}

.qr-container.hidden {
  display: none;
}

.qr-hint {
  color: #111;
  font-size: 12px;
  font-weight: 600;
  margin-top: 8px;
}

.roster-section {
  text-align: left;
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 24px;
  border: 1px solid var(--border-color);
}

.roster-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.pulse-indicator {
  width: 8px;
  height: 8px;
  background-color: var(--color-smash);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--color-smash);
  animation: pulse 1.5s infinite;
}

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

.participant-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
}

.participant-badge.is-host {
  border: 1px solid rgba(255, 159, 67, 0.5);
  background: rgba(255, 159, 67, 0.1);
}

.waiting-msg {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 15px;
  padding: 16px;
}
.waiting-msg.hidden {
  display: none;
}

/* SWIPE ARENA */
.swipe-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.swipe-top-bar {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding: 0 4px;
}

.deck-tag, .room-pill {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 4px 10px;
  border-radius: 12px;
}

.progress-pill {
  font-size: 14px;
  font-weight: 700;
  color: #ff9f43;
}

/* Card Deck Stack */
.card-deck-wrapper {
  position: relative;
  width: 100%;
  max-width: 380px;
  height: 480px;
  perspective: 1000px;
  margin-bottom: 24px;
}

.card-deck {
  position: relative;
  width: 100%;
  height: 100%;
}

.swipe-card {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-card-solid);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  user-select: none;
  touch-action: none;
  cursor: grab;
  transform-origin: 50% 100%;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
  display: flex;
  flex-direction: column;
}

.swipe-card:active {
  cursor: grabbing;
}

.card-image-box {
  position: relative;
  width: 100%;
  height: 60%;
  background: #000;
  overflow: hidden;
}

.card-image-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.card-gradient-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(to top, var(--bg-card-solid) 0%, transparent 100%);
}

.card-body {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex: 1;
}

.card-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
  line-height: 1.2;
}

.card-subtitle {
  font-size: 13px;
  font-weight: 600;
  color: #ff9f43;
  margin-bottom: 8px;
}

.card-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-pill {
  font-size: 11px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.08);
  padding: 3px 8px;
  border-radius: 10px;
  color: var(--text-muted);
}

/* Stamps (Smash & Pass) */
.card-stamp {
  position: absolute;
  top: 30px;
  padding: 8px 16px;
  border: 4px solid;
  border-radius: 12px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 2px;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
  z-index: 20;
  transition: opacity 0.1s ease;
}

.stamp-smash {
  right: 25px;
  color: var(--color-smash);
  border-color: var(--color-smash);
  transform: rotate(15deg);
}

.stamp-pass {
  left: 25px;
  color: var(--color-pass);
  border-color: var(--color-pass);
  transform: rotate(-15deg);
}

/* Controls */
.swipe-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  width: 100%;
}

.control-btn {
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  user-select: none;
}

.control-btn:active {
  transform: scale(0.92);
}

.btn-pass {
  width: 72px;
  height: 72px;
  background: rgba(239, 68, 68, 0.12);
  border: 2px solid rgba(239, 68, 68, 0.4);
  color: #ef4444;
}
.btn-pass:hover {
  background: rgba(239, 68, 68, 0.2);
  box-shadow: 0 0 25px var(--color-pass-glow);
}

.btn-smash {
  width: 72px;
  height: 72px;
  background: var(--flame-gradient);
  color: #fff;
  box-shadow: var(--shadow-neon);
}
.btn-smash:hover {
  transform: scale(1.05);
  box-shadow: 0 0 35px rgba(255, 77, 59, 0.6);
}

.btn-undo {
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
}
.btn-undo:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-main);
}

.control-icon {
  font-size: 26px;
}
.control-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.keyboard-hint {
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
}

/* MATCH CELEBRATION */
.match-card {
  text-align: center;
}

.match-badge {
  display: inline-block;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 18px;
  font-weight: 800;
  padding: 8px 18px;
  border-radius: 30px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  box-shadow: 0 0 25px var(--color-smash-glow);
  margin-bottom: 12px;
}

.match-headline {
  font-size: 20px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 24px;
}

.winning-card-preview {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(16, 185, 129, 0.4);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 24px;
  box-shadow: 0 10px 30px rgba(16, 185, 129, 0.2);
}

.winner-image-container {
  position: relative;
  width: 100%;
  height: 240px;
}

.winner-image-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.winner-overlay {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.winner-trophy {
  font-size: 22px;
}

.winner-info {
  padding: 20px;
  text-align: left;
}

.winner-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 24px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 4px;
}

.winner-subtitle {
  font-size: 14px;
  font-weight: 600;
  color: #ff9f43;
  margin-bottom: 10px;
}

.winner-desc {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 14px;
}

.winner-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.match-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* LEADERBOARD VIEW */
.consensus-header {
  text-align: center;
  margin-bottom: 20px;
}

.consensus-header h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 26px;
  margin-top: 8px;
  margin-bottom: 6px;
}

.consensus-header p {
  color: var(--text-muted);
  font-size: 14px;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  padding: 12px 16px;
  border-radius: var(--radius-md);
}

.rank-badge {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 18px;
  font-weight: 800;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
}

.rank-1 {
  background: var(--flame-gradient);
  color: #fff;
}

.leaderboard-thumb {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

.leaderboard-details {
  flex: 1;
}

.leaderboard-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}

.leaderboard-score {
  font-size: 13px;
  color: var(--color-smash);
  font-weight: 600;
}

/* Toast notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: rgba(18, 23, 34, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-hover);
  color: #fff;
  padding: 12px 20px;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  animation: toastIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(20px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes flame-pulse {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 5px rgba(255, 77, 59, 0.6)); }
  50% { transform: scale(1.1); filter: drop-shadow(0 0 12px rgba(255, 77, 59, 0.9)); }
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.7; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.7; }
}

/* Responsive adjustments */
@media (max-width: 480px) {
  .hero-title {
    font-size: 26px;
  }
  .card-deck-wrapper {
    height: 440px;
  }
  .swipe-card {
    height: 440px;
  }
}
