/* Xenon Tick Analyser - Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Tamper deterrent: block text selection (inputs stay usable) */
body {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
input,
textarea,
select {
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: white;
  color: #1e293b;
  line-height: 1.5;
  padding: 1rem;
  min-height: 100vh;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  max-width: 1200px;
  margin: 0 auto 0.75rem auto;
  padding: 0 0.25rem;
}

.wide-eye {
  background: linear-gradient(135deg, #ff6b6b 0%, #4ecdc4 100%);
  color: #0b1220;
  border: none;
  padding: 0.6rem 1rem;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
}

.launch-ai {
  background: linear-gradient(135deg, #2563eb 0%, #38bdf8 100%);
  color: #e2e8f0;
  border: none;
  padding: 0.6rem 1rem;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 25px rgba(37, 99, 235, 0.24);
}

.launch-ai:hover { transform: translateY(-1px); }
.launch-ai:active { transform: translateY(0); }
.launch-ai.is-active {
  background: linear-gradient(135deg, #0ea5e9 0%, #22d3ee 100%);
}

.wide-eye-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.wide-eye-info {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.18);
  background: rgba(255, 255, 255, 0.75);
  color: rgba(15, 23, 42, 0.9);
  font-weight: 800;
  font-size: 0.85rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: help;
}

.wide-eye-info:hover {
  background: rgba(255, 255, 255, 0.95);
}

.dark .wide-eye-info {
  border-color: rgba(226, 232, 240, 0.18);
  background: rgba(15, 23, 42, 0.55);
  color: rgba(226, 232, 240, 0.92);
}

.ai-talking-orb {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 56px;
  height: 56px;
  border-radius: 999px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 30% 30%, #60a5fa 0%, #2563eb 55%, #1d4ed8 100%);
  box-shadow:
    0 0 0 0 rgba(59, 130, 246, 0.5),
    0 0 45px rgba(37, 99, 235, 0.65);
  z-index: 9999;
  pointer-events: none;
  animation: ai-orb-pulse 1.2s ease-in-out infinite;
}

.ai-talking-orb::before,
.ai-talking-orb::after {
  content: '';
  position: absolute;
  inset: -10px;
  border-radius: 999px;
  border: 2px solid rgba(96, 165, 250, 0.7);
  animation: ai-orb-ring 1.4s ease-out infinite;
}

.ai-talking-orb::after {
  animation-delay: 0.7s;
}

@keyframes ai-orb-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.12); }
}

@keyframes ai-orb-ring {
  0% { transform: scale(0.85); opacity: 0.85; }
  100% { transform: scale(1.5); opacity: 0; }
}

/* Robotic shift overlay for auto-switch to Wide Eye */
.ai-shift {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 50% 50%, rgba(59,130,246,0.15), rgba(59,130,246,0.05) 40%, transparent 60%),
    linear-gradient(120deg, rgba(2,6,23,0.85), rgba(15,23,42,0.85));
  backdrop-filter: blur(2px);
  z-index: 9998;
  display: grid;
  place-items: center;
  animation: ai-shift-fade 1.2s ease-in-out forwards;
  pointer-events: none; /* never block clicks */
}

.ai-shift-core {
  width: 84px;
  height: 84px;
  border-radius: 16px;
  border: 3px solid rgba(59,130,246,0.85);
  box-shadow:
    0 0 30px rgba(59,130,246,0.45),
    inset 0 0 20px rgba(59,130,246,0.35);
  animation: ai-shift-rotate 1.2s linear infinite;
}

@keyframes ai-shift-rotate {
  0% { transform: rotate(0deg) scale(0.9); }
  50% { transform: rotate(180deg) scale(1.05); }
  100% { transform: rotate(360deg) scale(0.9); }
}

@keyframes ai-shift-fade {
  0% { opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { opacity: 0; }
}

.wide-eye:hover { transform: translateY(-1px); }
.wide-eye:active { transform: translateY(0px); }

.wide-status {
  font-size: 0.875rem;
  color: rgba(30, 41, 59, 0.75);
}
.dark .wide-status {
  color: rgba(226, 232, 240, 0.75);
}

/* Wide grid */
.wide-grid {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  /* Desktop + mobile: one panel per row (like phone view) */
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.wide-panel {
  background: rgba(255, 255, 255, 0.8);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
}
.dark .wide-panel {
  background: rgba(15, 23, 42, 0.65);
  border-color: rgba(255, 255, 255, 0.08);
}

.wide-panel__title {
  padding: 0.6rem 0.75rem;
  font-weight: 700;
  font-size: 0.9rem;
  color: #0f172a;
  background: linear-gradient(135deg, rgba(255, 107, 107, 0.15), rgba(78, 205, 196, 0.12));
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
.dark .wide-panel__title {
  color: #e2e8f0;
  background: linear-gradient(135deg, rgba(78, 205, 196, 0.16), rgba(69, 183, 209, 0.10));
  border-bottom-color: rgba(255, 255, 255, 0.06);
}

.wide-panel__body {
  padding: 0.75rem;
}

.wide-panel__actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.35rem;
}

.wide-panel__btn {
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(255, 255, 255, 0.8);
  color: rgba(15, 23, 42, 0.9);
  border-radius: 10px;
  padding: 0.35rem 0.6rem;
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
}

.wide-panel__btn:hover {
  background: rgba(255, 255, 255, 0.95);
}

.dark .wide-panel__btn {
  border-color: rgba(226, 232, 240, 0.16);
  background: rgba(15, 23, 42, 0.55);
  color: rgba(226, 232, 240, 0.92);
}

.wide-panel__bars {
  margin-top: 0.5rem;
}

/* Wide mode tweaks: make circles smaller so many panels fit */
.wide-panel .digits {
  grid-template-columns: repeat(10, minmax(32px, 1fr));
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}
.wide-panel .circle {
  width: 42px;
  height: 42px;
}
.wide-panel .circle-num {
  font-size: 0.95rem;
}
.wide-panel .circle-pct {
  font-size: 0.6rem;
}
.wide-panel .display {
  margin: 0.25rem 0 0.5rem 0;
  padding: 0.75rem;
}
.wide-panel .price {
  font-size: 1.25rem;
}
.wide-panel .digit {
  font-size: 2rem;
}

@media (max-width: 420px) {
  .wide-grid {
    grid-template-columns: 1fr;
  }
  /* Phone: show digits 0-4 then 5-9 (like normal view) */
  .wide-panel .digits {
    grid-template-columns: repeat(5, 1fr);
    gap: 0.25rem;
    row-gap: 0.6rem;
  }
  .wide-panel .circle {
    width: 40px;
    height: 40px;
  }
}

/* Dark theme support */
.dark body {
  background: white;
  color: #1e293b;
}

.box {
  max-width: 100%;
  width: 100%;
  margin: 0 auto;
  background: white;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.dark .box {
  background: white;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Header: hide app title to save vertical space */
#app-title { display: none; }

/* Form elements */
label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: #374151;
}

.dark label {
  color: #374151;
}

select, input[type="number"] {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: white;
  color: #1e293b;
  font-size: 0.875rem;
}

.dark select, .dark input[type="number"] {
  border-color: #d1d5db;
  background: white;
  color: #1e293b;
}

select:focus, input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Display section */
.display {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  margin: 0.5rem 0;
  padding: 1rem;
  background: #f1f5f9;
  border-radius: 8px;
}

.dark .display {
  background: #f1f5f9;
}

.price {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1e293b;
}

.dark .price {
  color: #1e293b;
}

.digit {
  font-size: 2rem;
  font-weight: 700;
  color: #3b82f6;
}

/* Controls */
.controls {
  margin: 0.5rem 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  align-items: center;
}

.hint {
  font-size: 0.75rem;
  color: #6b7280;
}

.dark .hint {
  color: #6b7280;
}

/* Digits section */
.digits-section {
  margin: 0.75rem 0;
}

.digits-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.samples {
  font-size: 0.875rem;
  color: #6b7280;
  background: #f3f4f6;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

.dark .samples {
  color: #6b7280;
  background: #f3f4f6;
}

.digits {
  display: grid;
  grid-template-columns: repeat(10, minmax(48px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
  position: relative; /* anchor for the gliding tick marker */
}

/* Eye-catching marker that glides to the active digit */
#tick-cursor {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 16px solid #22d3ee;
  pointer-events: none;
  z-index: 20;
  margin-top: -20px; /* sit just above the circle's top edge */
  transform: translateX(-50%);
  will-change: left, top;
  animation: tick-cursor-bob 1s ease-in-out infinite;
}
#tick-cursor[hidden] {
  display: none;
}

@keyframes tick-cursor-bob {
  0%, 100% {
    transform: translateX(-50%) translateY(0);
    border-top-color: #22d3ee;
    filter: drop-shadow(0 0 4px rgba(34, 211, 238, 0.85));
  }
  50% {
    transform: translateX(-50%) translateY(-4px);
    border-top-color: #a855f7;
    filter: drop-shadow(0 0 10px rgba(168, 85, 247, 0.95));
  }
}

@media (min-width: 1024px) {
  .circle {
    width: 64px;
    height: 64px;
  }
}

.digit-item {
  display: flex;
  justify-content: center;
}

.circle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid #e5e7eb;
  background: white;
  position: relative;
  overflow: visible;
}

.dark .circle {
  border-color: #e5e7eb;
  background: white;
}

.circle:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.circle-content {
  text-align: center;
  z-index: 2;
  position: relative;
}

.circle-num {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1e293b;
}

.dark .circle-num {
  color: #1e293b;
}

.circle-pct {
  font-size: 0.75rem;
  color: #6b7280;
  margin-top: 0.125rem;
}

.dark .circle-pct {
  color: #6b7280;
}

/* Circle states */
.circle.current {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* Old stationary markers replaced by the shared gliding #tick-cursor */
.circle.current::before {
  content: none;
}
.circle.current::after {
  content: none;
}

.circle.top {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
}

.circle.top .circle-num,
.circle.top .circle-pct {
  color: white;
}

.circle.second {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: white;
}

.circle.second .circle-num,
.circle.second .circle-pct {
  color: white;
}

.circle.least {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
}

.circle.least .circle-num,
.circle.least .circle-pct {
  color: white;
}

.circle.secondleast {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
}

.circle.secondleast .circle-num,
.circle.secondleast .circle-pct {
  color: white;
}

/* Legend */
.legend {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: #6b7280;
}

.dark .legend-item {
  color: #6b7280;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.dot-current {
  background: #3b82f6;
}

.dot-least {
  background: #ef4444;
}

/* Separator */
.separator {
  height: 1px;
  background: #e5e7eb;
  margin: 1.5rem 0;
}

.dark .separator {
  background: #e5e7eb;
}

/* Section headers */
.ou-header, .md-header, .eo-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.ou-header span, .md-header span, .eo-header span {
  font-weight: 600;
  color: #1e293b;
}

.dark .ou-header span, .dark .md-header span, .dark .eo-header span {
  color: #1e293b;
}

/* Cards */
.ou-cards, .md-cards, .eo-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.ou-card, .md-card, .eo-card {
  background: #f8fafc;
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
}

.dark .ou-card, .dark .md-card, .dark .eo-card {
  background: #f8fafc;
}

.ou-card-title, .md-card-title, .eo-card-title {
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: #1e293b;
}

.dark .ou-card-title, .dark .md-card-title, .dark .eo-card-title {
  color: #1e293b;
}

.ou-card-value, .md-card-value, .eo-card-value {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: #1e293b;
}

.dark .ou-card-value, .dark .md-card-value, .dark .eo-card-value {
  color: #1e293b;
}

.muted {
  font-size: 0.875rem;
  color: #6b7280;
  font-weight: 400;
}

.dark .muted {
  color: #6b7280;
}

/* Bar lines */
.ou-barline, .md-barline, .eo-barline {
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
}

.dark .ou-barline, .dark .md-barline, .dark .eo-barline {
  background: #e5e7eb;
}

.ou-fill, .md-fill, .eo-fill {
  height: 100%;
  transition: width 0.3s ease;
}

.ou-fill-under {
  background: #10b981;
}

.ou-fill-equal {
  background: #6b7280;
}

.ou-fill-over {
  background: #ef4444;
}

.md-fill-match {
  background: #10b981;
}

.md-fill-differ {
  background: #ef4444;
}

.eo-fill-even {
  background: #10b981;
}

.eo-fill-odd {
  background: #ef4444;
}

/* Sequence sections */
.ou-seq, .md-seq, .eo-seq {
  margin-top: 1rem;
}

.ou-seq-header, .md-seq-header, .eo-seq-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.ou-seq-header span, .md-seq-header span, .eo-seq-header span {
  font-weight: 500;
  color: #1e293b;
}

.dark .ou-seq-header span, .dark .md-seq-header span, .dark .eo-seq-header span {
  color: #1e293b;
}

.ou-seq-header button, .md-seq-header button, .eo-seq-header button {
  background: #3b82f6;
  color: white;
  border: none;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.2s ease;
}

.ou-seq-header button:hover, .md-seq-header button:hover, .eo-seq-header button:hover {
  background: #2563eb;
}

/* Chips */
.ou-chips, .md-chips, .eo-chips {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.ou-chip, .md-chip, .eo-chip {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: white;
}

.ou-chip.under, .eo-chip.even, .md-chip.match {
  background: #10b981;
}

.ou-chip.equal {
  background: #6b7280;
}

.ou-chip.over, .eo-chip.odd, .md-chip.differ {
  background: #ef4444;
}

/* Responsive design */
@media (max-width: 640px) {
  .box {
    padding: 1rem;
    margin: 0.5rem;
  }
  
  .digits {
    grid-template-columns: repeat(5, 1fr);
    gap: 0.25rem;
    row-gap: 1rem;
  }
  
  .circle {
    width: 50px;
    height: 50px;
  }
  
  .circle-num {
    font-size: 1rem;
  }
  
  .circle-pct {
    font-size: 0.625rem;
  }
  
  .ou-cards, .md-cards, .eo-cards {
    grid-template-columns: 1fr;
  }
  
  .display {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .controls {
    flex-direction: column;
    align-items: flex-start;
  }
}
