/* DESIGN SYSTEM MOBILE-FIRST: CARDS PLAYTEST ADULT GAME */
:root {
  --bg-main: #0a0b0e;
  --bg-surface: #14161d;
  --bg-card: #1c1f2b;
  --bg-glass: rgba(28, 31, 43, 0.75);
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;

  --accent-gold: #f59e0b;
  --accent-crimson: #e11d48;
  --accent-ruby: #ef4444;
  --accent-purple: #8b5cf6;
  --accent-emerald: #10b981;

  /* Temi Mazzi */
  --deck-scintilla: #f59e0b;
  --deck-tentazione: #eab308;
  --deck-desiderio: #ef4444;
  --deck-senzafreni: #a855f7;
  --deck-finale: #ec4899;
  --deck-afterdark: #6366f1;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  overscroll-behavior-y: none;
}

/* Layout App Shell */
#app-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  max-width: 500px;
  margin: 0 auto;
  position: relative;
  background: radial-gradient(circle at 50% 10%, #1e1b2e 0%, var(--bg-main) 70%);
}

.screen {
  display: flex;
  flex-direction: column;
  flex: 1;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(var(--safe-top) + 12px) 16px calc(var(--safe-bottom) + 16px) 16px;
}

.hidden {
  display: none !important;
}

/* Tipografia */
h1, h2, h3, .serif-title {
  font-family: 'Cinzel', serif, Georgia;
  letter-spacing: 0.05em;
  font-weight: 700;
}

/* HEADER DI GIOCO */
.game-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 0 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.header-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge.user-lui {
  background: rgba(59, 130, 246, 0.18);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.4);
}

.badge.user-lei {
  background: rgba(236, 72, 153, 0.18);
  color: #f472b6;
  border: 1px solid rgba(236, 72, 153, 0.4);
}

.header-controls {
  display: flex;
  gap: 8px;
}

.btn-icon {
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-main);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.header-stats-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.03);
  padding: 6px 12px;
  border-radius: 8px;
}

.fire-counter {
  font-size: 1.15rem;
  font-weight: 800;
  color: #fbbf24;
  text-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}

.next-unlock {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* MANO DEL PARTNER (In Alto) */
.partner-area {
  padding: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.partner-status-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.partner-cards-row {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.card-back-mini {
  width: 44px;
  height: 60px;
  background: linear-gradient(135deg, #1e1b4b, #0f172a);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

.card-back-mini.turn-glow {
  border-color: var(--accent-gold);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.4);
}

/* CENTRO TAVOLO (Main Game Area) */
.center-table-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 0;
  min-height: 240px;
}

.table-prompt {
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 24px 20px;
  text-align: center;
  width: 100%;
}

.table-prompt.highlight {
  border-color: rgba(245, 158, 11, 0.4);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.08) 0%, var(--bg-surface) 100%);
}

.prompt-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.active-card-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.card-played-banner {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* COMPONENTE CARTA */
.card {
  width: 100%;
  border-radius: 16px;
  background: var(--bg-card);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card.compact {
  min-height: 195px;
}

.card.full {
  min-height: 220px;
}

.card-scintilla {
  border-color: rgba(245, 158, 11, 0.45);
  background: linear-gradient(160deg, #1e1915 0%, var(--bg-card) 60%);
}
.card-tentazione {
  border-color: rgba(234, 179, 8, 0.55);
  background: linear-gradient(160deg, #221e10 0%, var(--bg-card) 60%);
}
.card-desiderio {
  border-color: rgba(239, 68, 68, 0.55);
  background: linear-gradient(160deg, #281116 0%, var(--bg-card) 60%);
}
.card-senza_freni {
  border-color: rgba(168, 85, 247, 0.6);
  background: linear-gradient(160deg, #21122a 0%, var(--bg-card) 60%);
}
.card-finale {
  border-color: rgba(236, 72, 153, 0.7);
  background: linear-gradient(160deg, #290f23 0%, var(--bg-card) 60%);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.card-level-badge {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.card-fire-badge {
  font-size: 0.95rem;
}

.card-body {
  padding: 12px 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.card-title {
  font-size: 1.2rem;
  margin-bottom: 6px;
  color: #fff;
  font-weight: 700;
}

.card.compact .card-title {
  font-size: 1.08rem;
  margin-bottom: 6px;
}

.card-desc {
  font-size: 0.92rem;
  line-height: 1.4;
  color: #e5e7eb;
}

.card.compact .card-desc {
  font-size: 0.85rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 14px;
  background: rgba(0, 0, 0, 0.2);
}

.card-category-tag {
  font-size: 0.68rem;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.badge-rilancio {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
  font-size: 0.7rem;
}

.badge-oradopo {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.4);
  font-size: 0.7rem;
}

/* AZIONI RISOLUZIONE AL CENTRO */
.card-action-box {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 12px;
  border-radius: 12px;
  text-align: center;
}

.action-buttons-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.resolve-buttons-row {
  width: 100%;
}

.rilancio-box {
  width: 100%;
  margin-top: 6px;
}

.draw-picker-box {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 14px;
  border-radius: 14px;
  text-align: center;
}

.deck-picker-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

/* PROMESSE */
.promises-box {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 6px 0;
}

.promises-box h4 {
  font-size: 0.8rem;
  color: #93c5fd;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.promises-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.promise-item {
  background: var(--bg-surface);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.82rem;
}

.promise-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.promise-desc {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.promise-actions {
  display: flex;
  gap: 6px;
}

/* MANO DEL GIOCATORE (Bottom Dock) */
.player-dock-area {
  margin-top: auto;
  padding: 10px 0 calc(var(--safe-bottom) + 6px) 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: linear-gradient(0deg, var(--bg-main) 60%, transparent 100%);
}

.player-dock-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.hand-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.hand-cards-grid {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  gap: 12px;
  padding: 6px 4px 10px 4px;
}

.hand-cards-grid::-webkit-scrollbar {
  display: none;
}

.hand-card-wrapper {
  flex: 0 0 80%;
  max-width: 290px;
  scroll-snap-align: center;
  cursor: pointer;
  transition: transform 0.2s ease, filter 0.2s ease;
}

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

.hand-card-wrapper.selected .card {
  box-shadow: 0 0 20px var(--accent-gold);
  border-color: #fff;
}

.tap-to-open-hint {
  font-size: 0.72rem;
  color: var(--accent-gold);
  text-align: center;
  margin-top: 4px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

/* TIMER DELLA CARTA AL CENTRO TAVOLO */
.table-card-timer-box {
  width: 100%;
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.12) 0%, rgba(20, 22, 29, 0.95) 100%);
  border: 1.5px solid rgba(245, 158, 11, 0.4);
  border-radius: 14px;
  padding: 14px;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.table-timer-header {
  display: flex;
  justify-content: space-between;
  width: 100%;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.table-timer-display {
  font-family: 'Cinzel', monospace;
  font-size: 2.8rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 0 12px rgba(245, 158, 11, 0.6);
  line-height: 1;
}

.phase-indicator-pill {
  background: rgba(245, 158, 11, 0.2);
  border: 1px solid var(--accent-gold);
  color: #fde047;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
  animation: pulse-glow 1.5s infinite;
}

.table-timer-controls {
  display: flex;
  gap: 8px;
  width: 100%;
  margin-top: 4px;
}

.table-timer-controls .btn {
  flex: 1;
  padding: 10px 8px;
}

/* MODAL ANTEPRIMA CARTA INGRANDITA */
.modal-card-preview {
  max-width: 440px;
  width: 95%;
}

.preview-badge {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-gold);
  letter-spacing: 0.08em;
}

.card-preview-container .card {
  min-height: 280px;
  border-width: 2px;
}

.card-preview-container .card-title {
  font-size: 1.4rem;
  margin-bottom: 10px;
}

.card-preview-container .card-desc {
  font-size: 1.05rem;
  line-height: 1.5;
  color: #f3f4f6;
}

.card-preview-actions {
  display: flex;
  flex-direction: column;
  margin-top: 14px;
}

/* PULSANTI */
.btn {
  border: none;
  border-radius: 10px;
  font-weight: 600;
  padding: 10px 14px;
  font-size: 0.88rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-primary {
  background: linear-gradient(135deg, #e11d48, #be123c);
  color: #fff;
  box-shadow: 0 4px 12px rgba(225, 29, 72, 0.4);
}

.btn-secondary {
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-main);
}

.btn-accent {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
}

.btn-large {
  width: 100%;
  padding: 14px;
  font-size: 1rem;
}

.btn-sm {
  padding: 4px 8px;
  font-size: 0.75rem;
}

.btn-deck {
  padding: 10px 8px;
  font-size: 0.82rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: var(--bg-surface);
  color: #fff;
}

.btn-deck-scintilla { border-color: var(--deck-scintilla); }
.btn-deck-tentazione { border-color: var(--deck-tentazione); }
.btn-deck-desiderio { border-color: var(--deck-desiderio); }
.btn-deck-senza_freni { border-color: var(--deck-senzafreni); }
.btn-deck-finale { border-color: var(--deck-finale); }

.btn.disabled, .btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

/* SCHERMATA LOGIN */
.login-box {
  margin: auto 0;
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 24px 20px;
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  text-align: center;
}

.login-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 18px;
}

.input-field {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 12px 14px;
  color: #fff;
  font-size: 0.95rem;
  outline: none;
}

.input-field:focus {
  border-color: var(--accent-gold);
}

.login-quick-hints {
  margin-top: 16px;
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* SCHERMATA LIMITI */
.limits-header {
  margin-bottom: 16px;
  text-align: center;
}

.limits-list-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.limit-row {
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.limit-label {
  font-size: 0.88rem;
  font-weight: 600;
}

.limit-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.limit-btn {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 6px 0;
  font-size: 0.78rem;
  cursor: pointer;
}

.limit-btn.selected.yes {
  background: rgba(16, 185, 129, 0.2);
  border-color: var(--accent-emerald);
  color: #34d399;
}

.limit-btn.selected.depends {
  background: rgba(234, 179, 8, 0.2);
  border-color: #eab308;
  color: #fde047;
}

.limit-btn.selected.no {
  background: rgba(239, 68, 68, 0.25);
  border-color: var(--accent-ruby);
  color: #f87171;
}

/* MODAL OVERLAYS */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-content {
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 18px;
  width: 100%;
  max-width: 440px;
  max-height: 90dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 18px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.btn-close {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  color: var(--text-muted);
  cursor: pointer;
}

/* AFTER DARK MODAL & TIMER */
.afterdark-card-box {
  background: linear-gradient(160deg, #1b1633 0%, #121020 100%);
  border: 1px solid rgba(99, 102, 241, 0.4);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
}

.ad-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0;
  background: rgba(0, 0, 0, 0.25);
  padding: 10px;
  border-radius: 8px;
  font-size: 0.82rem;
}

.ad-meta-item strong {
  display: block;
  font-size: 0.72rem;
  color: #a5b4fc;
  text-transform: uppercase;
}

.timer-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 14px 0;
}

.timer-display {
  font-family: 'Cinzel', monospace;
  font-size: 3.2rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.05em;
  text-shadow: 0 0 15px rgba(245, 158, 11, 0.5);
}

.timer-bar-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 8px;
}

.timer-bar-progress {
  height: 100%;
  width: 100%;
  background: var(--accent-gold);
  transition: width 0.25s linear, background-color 0.3s ease;
}

.afterdark-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

/* ANIMAZIONI */
.pulse {
  animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
  0% { transform: scale(1); opacity: 0.95; }
  50% { transform: scale(1.02); opacity: 1; }
  100% { transform: scale(1); opacity: 0.95; }
}

.spin {
  animation: spin 3s linear infinite;
}

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

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