html, body {
  margin: 0;
  padding: 0;
  font-family: sans-serif;
  background-color: #f0f0f0;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  min-height: 100%;
  touch-action: manipulation;
}
.screen button,
button,
a,
input,
select {
  touch-action: manipulation;
}
.screen {
  display: none;
  width: 100%;
  min-height: 100vh;
  box-sizing: border-box;
  padding: 10px;
}
.visible {
  display: block;
}
.menu-screen, .practice-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
#menuScreen button {
  padding: 12px 24px;
  font-size: 18px;
}

.menu-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  margin: 30px 0 10px;
  width: 100%;
  max-width: 720px;
}

.menu-card {
  flex: 1 1 200px;
  max-width: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.menu-card button {
  width: 100%;
  margin: 0;
  border-radius: 8px;
}

.menu-card p {
  margin: 10px 0 0;
  font-size: 15px;
  color: #444;
}

.menu-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
}

.menu-actions button {
  margin: 0;
}
canvas {
  display: block;
  margin: 10px auto;
  background: white;
  border: 1px solid red;
  border-radius: 6px;
  width: min(90vmin, 500px);
  height: min(90vmin, 500px);
  touch-action: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

canvas.value-drill-canvas,
canvas.color-drill-canvas {
  background: #808080;
  border: none;
}

.value-slider {
  -webkit-appearance: none;
  appearance: none;
  width: min(90vmin, 500px);
  display: block;
  margin: 20px auto 0;
  height: 14px;
  border-radius: 8px;
  background: linear-gradient(to right, #000, #fff);
  border: none;
  outline: none;
}

.value-slider-wrapper {
  width: min(90vmin, 500px);
  margin: 0 auto;
}

.value-slider-wrapper .slider-indicators {
  margin-top: 8px;
}

.value-slider:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.6);
  outline-offset: 2px;
}

.value-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #f4f4f4;
  border: 2px solid #333;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

.value-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #f4f4f4;
  border: 2px solid #333;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

.value-slider::-moz-range-track {
  background: transparent;
  border: none;
}

.value-slider::-ms-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #f4f4f4;
  border: 2px solid #333;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

.value-slider::-ms-track {
  background: transparent;
  border: none;
  color: transparent;
}

.slider-group {
  width: min(90vmin, 500px);
  margin: 12px auto 0;
}

.slider-label {
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
  color: #333;
  text-align: left;
}

.exercise-context {
  max-width: min(90vmin, 520px);
  margin: 8px auto 16px;
  text-align: center;
  color: #444;
  line-height: 1.4;
}

.slider-indicators {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 4px;
  margin-top: 6px;
  font-size: 11px;
  color: #555;
  width: 100%;
}

.slider-indicators span {
  text-align: center;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.slider-indicators--hue {
  grid-template-columns: repeat(10, minmax(0, 1fr));
}

@media (max-width: 520px) {
  .slider-indicators {
    font-size: 10px;
  }

  .slider-indicators--hue {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    row-gap: 4px;
  }
}

.slider-group .value-slider,
.slider-group .color-slider,
.slider-group .color-value-slider {
  margin: 0;
}

.color-slider,
.color-value-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  display: block;
  height: 14px;
  border-radius: 8px;
  border: none;
  outline: none;
  background: linear-gradient(to right, #888, #888);
}

.color-slider::-webkit-slider-thumb,
.color-value-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #f4f4f4;
  border: 2px solid #333;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

.color-slider::-moz-range-thumb,
.color-value-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #f4f4f4;
  border: 2px solid #333;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

.color-slider::-moz-range-track,
.color-value-slider::-moz-range-track {
  background: transparent;
  border: none;
}

.color-slider::-ms-thumb,
.color-value-slider::-ms-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #f4f4f4;
  border: 2px solid #333;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

.color-slider::-ms-track,
.color-value-slider::-ms-track {
  background: transparent;
  border: none;
  color: transparent;
}

.confirm-button {
  margin-top: 20px;
  padding: 10px 24px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  background-color: #1e88e5;
  color: #fff;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.confirm-button:disabled {
  background-color: #90caf9;
  cursor: not-allowed;
}

.confirm-button:not(:disabled):hover,
.confirm-button:not(:disabled):focus-visible {
  background-color: #1565c0;
}

.value-slider-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.play-area {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
}

.play-area.reverse {
  flex-direction: row-reverse;
}

.view-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.canvas-wrapper {
  position: relative;
}

.tool-icons {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tool-icons button {
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 4px;
  font-size: 20px;
  cursor: pointer;
}

.tool-icons button.active {
  background-color: #2196F3;
  color: #fff;
}

#compareBtn.active {
  background-color: #2196F3;
  color: #fff;
}

.overlay {
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0.5;
  pointer-events: none;
}

.scoreboard {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-weight: bold;
  position: relative;
  align-items: center;
  margin: 10px auto 0;
  font-size: 24px;
  text-align: center;
}

.scoreboard p {
  margin: 2px 0;
}

.scoreboard .score-value {
  color: black;
  transition: color 0.3s;
}

.scoreboard .score-value.increase {
  color: green;
}

.scoreboard .score-value.decrease {
  color: red;
}

.score-change {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-weight: bold;
  animation: float-score 1s forwards;
}

.score-change.positive {
  color: green;
}

.score-change.negative {
  color: red;
}

@keyframes float-score {
  from {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -20px);
  }
}
.controls, .switches-group, .checkboxes-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 10px;
  align-items: center;
}

.controls button.active {
  background-color: #2196F3;
  color: #fff;
}
.score {
  text-align: center;
  font-weight: bold;
  min-height: 1.5em;
}
.timer {
  text-align: center;
  font-size: 24px;
  margin: 10px 0;
}
.switch-label-container {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 24px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: #2196F3;
}
input:checked + .slider:before {
  transform: translateX(26px);
}
.switch-text {
  margin-left: 8px;
  user-select: none;
  font-size: 14px;
  white-space: nowrap;
}
.checkboxes-group label {
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 4px;
}
button {
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
h2, h1 { margin: 10px 0; }

/* Angles drill styles */
.angle-options {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin: 10px 0;
}

.angle-option {
  position: relative;
  padding-left: 20px;
  font-size: 14px;
}

.angle-option input {
  position: absolute;
  left: 0;
  top: 0;
  width: 16px;
  height: 16px;
  opacity: 0;
}

.angle-option .box {
  position: absolute;
  left: 0;
  top: 2px;
  width: 16px;
  height: 16px;
  border: 1px solid #333;
  box-sizing: border-box;
}

.angle-option.correct .box::after {
  content: '\2713';
  color: green;
  position: absolute;
  left: 2px;
  top: -3px;
  font-size: 18px;
}

.angle-option.close .box::after {
  content: '!';
  color: orange;
  position: absolute;
  left: 3px;
  top: -3px;
  font-size: 18px;
}

.angle-option.incorrect .box::after {
  content: '\2717';
  color: red;
  position: absolute;
  left: 2px;
  top: -3px;
  font-size: 18px;
}
/* Drill menu styles */
.drill-category-menu {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  margin: 20px 0;
  width: 100%;
  max-width: 900px;
}

.drill-category-item {
  flex: 1 1 220px;
  max-width: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.drill-category-item button {
  width: 100%;
  padding: 12px 24px;
  font-size: 18px;
  border-radius: 8px;
  margin: 0;
}

.drill-category-item p {
  margin: 10px 0 0;
  font-size: 15px;
  color: #444;
}

.drill-category-item button.active {
  background-color: #2196F3;
  color: #fff;
  border-color: #2196F3;
}

/* Exercise list styles */
.exercise-columns {
  display: flex;
  flex-wrap: wrap;
  gap: 25px;
  width: 100%;
  justify-content: center;
}

.exercise-group {
  flex: 1 1 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.exercise-group > h3 {
  margin: 0;
  font-size: 22px;
  color: #333;
}

.exercise-list {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 600px;
  max-height: 60vh;
  overflow-y: auto;
  gap: 15px;
}

.exercise-item {
  display: flex;
  align-items: center;
  width: 100%;
  box-sizing: border-box;
  background: white;
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 15px;
  cursor: pointer;
  position: relative;
}

.exercise-item:hover {
  background-color: #f9f9f9;
}

.exercise-item.selected {
  border-color: #2196F3;
  background-color: #e3f2fd;
}

.exercise-item img.exercise-gif {
  width: 80px;
  height: 80px;
  margin-right: 15px;
  object-fit: cover;
  border-radius: 4px;
}

.exercise-item .exercise-info {
  display: flex;
  flex-direction: column;
}

.exercise-item h3 {
  margin: 0;
  font-size: 18px;
}

.exercise-item p {
  margin: 4px 0 0;
  font-size: 16px;
}

.exercise-item .high-score {
  margin-top: 8px;
  font-size: 14px;
  color: #555;
}

.tag-container {
  position: absolute;
  top: 5px;
  right: 5px;
  display: flex;
  gap: 5px;
}

.difficulty-label,
.category-label,
.subject-label,
.experimental-label,
.tag-label {
  padding: 4px 8px;
  border-radius: 10px;
  font-size: 12px;
  color: #fff;
}

.category-label {
  background-color: #9e9e9e;
}

.subject-label {
  background-color: #bdbdbd;
}

.experimental-label {
  background-color: #ffeb3b;
}

.tag-label {
  background-color: #607d8b;
}

.category-memorization {
  background-color: #82B3B3;
}

.category-dexterity {
  background-color: #B382B3;
}

.difficulty-beginner {
  background-color: #4caf50;
}

.difficulty-adept {
  background-color: #ff9800;
}

.difficulty-expert {
  background-color: #f44336;
}
.strikes,
.timer {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
  padding: 6px 12px;
  border: 2px solid #333;
  border-radius: 8px;
  background-color: #fff;
  font-weight: 700;
  font-size: 18px;
  color: #1b5e20;
  position: relative;
  overflow: visible;
}

.timer-display {
  min-width: 64px;
  text-align: center;
}

.timer-delta {
  position: absolute;
  right: 6px;
  top: -18px;
  font-size: 16px;
  font-weight: 700;
  opacity: 0;
  transform: translateY(6px) scale(0.95);
  pointer-events: none;
}

.timer-delta.positive {
  color: #2e7d32;
}

.timer-delta.negative {
  color: #c62828;
}

.timer-delta.show {
  animation: timerDeltaPop 0.9s ease-out;
}

@keyframes timerDeltaPop {
  0% {
    opacity: 0;
    transform: translateY(6px) scale(0.95);
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-10px) scale(1.02);
  }
}
/* Tutorial page layout */
.tutorial-body {
  background: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

.tutorial-body #message {
  margin-top: 40px;
  text-align: center;
  padding: 0 10px;
  font-size: 24px;
  font-weight: bold;
}

.tutorial-body #tutorialCanvas {
  flex: none;
  border: none;
  border-radius: 0;
  background: white;
  width: min(90vmin, 500px);
  height: min(90vmin, 500px);
}

.tutorial-body #tapInstruction {
  margin-top: 10px;
  text-align: center;
  font-size: 20px;
}

.tutorial-body #nextBtn {
  margin: 20px;
}

.tutorial-body #backBtn {
  align-self: flex-start;
  margin: 10px;
}
.leaderboard-overlay {
  position: absolute;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px;
  border-radius: 8px;
  max-height: 90%;
  z-index: 1000;
  box-sizing: border-box;
}

.leaderboard-list {
  flex: 1;
  overflow-y: auto;
  margin: 10px 0;
  text-align: left;
}

.leaderboard-entry {
  padding: 2px 0;
}

.leaderboard-score {
  font-size: 1.5em;
  margin: 10px 0;
}

.leaderboard-new-high {
  font-size: 1.2em;
  font-weight: bold;
  color: #ffd700;
  margin: 5px 0;
}

.leaderboard-buttons {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: auto;
}

.leaderboard-buttons button {
  padding: 8px 16px;
  font-size: 1em;
  cursor: pointer;
}

/* SVG shape drill layout */
.layout-two-column {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 12px;
  align-items: flex-start;
}

.canvas-column {
  flex: 2 1 640px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.canvas-wrapper {
  position: relative;
  width: 100%;
}

.canvas-wrapper canvas {
  width: 100%;
  height: auto;
  max-width: 960px;
  border-radius: 12px;
}

.start-btn {
  padding: 12px 24px;
  font-size: 18px;
  border-radius: 10px;
  border: none;
  background: #4caf50;
  color: white;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}

.controls {
  flex: 1 1 260px;
  background: #fff;
  padding: 16px;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

.controls .hint {
  color: #555;
  font-size: 14px;
}

.shape-label {
  text-align: center;
  font-weight: 700;
  font-size: 18px;
  color: #333;
}

.result {
  text-align: center;
  min-height: 22px;
  font-weight: 600;
}

.strike-container {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 6px;
}

@media (max-width: 900px) {
  .controls {
    width: 100%;
  }
}
