:root {
  --bg: #e3f2fd;
  --fg: #0d47a1;
  --panel: #ffffff;
  --ok: #4caf50;
  --err: #f44336;
  --key: #e0e7ff;
  --key-active: #ffeb3b;
}
:root.dark {
  --bg: #0b1220;
  --fg: #cbd5e1;
  --panel: #111827;
  --key: #1f2937;
  --key-active: #f59e0b;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Noto Sans, Arial; background: var(--bg); color: var(--fg); }
.app { display: grid; grid-template-rows: auto 1fr auto; height: 100%; min-height: 100dvh; }
.app .scale-practice, .app .scale-keyboard, .app .scale-fingers { transform-origin: center; }
.topbar { display:grid; grid-template-columns: 1fr 1fr 1fr; align-items:center; gap: 8px; padding: 8px 12px; background: var(--panel); box-shadow: 0 1px 2px rgb(0 0 0 / 0.1); padding-left: calc(12px + env(safe-area-inset-left)); padding-right: calc(12px + env(safe-area-inset-right)); padding-top: calc(8px + env(safe-area-inset-top)); }
.controls { display:flex; gap: 8px; align-items:center; flex-wrap: wrap; }
.run-controls { display:flex; gap: 8px; align-items:center; }
.btn { font-size: 14px; padding: 6px 10px; border-radius: 6px; border: none; box-shadow: 0 1px 0 rgb(0 0 0 / .15); background: #e5e7eb; color: #111827; }
.btn.primary { background: #2563eb; color: #fff; }
.btn.small { font-size: 12px; padding: 4px 8px; }
.brand { justify-self: start; grid-column: 1; }
.top-hud { grid-column: 2; justify-self: center; font-weight: 700; font-size: 14px; display:flex; gap: 12px; align-items: baseline; white-space: nowrap; }
.controls {
  grid-column: 3;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.main { display: grid; grid-template-rows: 1fr auto auto; gap: 8px; padding: 12px; }
.big-btn { font-size: 22px; padding: 10px 18px; border-radius: 10px; border: none; box-shadow: 0 2px 0 rgb(0 0 0 / .15); }
.big-btn.primary { background: #2563eb; color: #fff; }
.practice { display:grid; place-items:center; background: var(--panel); border-radius: 8px; padding: 5px; min-height: 160px; position: relative; }
.timed-view .word { font-size: 68px; font-weight: 800; letter-spacing: 1px; }
.timed-view #current { background: var(--key-active); color: #111827; padding: 4px 6px; border-radius: 6px; box-shadow: 0 2px 0 rgb(0 0 0 / .15); animation: appear .25s ease; }
@keyframes appear { from { transform: scale(0.9); opacity: 0.5; } to { transform: scale(1); opacity: 1; } }
.flash-ok { animation: flashOk .25s ease; }
.flash-err { animation: flashErr .35s ease; }
@keyframes flashOk { from { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.5);} to { box-shadow: 0 0 0 16px rgba(76, 175, 80, 0);} }
@keyframes flashErr { 0% { background: rgba(244, 67, 54, 0.08);} 100% { background: transparent; } }
.hidden { display:none; }
.keyboard { background: var(--panel); border-radius: 8px; padding: 16px; display: grid; gap: 12px; }
.row { display:flex; gap: 12px; justify-content:center; }
.key { background: var(--key); padding: 16px 12px; min-width: 48px; text-align: center; border-radius: 8px; user-select: none; transition: transform .05s ease, background .2s; box-shadow: inset 0 -2px 0 rgb(0 0 0 / .06); font-size: 18px; }
.key.active { background: var(--key-active); transform: translateY(1px) scale(0.98); }
.key.target { outline: 3px solid var(--key-active); animation: pulse 1s infinite ease-in-out; }
.key.ok { animation: keyOk .25s ease; }
.key.err { animation: keyErr .35s ease; }
.timed-view #current { background: var(--key-active); color: #111827; padding: 2px 4px; border-radius: 4px; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.5);} 70% { box-shadow: 0 0 0 8px rgba(245, 158, 11, 0);} 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);} }
@keyframes keyOk { from { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6);} to { box-shadow: 0 0 0 12px rgba(52, 211, 153, 0);} }
@keyframes keyErr { 0% { background: rgba(244, 67, 54, 0.2);} 100% { background: var(--key);} }
.key.wide { min-width: 96px; }
.key.space { min-width: 420px; }
#hud { display:none; }
.status { display:none; }
.fingers { display:flex; gap: 80px; align-items:center; font-size: 20px; justify-content: center; }
.hand-group { display:flex; gap: 16px; align-items:center; }
.finger { padding: 4px 6px; border-radius: 12px; background: #e5e7eb; color: #111827; position: relative; }
.finger.active { background: #a7f3d0; animation: fingerPulse 0.9s ease-in-out infinite; }
.finger.active::after {
  content: '';
  position: absolute;
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 140%; height: 140%; border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6);
  animation: fingerRipple 1.2s ease-out infinite;
}
@keyframes fingerPulse { 0% { transform: scale(1); } 50% { transform: scale(1.06); } 100% { transform: scale(1); } }
@keyframes fingerRipple { 0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.4);} 100% { box-shadow: 0 0 0 16px rgba(52, 211, 153, 0);} }
.finger.left { border: 1px solid #60a5fa; }
.finger.right { border: 1px solid #f87171; }
.ok { color: var(--ok); }
.err { color: var(--err); }
.primary { background: #2563eb; color: white; border: none; padding: 8px 12px; border-radius: 6px; }
.hud-number { font-variant-numeric: tabular-nums; display: inline-block; min-width: 4ch; text-align: right; }
.hud-number.time { min-width: 5ch; }
.footer { display:flex; flex-direction: column; gap: 8px; align-items: stretch; justify-content: center; padding: 8px 12px; background: var(--panel); padding-left: calc(12px + env(safe-area-inset-left)); padding-right: calc(12px + env(safe-area-inset-right)); padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
.footer-bar { display:grid; grid-template-columns: 1fr 1fr 1fr; align-items:center; }
.footer-center { justify-self: center; }
.footer-center.scalable { display: flex; justify-content: center; }
.history { max-height: 180px; overflow:auto; font-size: 12px; }
canvas.falling-view { width: 100%; height: 260px; background: linear-gradient(180deg, rgb(59 130 246 / .08), transparent); border-radius: 8px; }

/* Responsive adjustments for mobile and tablets */
@media (max-width: 1024px) {
  .top-hud { font-size: 12px; gap: 8px; }
  .timed-view .word { font-size: 48px; }
  .keyboard .key { font-size: 16px; padding: 14px 10px; min-width: 44px; }
  .key.space { min-width: 360px; }
  .fingers { gap: 64px; }
  .finger { font-size: 20px; padding: 10px 14px; }
}
/* iPad-friendly tuning */
@media (min-width: 768px) and (max-width: 1080px) {
  .top-hud { font-size: 13px; }
  .timed-view .word { font-size: 56px; }
  .key.space { min-width: clamp(300px, 50vw, 420px); }
  .fingers { gap: 72px; }
}

/* iPad specific optimizations */
@media (min-width: 768px) and (max-width: 1366px) and (hover: none) and (pointer: coarse) {
  /* Touch-friendly button sizes */
  .btn {
    font-size: 16px;
    padding: 12px 18px;
    min-height: 44px;
    border-radius: 10px;
  }

  .btn.small {
    font-size: 14px;
    padding: 10px 14px;
    min-height: 40px;
  }

  /* Larger topbar for touch */
  .topbar {
    padding: 12px 16px;
    gap: 12px;
  }

  .controls {
    gap: 10px;
  }

  /* Larger touch targets for keyboard */
  .keyboard {
    padding: 16px 8px;
    gap: 10px;
  }

  .row {
    gap: 6px;
  }

  .key {
    font-size: 18px;
    padding: 16px 10px;
    min-width: 52px;
    min-height: 52px;
    border-radius: 10px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  .key:active {
    transform: translateY(2px) scale(0.96);
    background: var(--key-active);
  }

  .key.wide {
    min-width: 80px;
  }

  .key.space {
    min-width: clamp(280px, 45vw, 380px);
    padding: 18px 20px;
  }

  /* Practice area touch optimization */
  .practice {
    min-height: 180px;
    padding: 20px;
  }

  .timed-view .word {
    font-size: 52px;
  }

  /* Finger guides touch-friendly */
  .fingers {
    gap: 60px;
    font-size: 18px;
  }

  .finger {
    padding: 12px 16px;
    font-size: 20px;
  }

  /* Footer optimization */
  .footer {
    padding: 12px 16px;
  }

  #history-btn {
    font-size: 16px;
    padding: 10px 16px;
    min-height: 44px;
  }

  /* Practice menu touch optimization */
  .practice-menu-content {
    padding: 24px;
  }

  .checkbox-label,
  .radio-label {
    padding: 14px 18px;
    font-size: 17px;
    min-height: 52px;
  }

  .menu-btn {
    padding: 14px 28px;
    font-size: 17px;
    min-height: 48px;
  }

  /* HUD larger text */
  .top-hud {
    font-size: 14px;
    gap: 14px;
  }
}

/* iPad landscape mode */
@media (min-width: 1024px) and (max-width: 1366px) and (orientation: landscape) and (hover: none) {
  .app {
    grid-template-rows: auto 1fr auto;
  }

  .main {
    grid-template-rows: 1fr auto auto;
    gap: 12px;
    padding: 12px 20px;
  }

  .keyboard {
    max-width: 900px;
    margin: 0 auto;
  }

  .key {
    min-width: 56px;
    padding: 14px 12px;
  }

  .key.space {
    min-width: clamp(320px, 40vw, 450px);
  }

  .timed-view .word {
    font-size: 60px;
  }
}

/* iPad portrait mode */
@media (min-width: 768px) and (max-width: 834px) and (orientation: portrait) and (hover: none) {
  .keyboard {
    padding: 12px 4px;
  }

  .row {
    gap: 4px;
  }

  .key {
    min-width: 44px;
    padding: 14px 6px;
    font-size: 16px;
  }

  .key.space {
    min-width: clamp(200px, 55vw, 320px);
  }

  .timed-view .word {
    font-size: 44px;
  }

  .fingers {
    gap: 40px;
  }
}

/* iPad Pro 12.9" */
@media (min-width: 1024px) and (max-width: 1366px) and (hover: none) and (pointer: coarse) {
  .key {
    min-width: 60px;
    padding: 18px 14px;
    font-size: 20px;
  }

  .key.space {
    min-width: clamp(350px, 35vw, 500px);
  }

  .timed-view .word {
    font-size: 64px;
  }

  .top-hud {
    font-size: 16px;
  }
}

/* Hidden input for system keyboard support on iPad */
.hidden-input {
  position: absolute;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
@media (max-width: 768px) {
  .topbar { grid-template-columns: 1fr; gap: 6px; }
  .brand { display: none; }
  .controls { grid-column: 1; justify-self: center; }
  .top-hud { grid-column: 1; justify-self: center; font-size: 12px; flex-wrap: wrap; }
  .main { grid-template-rows: auto 1fr auto; padding: 8px; }
  .practice { min-height: 140px; }
  .timed-view .word { font-size: 40px; }
  .keyboard { gap: 8px; padding: 10px; }
  .row { gap: 6px; }
  .key { font-size: 14px; min-width: 36px; padding: 12px 8px; }
  .key.wide { min-width: 72px; }
  .key.space { min-width: 240px; }
  .fingers { gap: 48px; font-size: 16px; }
  .hand-group { gap: 10px; }
  .finger { font-size: 18px; padding: 8px 12px; }
}

/* Victory Celebration Styles */
.victory-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: victoryFadeIn 0.5s ease-out;
}

.dark .victory-overlay {
  background: rgba(11, 18, 32, 0.95);
}

.victory-content {
  text-align: center;
  z-index: 1001;
  max-width: 400px;
  width: 90vw;
  max-width: min(400px, 90vw);
  padding: 40px;
  padding: clamp(20px, 5vw, 40px);
  background: var(--panel);
  border-radius: 20px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  animation: victoryBounceIn 0.6s ease-out;
}

.victory-stars {
  font-size: 32px;
  margin-bottom: 20px;
  animation: victorySparkle 2s ease-in-out infinite;
}

.victory-title {
  font-size: clamp(32px, 12vw, 48px);
  font-weight: 800;
  color: var(--ok);
  margin: 20px 0;
  animation: victoryGlow 1.5s ease-in-out infinite alternate;
}

.victory-subtitle {
  font-size: 18px;
  color: var(--fg);
  margin: 10px 0;
  font-weight: 600;
}

.victory-score {
  font-size: 24px;
  font-weight: 700;
  color: var(--fg);
  margin: 15px 0;
  animation: victoryPulse 1s ease-in-out infinite;
}

.victory-encouragement {
  font-size: 16px;
  color: #666;
  margin: 20px 0;
  font-style: italic;
}

.victory-continue-btn {
  background: var(--ok);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 25px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 20px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

.victory-continue-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

.victory-canvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 1000;
}

/* Victory Animations */
@keyframes victoryFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes victoryBounceIn {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.05); }
  70% { transform: scale(0.9); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes victorySparkle {
  0%, 100% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(5deg) scale(1.1); }
  75% { transform: rotate(-5deg) scale(1.1); }
}

@keyframes victoryGlow {
  from { text-shadow: 0 0 20px rgba(76, 175, 80, 0.5); }
  to { text-shadow: 0 0 30px rgba(76, 175, 80, 0.8), 0 0 40px rgba(76, 175, 80, 0.3); }
}

@keyframes victoryPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* Milestone Celebration Styles (every 50 correct hits) */
.milestone-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  z-index: 1000;
  pointer-events: none;
  animation: milestoneFadeIn 0.3s ease-out;
}

.milestone-content {
  text-align: center;
  z-index: 1001;
  padding: 20px 40px;
  background: linear-gradient(135deg, #ffd700, #ffb700);
  border-radius: 50px;
  box-shadow: 0 10px 30px rgba(255, 183, 0, 0.4);
  animation: milestoneBounce 0.5s ease-out;
}

.dark .milestone-content {
  background: linear-gradient(135deg, #ff9800, #ff6d00);
  box-shadow: 0 10px 30px rgba(255, 109, 0, 0.4);
}

.milestone-stars {
  font-size: 28px;
  margin-bottom: 5px;
}

.milestone-text {
  font-size: 24px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.milestone-canvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 999;
}

@keyframes milestoneFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes milestoneBounce {
  0% { transform: scale(0.5) translateY(-20px); opacity: 0; }
  60% { transform: scale(1.1) translateY(0); }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

/* Streak Effect Styles (when streak > 20) */
.streak-burst {
  --streak-hue: 45;
  --streak-intensity: 1;
  --streak-color: hsl(var(--streak-hue), 100%, 50%);
  --streak-color-light: hsl(var(--streak-hue), 100%, 70%);
  position: fixed;
  top: 15%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 300px;
  height: 300px;
  pointer-events: none;
  z-index: 1000;
}

/* Expanding ring effect */
.streak-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 60px;
  height: 60px;
  border: 4px solid var(--streak-color);
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
  animation: streakRingExpand 0.6s ease-out forwards;
  box-shadow: 
    0 0 20px var(--streak-color),
    0 0 40px var(--streak-color),
    inset 0 0 20px var(--streak-color);
}

.streak-ring-2 {
  animation-delay: 0.1s;
  border-width: 2px;
  opacity: 0.7;
}

/* Particle burst */
.streak-particles {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
}

.streak-particle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--streak-color-light);
  border-radius: 50%;
  box-shadow: 0 0 15px var(--streak-color), 0 0 30px var(--streak-color);
  animation: streakParticleFly 0.7s ease-out forwards;
}

.streak-particle:nth-child(1) { --angle: 0deg; --distance: 80px; }
.streak-particle:nth-child(2) { --angle: 60deg; --distance: 90px; animation-delay: 0.05s; }
.streak-particle:nth-child(3) { --angle: 120deg; --distance: 75px; animation-delay: 0.1s; }
.streak-particle:nth-child(4) { --angle: 180deg; --distance: 85px; animation-delay: 0.03s; }
.streak-particle:nth-child(5) { --angle: 240deg; --distance: 70px; animation-delay: 0.08s; }
.streak-particle:nth-child(6) { --angle: 300deg; --distance: 95px; animation-delay: 0.06s; }

/* Streak number display */
.streak-number {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 52px;
  font-weight: 900;
  color: #ffffff;
  white-space: nowrap;
  text-shadow: 
    -2px -2px 0 #222,
    2px -2px 0 #222,
    -2px 2px 0 #222,
    2px 2px 0 #222,
    0 0 20px var(--streak-color),
    0 0 40px var(--streak-color),
    0 6px 12px rgba(0,0,0,0.6);
  animation: streakNumberPop 0.8s ease-out forwards;
}

@keyframes streakRingExpand {
  0% {
    transform: translate(-50%, -50%) scale(0);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(calc(4 * var(--streak-intensity)));
    opacity: 0;
  }
}

@keyframes streakParticleFly {
  0% {
    transform: translate(-50%, -50%) rotate(var(--angle)) translateY(0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) rotate(var(--angle)) translateY(calc(-1 * var(--distance) * var(--streak-intensity))) scale(0);
    opacity: 0;
  }
}

@keyframes streakNumberPop {
  0% {
    transform: translate(-50%, -50%) scale(0.2);
    opacity: 0;
  }
  20% {
    transform: translate(-50%, -50%) scale(1.3);
    opacity: 1;
  }
  40% {
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    transform: translate(-50%, -100%) scale(1.1);
    opacity: 0;
  }
}

/* Accessibility: Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .victory-overlay,
  .victory-content,
  .victory-stars,
  .victory-title,
  .victory-score,
  .milestone-overlay,
  .milestone-content,
  .streak-burst,
  .streak-ring,
  .streak-particle,
  .streak-number {
    animation: none;
  }

  .victory-continue-btn {
    transition: none;
  }

  .victory-continue-btn:hover {
    transform: none;
  }
}

/* Practice Menu Styles */
.practice-menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.dark .practice-menu-overlay {
  background: rgba(11, 18, 32, 0.95);
}

.practice-menu-overlay:not(.hidden) {
  opacity: 1;
  visibility: visible;
}

.practice-menu-content {
  background: var(--panel);
  border-radius: 20px;
  padding: 30px;
  max-width: 720px;
  width: 90vw;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  animation: menuSlideIn 0.4s ease-out;
}

/* Two-column layout for menu */
.menu-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
}

.menu-column {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.menu-title {
  font-size: 28px;
  font-weight: 800;
  color: var(--fg);
  text-align: center;
  margin-bottom: 30px;
  margin-top: 0;
}

.menu-section {
  margin-bottom: 0;
}

.menu-columns + .menu-actions {
  margin-top: 24px;
}

.menu-section h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 15px;
  margin-top: 0;
}

/* Custom Checkboxes */
.checkbox-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 16px;
  font-weight: 500;
  color: var(--fg);
  padding: 12px 16px;
  border-radius: 12px;
  border: 2px solid var(--key);
  transition: all 0.2s ease;
  user-select: none;
}

.checkbox-label:hover {
  background: var(--key);
  border-color: var(--key-active);
}

.checkbox-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  cursor: pointer;
}

.checkmark {
  position: relative;
  height: 20px;
  width: 20px;
  background-color: #fff;
  border: 2px solid var(--key);
  border-radius: 4px;
  margin-right: 12px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.checkbox-label input[type="checkbox"]:checked ~ .checkmark {
  background-color: var(--ok);
  border-color: var(--ok);
}

.checkmark:after {
  content: "";
  position: absolute;
  display: none;
  left: 6px;
  top: 2px;
  width: 6px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.checkbox-label input[type="checkbox"]:checked ~ .checkmark:after {
  display: block;
}

/* Custom Radio Buttons */
.radio-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.radio-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 16px;
  font-weight: 500;
  color: var(--fg);
  padding: 12px 16px;
  border-radius: 12px;
  border: 2px solid var(--key);
  transition: all 0.2s ease;
  user-select: none;
}

.radio-label:hover {
  background: var(--key);
  border-color: var(--key-active);
}

.radio-label input[type="radio"] {
  position: absolute;
  opacity: 0;
  cursor: pointer;
}

.radiomark {
  position: relative;
  height: 20px;
  width: 20px;
  background-color: #fff;
  border: 2px solid var(--key);
  border-radius: 50%;
  margin-right: 12px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.radio-label input[type="radio"]:checked ~ .radiomark {
  border-color: var(--ok);
}

.radiomark:after {
  content: "";
  position: absolute;
  display: none;
  top: 4px;
  left: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
}

.radio-label input[type="radio"]:checked ~ .radiomark:after {
  display: block;
}

/* Scale Group */
.scale-group {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.scale-group label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 16px;
  font-weight: 500;
  color: var(--fg);
}

.scale-group input[type="range"] {
  width: 100%;
  max-width: 200px;
}

/* Settings Group */
.settings-group {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-group label {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
  font-weight: 500;
  color: var(--fg);
}

.settings-group select {
  padding: 8px 12px;
  border: 2px solid var(--key);
  border-radius: 8px;
  background: var(--panel);
  color: var(--fg);
  font-size: 14px;
  flex: 1;
}

.settings-group select:focus {
  outline: none;
  border-color: var(--key-active);
}

/* Menu Actions */
.menu-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 30px;
}

.menu-btn {
  padding: 12px 24px;
  border: none;
  border-radius: 25px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 100px;
}

.menu-btn.primary {
  background: var(--ok);
  color: white;
  box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

.menu-btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

.menu-btn:not(.primary) {
  background: var(--key);
  color: var(--fg);
}

.menu-btn:not(.primary):hover {
  background: var(--key-active);
  color: #111827;
}

/* Menu Animations */
@keyframes menuSlideIn {
  from {
    transform: scale(0.8) translateY(20px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

/* Achievement Notifications */
.achievement-notification {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--panel);
  border: 3px solid var(--ok);
  border-radius: 15px;
  padding: 20px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  gap: 15px;
  z-index: 3000;
  transform: translateX(400px);
  opacity: 0;
  transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  max-width: 350px;
}

.achievement-notification.show {
  transform: translateX(0);
  opacity: 1;
}

.achievement-icon {
  font-size: 48px;
  animation: achievementBounce 0.6s ease-out;
}

.achievement-content {
  flex: 1;
}

.achievement-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ok);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.achievement-name {
  font-size: 18px;
  font-weight: 800;
  color: var(--fg);
  margin-bottom: 5px;
}

.achievement-desc {
  font-size: 14px;
  color: var(--fg);
  opacity: 0.8;
}

@keyframes achievementBounce {
  0% { transform: scale(0.3); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* Achievement Display */
.achievements-section,
.history-section {
  margin-bottom: 30px;
}

.achievements-section h3,
.history-section h3 {
  color: var(--fg);
  margin-bottom: 15px;
  font-size: 18px;
  font-weight: 700;
}

.achievement-category {
  margin-bottom: 20px;
}

.achievement-category h4 {
  color: var(--fg);
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 10px;
  padding-bottom: 5px;
  border-bottom: 2px solid var(--key);
}

.achievement-badges {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 15px;
}

.achievement-badge {
  background: var(--panel);
  border: 2px solid var(--key);
  border-radius: 12px;
  padding: 15px;
  text-align: center;
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.achievement-badge:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.achievement-badge.unlocked {
  border-color: var(--ok);
  background: linear-gradient(135deg, var(--panel) 0%, rgba(76, 175, 80, 0.1) 100%);
  animation: achievementUnlock 0.6s ease-out;
}

.achievement-badge.locked {
  opacity: 0.6;
  filter: grayscale(50%);
}

.achievement-badge.locked::after {
  content: '🔒';
  position: absolute;
  top: 5px;
  right: 5px;
  font-size: 16px;
  opacity: 0.7;
}

.badge-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.badge-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--fg);
  line-height: 1.2;
}

.history-item {
  padding: 8px 12px;
  margin-bottom: 8px;
  background: var(--panel);
  border-radius: 8px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  color: var(--fg);
  border-left: 3px solid var(--key);
}

.no-achievements {
  text-align: center;
  color: var(--fg);
  opacity: 0.6;
  padding: 20px;
  font-style: italic;
}

@keyframes achievementUnlock {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* Mobile Responsiveness */
@media (max-width: 680px) {
  .menu-columns {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .practice-menu-content {
    max-width: 450px;
  }
}

@media (max-width: 480px) {
  .checkbox-group,
  .radio-group {
    grid-template-columns: 1fr;
  }

  .menu-actions {
    flex-direction: column;
  }

  .menu-btn {
    width: 100%;
  }

  .achievement-notification {
    left: 10px;
    right: 10px;
    max-width: none;
  }

  .achievement-badges {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
  }

  .achievement-badge {
    padding: 12px;
  }

  .badge-icon {
    font-size: 28px;
  }

  .badge-name {
    font-size: 11px;
  }
}
