:root {
  --primary-blue: #2A75B3;
  --dark-blue: #1E5A8A;
  --light-blue: #D0E4F5;
  --accent-yellow: #FFD60A;
  --success-color: #4CAF50;
  --error-color: #F44336;
  --text-white: #FFFFFF;
  --text-dark: #1E5A8A;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Fredoka', sans-serif;
  background-color: #E5E7EB;
  color: var(--text-white);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 10px;
}

.container {
  background: var(--primary-blue);
  width: 95%;
  max-width: 450px;
  min-height: 80vh;
  max-height: 95vh;
  padding: 20px;
  border-radius: 50px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
  text-align: center;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-y: auto;
  scrollbar-width: none; /* Firefox */
}

.container::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}

.setup-screen, .game-screen {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  width: 100%;
}

.setup-screen {
  padding: 10px 0;
}

.game-screen {
  padding: 5px 0;
}

.hidden {
  display: none !important;
}

.btn-primary {
  background-color: var(--accent-yellow);
  color: var(--text-dark);
  border: none;
  padding: 15px 25px;
  border-radius: 20px;
  font-family: inherit;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 0 #D4AF37;
  transition: all 0.1s;
}

.btn-primary:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #D4AF37;
}

.btn-primary.large {
  width: 100%;
  margin-top: 20px;
}

.game-header {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 20px;
  background: rgba(0, 0, 0, 0.1);
  padding: 15px;
  border-radius: 25px;
}

.btn-back {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  padding: 8px 15px;
  border-radius: 12px;
  font-size: 0.9rem;
  cursor: pointer;
}

.game-info {
  font-size: 1rem;
  font-weight: 600;
  text-align: left;
  flex-grow: 1;
}

header {
  position: relative;
  margin-bottom: 15px;
}

.settings-btn {
  position: absolute;
  top: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 8px;
  border-radius: 15px;
  transition: all 0.2s;
  z-index: 10;
}

.settings-btn:hover {
  background: rgba(255, 255, 255, 0.4);
  transform: rotate(45deg);
}

.logo-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.logo {
  width: 70px;
  height: 70px;
}

h1 {
  color: var(--text-white);
  font-size: 26px;
  font-weight: 600;
  margin: 0;
}

.selection-area {
  margin-bottom: 30px;
}

.control-panel {
  background-color: rgba(0, 0, 0, 0.1);
  padding: 15px;
  border-radius: 30px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.select-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.select-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-white);
  text-transform: capitalize;
}

.select-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
}

select {
  background-color: var(--light-blue);
  color: var(--text-dark);
  padding: 8px 15px;
  border-radius: 10px;
  border: none;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  min-width: 100px;
  text-align: center;
  appearance: none;
}

select:hover {
  background-color: #FFFFFF;
  transform: scale(1.02);
}

select:focus {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
}

.mode-icon {
  font-size: 1.5rem;
}

.instruction-text {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 15px;
  color: var(--accent-yellow);
}

.exercise-area {
  background-color: rgba(255, 255, 255, 0.1);
  padding: 20px;
  border-radius: 40px;
  margin-bottom: 20px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.1);
  overflow-y: visible; /* Let the container handle scrolling if needed */
}

/* Speed Mode Styles */
.speed-question {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.speed-pronoun {
  font-size: 1.6rem;
  font-weight: 600;
  margin-bottom: 10px;
}

.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

.option-btn {
  background-color: var(--light-blue);
  color: var(--text-dark);
  border: none;
  padding: 15px;
  border-radius: 15px;
  font-family: inherit;
  font-size: 1.2rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.1);
}

.option-btn:hover {
  transform: translateY(-2px);
  background-color: #FFFFFF;
}

.option-btn.correct {
  background-color: var(--success-color);
  color: white;
}

.option-btn.wrong {
  background-color: var(--error-color);
  color: white;
}

/* Write Mode Styles */
.conjugation-row {
  display: grid;
  grid-template-columns: 85px 1fr auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  text-align: left;
}

.pronoun {
  font-weight: 600;
  font-size: 1rem;
}

input[type="text"] {
  padding: 10px 15px;
  border-radius: 10px;
  border: none;
  background-color: var(--light-blue);
  color: var(--text-dark);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  outline: none;
  width: 100%;
}

input.correct {
  background-color: #C8E6C9;
}

input.wrong {
  background-color: #FFCDD2;
}

.correction {
  font-size: 0.85rem;
  color: var(--accent-yellow);
  font-weight: 600;
  min-width: 60px;
}

.actions {
  margin-bottom: 20px;
}

#check-btn {
  background-color: var(--light-blue);
  color: var(--text-dark);
  border: none;
  padding: 12px 30px;
  font-size: 1.1rem;
  font-weight: 600;
  border-radius: 15px;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.1);
}

.footer-icon {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}

.stopwatch {
  width: 100px;
  height: 100px;
}

.score-area {
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.stars {
  font-size: 2.5rem;
  color: var(--accent-yellow);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  margin-bottom: 10px;
  display: block;
}

.score-text {
  font-size: 1.1rem;
  font-weight: 600;
}

.btn-small {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.75rem;
  cursor: pointer;
  margin-top: 10px;
}

/* Parent Zone Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay.hidden {
  display: none;
}

.parent-zone {
  background: white;
  color: #333;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 30px;
  border-radius: 30px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  text-align: left;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 2px solid #eee;
  padding-bottom: 10px;
}

.modal-header h3 {
  margin: 0;
  color: var(--text-dark);
}

.close-btn {
  background: #eee;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 5px 12px;
  border-radius: 50%;
  transition: background 0.2s;
}

.close-btn:hover {
  background: #ddd;
}

#json-editor {
  width: 100%;
  height: 300px;
  background: #f5f5f5;
  color: #333;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 15px;
  font-size: 0.9rem;
  font-family: 'Courier New', Courier, monospace;
  margin: 15px 0;
}

.parent-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.parent-actions button {
  padding: 8px 12px;
  font-size: 0.8rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
}

.btn-success { background-color: var(--success-color); color: white; }
.btn-danger { background-color: var(--error-color); color: white; }
.btn-info { background-color: var(--primary-blue); color: white; }

/* Handwriting Mode Styles */
.handwriting-container {
  display: flex;
  flex-direction: column;
  gap: 15px;
  align-items: center;
}

.handwriting-pronoun {
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--text-white);
}

.canvas-wrapper {
  background: white;
  border-radius: 20px;
  padding: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  position: relative;
}

#handwriting-canvas {
  border: 2px dashed var(--primary-blue);
  border-radius: 15px;
  cursor: crosshair;
  touch-action: none;
  background-color: #f9f9f9;
  max-width: 100%;
  height: auto;
}

.candidates-list {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  min-height: 40px;
  margin: 10px 0;
}

.candidate-word {
  background: rgba(255, 255, 255, 0.2);
  padding: 4px 10px;
  border-radius: 20px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
  border: 1px solid transparent;
}

.candidate-word:hover {
  background: rgba(255, 255, 255, 0.4);
}

.candidate-word.selected {
  background: var(--accent-yellow);
  color: var(--text-dark);
  transform: scale(1.1);
}

.placeholder {
  opacity: 0.6;
  font-style: italic;
}

.handwriting-actions {
  display: flex;
  gap: 10px;
  width: 100%;
  justify-content: center;
}

.btn-clear {
  background-color: var(--error-color) !important;
  color: white !important;
}

@media (max-width: 400px) {
  #handwriting-canvas {
    width: 260px;
    height: 180px;
  }
  .container {
    padding: 15px;
    border-radius: 30px;
  }
}


