/* -----------------------------------
   GLOBAL RESET & BASE
----------------------------------- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0f172a; /* deep navy */
  color: #e5e7eb;      /* soft gray */
  display: flex;
  flex-direction: column;
  line-height: 1.5;
}

/* -----------------------------------
   APP CONTAINER
----------------------------------- */
.app {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 20px 40px;
  background: #020617;
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.55);
  flex: 1;
}

/* -----------------------------------
   HEADER
----------------------------------- */
header {
  text-align: center;
  margin-bottom: 28px;
}

header h1 {
  font-size: 2rem;
  margin-bottom: 6px;
  font-weight: 700;
  color: #ffffff;
}

header p {
  color: #9ca3af;
  font-size: 0.95rem;
}

/* -----------------------------------
   CONTROLS
----------------------------------- */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 24px;
}

.controls label {
  font-size: 0.95rem;
}

#categorySelect, #modeSelect {
  flex: 1;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #475569;
  background: #0f172a;
  color: #e5e7eb;
  font-size: 0.95rem;
}

/* -----------------------------------
   BUTTONS
----------------------------------- */
button {
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 0.95rem;
  cursor: pointer;
  background: #22c55e;
  color: #022c22;
  font-weight: 600;
  transition: background 0.15s ease, transform 0.1s ease;
}

button:hover {
  background: #16a34a;
  transform: translateY(-1px);
}

#startGameBtn, #submitAnswerBtn {
  width: 100%;
}

button.secondary, #nextWordBtn, #endGameBtn, #playAgainBtn {
  background: #1f2937;
  color: #e5e7eb;
}

button.secondary:hover, #nextWordBtn:hover {
  background: #374151;
}

/* -----------------------------------
   GAME SECTION
----------------------------------- */
.hidden {
  display: none !important;
}

.status-bar {
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
  font-size: 0.9rem;
  color: #9ca3af;
}

/* Scramble Box */
.scramble-box {
  background: radial-gradient(circle at top, #1d4ed8, #020617);
  border-radius: 16px;
  padding: 28px;
  text-align: center;
  margin-bottom: 20px;
}

#scrambledWord {
  font-size: 2.2rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-weight: 700;
  color: #ffffff;
}

/* Input Row */
.input-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

#answerInput {
  flex: 1;
  padding: 12px 14px;
  border-radius: 999px;
  border: 1px solid #475569;
  background: #0f172a;
  color: #e5e7eb;
  font-size: 1rem;
  text-align: center;
}

/* Feedback - prevent layout jump */
.feedback {
  min-height: 26px;
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  margin-bottom: 14px;
  transition: opacity 0.2s;
}

.feedback.correct { color: #4ade80; }
.feedback.incorrect { color: #f87171; }

/* Actions */
.actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* -----------------------------------
   TIMER BAR    
----------------------------------- */
.timer-bar {
  width: 100%;
  height: 10px;
  background: #1e293b;
  border-radius: 5px;
  margin-top: 8px;
  overflow: hidden;
}

#timerFill {
  height: 100%;
  width: 100%;
  background: #4caf50; /* default green */
  transition: width 1s linear, background-color 0.3s ease;
}

/* -----------------------------------
   SUMMARY SECTION
----------------------------------- */
.summary h2 {
  margin-bottom: 12px;
  font-size: 1.6rem;
  text-align: center;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.summary-list {
  margin: 20px 0;
  max-height: 300px;
  overflow-y: auto;
  background: #111827;
  border-radius: 12px;
  padding: 8px;
  border: 1px solid #1f2937;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid #1f2937;
}

.word-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.word-flow {
  display: flex;
  align-items: center;
  gap: 8px;
}

.scrambled-text {
  color: #94a3b8;
  font-family: monospace;
  font-size: 0.9rem;
}

.arrow { color: #4b5563; font-size: 0.8rem; }

.correct-text {
  font-weight: 700;
  color: #f3f4f6;
}

.decoys-text {
  color: #6366f1; 
  font-size: 0.75rem;
  font-style: italic;
}

.history-item.correct .status-icon { color: #4ade80; }
.history-item.incorrect .status-icon { color: #f87171; }

/* -----------------------------------
   FOOTER
----------------------------------- */
footer {
  margin-top: auto;
  padding: 20px;
  text-align: center;
  color: #9ca3af;
  font-size: 0.9rem;
}

footer a {
  color: #93c5fd;
  text-decoration: none;
}

.help-icon-btn {
  position: absolute;
  top: 15px;
  right: 15px;
  width: 35px;
  height: 35px;
  border-radius: 50%;
  border: 2px solid var(--primary-color, #4ade80);
  background: transparent;
  color: var(--primary-color, #4ade80);
  font-weight: bold;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  z-index: 100; /* Ensure it stays above everything */
}

.help-icon-btn:hover {
  background: var(--primary-color, #4ade80);
  color: #1a1a1a;
  transform: scale(1.1) rotate(10deg);
  box-shadow: 0 0 15px rgba(74, 222, 128, 0.4);
}

/* Hide the help icon when the help page itself or the game is active */
.hidden-help {
  display: none;
}

/* Example Box Styling */
.example-box {
  background: rgba(0, 0, 0, 0.2);
  border: 1px dashed rgba(255, 255, 255, 0.3);
  border-radius: 12px;
  padding: 15px;
  margin-bottom: 20px;
  text-align: center;
}

.example-box h4 {
  margin-top: 0;
  color: var(--primary-color, #4ade80);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.example-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  margin: 10px 0;
  font-family: 'Courier New', Courier, monospace;
}

.scramble-preview {
  font-size: 1.1rem;
  letter-spacing: 2px;
  background: #2a2a2a;
  padding: 8px 12px;
  border-radius: 6px;
}

.decoy-highlight {
  color: #f87171; /* Reddish color for decoys */
  font-weight: bold;
  text-decoration: line-through;
  opacity: 0.7;
}

.result-preview {
  font-size: 1.2rem;
  font-weight: bold;
  color: #4ade80;
  border-bottom: 2px solid #4ade80;
}

.example-caption {
  font-size: 0.85rem;
  font-style: italic;
  margin-bottom: 0;
  opacity: 0.8;
}

.arrow {
  font-size: 1.5rem;
  color: rgba(255, 255, 255, 0.5);
}