:root,
[data-theme="dark"] {
  --font-main: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --bg-page: #090d16;
  --bg-card: #111827;
  --bg-card-hover: #172033;
  --bg-input: #0d131f;
  --border-color: #273549;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;

  --primary: #f43f5e;
  --primary-hover: #e11d48;
  --gold: #f59e0b;
  --gold-glow: rgba(245, 158, 11, 0.35);
  --cyan: #38bdf8;
  --cyan-glow: rgba(56, 189, 248, 0.35);
  --success: #10b981;
}

[data-theme="light"] {
  --bg-page: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-input: #f8fafc;
  --border-color: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #64748b;

  --primary: #e11d48;
  --primary-hover: #be123c;
  --gold: #d97706;
  --gold-glow: rgba(217, 119, 6, 0.25);
  --cyan: #0284c7;
  --cyan-glow: rgba(2, 132, 199, 0.25);
  --success: #059669;
}

/* Contención y layout base */
body {
  font-family: var(--font-main);
  background-color: var(--bg-page);
  color: var(--text-main);
  margin: 0;
  padding: 0;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1,
h2,
h3,
h4,
h5,
h6,
.brand-title,
.section-title {
  font-family: var(--font-heading);
}

.mono,
.hud-val,
.telemetry-val {
  font-family: var(--font-mono);
}

.tool-layout {
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  box-sizing: border-box;
  flex: 1 0 auto;
  width: 100%;
}

.tool-with-sidebar {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  width: 100%;
}

.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
  width: 100%;
}

/* Tarjeta principal del simulador de Pachinko */
.card-main {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2);
  margin-bottom: 2rem;
}

/* Cabecera del juego arcade */
.arcade-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.arcade-title-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.arcade-title-box h2 {
  margin: 0;
  font-size: 1.35rem;
  color: var(--text-main);
}

.arcade-badge {
  background: rgba(244, 63, 94, 0.15);
  color: var(--primary);
  border: 1px solid rgba(244, 63, 94, 0.3);
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.arcade-top-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-arcade-icon {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-arcade-icon:hover {
  color: var(--text-main);
  border-color: var(--primary);
  background: var(--bg-card-hover);
}

.btn-arcade-icon.is-active {
  color: #38bdf8;
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.15);
}

.btn-arcade-icon.is-muted svg {
  opacity: 0.4;
}

/* Marco exterior de la máquina (Cabinet) */
.pachinko-arcade-cabinet {
  background: #060913;
  border: 2px solid #273549;
  border-radius: 20px;
  padding: 1.5rem;
  position: relative;
  box-shadow: 0 15px 35px -5px rgba(0, 0, 0, 0.5), inset 0 0 40px rgba(56, 189, 248, 0.05);
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: center;
  gap: 1.75rem;
  width: 100%;
  box-sizing: border-box;
}

/* Columna del tablero 3D */
.pachinko-board-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 560px;
  flex-shrink: 0;
  transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Marcador HUD superior integrado */
.pachinko-hud {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  width: 100%;
  margin-bottom: 0.85rem;
}

.hud-item {
  background: #0c1322;
  border: 1px solid #1e293b;
  border-radius: 12px;
  padding: 0.6rem 0.8rem;
  text-align: center;
}

.hud-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: #94a3b8;
  margin-bottom: 0.2rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hud-val {
  font-size: 1.35rem;
  font-weight: 700;
  color: #f8fafc;
}

.val-gold {
  color: #f59e0b;
  text-shadow: 0 0 12px rgba(245, 158, 11, 0.4);
}

.val-fever {
  color: #f43f5e;
  text-shadow: 0 0 12px rgba(244, 63, 94, 0.4);
}

/* Contenedor del visor 3D Three.js */
.pachinko-viewport-wrapper {
  position: relative;
  width: 100%;
  height: 760px;
  border-radius: 16px;
  overflow: hidden;
  background: #000000;
  border: 2px solid #334155;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.7), inset 0 0 30px rgba(56, 189, 248, 0.08);
  transition: height 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.pachinko-canvas-container {
  width: 100%;
  height: 100%;
  display: block;
}

.pachinko-canvas-container canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* Modo teatro / tablero ampliado en desktop (>= 992px) */
@media (min-width: 992px) {
  .pachinko-arcade-cabinet.is-large-cabinet .pachinko-board-col {
    width: 640px;
  }

  .pachinko-arcade-cabinet.is-large-cabinet .pachinko-viewport-wrapper {
    height: 840px;
  }
}

@media (max-width: 991px) {
  #btn-pachinko-size {
    display: none;
  }
}

/* Marquesina digital de avisos y eventos (exterior al visor 3D) */
.pachinko-marquee-bar {
  width: 100%;
  box-sizing: border-box;
  background: #080d19;
  border: 1px solid #1e293b;
  border-radius: 10px;
  padding: 0.45rem 0.85rem;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  min-height: 40px;
  box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.7), 0 2px 8px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  position: relative;
}

.marquee-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #38bdf8;
  box-shadow: 0 0 8px #38bdf8;
  flex-shrink: 0;
  animation: pulse-dot 1.2s infinite alternate;
}

@keyframes pulse-dot {
  0% {
    opacity: 0.35;
    transform: scale(0.8);
  }

  100% {
    opacity: 1;
    transform: scale(1.2);
  }
}

.pachinko-announcement {
  font-family: var(--font-heading);
  font-size: 0.82rem;
  font-weight: 700;
  color: #94a3b8;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.03em;
  transition: all 0.25s ease;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
}

.pachinko-announcement.notice-active {
  animation: marquee-pop 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes marquee-pop {
  0% {
    transform: scale(0.95);
    opacity: 0.6;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.notice-info {
  background: rgba(14, 165, 233, 0.22);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.45);
  text-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
}

.notice-success {
  background: rgba(16, 185, 129, 0.22);
  color: #34d399;
  border: 1px solid rgba(52, 211, 153, 0.45);
  text-shadow: 0 0 10px rgba(52, 211, 153, 0.5);
}

.notice-gold {
  background: rgba(245, 158, 11, 0.22);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.45);
  text-shadow: 0 0 12px rgba(251, 191, 36, 0.6);
}

.notice-reach {
  background: rgba(239, 68, 68, 0.25);
  color: #f87171;
  border: 1px solid rgba(248, 113, 113, 0.5);
  text-shadow: 0 0 14px rgba(248, 113, 113, 0.7);
  animation: pulse-reach 0.7s infinite alternate;
}

@keyframes pulse-reach {
  0% {
    transform: scale(0.98);
    opacity: 0.85;
  }

  100% {
    transform: scale(1.02);
    opacity: 1;
    text-shadow: 0 0 20px rgba(248, 113, 113, 1);
  }
}

.notice-fever {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.4), rgba(245, 158, 11, 0.4));
  color: #fde047;
  border: 1px solid #facc15;
  text-shadow: 0 0 18px rgba(253, 224, 71, 0.9), 0 0 30px rgba(244, 63, 94, 0.8);
  font-size: 0.86rem;
  animation: pulse-fever 0.6s infinite alternate;
}

.notice-warning {
  background: rgba(234, 88, 12, 0.22);
  color: #fb923c;
  border: 1px solid rgba(251, 146, 60, 0.45);
  text-shadow: 0 0 10px rgba(251, 146, 60, 0.5);
}

@keyframes pulse-fever {
  0% {
    transform: scale(0.98);
  }

  100% {
    transform: scale(1.02);
  }
}

/* Columna lateral: Consola arcade y telemetría de salón */
.pachinko-side-console {
  flex: 1 1 0%;
  min-width: 320px;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.console-card {
  background: #0b111e;
  border: 1px solid #1e293b;
  border-radius: 14px;
  padding: 1.15rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.console-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid #1e293b;
}

.console-card-title {
  font-family: var(--font-heading);
  font-size: 0.94rem;
  font-weight: 700;
  color: #f8fafc;
}

.console-card-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.console-card-badge.badge-cyan {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.3);
}

.console-card-badge.badge-reach {
  background: rgba(244, 63, 94, 0.2);
  color: #f43f5e;
  border-color: rgba(244, 63, 94, 0.4);
}

.console-card-badge.badge-fever {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.3), rgba(245, 158, 11, 0.3));
  color: #fde047;
  border-color: #facc15;
}

.arcade-kbd {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  font-size: 0.68rem;
  font-family: var(--font-mono);
  font-weight: 600;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.85);
  margin-left: 0.35rem;
}

.console-controls-body {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.deck-buttons-row {
  display: flex;
  gap: 0.65rem;
  width: 100%;
}

.btn-arcade {
  flex: 1;
  min-height: 44px;
  border-radius: 10px;
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  user-select: none;
}

.btn-primary {
  background: linear-gradient(135deg, #f43f5e, #e11d48);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(244, 63, 94, 0.35);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #fb7185, #f43f5e);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(1px);
}

.btn-secondary {
  background: #172554;
  border-color: #1e3a8a;
  color: #38bdf8;
}

.btn-secondary:hover {
  background: #1e3a8a;
  color: #ffffff;
}

.btn-secondary.btn-active {
  background: #16a34a;
  border-color: #22c55e;
  color: #ffffff;
  box-shadow: 0 0 15px rgba(34, 197, 94, 0.4);
}

.btn-refill {
  background: #1e293b;
  border-color: #334155;
  color: #cbd5e1;
  width: 100%;
}

.btn-refill:hover {
  background: #334155;
  color: #ffffff;
}

/* Ajuste de potencia con dial y presets */
.dial-and-power-box {
  display: flex;
  align-items: center;
  gap: 1.15rem;
  background: #070d18;
  border: 1px solid #1a2536;
  border-radius: 12px;
  padding: 0.85rem 1rem;
}

.dial-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.pachinko-dial-wrapper {
  position: relative;
  width: 82px;
  height: 82px;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.pachinko-dial-wrapper:active {
  cursor: grabbing;
}

.dial-rim {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #334155, #0f172a);
  border: 3px solid #64748b;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.6), inset 0 2px 5px rgba(255, 255, 255, 0.15);
}

.dial-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 34px;
  background: linear-gradient(to bottom, #f43f5e, #be123c);
  border-radius: 6px;
  transform-origin: center bottom;
  transform: rotate(45deg);
  margin-left: -5px;
  margin-top: -34px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  border: 1px solid #fecdd3;
}

.dial-center-cap {
  position: absolute;
  inset: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 40%, #94a3b8, #1e293b);
  border: 2px solid #475569;
}

.dial-hint {
  font-size: 0.68rem;
  color: #64748b;
  font-weight: 600;
  text-align: center;
}

.power-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.power-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  font-weight: 600;
  color: #94a3b8;
}

.power-bar-track {
  height: 8px;
  background: #060913;
  border-radius: 9999px;
  overflow: hidden;
  border: 1px solid #1e293b;
}

.power-bar-fill {
  height: 100%;
  width: 65%;
  background: linear-gradient(90deg, #38bdf8, #f59e0b, #f43f5e);
  border-radius: 9999px;
  transition: width 0.05s linear;
}

/* Presets de potencia rápida */
.power-presets-row {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.25rem;
}

.btn-preset {
  flex: 1;
  padding: 0.35rem 0.2rem;
  font-size: 0.72rem;
  font-family: var(--font-mono);
  font-weight: 700;
  background: #0f172a;
  border: 1px solid #1e293b;
  color: #94a3b8;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
}

.btn-preset:hover {
  color: #ffffff;
  border-color: #38bdf8;
  background: #1e293b;
}

.btn-preset.is-active {
  background: #0284c7;
  border-color: #38bdf8;
  color: #ffffff;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
}

/* Telemetría y estadísticas */
.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.65rem;
}

.telemetry-item {
  background: #070d18;
  border: 1px solid #1a2536;
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.telemetry-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.telemetry-val {
  font-size: 1.15rem;
  font-weight: 700;
  color: #f8fafc;
}

/* Tabla de pagos (Paytable) */
.paytable-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.paytable-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background: #070d18;
  border: 1px solid #1a2536;
  border-radius: 8px;
  font-size: 0.8rem;
  gap: 0.5rem;
}

.pay-target {
  color: #f8fafc;
  white-space: nowrap;
  font-size: 0.82rem;
}

.pay-desc {
  color: #94a3b8;
  font-size: 0.75rem;
  flex: 1;
  text-align: left;
}

.pay-reward {
  font-family: var(--font-mono);
  font-weight: 700;
  color: #38bdf8;
  white-space: nowrap;
}

/* Modo pantalla completa en wrapper */
:fullscreen .pachinko-arcade-cabinet {
  height: 100vh;
  justify-content: center;
  border-radius: 0;
  border: none;
  padding: 1rem;
}

:fullscreen .pachinko-board-col {
  height: 100%;
}

:fullscreen .pachinko-viewport-wrapper {
  height: calc(100vh - 120px);
}

/* Adaptación responsive para pantallas medianas y móviles */
@media (max-width: 991px) {
  .pachinko-arcade-cabinet {
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    padding: 1rem;
  }

  .pachinko-board-col {
    width: 100%;
    max-width: 500px;
  }

  .pachinko-viewport-wrapper {
    height: 600px;
  }

  .pachinko-side-console {
    width: 100%;
    max-width: 500px;
  }
}

@media (max-width: 768px) {
  .tool-layout {
    margin: 1rem auto 2rem;
    padding: 0 0.75rem;
  }

  .card-main {
    padding: 1rem;
  }

  .pachinko-arcade-cabinet {
    padding: 0.85rem;
  }

  .pachinko-board-col {
    max-width: 100%;
  }

  .pachinko-viewport-wrapper {
    height: 520px;
  }

  .pachinko-side-console {
    max-width: 100%;
  }

  .deck-buttons-row {
    flex-direction: row;
  }
}

@media (max-width: 480px) {
  .pachinko-viewport-wrapper {
    height: 460px;
  }

  .hud-val {
    font-size: 1.15rem;
  }

  .dial-and-power-box {
    flex-direction: column;
    gap: 0.85rem;
  }

  .power-section {
    width: 100%;
  }
}