/* GamerTube Runebound Solitaire — Stylesheet */

:root {
  --color-bg: #07090e;
  --color-felt: #0c1a14;
  --color-gold: #f3ca6b;
  --color-gold-hover: #ffd97d;
  --color-gold-border: rgba(224, 175, 75, 0.4);
  --color-card-bg: #fdfbf7;
  --color-black-suit: #151821;
  --color-red-suit: #b91c1c;
  --card-radius: 8px;
  --card-width: clamp(44px, 12.8vw, 96px);
  --card-height: calc(var(--card-width) * 1.4);
  --card-overlap-down: clamp(8px, 2.2vh, 16px);
  --card-overlap-up: clamp(16px, 4.2vh, 28px);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  background-color: var(--color-bg);
  color: #f1f5f9;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

/* Background Artwork Layers */
.bg-table {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-image: url("/games/solitaire/assets/table-felt.jpg"), url("/games/solitaire/assets/table-bg.jpg");
  background-size: cover;
  background-position: center center;
  opacity: 0.65;
  filter: brightness(0.75) contrast(1.15);
  pointer-events: none;
}

.bg-vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  background: radial-gradient(circle at 50% 40%, rgba(12, 26, 20, 0.4) 0%, rgba(5, 7, 11, 0.95) 85%);
  pointer-events: none;
}

/* App Shell */
.app-shell {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 1080px;
  margin: 0 auto;
  padding: 10px 12px 24px;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.back-link {
  font-family: "Cinzel", Georgia, serif;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--color-gold);
  text-decoration: none;
  transition: color 0.15s ease;
}

.back-link:hover {
  color: var(--color-gold-hover);
}

.sync-link {
  font-size: 0.72rem;
  color: #38bdf8;
  text-decoration: none;
}

.title-group {
  display: flex;
  flex-direction: column;
}

.game-title {
  font-family: "Cinzel", Georgia, serif;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #f8fafc;
  line-height: 1.1;
}

.game-subtitle {
  font-size: 0.72rem;
  color: #94a3b8;
  letter-spacing: 0.02em;
}

/* Adventurer Card */
.adventurer-card {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  background: rgba(18, 24, 38, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 6px 12px;
  backdrop-filter: blur(8px);
}

.adv-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.adv-badge-slot {
  display: inline-flex;
  width: 18px;
  height: 18px;
}

.adv-badge-slot svg {
  width: 100%;
  height: 100%;
}

.adv-level {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--color-gold);
}

.adv-rank {
  font-family: "Cinzel", serif;
  font-size: 0.74rem;
  color: #cbd5e1;
}

.adv-cleared {
  font-size: 0.7rem;
  color: #64748b;
  margin-left: 4px;
}

.xp-track {
  width: 100px;
  height: 5px;
  background: #1e293b;
  border-radius: 3px;
  overflow: hidden;
  margin: 3px 0 2px;
}

.xp-fill {
  height: 100%;
  background: linear-gradient(90deg, #e0af4b, #38bdf8);
  transition: width 0.3s ease;
}

.adv-xp-text {
  font-size: 0.64rem;
  color: #94a3b8;
  font-family: "JetBrains Mono", monospace;
}

/* Action Bar */
.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 0;
  margin-bottom: 6px;
}

.btn-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(26, 35, 54, 0.85);
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.action-btn:hover:not(:disabled) {
  background: rgba(38, 51, 79, 0.95);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.25);
}

.action-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.action-btn--primary {
  background: linear-gradient(135deg, #2a3754 0%, #1e273b 100%);
  color: var(--color-gold);
  border-color: var(--color-gold-border);
}

.action-btn--primary:hover {
  background: linear-gradient(135deg, #37486e 0%, #26334f 100%);
  border-color: var(--color-gold);
}

.action-btn--gold {
  background: linear-gradient(135deg, #f3ca6b 0%, #c9922c 100%);
  color: #0b0d12;
  font-family: "Cinzel", Georgia, serif;
  font-weight: 800;
  border: none;
  box-shadow: 0 0 16px rgba(243, 202, 107, 0.4);
  animation: pulse-gold 1.6s infinite ease-in-out;
}

@keyframes pulse-gold {
  0%, 100% { transform: scale(1); box-shadow: 0 0 14px rgba(243, 202, 107, 0.4); }
  50% { transform: scale(1.04); box-shadow: 0 0 22px rgba(243, 202, 107, 0.7); }
}

.icon-btn {
  background: rgba(26, 35, 54, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #94a3b8;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

.icon-btn:hover {
  background: rgba(38, 51, 79, 0.95);
  color: #fff;
}

.stats-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.74rem;
  color: #94a3b8;
}

.stat-val {
  color: #f1f5f9;
  font-weight: 700;
}

/* Playing Felt Area */
.table-felt {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 520px;
  padding: 10px 4px 60px;
}

/* Card Slot Base */
.card-slot {
  position: relative;
  width: var(--card-width);
  height: var(--card-height);
  border: 1.5px dashed rgba(224, 175, 75, 0.22);
  border-radius: var(--card-radius);
  background: rgba(8, 14, 12, 0.45);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.slot-marker {
  font-family: "Cinzel", serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: rgba(224, 175, 75, 0.28);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stock-marker .slot-symbol {
  font-size: 1.2rem;
  line-height: 1;
}

.stock-marker .slot-text {
  font-size: 0.55rem;
  letter-spacing: 0.1em;
  margin-top: 2px;
}

.slot-pile {
  position: absolute;
  inset: 0;
}

/* Top Row: Stock, Waste, Foundations */
.top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  width: 100%;
}

.deck-area {
  display: flex;
  gap: 8px;
}

.table-spacer {
  flex: 1;
}

.foundations-area {
  display: flex;
  gap: 8px;
}

/* Bottom Row: 7 Tableau Columns */
.tableau-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  width: 100%;
  align-items: start;
}

.tableau-col {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 380px;
}

.tableau-slot {
  width: var(--card-width);
}

.tableau-pile {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--card-width);
  height: 100%;
  pointer-events: auto;
}

/* THE CARDS */
.card {
  position: absolute;
  width: var(--card-width);
  height: var(--card-height);
  border-radius: var(--card-radius);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.55), 0 1px 3px rgba(0,0,0,0.3);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
  box-sizing: border-box;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.7);
}

.card.is-selected {
  outline: 2px solid #f59e0b;
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.6), 0 8px 24px rgba(0, 0, 0, 0.8) !important;
  transform: translateY(-4px);
  z-index: 99 !important;
}

.card.is-dragging {
  opacity: 0.9;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.85);
  pointer-events: none;
  z-index: 999 !important;
}

/* Face Down Card (Art Back) */
.card--face-down {
  background-color: #0d121c;
  background-image: url("/games/solitaire/assets/card-back.jpg");
  background-size: cover;
  background-position: center;
  border: 1px solid rgba(224, 175, 75, 0.4);
}

/* Face Up Card (Parchment & Runic Deck) */
.card--face-up {
  background: var(--color-card-bg);
  border: 1px solid #d4c8af;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(255, 255, 255, 0.6);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 4px 5px;
}

/* Suit Colors */
.card--face-up[data-suit="spades"],
.card--face-up[data-suit="clubs"] {
  color: var(--color-black-suit);
}

.card--face-up[data-suit="hearts"],
.card--face-up[data-suit="diamonds"] {
  color: var(--color-red-suit);
}

/* Card Corners */
.card-corner {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  pointer-events: none;
}

.card-corner.top-left {
  align-self: flex-start;
}

.card-corner.bottom-right {
  align-self: flex-end;
  transform: rotate(180deg);
}

.card-rank {
  font-family: "Cinzel", Georgia, serif;
  font-size: clamp(0.72rem, 2.2vw, 1.05rem);
  font-weight: 800;
  letter-spacing: -0.04em;
}

.card-suit-mini {
  font-size: clamp(0.68rem, 1.9vw, 0.95rem);
  margin-top: 1px;
}

/* Card Center / Face Illustration */
.card-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  position: relative;
  overflow: hidden;
}

/* Number Card Pips */
.card-pip-large {
  font-size: clamp(1.4rem, 4vw, 2.4rem);
  opacity: 0.9;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.15));
}

/* Ace of Spades / Crest */
.card-ace-crest {
  font-size: clamp(1.8rem, 5vw, 3rem);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25));
}

/* Royal Face Portraits (Jack, Queen, King) */
.card-royal-frame {
  width: 90%;
  height: 82%;
  border: 1px solid rgba(180, 140, 50, 0.6);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.4);
  position: relative;
}

.card-royal-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 20%;
  filter: contrast(1.05) saturate(1.1);
}

/* Floating Toast XP */
.xp-toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--color-gold);
  border-radius: 30px;
  padding: 8px 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.8), 0 0 20px rgba(243, 202, 107, 0.35);
  z-index: 100;
  animation: toast-in-out 2.2s ease forwards;
  pointer-events: none;
}

@keyframes toast-in-out {
  0% { opacity: 0; transform: translate(-50%, 20px) scale(0.9); }
  15% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  80% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -10px) scale(0.95); }
}

.xp-toast-amount {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--color-gold);
}

.xp-toast-label {
  font-size: 0.78rem;
  color: #f1f5f9;
}

[hidden],
.modal-backdrop[hidden] {
  display: none !important;
}

/* Victory Celebration Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 12, 0.85);
  backdrop-filter: blur(10px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.victory-card {
  position: relative;
  background: #0f1523;
  border: 1.5px solid var(--color-gold);
  border-radius: 16px;
  padding: 32px 28px;
  max-width: 460px;
  width: 100%;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.8), 0 0 32px rgba(224, 175, 75, 0.25);
  animation: victory-pop 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes victory-pop {
  0% { transform: scale(0.92); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.kicker {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: #38bdf8;
  display: block;
  margin-bottom: 6px;
}

.victory-title {
  font-family: "Cinzel", Georgia, serif;
  font-size: 1.6rem;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 6px;
}

.victory-subtitle {
  font-size: 0.86rem;
  color: #94a3b8;
  margin-bottom: 22px;
}

.victory-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 22px;
}

.v-stat-box {
  background: #090c14;
  border: 1px solid #1e293b;
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.v-stat-box.highlight {
  border-color: var(--color-gold-border);
  background: rgba(224, 175, 75, 0.08);
}

.v-stat-lbl {
  font-size: 0.68rem;
  color: #64748b;
  text-transform: uppercase;
}

.v-stat-val {
  font-family: "JetBrains Mono", monospace;
  font-size: 1.1rem;
  font-weight: 700;
  color: #f1f5f9;
}

.v-stat-val.gold {
  color: var(--color-gold);
}

.victory-level-box {
  background: #090c14;
  border: 1px solid #1e293b;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 24px;
}

.victory-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f3ca6b 0%, #c9922c 100%);
  color: #0b0d12;
  font-family: "Cinzel", Georgia, serif;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 12px 24px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(224, 175, 75, 0.4);
  text-decoration: none;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: #94a3b8;
  font-size: 0.85rem;
  padding: 10px 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  text-decoration: none;
  cursor: pointer;
}

.btn-ghost:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
}

/* Mobile Responsiveness */
@media (max-width: 680px) {
  .app-shell {
    padding: 8px 6px 36px;
  }

  .topbar {
    gap: 8px;
  }

  .game-title {
    font-size: 1.05rem;
  }

  .adventurer-card {
    padding: 4px 8px;
  }

  .adv-rank {
    display: none;
  }

  .adv-cleared {
    display: none;
  }

  .xp-track {
    width: 72px;
  }

  .action-bar {
    gap: 6px;
  }

  .action-btn {
    padding: 5px 8px;
    font-size: 0.72rem;
  }

  .stat-pill {
    font-size: 0.68rem;
  }

  .deck-area,
  .foundations-area,
  .tableau-row {
    gap: 4px;
  }

  .card-slot {
    border-radius: 6px;
  }

  .card {
    border-radius: 6px;
    padding: 2px 3px;
  }

  .card-royal-frame {
    height: 78%;
  }
}
