/* =========================================================
   modal.css - 결과 화면, 시상식 포디움, 영수증 벌칙 티켓 및 모달 스타일
   ========================================================= */

/* Modal Backdrop */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.modal-container {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  padding: 28px;
  transform: scale(0.95) translateY(10px);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.modal-overlay.active .modal-container {
  transform: scale(1) translateY(0);
}

/* Podium Header */
.result-header {
  text-align: center;
}

.result-title {
  font-size: 26px;
  font-weight: 800;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.result-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
}

/* Podium Visual */
.podium-container {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 12px;
  margin: 16px 0 8px;
  padding: 10px 0;
}

.podium-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  max-width: 120px;
}

.podium-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
  position: relative;
}

.podium-name {
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100px;
}

.podium-block {
  width: 100%;
  border-radius: 8px 8px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  color: rgba(255, 255, 255, 0.9);
}

.podium-step.rank-1 .podium-block {
  height: 85px;
  background: linear-gradient(180deg, #F59E0B, #B45309);
  border: 1px solid #FCD34D;
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.4);
}

.podium-step.rank-2 .podium-block {
  height: 60px;
  background: linear-gradient(180deg, #94A3B8, #475569);
  border: 1px solid #CBD5E1;
}

.podium-step.rank-3 .podium-block {
  height: 45px;
  background: linear-gradient(180deg, #D97706, #78350F);
  border: 1px solid #FDBA74;
}

/* =========================================================
   Realistic Thermal Coffee Receipt Card (영수증 벌칙 티켓)
   ========================================================= */
.receipt-card {
  background: #FFFDF9;
  color: #1E293B;
  border-radius: 4px;
  padding: 24px 20px;
  font-family: 'Courier New', Courier, monospace;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  position: relative;
  border-left: 1px dashed #CBD5E1;
  border-right: 1px dashed #CBD5E1;
}

/* Top & bottom zigzag paper cut */
.receipt-card::before, .receipt-card::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 8px;
  background-size: 16px 8px;
}

.receipt-card::before {
  top: -8px;
  background-image: radial-gradient(circle at 8px 8px, transparent 8px, #FFFDF9 8px);
}

.receipt-card::after {
  bottom: -8px;
  background-image: radial-gradient(circle at 8px 0, transparent 8px, #FFFDF9 8px);
}

.receipt-header {
  text-align: center;
  border-bottom: 1px dashed #64748B;
  padding-bottom: 12px;
  margin-bottom: 14px;
}

.receipt-store-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.receipt-sub {
  font-size: 11px;
  color: #64748B;
}

.receipt-body {
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 14px;
}

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

.receipt-row.bold {
  font-weight: 800;
  font-size: 14px;
  color: #0F172A;
}

.receipt-row.highlight {
  background: #FEF3C7;
  padding: 4px 6px;
  border-radius: 2px;
  font-weight: 700;
}

.receipt-divider {
  border-top: 1px dashed #94A3B8;
  margin: 12px 0;
}

.receipt-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 17px;
  font-weight: 800;
  border-top: 2px solid #1E293B;
  border-bottom: 2px solid #1E293B;
  padding: 8px 0;
  margin-top: 10px;
}

/* Rubber Stamp Overlay */
.receipt-stamp {
  position: absolute;
  top: 35%;
  right: 25px;
  border: 3px solid #E11D48;
  color: #E11D48;
  font-size: 16px;
  font-weight: 900;
  padding: 6px 14px;
  border-radius: 6px;
  text-transform: uppercase;
  transform: rotate(-14deg);
  opacity: 0.85;
  letter-spacing: 2px;
  pointer-events: none;
  box-shadow: 0 0 0 2px rgba(225, 29, 72, 0.2);
}

.receipt-footer-notes {
  margin-top: 14px;
  text-align: center;
  font-size: 10px;
  color: #64748B;
  line-height: 1.5;
}

/* Barcode visual */
.barcode-visual {
  display: flex;
  justify-content: center;
  gap: 2px;
  margin-top: 10px;
  height: 28px;
}

.bar-line {
  background: #1E293B;
  height: 100%;
}

/* On-Device AI Newspaper Card */
.ai-article-card {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.08) 0%, rgba(124, 58, 237, 0.08) 100%);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  position: relative;
}

.ai-article-header {
  font-size: 11px;
  font-weight: 800;
  color: var(--accent-gold);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-article-content {
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-primary);
  white-space: pre-line;
  background: rgba(0, 0, 0, 0.25);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent-gold);
}

/* Ranking Table inside Modal */
.ranking-details-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
}

.ranking-table-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.modal-rank-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  font-size: 13px;
}

.modal-rank-row.winner {
  border-left: 3px solid var(--accent-gold);
}

.modal-rank-row.loser {
  border-left: 3px solid var(--accent-rose);
  background: rgba(244, 63, 94, 0.1);
}

/* Modal Actions */
.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 500px) {
  .modal-actions {
    grid-template-columns: 1fr;
  }
}

.action-btn-copy {
  background: linear-gradient(135deg, #3B82F6, #1D4ED8);
  color: #FFFFFF;
  border: none;
  font-weight: 700;
  font-size: 14px;
  padding: 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
}

.action-btn-copy:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.action-btn-rematch {
  background: linear-gradient(135deg, #10B981, #059669);
  color: #FFFFFF;
  border: none;
  font-weight: 700;
  font-size: 14px;
  padding: 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
}

.action-btn-rematch:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.action-btn-setup {
  grid-column: 1 / -1;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  font-weight: 600;
  font-size: 13px;
  padding: 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}

.action-btn-setup:hover {
  color: #FFFFFF;
  background: #475569;
}

/* Toast notification */
.toast-msg {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(50px);
  background: #0F172A;
  border: 1px solid var(--accent-emerald);
  color: #FFFFFF;
  padding: 12px 20px;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast-msg.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Stable Horse Grid & Cards */
.stable-horse-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  max-height: 480px;
  overflow-y: auto;
  padding-right: 4px;
}

.stable-horse-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.2s ease;
  position: relative;
}

.stable-horse-card:hover {
  border-color: var(--accent-cyan);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stable-horse-card.selected {
  border-color: var(--accent-gold);
  background: rgba(245, 158, 11, 0.05);
}

.horse-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.horse-silk-badge {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  flex-shrink: 0;
}

.horse-card-info {
  flex: 1;
  min-width: 0;
}

.horse-card-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.horse-card-title {
  font-size: 11px;
  color: var(--text-muted);
}

.horse-card-lore {
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.4;
  background: var(--bg-secondary);
  padding: 6px 8px;
  border-radius: var(--radius-sm);
}

.stat-bars-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
}

.stat-label {
  width: 75px;
  color: var(--text-muted);
}

.stat-bar-track {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
  margin: 0 8px;
}

.stat-bar-fill {
  height: 100%;
  border-radius: 3px;
}

.stat-val {
  font-family: monospace;
  font-weight: 700;
  width: 22px;
  text-align: right;
  color: var(--text-primary);
}

.horse-select-btn {
  width: 100%;
  padding: 6px 0;
  font-size: 12px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.15s ease;
}

.horse-select-btn:hover {
  background: var(--accent-cyan);
  color: #0F172A;
  border-color: var(--accent-cyan);
}

/* =========================================================
   Modal Mobile Optimization (< 768px)
   ========================================================= */

@media (max-width: 768px) {
  .modal-overlay {
    padding: 12px;
  }

  .modal-container {
    width: 95vw;
    max-height: 90vh;
    padding: 20px 14px;
    border-radius: var(--radius-md);
  }

  .result-title {
    font-size: 20px;
  }

  .result-subtitle {
    font-size: 12px;
  }

  .podium-container {
    height: 135px;
    margin: 10px 0 16px;
    gap: 8px;
  }

  .podium-step {
    width: 76px;
  }

  .podium-step.rank-1 { height: 80px; }
  .podium-step.rank-2 { height: 60px; }
  .podium-step.rank-3 { height: 48px; }

  .podium-name {
    font-size: 12px;
    max-width: 72px;
  }

  .receipt-ticket {
    padding: 16px 12px 24px;
    margin-bottom: 14px;
  }

  .receipt-header .receipt-title {
    font-size: 15px;
  }

  .receipt-stamp {
    right: 8px;
    top: 50px;
    padding: 3px 10px;
    font-size: 15px;
    transform: rotate(-14deg);
  }

  .modal-actions {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .action-btn-copy, .action-btn-rematch, .action-btn-setup {
    padding: 12px;
    font-size: 13px;
  }

  .stable-horse-grid {
    grid-template-columns: 1fr;
    max-height: 380px;
    gap: 10px;
  }

  .stable-horse-card {
    padding: 12px;
  }

  .stat-row {
    font-size: 10.5px;
  }

  .toast-msg {
    width: 90vw;
    font-size: 13px;
    padding: 10px 16px;
    justify-content: center;
    bottom: 16px;
  }
}

/* =========================================================
   On-Device AI Neural Loading Modal & HUD Styles
   ========================================================= */
.ai-loading-overlay {
  z-index: 200;
  background: rgba(10, 15, 29, 0.88);
  backdrop-filter: blur(14px);
}

.ai-loading-container {
  max-width: 480px;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.95), rgba(8, 14, 26, 0.98));
  border: 1px solid rgba(56, 189, 248, 0.35);
  box-shadow: 0 0 40px rgba(6, 182, 212, 0.25), 0 20px 50px rgba(0, 0, 0, 0.7);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  text-align: center;
  gap: 20px;
  position: relative;
  overflow: hidden;
}

.ai-loading-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, #38BDF8, #A855F7, #38BDF8, transparent);
  background-size: 200% 100%;
  animation: ai-top-glow 2s linear infinite;
}

@keyframes ai-top-glow {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* AI Neural Visualizer */
.ai-neural-visualizer {
  position: relative;
  width: 100px;
  height: 100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-orbit-ring {
  position: absolute;
  border-radius: 50%;
  border: 1.5px dashed rgba(56, 189, 248, 0.4);
}

.ring-outer {
  width: 100px;
  height: 100px;
  border-color: rgba(168, 85, 247, 0.4);
  animation: spin-clockwise 6s linear infinite;
}

.ring-middle {
  width: 76px;
  height: 76px;
  border-color: rgba(56, 189, 248, 0.6);
  animation: spin-counter 4s linear infinite;
}

.ring-inner {
  width: 54px;
  height: 54px;
  border-color: rgba(6, 182, 212, 0.8);
  border-style: dotted;
  animation: spin-clockwise 2.5s linear infinite;
}

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

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

.ai-neural-core {
  position: relative;
  width: 44px;
  height: 44px;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.3) 0%, rgba(15, 23, 42, 0.8) 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.5);
}

.ai-core-icon {
  font-size: 22px;
  animation: ai-core-float 1.8s ease-in-out infinite alternate;
}

@keyframes ai-core-float {
  from { transform: scale(0.92); }
  to { transform: scale(1.08); filter: drop-shadow(0 0 8px #38BDF8); }
}

.ai-core-pulse {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.15);
  animation: ai-core-pulse-wave 1.6s ease-out infinite;
  z-index: -1;
}

@keyframes ai-core-pulse-wave {
  0% { transform: scale(0.8); opacity: 0.8; }
  100% { transform: scale(1.6); opacity: 0; }
}

.ai-scan-radar {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0deg 300deg, rgba(56, 189, 248, 0.25) 360deg);
  animation: spin-clockwise 2s linear infinite;
  pointer-events: none;
}

/* AI Header */
.ai-loading-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.ai-engine-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: #38BDF8;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

.pulse-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #38BDF8;
  box-shadow: 0 0 8px #38BDF8;
  animation: pulse-dot 1.2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.75); }
}

.ai-loading-title {
  font-size: 17px;
  font-weight: 800;
  color: #F8FAFC;
  margin: 0;
  letter-spacing: -0.01em;
}

.ai-loading-subtitle {
  font-size: 12px;
  color: #94A3B8;
  margin: 0;
}

/* Terminal Console Log */
.ai-terminal-console {
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  overflow: hidden;
  text-align: left;
  font-family: 'JetBrains Mono', 'Fira Code', Menlo, Monaco, Consolas, monospace;
}

.console-header {
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.console-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.dot-red { background: #EF4444; }
.dot-yellow { background: #F59E0B; }
.dot-green { background: #10B981; }

.console-title {
  font-size: 10px;
  color: #64748B;
  margin-left: 6px;
}

.console-body {
  padding: 10px 12px;
  max-height: 105px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 11px;
  line-height: 1.45;
}

.console-line {
  color: #CBD5E1;
  word-break: break-all;
  animation: console-fade-in 0.2s ease;
}

@keyframes console-fade-in {
  from { opacity: 0; transform: translateY(2px); }
  to { opacity: 1; transform: translateY(0); }
}

.log-prefix {
  color: #38BDF8;
  font-weight: 700;
  margin-right: 4px;
}

/* Progress Wrap */
.ai-progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.ai-progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  color: #94A3B8;
  font-weight: 600;
}

#aiProgressPercent {
  color: #38BDF8;
  font-family: monospace;
  font-weight: 700;
}

.ai-progress-bar-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.ai-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #38BDF8, #A855F7);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.8);
  border-radius: 3px;
  transition: width 0.15s ease-out;
}

/* =========================================================
   Result Modal: AI Reporter Typing & Skeleton Styles
   ========================================================= */
.ai-reporter-loading {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 4px;
}

.ai-reporter-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 700;
  color: #38BDF8;
}

.ai-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #38BDF8;
  box-shadow: 0 0 8px #38BDF8;
  animation: pulse-dot 1s infinite;
}

.ai-skeleton-lines {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-skeleton-line {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(56,189,248,0.12) 50%, rgba(255,255,255,0.04) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite linear;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.ai-article-text {
  line-height: 1.7;
  color: #F1F5F9;
  font-size: 13.5px;
}

.ai-cursor {
  display: inline-block;
  color: #38BDF8;
  font-weight: 900;
  animation: cursor-blink 0.7s infinite;
  margin-left: 2px;
}

@keyframes cursor-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

