/* ==========================================================================
   10-SEC BLITZ — Direct Arena & Smart Time-Guard Styling
   ========================================================================== */

:root {
  /* Dark Mode Palette Default */
  --bg-primary: #090d16;
  --bg-secondary: #111726;
  --bg-tertiary: #192238;
  --glass-bg: rgba(17, 23, 38, 0.75);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-border-glow: rgba(99, 102, 241, 0.3);
  
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-cyan: #06b6d4;
  --accent-purple: #8b5cf6;
  --accent-indigo: #6366f1;
  --accent-pink: #ec4899;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;

  --glow-cyan: rgba(6, 182, 212, 0.4);
  --glow-emerald: rgba(16, 185, 129, 0.4);

  --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --glass-bg: rgba(255, 255, 255, 0.85);
  --glass-border: rgba(0, 0, 0, 0.08);
  --glass-border-glow: rgba(99, 102, 241, 0.2);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --glow-cyan: rgba(6, 182, 212, 0.2);
  --glow-emerald: rgba(16, 185, 129, 0.2);
}

/* Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  line-height: 1.5;
}

/* Background Radial Gradient */
.bg-mesh {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -2;
  background: 
    radial-gradient(circle at 15% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 40%),
    radial-gradient(circle at 85% 75%, rgba(6, 182, 212, 0.15) 0%, transparent 45%);
  pointer-events: none;
}

.accent-text {
  color: var(--accent-cyan);
}

.hidden {
  display: none !important;
}

/* Header Bar */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--glass-border);
  padding: 0.75rem 1.5rem;
  transition: background 0.3s ease;
}

@media (max-width: 768px) {
  .top-nav {
    padding-top: max(env(safe-area-inset-top, 0px), 50px) !important;
  }
}

.nav-container {
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 900;
  font-size: 1.35rem;
  letter-spacing: -0.5px;
  user-select: none;
}

.logo-icon {
  font-size: 1.5rem;
}

.nav-controls {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.session-badge {
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: var(--accent-indigo);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-full);
}

/* Icon Buttons */
.icon-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  transition: var(--transition-fast);
}

.icon-btn:hover {
  background: var(--glass-border-glow);
  border-color: var(--accent-indigo);
}

/* Hamburger Menu Button */
.hamburger-btn {
  flex-direction: column;
  gap: 4px;
  padding: 10px;
}

.hamburger-bar {
  width: 20px;
  height: 2px;
  background-color: var(--text-primary);
  border-radius: 2px;
  transition: var(--transition-normal);
}

.hamburger-btn[aria-expanded="true"] .hamburger-bar:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

.hamburger-btn[aria-expanded="true"] .hamburger-bar:nth-child(2) {
  opacity: 0;
}

.hamburger-btn[aria-expanded="true"] .hamburger-bar:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* Mobile Dropdown Menu */
.mobile-nav-dropdown {
  max-width: 1000px;
  margin: 0.5rem auto 0 auto;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}

.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.nav-link {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
}

.nav-link:hover {
  background: var(--glass-border-glow);
  color: var(--accent-cyan);
}

.nav-link-muted {
  color: var(--text-muted) !important;
  font-weight: 500 !important;
}

/* Main Content */
.main-wrapper {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem 1.25rem;
}

.view-section {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Arena HUD Header */
.arena-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
}

.hud-item {
  display: flex;
  flex-direction: column;
}

.align-right { text-align: right; }

.hud-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.hud-value {
  font-weight: 800;
  font-size: 1.1rem;
}

/* INTEGER COUNTDOWN TIMER STYLING (10..9..8...0) */
.timer-container {
  position: relative;
  width: 76px;
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.timer-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.timer-bg {
  fill: none;
  stroke: var(--bg-tertiary);
  stroke-width: 8;
}

.timer-progress {
  fill: none;
  stroke: var(--accent-cyan);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 276.46;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.15s linear, stroke 0.3s ease;
}

.integer-timer {
  position: absolute;
  font-family: var(--font-mono);
  font-weight: 900;
  font-size: 1.65rem;
  color: var(--text-primary);
  transition: transform 0.1s ease;
}

.timer-tick-anim {
  animation: tickPulse 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes tickPulse {
  0% { transform: scale(1.3); color: var(--accent-cyan); }
  100% { transform: scale(1); }
}

.timer-warning .timer-progress { stroke: var(--accent-amber); }
.timer-danger .timer-progress { stroke: var(--accent-rose); }
.timer-danger .integer-timer { color: var(--accent-rose); }

/* High-Visibility Big Instruction Bar */
.arena-instruction-bar {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(6, 182, 212, 0.15));
  border: 2px solid var(--accent-cyan);
  box-shadow: 0 4px 20px rgba(6, 182, 212, 0.25);
  padding: 0.95rem 1.25rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  margin-bottom: 1.25rem;
  text-align: center;
  animation: barPulse 2s infinite alternate;
}

@keyframes barPulse {
  0% { box-shadow: 0 4px 16px rgba(6, 182, 212, 0.2); }
  100% { box-shadow: 0 6px 26px rgba(99, 102, 241, 0.4); }
}

.instruction-icon {
  font-size: 2rem;
  filter: drop-shadow(0 0 6px var(--accent-cyan));
}

.instruction-text {
  font-size: 1.3rem;
  font-weight: 900;
  letter-spacing: -0.2px;
  color: #ffffff;
  line-height: 1.25;
}

.instruction-text strong {
  color: var(--accent-cyan);
  text-transform: uppercase;
}

/* Arena Canvas Box */
.arena-canvas-box {
  background: var(--bg-secondary);
  border: 2px solid var(--glass-border);
  border-radius: var(--radius-lg);
  position: relative;
  width: 100%;
  height: 420px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
}

#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.html-game-container {
  width: 100%;
  height: 100%;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  user-select: none;
}

/* Interactive Puzzle Options & Numbers (High Contrast for Dark & Light Mode) */
.math-expression-display {
  font-family: var(--font-mono);
  font-size: 3rem;
  font-weight: 900;
  color: var(--text-primary);
  margin-bottom: 1.75rem;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  letter-spacing: 2px;
}

.puzzle-option-btn {
  background: var(--bg-tertiary) !important;
  color: var(--text-primary) !important;
  border: 2px solid var(--glass-border) !important;
  border-radius: var(--radius-md) !important;
  font-family: var(--font-mono) !important;
  font-size: 1.75rem !important;
  font-weight: 800 !important;
  padding: 1.1rem 1.5rem !important;
  cursor: pointer;
  transition: all 0.15s ease !important;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2) !important;
}

.puzzle-option-btn:hover {
  border-color: var(--accent-cyan) !important;
  background: var(--glass-border-glow) !important;
  transform: translateY(-3px) scale(1.03) !important;
  color: var(--accent-cyan) !important;
  box-shadow: 0 6px 20px var(--glow-cyan) !important;
}

.odd-tile-btn {
  background: var(--bg-tertiary) !important;
  border: 2px solid var(--glass-border) !important;
  border-radius: var(--radius-md) !important;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.25rem;
  cursor: pointer;
  transition: all 0.15s ease !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
}

.odd-tile-btn:hover {
  border-color: var(--accent-cyan) !important;
  transform: scale(1.08) !important;
}

/* BUTTON SYSTEM & VISUAL HIERARCHY */
.btn {
  font-family: var(--font-main);
  font-weight: 800;
  font-size: 0.95rem;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: var(--transition-fast);
  user-select: none;
}

/* Vibrant Primary CTA */
.btn-primary {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-indigo));
  color: #ffffff;
  box-shadow: 0 4px 16px var(--glow-cyan);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(6, 182, 212, 0.5);
}

/* Save Time / Anti-Procrastination CTA */
.btn-save-time {
  background: linear-gradient(135deg, var(--accent-emerald), #047857);
  color: #ffffff;
  box-shadow: 0 4px 16px var(--glow-emerald);
}

.btn-save-time:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(16, 185, 129, 0.5);
}

/* Restart CTA on Fail */
.btn-restart {
  background: linear-gradient(135deg, var(--accent-rose), #be123c);
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(244, 63, 94, 0.4);
}

.btn-restart:hover {
  transform: translateY(-2px);
}

.btn-block {
  width: 100%;
}

.pulse-btn {
  animation: btnPulse 2s infinite;
}

@keyframes btnPulse {
  0% { box-shadow: 0 0 0 0 rgba(6, 182, 212, 0.5); }
  70% { box-shadow: 0 0 0 12px rgba(6, 182, 212, 0); }
  100% { box-shadow: 0 0 0 0 rgba(6, 182, 212, 0); }
}

/* CRITICAL RULE #6: MUTED / LESS APPEALING "CONTINUE TO APP" BUTTON */
.btn-continue-muted {
  background: transparent;
  border: 1px dashed var(--glass-border);
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-md);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  transition: var(--transition-fast);
  margin-top: 0.35rem;
}

.btn-continue-muted:hover {
  color: var(--text-secondary);
  opacity: 1;
  border-style: solid;
  border-color: var(--text-secondary);
}

/* MODAL OVERLAY */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(9, 13, 22, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: fadeIn 0.25s ease;
}

.modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  max-width: 440px;
  width: 100%;
  padding: 2rem;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

.modal-status-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.modal-header h2 {
  font-size: 1.75rem;
  font-weight: 900;
  margin-bottom: 0.25rem;
}

.modal-header p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* PRODUCTIVITY SHIELD VIEW */
.shield-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  text-align: center;
}

.shield-icon {
  font-size: 3.5rem;
  margin-bottom: 0.75rem;
}

.shield-title {
  font-size: 2rem;
  font-weight: 900;
  margin-bottom: 0.5rem;
}

.shield-desc {
  color: var(--text-secondary);
  font-size: 1.05rem;
  margin-bottom: 2rem;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

.shield-stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 2rem;
  background: var(--bg-tertiary);
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border);
}

.shield-stat-item {
  display: flex;
  flex-direction: column;
}

.shield-stat-item span {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
}

.shield-stat-item strong {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--accent-emerald);
}

.shield-actions {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.btn-muted-link {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-decoration: none;
  transition: var(--transition-fast);
}

.btn-muted-link:hover {
  color: var(--accent-cyan);
}

@media (max-width: 640px) {
  .arena-canvas-box { height: 340px; }
  .shield-card { padding: 1.75rem 1.25rem; }
}
