/* Reset & Base variables */
:root {
  --bg-dark: #0f0505;
  --bg-stage: #1a0a0a;
  --velvet-red: #800020;
  --velvet-light: #b3002d;
  --gold: #d4af37;
  --gold-glow: rgba(212, 175, 55, 0.4);
  --text-light: #f5ebeb;
  --text-dark: #121212;
  --text-gray: #bfa6a6;
  --strong-color: #ff4d4d;
  --weak-color: #3399ff;
  --action-color: #ffd700;
  
  --font-title: 'Outfit', 'Noto Sans KR', sans-serif;
  --font-body: 'Noto Sans KR', sans-serif;
}

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

body {
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(circle at 50% -20%, #4a0d0d 0%, #120303 60%, #050101 100%);
  color: var(--text-light);
  font-family: var(--font-body);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* Stage Lighting Effects */
.spotlight {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 600px;
  height: 50vh;
  background: radial-gradient(ellipse at top, rgba(255, 215, 0, 0.12) 0%, rgba(255, 215, 0, 0) 70%);
  pointer-events: none;
  z-index: 1;
}

/* Side Velvet Curtains (Decorative subtle folds on extreme left/right) */
.curtain-overlay-left, .curtain-overlay-right {
  position: fixed;
  top: 0;
  width: 15px;
  height: 100%;
  background: linear-gradient(to right, #400010 0%, #1a0006 50%, #400010 100%);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  z-index: 99;
}
.curtain-overlay-left { left: 0; }
.curtain-overlay-right { right: 0; }

/* Main App Container */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  padding: 16px 20px;
  z-index: 2;
  position: relative;
}

/* Header styling */
.app-header {
  text-align: center;
  margin-top: 10px;
  margin-bottom: 20px;
}
.header-decor {
  font-size: 2.2rem;
  margin-bottom: 2px;
  filter: drop-shadow(0 0 8px var(--gold));
  animation: float 3s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.header-title {
  font-family: var(--font-title);
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(135deg, #fff 30%, var(--gold) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.7));
  text-shadow: 0 0 15px rgba(212, 175, 55, 0.3);
}
.header-subtitle {
  font-size: 0.95rem;
  color: var(--text-gray);
  font-weight: 500;
  margin-top: 4px;
  letter-spacing: 0.5px;
}

/* Navigation Tabs */
.app-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  background: rgba(0, 0, 0, 0.4);
  padding: 6px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 24px;
}
.tab-btn {
  background: transparent;
  border: none;
  border-radius: 12px;
  padding: 12px 6px;
  color: var(--text-gray);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.tab-btn .tab-icon {
  font-size: 1.3rem;
  filter: grayscale(40%);
  transition: transform 0.2s ease;
}
.tab-btn.active {
  background: linear-gradient(135deg, var(--velvet-red) 0%, #4a0010 100%);
  color: var(--text-light);
  border: 1px solid rgba(212, 175, 55, 0.3);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.tab-btn.active .tab-icon {
  filter: grayscale(0%);
  transform: scale(1.15);
}

/* Tab Panels */
.tab-panel {
  display: none;
  animation: fadeIn 0.4s ease-out forwards;
}
.tab-panel.active {
  display: block;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel-header {
  text-align: center;
  margin-bottom: 20px;
}
.panel-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-light);
}
.panel-desc {
  font-size: 0.9rem;
  color: var(--text-gray);
  margin-top: 4px;
}

/* Stage Area for Card Drawing */
.stage-area {
  position: relative;
  width: 100%;
  height: 410px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle at center, rgba(30, 10, 10, 0.6) 0%, rgba(10, 2, 2, 0.9) 100%);
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.9);
  overflow: hidden;
  margin-bottom: 24px;
}
.b-stage-area {
  margin-top: 24px;
  height: 300px;
}
.stage-floor {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 40px;
  background: linear-gradient(to top, #1a0808 0%, #301010 100%);
  border-top: 2px solid var(--gold);
  opacity: 0.8;
  z-index: 1;
}

/* Flipping Stage Card */
.stage-card {
  perspective: 1000px;
  width: 250px;
  height: 340px;
  z-index: 2;
}
.b-stage-area .stage-card {
  width: 280px;
  height: 230px;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.15);
  transform-style: preserve-3d;
}

/* When flipped, show card back */
.stage-card.flipped .card-inner {
  transform: rotateY(180deg);
}

.card-front, .card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 24px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
  border: 3px solid var(--gold);
  overflow: hidden;
}

/* Card Front (Mystery / Backside image) */
.card-front {
  background: linear-gradient(135deg, #2b040a 0%, #150004 100%);
  color: var(--gold);
}
.card-front::after {
  content: '';
  position: absolute;
  inset: 6px;
  border: 1px dashed rgba(212, 175, 55, 0.4);
  border-radius: 12px;
  pointer-events: none;
}
.card-brand {
  font-family: var(--font-title);
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 2px;
  margin-bottom: 20px;
  text-shadow: 0 0 10px var(--gold-glow);
}
.card-mystery {
  font-size: 4.5rem;
  margin-bottom: 20px;
  filter: drop-shadow(0 0 15px rgba(212, 175, 55, 0.6));
}
.card-front p {
  font-size: 0.95rem;
  color: var(--text-gray);
  letter-spacing: 1px;
}

/* Card Back (Active drawn info) */
.card-back {
  transform: rotateY(180deg);
  background: linear-gradient(135deg, #1f1f1f 0%, #111111 100%);
  justify-content: flex-start;
  align-items: center;
  padding-top: 28px;
}

/* Card Glow Effect inside */
.stage-light-glow {
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.05) 0%, transparent 60%);
  pointer-events: none;
}

/* Type variations on card reveal */
.type-a {
  border-color: var(--gold);
}
.type-b {
  border-color: #e62e00;
  box-shadow: 0 0 20px rgba(230, 46, 0, 0.3);
}
.type-action {
  border-color: var(--action-color);
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

.card-type-tag {
  font-size: 0.85rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 20px;
  margin-bottom: 12px;
  letter-spacing: 1px;
}
.card-type-tag.strong {
  background: var(--strong-color);
  color: white;
}
.card-type-tag.weak {
  background: var(--weak-color);
  color: white;
}

.card-title {
  font-size: 1.8rem;
  font-weight: 800;
  color: white;
  margin-bottom: 16px;
  letter-spacing: -0.5px;
}
.card-divider {
  width: 50px;
  height: 3px;
  background: var(--gold);
  margin-bottom: 20px;
  border-radius: 2px;
}
.card-meta {
  width: 100%;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.meta-section h4 {
  font-size: 0.85rem;
  color: var(--gold);
  margin-bottom: 4px;
  text-transform: uppercase;
  font-weight: 700;
}
.meta-section p {
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--text-light);
}

/* Combo Card Styling for B-Stage */
.combo-badge {
  font-size: 0.85rem;
  font-weight: 700;
  background: var(--velvet-red);
  color: white;
  padding: 4px 10px;
  border-radius: 8px;
  margin-bottom: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.combo-title {
  font-size: 1.7rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.combo-title .text-a { color: var(--strong-color); }
.combo-title .text-b { color: var(--action-color); }
.combo-title .plus-symbol { color: white; font-size: 1.2rem; }
.combo-sub {
  font-size: 0.9rem;
  color: var(--text-gray);
}

/* Action Card Specific styling */
.action-tag {
  font-size: 0.9rem;
  font-weight: 800;
  background: var(--action-color);
  color: var(--text-dark);
  padding: 4px 14px;
  border-radius: 4px;
  margin-bottom: 30px;
  letter-spacing: 2px;
}
.action-card-title {
  font-size: 2rem;
  font-weight: 900;
  color: white;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
  margin-top: 10px;
  line-height: 1.3;
}

/* Custom Interactive Selection grids for B */
.selection-section {
  background: rgba(18, 5, 5, 0.5);
  border-radius: 18px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  margin-bottom: 18px;
}
.section-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.sub-group-title {
  font-size: 0.85rem;
  font-weight: 700;
  margin: 10px 0 6px 0;
  letter-spacing: 0.5px;
}
.sub-group-title.text-strong { color: var(--strong-color); }
.sub-group-title.text-weak { color: var(--weak-color); }

.btn-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.grid-btn {
  background: rgba(0, 0, 0, 0.3);
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: var(--text-gray);
  padding: 12px 4px;
  font-size: 0.95rem;
  font-weight: 700;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Highlight A-Card strength classes when selected */
.grid-btn.selected-strong {
  background: rgba(255, 77, 77, 0.2);
  border-color: var(--strong-color);
  color: white;
  box-shadow: 0 0 10px rgba(255, 77, 77, 0.3);
  transform: translateY(-1px);
}
.grid-btn.selected-weak {
  background: rgba(51, 153, 255, 0.2);
  border-color: var(--weak-color);
  color: white;
  box-shadow: 0 0 10px rgba(51, 153, 255, 0.3);
  transform: translateY(-1px);
}

/* Role Grid Button Styles */
.role-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.role-btn {
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: var(--text-gray);
  padding: 14px;
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
  min-height: 52px;
}
.role-btn .role-emoji {
  font-size: 1.2rem;
  opacity: 0.6;
}
.role-btn.active {
  background: linear-gradient(135deg, #d4af37 0%, #aa8410 100%);
  border-color: var(--gold);
  color: var(--text-dark);
  box-shadow: 0 0 15px rgba(212, 175, 55, 0.4);
  transform: translateY(-1px);
}
.role-btn.active .role-emoji {
  opacity: 1;
}

/* Action Buttons & Draw Triggers */
.btn {
  width: 100%;
  border: none;
  font-family: var(--font-body);
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Big Gold Stage CTA Button */
.btn-primary {
  background: linear-gradient(135deg, var(--velvet-light) 0%, var(--velvet-red) 100%);
  color: white;
  height: 58px;
  font-size: 1.2rem;
  border-radius: 16px;
  border: 2px solid var(--gold);
  box-shadow: 0 6px 20px rgba(128, 0, 32, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.1);
  position: relative;
  overflow: hidden;
}
.btn-primary:active {
  transform: scale(0.97);
  box-shadow: 0 2px 10px rgba(128, 0, 32, 0.5);
}
.btn-primary.disabled {
  background: #331f1f;
  color: #735959;
  border-color: #4d3333;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}
.btn-primary.disabled:active {
  transform: none;
}

/* Shiny moving light effect on primary button */
.btn-glow {
  position: absolute;
  top: 0;
  left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(
    to right,
    rgba(255,255,255,0) 0%,
    rgba(255,255,255,0.2) 50%,
    rgba(255,255,255,0) 100-percent
  );
  transform: skewX(-25deg);
  animation: shine 4s infinite;
}
.btn-primary.disabled .btn-glow {
  display: none;
}
@keyframes shine {
  0% { left: -100%; }
  30% { left: 150%; }
  100% { left: 150%; }
}

/* Interpretation Details Panels */
.details-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 10px;
  animation: slideUp 0.5s ease forwards;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}

.card-details-box {
  background: rgba(18, 5, 5, 0.7);
  border-radius: 16px;
  padding: 20px;
  position: relative;
}
.card-details-box.border-a {
  border: 1.5px solid var(--strong-color);
}
.card-details-box.border-b {
  border: 1.5px solid var(--action-color);
}

.details-badge {
  position: absolute;
  top: -11px;
  left: 16px;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 6px;
  color: white;
}
.badge-a { background: var(--strong-color); }
.badge-b { background: var(--action-color); color: var(--text-dark); }

.details-title {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 12px;
  margin-top: 2px;
}
.badge-sub {
  font-size: 0.8rem;
  font-weight: 600;
  vertical-align: middle;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
}

.detail-item {
  margin-bottom: 12px;
}
.detail-item:last-child {
  margin-bottom: 0;
}
.detail-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-gray);
  margin-bottom: 4px;
}
.detail-item p {
  font-size: 1rem;
  line-height: 1.45;
  color: var(--text-light);
}

/* Controls Grid */
.control-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 10px;
}
.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  color: var(--text-light);
  height: 52px;
  font-size: 1rem;
  border-radius: 12px;
}
.btn-secondary:active {
  background: rgba(255, 255, 255, 0.15);
}

.btn-reset-b {
  border-color: rgba(255, 77, 77, 0.4);
  color: #ff9999;
}
.btn-reset-b:active {
  background: rgba(255, 77, 77, 0.1);
}

.btn-danger {
  background: transparent;
  color: #ff4d4d;
  height: 40px;
  font-size: 0.85rem;
  border-radius: 8px;
  opacity: 0.65;
  border: none;
}
.btn-danger:active {
  opacity: 1;
  background: rgba(255, 77, 77, 0.15);
}

/* Toast Message */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(212, 175, 55, 0.95);
  color: var(--text-dark);
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 700;
  z-index: 1000;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  text-align: center;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

.hidden {
  display: none !important;
}

/* Footer Styling */
.app-footer {
  text-align: center;
  margin-top: 40px;
  margin-bottom: 20px;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.3);
}

/* Spin animation for roulette look */
@keyframes shake {
  0%, 100% { transform: translateY(0); }
  25% { transform: translateY(-4px) rotate(1deg); }
  75% { transform: translateY(4px) rotate(-1deg); }
}
.card-inner.spinning {
  animation: shake 0.1s infinite;
  filter: blur(1.5px);
}

/* --- Order Drawer Styles --- */
.order-inputs {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.input-row {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 6px 16px;
  min-height: 52px;
}
.input-row label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--gold);
  width: 85px;
  text-shadow: 0 0 5px rgba(212, 175, 55, 0.2);
}
.input-row input {
  flex: 1;
  background: transparent;
  border: none;
  color: white;
  font-size: 1.1rem;
  font-weight: 700;
  outline: none;
  font-family: var(--font-body);
}
.order-stage-area {
  height: 250px;
  margin-top: 15px;
}
.order-result-box {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 18px;
  z-index: 2;
  width: 100%;
  padding: 20px;
  text-align: center;
}
.result-line {
  font-size: 1.35rem;
  font-weight: 800;
  color: white;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  letter-spacing: -0.5px;
  animation: pulseLight 2s infinite ease-in-out;
}
.result-line:nth-child(2) {
  animation-delay: 0.3s;
}
.result-line:nth-child(3) {
  animation-delay: 0.6s;
}
@keyframes pulseLight {
  0%, 100% { opacity: 0.9; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.03); color: var(--gold); text-shadow: 0 0 10px rgba(212, 175, 55, 0.4); }
}
.action-bar-order {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
}
.tab-btn {
  padding: 10px 4px; /* Slightly adjust padding for 4 tabs */
  font-size: 0.8rem;
}

