/* ============================================
   SEALED SIMULATOR — Barto Club
   Inherits theme variables from style.css:
   --bg --surface --border --text --text-muted --accent
   ============================================ */

.sealed-header .subtitle { color: var(--text-muted); font-size: 13px; }

/* Rarity accent colours (theme-independent, kept subtle) */
:root {
  --card-ratio: 367 / 512;
  --card-width: 130px;
}

/* ---- PHASES ---- */
.phase { display: none; }
.phase.active { display: block; }

/* ---- PHASE 1: SET SELECT ---- */
.set-select-phase {
  max-width: 720px;
  margin: 48px auto;
  padding: 0 24px;
  text-align: center;
}

.set-select-phase h2 {
  font-size: 22px;
  font-weight: 500;
  margin: 0 0 8px;
}

.set-select-phase .instructions {
  color: var(--text-muted);
  margin-bottom: 28px;
  font-size: 14px;
  line-height: 1.5;
}

.set-grid {
  display: grid;
  grid-template-columns: repeat(5, 120px);
  justify-content: center;
  gap: 10px;
  margin-bottom: 28px;
}
@media (max-width: 680px) {
  .set-grid { grid-template-columns: repeat(3, 1fr); }
}

.set-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  height: 46px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.set-btn:hover { border-color: var(--accent); }

.set-btn.selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 15%, var(--surface));
  box-shadow: 0 0 0 1px var(--accent);
}

/* start button uses .nav-button; just size it up */
.start-btn {
  height: 40px !important;
  padding: 0 32px !important;
  font-size: 15px;
  font-weight: 500;
  border-color: var(--accent) !important;
  background: color-mix(in srgb, var(--accent) 18%, var(--surface)) !important;
}
.start-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---- PHASE 2: PACK OPENING ---- */
.pack-phase { max-width: 1780px; margin: 0 auto; padding: 24px; }

.pack-header { text-align: center; margin-bottom: 20px; }
.pack-header h2 { font-size: 18px; font-weight: 500; margin: 0 0 4px; }
.pack-progress { color: var(--text-muted); font-size: 13px; }
.pack-progress strong { color: var(--accent); }

.reveal-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  min-height: 420px;
  justify-content: center;
}

.reveal-card-container { perspective: 800px; width: 220px; cursor: pointer; }

.reveal-card {
  width: 220px;
  aspect-ratio: var(--card-ratio);
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.5s ease;
}
.reveal-card.flipped { transform: rotateY(180deg); }

.reveal-card-front,
.reveal-card-back {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  backface-visibility: hidden;
  overflow: hidden;
  border: 1px solid var(--border);
}

.reveal-card-front {
  background: color-mix(in srgb, var(--accent) 30%, var(--surface));
  display: flex;
  align-items: center;
  justify-content: center;
}
.reveal-card-front::after {
  content: '?';
  font-size: 4rem;
  font-weight: 900;
  color: color-mix(in srgb, var(--text) 20%, transparent);
}

.reveal-card-back { transform: rotateY(180deg); }
.reveal-card-back img { width: 100%; height: 100%; object-fit: cover; }

.reveal-card-info { text-align: center; min-height: 56px; }
.reveal-card-info .card-name { font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.reveal-card-info .card-meta { font-size: 15px; color: var(--text-muted); }

.rarity-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

/* Rarity accent colours */
.rarity-C   { background: rgba(154,154,154,0.18); color: #b8b8b8; }
.rarity-UC  { background: rgba(126,200,227,0.16); color: #7ec8e3; }
.rarity-R   { background: rgba(192,192,192,0.16); color: #d0d0d0; }
.rarity-L   { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); }
.rarity-SR  { background: rgba(255,209,102,0.16); color: #ffd166; }
.rarity-SEC { background: rgba(255,159,28,0.16); color: #ff9f1c; }
.rarity-SP  { background: rgba(199,125,255,0.16); color: #c77dff; }
.rarity-P   { background: rgba(199,125,255,0.16); color: #c77dff; }
.rarity-TR      { background: rgba(255,215,0,0.16); color: #ffd700; border: 1px solid rgba(255,215,0,0.3); }
.rarity-Manga,
.rarity-manga   { background: rgba(255,255,255,0.12); color: #fff; border: 1px solid rgba(255,255,255,0.3); }
.rarity-tr      { background: rgba(255,215,0,0.16); color: #ffd700; border: 1px solid rgba(255,215,0,0.3); }
.rarity-panda   { background: rgba(255,182,193,0.16); color: #ffb6c1; }
.rarity-aa      { background: rgba(6,214,160,0.16); color: #06d6a0; }

.reveal-hint {
  color: var(--text-muted);
  font-size: 13px;
  opacity: 0.7;
}

.opened-strip {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 16px;
  padding: 12px;
  background: var(--surface);
  border-radius: 8px;
  border: 1px solid var(--border);
  min-height: 60px;
}
.strip-empty { color: var(--text-muted); font-size: 13px; }

.opened-strip .mini-card {
  width: 40px;
  aspect-ratio: var(--card-ratio);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
  opacity: 0.7;
}
.opened-strip .mini-card:last-child { opacity: 1; border-color: var(--accent); }
.opened-strip .mini-card img { width: 100%; height: 100%; object-fit: cover; }

.next-pack-btn {
  margin-top: 16px;
  height: 38px !important;
  padding: 0 28px !important;
  font-size: 14px;
  border-color: var(--accent) !important;
  background: color-mix(in srgb, var(--accent) 18%, var(--surface)) !important;
}

.deck-counter { font-size: 16px; font-weight: 600; }
.deck-counter .count { color: var(--accent); font-size: 20px; }
.deck-counter.complete .count { color: #4ea87a; }

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Reset link (plain text button) */
.reset-link {
  color: var(--text-muted) !important;
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  background: none !important;
  border: none !important;
  height: auto !important;
  padding: 0 !important;
}
.reset-link:hover { color: var(--text) !important; }

/* Open all packs — inline accent link in the header */
.open-all-btn {
  color: var(--accent) !important;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  background: none !important;
  border: none !important;
  height: auto !important;
  padding: 0 !important;
}
.open-all-btn:hover { filter: brightness(1.2); }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--surface);
  border: 1px solid #4ea87a;
  color: #4ea87a;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  transition: transform 0.3s ease;
  z-index: 100;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ============================================
   PACK OPENING — two-column layout
   ============================================ */
.opening-layout {
  display: grid;
  grid-template-columns: 960px minmax(0, 1fr);
  gap: 28px;
  max-width: 1720px;
  margin: 0 auto;
  align-items: start;
}
@media (max-width: 1580px) {
  .opening-layout { grid-template-columns: 1fr; }
  .opening-side { order: -1; }
}

.opening-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  min-height: 520px;
  padding-top: 8px;
  min-width: 0;
}

/* Text panel + card side by side, centred as a pair */
.reveal-row {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 24px;
  width: 100%;
  min-width: 0;
}

/* Left column: text box with controls stacked underneath it */
.reveal-left {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 400px;
  flex-shrink: 0;
  align-self: center;
}

/* Reveal card */
.reveal-card-container { perspective: 1100px; width: 520px; cursor: pointer; flex-shrink: 0; }
.reveal-card { width: 500px; }

/* Text panel (width comes from .reveal-left) */
.reveal-card-text {
  width: 100%;
}

/* Controls sit under the text box */
.reveal-controls {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  min-height: 40px;
}
.reveal-controls .reveal-hint { text-align: center; }

/* Pulled-cards side panel — now a multi-column grid */
.opening-side {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  position: sticky;
  top: 16px;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
}
.pulled-count { color: var(--text-muted); font-weight: 400; }

.pulled-list {
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 6px;
  margin-top: 8px;
  align-content: start;
}
@media (max-width: 1100px) {
  .pulled-list { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
.pulled-empty {
  grid-column: 1 / -1;
  color: var(--text-muted);
  font-size: 13px;
  padding: 12px 4px;
}

.pulled-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 5px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  min-width: 0;
  overflow: hidden;
}
.pulled-thumb {
  width: 26px;
  aspect-ratio: var(--card-ratio);
  border-radius: 3px;
  overflow: hidden;
  flex-shrink: 0;
}
.pulled-thumb img { width: 100%; height: 100%; object-fit: cover; }
.pulled-meta {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}
.pulled-name {
  font-size: 11px;
  font-weight: 500;
  line-height: 1.25;
  /* wrap onto a 2nd line, then clamp with ellipsis */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.pulled-id { font-size: 9px; color: var(--text-muted); margin-top: 2px; }
.pulled-row .rarity-badge { flex-shrink: 0; align-self: flex-start; font-size: 9px; padding: 1px 5px; }

/* Card swap animations (non-flip advance) */
@keyframes cardOut { to { opacity: 0; transform: scale(0.96); } }
@keyframes cardIn  { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }

/* Bigger builder cards too */
:root { --card-width: 150px; }

/* ============================================
   SEALED DECK BUILDER — reuses .db-* classes
   from style.css; these are the sealed extras
   ============================================ */
.builder-phase {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 24px 24px;
  height: calc(100vh - 70px);
  display: flex;
  flex-direction: column;
}

.sealed-db-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.sealed-db-header h2 { font-size: 18px; font-weight: 500; margin: 0; }
.sealed-deck-status { margin-left: 4px; }

.builder-phase .db-builder {
  display: flex;
  gap: 14px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.sealed-leader-img {
  width: 100%;
  max-width: 260px;
  aspect-ratio: var(--card-ratio);
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid #ffd166;
  display: block;
}

.sealed-pool-label { font-size: 13px; color: var(--text-muted); }

.sealed-deck-empty,
.sealed-pool-empty {
  color: var(--text-muted);
  font-size: 13px;
  padding: 12px 4px;
  text-align: center;
}

/* qty badge already styled by .db-pool-qty; add the in-deck badge */
.sealed-indeck-badge {
  position: absolute;
  bottom: 4px;
  left: 4px;
  background: color-mix(in srgb, #4ea87a 85%, black);
  color: #fff;
  font-size: 10px;
  border-radius: 4px;
  padding: 1px 5px;
  z-index: 2;
}
.sealed-pool-rarity {
  position: absolute;
  top: 4px;
  left: 4px;
  z-index: 2;
}
.sealed-pool-card.sealed-add,
.sealed-pool-card .sealed-add { cursor: pointer; }

/* disabled qty buttons */
.db-pool-card-qty button:disabled,
.db-deck-row button:disabled { opacity: 0.35; cursor: not-allowed; }

/* Sealed pool filter bar */
.sealed-pool-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-bottom: 4px;
}
.sealed-pool-filters select,
.sealed-pool-filters input[type="text"] {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
  height: 32px;
}
.sealed-pool-filters input[type="text"] {
  flex: 1;
  min-width: 160px;
}
.sealed-pool-filters select:focus,
.sealed-pool-filters input:focus {
  outline: none;
  border-color: var(--accent);
}

/* Card text panel under the reveal card */
.reveal-card-text {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 22px;
  font-size: 15px;
  line-height: 1.65;
  min-height: 40px;
}
.reveal-card-text:empty { visibility: hidden; }
.reveal-card-text .db-pool-tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--text-muted);
  font-size: 15px;
  padding: 3px 0;
}
.reveal-card-text .db-pool-tooltip-effect {
  margin-top: 10px;
  color: var(--text);
  font-size: 15px;
}

/* Sealed tooltip sits above everything — bigger & more readable */
.sealed-tooltip {
  z-index: 400;
  font-size: 15px !important;
  line-height: 1.55 !important;
  padding: 14px 16px !important;
  max-height: 420px !important;
  border-radius: 10px !important;
  box-shadow: 0 8px 28px rgba(0,0,0,0.55) !important;
}
.sealed-tooltip .db-pool-tooltip-row {
  font-size: 15px;
  padding: 2px 0;
}
.sealed-tooltip .db-pool-tooltip-effect {
  font-size: 15px;
  margin-top: 8px;
}
.sealed-tooltip.hidden { display: none; }

/* ============================================
   KEYWORD PILLS — mimic official card design
   ============================================ */
.kw-pill {
  display: inline-block;
  padding: 0 7px;
  border-radius: 4px;          /* rounded-rectangle, like the cards */
  font-size: 0.86em;
  font-weight: 700;
  color: #fff;
  line-height: 1.55;
  white-space: nowrap;
  vertical-align: baseline;
  margin: 0 2px;
  letter-spacing: 0.01em;
}
.kw-blue    { background: #0c71b2; }   /* On Play, Main, Activate:Main, Opponent's Turn */
.kw-red     { background: #e30214; }   /* Counter, Unblockable */
.kw-yellow  { background: #ffeb25; color: #1a1a1a; }  /* Trigger */
.kw-amber   { background: #e08a1e; }   /* Blocker */
.kw-rose    { background: #d44c6a; }   /* Once Per Turn, Your Turn */
.kw-black   { background: #2a2a2a; border: 1px solid #555; }  /* DON!! x1 */
.kw-neutral { background: #514c66; }   /* [bracketed] card / type names */
.kw-type    { background: #6b7280; }   /* {curly} type references */

/* Yellow lightning bolt on the Counter pill (matches the card) */
.kw-red::before { content: "\26A1"; margin-right: 2px; font-size: 0.85em; color: #ffeb25; }

/* ============================================
   MODE SELECT (Sealed / Box / Case)
   ============================================ */
.mode-select {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 8px 0 24px;
  flex-wrap: wrap;
}
.mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 150px;
  min-height: 64px;
  padding: 12px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}
.mode-btn:hover { border-color: var(--accent); }
.mode-btn.selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, var(--surface));
  box-shadow: 0 0 0 1px var(--accent);
}
.mode-title { font-size: 16px; font-weight: 600; }
.mode-sub { font-size: 12px; color: var(--text-muted); }

/* ============================================
   OPEN-PACKS SUMMARY
   ============================================ */
.summary-phase { max-width: 1500px; margin: 0 auto; padding: 24px; }
.summary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}
.summary-title { font-size: 20px; font-weight: 600; margin: 0; }
.summary-controls { display: flex; align-items: center; gap: 14px; }
.summary-controls label { font-size: 13px; color: var(--text-muted); display: flex; gap: 6px; align-items: center; }
.summary-controls select {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 8px; font-size: 13px;
}
.summary-stats { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.stat-pill {
  font-size: 13px; font-weight: 700;
  padding: 4px 12px; border-radius: 20px;
  background: var(--surface); border: 1px solid var(--border);
}
.summary-group { margin-bottom: 24px; }
.summary-group-title {
  font-size: 14px; font-weight: 600;
  color: var(--text-muted); margin-bottom: 10px;
  text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border); padding-bottom: 5px;
}
.summary-group-title span { color: var(--accent); }
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
}
.summary-card {
  position: relative;
  aspect-ratio: var(--card-ratio);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.summary-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.summary-card-rarity {
  position: absolute; top: 3px; right: 3px;
  font-size: 9px; font-weight: 700;
  padding: 1px 5px; border-radius: 3px;
}
.summary-restart { height: 36px !important; padding: 0 20px !important; }
