/* ===== RESET & BASE ===== */

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

[hidden] {
  display: none !important;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  background: #f7f6ec;
  color: #0a0a0a;
  -webkit-user-select: none;
  user-select: none;
}

/* ===== SHARED: screen wrapper ===== */

.screen {
  position: relative;
  width: 100vw;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ===== SHARED: glassmorphism button ===== */

.btn-primary {
  display: block;
  width: 100%;
  padding: 4.5vw 0;
  background: rgba(247, 246, 236, 0.25);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  backdrop-filter: blur(16px) saturate(180%);
  color: #0a0a0a;
  font-family: inherit;
  font-size: 4.5vw;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 4px 24px rgba(0,0,0,0.08), inset 0 1px 0 rgba(255,255,255,0.5);
  cursor: pointer;
  border-radius: 2px;
  transition: background 0.2s, box-shadow 0.2s;
  text-decoration: none;
}

.btn-primary:active {
  background: rgba(247, 246, 236, 0.45);
  box-shadow: 0 2px 12px rgba(0,0,0,0.06), inset 0 1px 0 rgba(255,255,255,0.5);
}

.btn-glass {
  flex: 1;
  padding: 3.5vw 0;
  background: rgba(247, 246, 236, 0.2);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  backdrop-filter: blur(12px) saturate(160%);
  color: #0a0a0a;
  font-family: inherit;
  font-size: 3.8vw;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 2px 12px rgba(0,0,0,0.06), inset 0 1px 0 rgba(255,255,255,0.4);
  cursor: pointer;
  border-radius: 2px;
  transition: background 0.15s;
}

.btn-glass:active {
  background: rgba(247, 246, 236, 0.4);
}

/* ===== SPLASH ===== */

#splash {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: #f7f6ec;
  justify-content: space-between;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

.splash-content {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  padding: 7vw 7vw 8vw;
}

.splash-content .top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: max(env(safe-area-inset-top), 4vw);
}

.splash-brand {
  font-size: 3.2vw;
  font-weight: 600;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  opacity: 0.45;
}

.splash-content .hamburger {
  background: none;
  border: none;
  color: rgba(10, 10, 10, 0.4);
  cursor: pointer;
  padding: 8px;
  transition: color 0.2s;
}

.splash-content .hamburger:active {
  color: rgba(10, 10, 10, 0.7);
}

.splash-content .nav-menu[hidden] { display: none !important; }

.splash-content .nav-menu {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(247, 246, 236, 0.55);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6vw;
  animation: menu-in-splash 0.25s ease-out;
}

@keyframes menu-in-splash {
  from { opacity: 0; }
  to { opacity: 1; }
}

.splash-content .nav-link {
  font-family: 'Bodoni Moda', 'Didot', 'Georgia', serif;
  font-style: normal;
  font-size: 7vw;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  color: #0a0a0a;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.splash-content .nav-link:active {
  opacity: 1;
}

.splash-content .nav-credit {
  position: absolute;
  bottom: max(env(safe-area-inset-bottom), 6vw);
  font-size: 2.8vw;
  letter-spacing: 0.05em;
  opacity: 0.3;
  color: #0a0a0a;
}

.splash-content .nav-credit a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.splash-headline {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 0.88;
  padding: 4vw 0;
}

.splash-h1 {
  font-family: 'Bodoni Moda', 'Didot', 'Georgia', serif;
  font-style: italic;
  font-weight: 400;
  font-size: 19vw;
  letter-spacing: -0.03em;
  text-transform: uppercase;
  display: block;
}

.splash-h2 {
  font-weight: 700;
  font-size: 13.5vw;
  letter-spacing: -0.04em;
  text-transform: uppercase;
  display: block;
  margin-top: 1.5vw;
}

.splash-sub {
  font-size: 3.8vw;
  line-height: 1.45;
  opacity: 0.65;
  max-width: 82vw;
  margin-top: 5vw;
  margin-bottom: auto;
}

.splash-cta {
  display: flex;
  flex-direction: column;
  gap: 3.5vw;
}

.splash-hint {
  font-size: 2.8vw;
  letter-spacing: 0.1em;
  text-align: center;
  opacity: 0.35;
  font-weight: 500;
  text-transform: uppercase;
}


/* ===== SPLASH LOADING STATE ===== */

.splash-ribbons {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

.splash-content {
  position: relative;
  z-index: 10;
}

.btn-primary.is-loading {
  pointer-events: none;
  animation: btn-pulse 1.8s ease-in-out infinite;
}

@keyframes btn-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.splash-hint.is-loading {
  opacity: 0.5;
}

/* ===== APP LAYOUT ===== */

#app {
  background: #f7f6ec;
  transition: background 0.8s ease;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 3vw;
  padding: max(env(safe-area-inset-top), 3vw) 5vw 2.5vw;
  background: transparent;
}

.header-left {
  flex-shrink: 0;
}

.level-name {
  font-size: 3.2vw;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  opacity: 0.4;
  white-space: nowrap;
}

#counter {
  font-family: 'Bodoni Moda', 'Didot', 'Georgia', serif;
  font-style: italic;
  font-size: 8vw;
  font-weight: 400;
  letter-spacing: -0.02em;
  opacity: 0.3;
}

main {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.visual-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* ===== POMLAZKA CANVAS ===== */

#pomlazka-canvas {
  background: #f7f6ec;
  transition: background 0.8s ease;
}

/* ===== SABER VISUAL ===== */

#saber-canvas {
  display: none;
}

[data-mode="saber"] #pomlazka-canvas {
  display: none;
}

[data-mode="saber"] #saber-canvas {
  display: block;
  background: #0a0a12;
}

[data-mode="saber"] #app {
  background: #0a0a12;
}

[data-mode="saber"] header {
  color: rgba(255, 255, 255, 0.5);
}

[data-mode="saber"] .level-name {
  opacity: 0.3;
  color: #fff;
}

[data-mode="saber"] #counter {
  color: #fff;
  opacity: 0.2;
}

[data-mode="saber"] footer {
  background: rgba(10, 10, 18, 0.8);
  border-top-color: rgba(255, 255, 255, 0.08);
}

[data-mode="saber"] .btn-glass {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.8);
  border-color: rgba(255, 255, 255, 0.12);
}

[data-mode="saber"] .btn-glass:active {
  background: rgba(255, 255, 255, 0.15);
}

[data-mode="saber"] .sensitivity-control {
  color: rgba(255, 255, 255, 0.4);
}

[data-mode="saber"] .sensitivity-control input[type="range"] {
  background: rgba(255, 255, 255, 0.15);
}

[data-mode="saber"] .sensitivity-control input[type="range"]::-webkit-slider-thumb {
  background: rgba(255, 255, 255, 0.6);
}

/* ===== PROGRESS BAR ===== */

.header-right {
  flex: 1;
  min-width: 0;
}

.level-steps {
  position: relative;
  width: 100%;
  height: 40px;
  padding: 0 15px;
}

.step-track {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  background: rgba(10, 10, 10, 0.12);
  transform: translateY(-50%);
}

.step-milestone {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #f7f6ec;
  border: 1px solid rgba(10, 10, 10, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 500;
  color: rgba(10, 10, 10, 0.3);
}

.step-current {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(10, 10, 10, 0.1);
  border: 2px solid rgba(10, 10, 10, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: rgba(10, 10, 10, 0.6);
  transition: left 0.3s ease-out;
  z-index: 1;
}

/* ===== FOOTER / CONTROLS ===== */

footer {
  position: relative;
  padding: 3.5vw 5vw;
  padding-bottom: max(3.5vw, env(safe-area-inset-bottom));
  background: rgba(247, 246, 236, 0.8);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  transition: background 0.8s ease, border-top-color 0.8s ease;
}

.controls {
  display: flex;
  gap: 3vw;
  margin-bottom: 3vw;
}

.sensitivity-control {
  display: flex;
  align-items: center;
  gap: 3vw;
  color: rgba(10, 10, 10, 0.4);
  font-size: 2.8vw;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sensitivity-control label {
  white-space: nowrap;
}

.sensitivity-control input[type="range"] {
  flex: 1;
  height: 3px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(10, 10, 10, 0.15);
  border-radius: 2px;
  outline: none;
}

.sensitivity-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  background: rgba(10, 10, 10, 0.25);
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.15s;
}

.sensitivity-control input[type="range"]::-webkit-slider-thumb:active {
  background: rgba(10, 10, 10, 0.4);
}

/* ===== COLOR PICKER MODAL ===== */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(10, 10, 10, 0.5);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: modal-fade-in 0.3s ease-out;
}

@keyframes modal-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-content {
  background: rgba(247, 246, 236, 0.9);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border-radius: 20px;
  padding: 8vw 7vw;
  text-align: center;
  max-width: 85vw;
  width: 320px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 8px 40px rgba(0,0,0,0.15);
}

.modal-emoji {
  font-size: 10vw;
  margin-bottom: 2vw;
}

.modal-title {
  font-family: 'Bodoni Moda', serif;
  font-style: italic;
  font-size: 6vw;
  font-weight: 500;
  margin-bottom: 1vw;
}

.modal-subtitle {
  font-size: 3.2vw;
  opacity: 0.5;
  margin-bottom: 5vw;
}

.color-slots {
  display: flex;
  flex-direction: column;
  gap: 4vw;
  align-items: center;
}

.color-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2vw;
}

.color-slot-label {
  font-size: 2.5vw;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.4;
}

.color-options {
  display: flex;
  gap: 3vw;
  justify-content: center;
  flex-wrap: wrap;
}

.color-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}

.color-circle:active {
  transform: scale(0.9);
}

.color-circle.selected {
  border-color: #0a0a0a;
  transform: scale(1.1);
}

/* ===== FOOTER CONTROLS ===== */

.footer-row {
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 0 12vw;
}

.btn-back {
  position: absolute;
  left: 5vw;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: transparent;
  color: rgba(10, 10, 10, 0.25);
  border: none;
  text-decoration: none;
  transition: color 0.2s;
}

.btn-back:active {
  color: rgba(10, 10, 10, 0.5);
}

[data-level="jedi"] .btn-back {
  color: rgba(255, 255, 255, 0.25);
}

.btn-mode-toggle {
  display: block;
  padding: 3.5vw 6vw;
  background: transparent;
  color: rgba(10, 10, 10, 0.4);
  font-family: inherit;
  font-size: 3.2vw;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: 1px solid rgba(10, 10, 10, 0.12);
  border-radius: 2px;
  cursor: pointer;
  transition: color 0.8s ease, border-color 0.8s ease;
}

.btn-mode-toggle:active {
  color: rgba(10, 10, 10, 0.6);
  border-color: rgba(10, 10, 10, 0.25);
}

/* ===== TOAST ===== */

#toast {
  position: fixed;
  bottom: 30%;
  left: 50%;
  transform: translateX(-50%);
  padding: 3vw 6vw;
  background: rgba(10, 10, 10, 0.85);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  color: #fff;
  font-size: 4vw;
  font-weight: 700;
  letter-spacing: 0.04em;
  border-radius: 2px;
  pointer-events: none;
  animation: toast-in 0.3s ease-out, toast-out 0.3s ease-in 1.5s forwards;
  z-index: 100;
  white-space: nowrap;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toast-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* ===== JEDI MASTER DARK MODE ===== */

[data-level="jedi"] #app {
  background: #0a0a1a;
  transition: background 0.6s ease;
}

[data-level="jedi"] #pomlazka-canvas {
  background: #0a0a1a;
  transition: background 0.6s ease;
}

[data-level="jedi"] header {
  color: rgba(255, 255, 255, 0.5);
}

[data-level="jedi"] .level-name {
  opacity: 0.5;
  color: rgba(0, 212, 255, 0.8);
  text-shadow: 0 0 10px rgba(0, 212, 255, 0.4);
}

[data-level="jedi"] #counter {
  color: #00d4ff;
  opacity: 0.8;
  text-shadow: 0 0 12px rgba(0, 212, 255, 0.5);
}

[data-level="jedi"] .step-track {
  background: rgba(0, 212, 255, 0.15);
}

[data-level="jedi"] .step-milestone {
  color: rgba(0, 212, 255, 0.35);
  background: rgba(0, 212, 255, 0.06);
  border-color: rgba(0, 212, 255, 0.15);
}

[data-level="jedi"] .step-current {
  color: rgba(0, 212, 255, 0.9);
  background: rgba(0, 212, 255, 0.15);
  border-color: rgba(0, 212, 255, 0.5);
  box-shadow: 0 0 10px rgba(0, 212, 255, 0.3);
}

[data-level="jedi"] .progress-bar {
  background: linear-gradient(90deg, #9b59b6, #00d4ff);
  box-shadow: 0 0 8px rgba(0, 212, 255, 0.4);
}

[data-level="jedi"] footer {
  background: rgba(10, 10, 26, 0.8);
  border-top-color: rgba(255, 255, 255, 0.08);
}

[data-level="jedi"] .btn-mode-toggle {
  color: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.1);
}

[data-level="jedi"] .btn-mode-toggle:active {
  color: rgba(255, 255, 255, 0.5);
}

[data-level="jedi"] #toast {
  background: rgba(0, 212, 255, 0.15);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  color: #00d4ff;
  text-shadow: 0 0 8px rgba(0, 212, 255, 0.4);
}

[data-level="jedi"] .modal-content {
  background: rgba(10, 10, 26, 0.9);
  border-color: rgba(0, 212, 255, 0.2);
  color: #fff;
}

[data-level="jedi"] .modal-subtitle {
  color: rgba(255, 255, 255, 0.5);
}

[data-level="jedi"] .color-slot-label {
  color: rgba(255, 255, 255, 0.4);
}

[data-level="jedi"] .color-circle.selected {
  border-color: #00d4ff;
  box-shadow: 0 0 12px rgba(0, 212, 255, 0.4);
}

/* ============================================================
   RESPONSIVE — tablet (≥600px)
   ============================================================ */

@media (min-width: 600px) {

  /* --- Splash --- */
  .splash-content {
    padding: 4vw 8vw 5vw;
    max-width: 720px;
    margin: 0 auto;
  }
  .splash-brand       { font-size: 14px; }
  .splash-h1          { font-size: 90px; }
  .splash-h2          { font-size: 68px; }
  .splash-sub         { font-size: 18px; max-width: 480px; margin-top: 24px; }
  .splash-cta         { gap: 14px; }
  .splash-hint        { font-size: 11px; }

  .btn-primary        { padding: 20px 0; font-size: 18px; max-width: 400px; margin: 0 auto; }

  /* --- App --- */
  header              { padding: max(env(safe-area-inset-top), 16px) 24px 12px; }
  .level-name         { font-size: 14px; }
  #counter            { font-size: 42px; }
  .level-steps        { height: 34px; }
  .step-milestone     { width: 22px; height: 22px; font-size: 9px; }
  .step-current       { width: 30px; height: 30px; font-size: 12px; }

  footer              { padding: 16px 24px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .controls           { gap: 12px; margin-bottom: 12px; }
  .btn-glass          { padding: 14px 0; font-size: 15px; }
  .sensitivity-control { gap: 12px; font-size: 12px; }

  .btn-mode-toggle { padding: 10px 0; font-size: 11px; max-width: 300px; margin: 0 auto; }

  #toast              { padding: 12px 28px; font-size: 16px; }

  .modal-content { padding: 32px 28px; width: 360px; }
  .modal-emoji { font-size: 40px; margin-bottom: 8px; }
  .modal-title { font-size: 24px; margin-bottom: 4px; }
  .modal-subtitle { font-size: 13px; margin-bottom: 20px; }
  .color-slots { gap: 16px; }
  .color-slot { gap: 8px; }
  .color-slot-label { font-size: 10px; }
  .color-options { gap: 12px; }
}

/* ============================================================
   RESPONSIVE — desktop (≥960px)
   ============================================================ */

@media (min-width: 960px) {

  /* --- Splash --- */
  .splash-content {
    padding: 40px 60px 48px;
    max-width: 900px;
  }
  .splash-brand       { font-size: 15px; padding-top: 0; }
  .splash-h1          { font-size: 120px; }
  .splash-h2          { font-size: 88px; margin-top: 8px; }
  .splash-sub         { font-size: 20px; max-width: 520px; margin-top: 32px; }
  .splash-hint        { font-size: 12px; }

  .btn-primary        { padding: 22px 0; font-size: 18px; max-width: 380px;
                         border-radius: 2px; }
  .btn-primary:hover  { background: rgba(247, 246, 236, 0.4); }

  /* --- App --- */
  header              { padding: 20px 32px 14px; }
  .level-name         { font-size: 15px; }
  #counter            { font-size: 48px; }
  .level-steps        { height: 36px; max-width: 320px; }
  .step-milestone     { width: 24px; height: 24px; font-size: 10px; }
  .step-current       { width: 32px; height: 32px; font-size: 13px; }

  footer              { padding: 18px 32px; padding-bottom: max(18px, env(safe-area-inset-bottom)); }
  .controls           { gap: 14px; margin-bottom: 14px; max-width: 500px; }
  .btn-glass          { padding: 16px 0; font-size: 15px; border-radius: 2px; }
  .btn-glass:hover    { background: rgba(247, 246, 236, 0.35); }
  .sensitivity-control { gap: 14px; font-size: 12px; max-width: 400px; }

  .btn-mode-toggle { padding: 12px 0; font-size: 12px; }
  .btn-mode-toggle:hover { color: rgba(10, 10, 10, 0.5); border-color: rgba(10, 10, 10, 0.2); }

  #toast              { padding: 14px 32px; font-size: 17px; border-radius: 2px; }

  /* Saber hover states */
  [data-mode="saber"] .btn-glass:hover {
    background: rgba(255, 255, 255, 0.12);
  }
}

/* ============================================================
   RESPONSIVE — wide desktop (≥1200px)
   ============================================================ */

@media (min-width: 1200px) {
  .splash-content     { max-width: 1000px; }
  .splash-h1          { font-size: 140px; }
  .splash-h2          { font-size: 100px; }
  .splash-sub         { font-size: 22px; }
}
