/* ============================================================
   Eläinpolku — Animal Trail Stylesheet
   Dark Navy (Near-Black) theme, high contrast, all text white.
   ============================================================ */

/* ===== Reset ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== Page base ===== */
html, body {
  height: auto;
  min-height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
  background: #050a14; /* Very dark navy, near black */
}

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: #ffffff; /* All text white */
  line-height: 1.4;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ===== Game container ===== */
#game-container {
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

/* ===== Top bar ===== */
.top-bar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.score-board {
  font-size: 1.1rem;
  font-weight: bold;
  color: #ffffff;
}

.icon-group {
  display: flex;
  gap: 0.35rem;
}

.icon-btn {
  width: 36px;
  height: 36px;
  font-size: 1.1rem;
  line-height: 1;
  background: #0d1b2a; /* Dark navy */
  color: #ffffff;
  border: 2px solid #1e3a5f; /* Darker navy border */
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.icon-btn:hover,
.icon-btn:focus-visible {
  background: #152a45;
  border-color: #ffffff;
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

.icon-btn[aria-pressed="true"] {
  background: #ffffff;
  color: #0d1b2a;
  border-color: #ffffff;
}

.listen-btn {
  background: #0d1b2a;
  border-color: #ffffff;
  animation: pulse 1.6s ease-in-out infinite;
}

.listen-btn:hover,
.listen-btn:focus-visible {
  background: #152a45;
  border-color: #ffffff;
}

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

@media (prefers-reduced-motion: reduce) {
  .listen-btn { animation: none; }
}

/* ===== Canvas (fixed internal resolution) ===== */
#game-canvas {
  display: block;
  width: 100%;
  height: auto;
  max-width: 400px;
  max-height: 55dvh;
  aspect-ratio: 1 / 1;
  border: 3px solid #1e3a5f;
  background: #050a14;
  border-radius: 8px;
  image-rendering: crisp-edges;
}

#game-canvas:focus {
  outline: 3px solid #ffffff;
  outline-offset: 2px;
}

/* ===== Direction pad ===== */
.controls {
  display: grid;
  grid-template-columns: repeat(3, 48px);
  gap: 6px;
  justify-content: center;
}

.controls button {
  width: 48px;
  height: 48px;
  font-size: 1.2rem;
  font-weight: bold;
  background: #0d1b2a;
  color: #ffffff;
  border: 2px solid #1e3a5f;
  border-radius: 8px;
  cursor: pointer;
}

.controls button:hover,
.controls button:focus-visible {
  background: #152a45;
  border-color: #ffffff;
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

.controls button:active { transform: scale(0.95); }

#btn-up    { grid-column: 2; grid-row: 1; }
#btn-left  { grid-column: 1; grid-row: 2; }
#btn-down  { grid-column: 2; grid-row: 2; }
#btn-right { grid-column: 3; grid-row: 2; }

/* ===== Screen-reader-only utility ===== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================
   PANELS (instructions, animals, notebook)
   ============================================================ */

.panel {
  width: 100%;
  max-width: 520px;
  margin: 0.75rem auto 0;
  padding: 0.75rem 0.8rem;
  background: #0a1420; /* Very dark navy */
  border: 1px solid #1e3a5f;
  border-radius: 8px;
  color: #ffffff;
}

.panel-title {
  font-size: 0.9rem;
  font-weight: bold;
  color: #ffffff;
  margin-bottom: 0.5rem;
  text-align: center;
}

.panel-note {
  font-size: 0.7rem;
  color: #ffffff; /* White instead of grey */
  text-align: center;
  line-height: 1.45;
  margin-bottom: 0.5rem;
}

/* ----- Instructions panel ----- */
.instr-panel {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.instr-text {
  flex: 1;
  font-size: 0.78rem;
  line-height: 1.4;
  color: #ffffff;
}

.audio-btn {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  font-size: 1rem;
  line-height: 1;
  background: #0d1b2a;
  color: #ffffff;
  border: 1px solid #1e3a5f;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.audio-btn:hover,
.audio-btn:focus-visible {
  border-color: #ffffff;
  background: #152a45;
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

/* ----- Animals panel ----- */
.fruits-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.fruit-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  padding: 0.3rem 0.2rem;
  background: #0d1b2a;
  border: 1px solid #1e3a5f;
  border-radius: 6px;
  color: #ffffff;
  font-size: 0.65rem;
  cursor: pointer;
  text-align: center;
  line-height: 1.2;
  transition: border-color 0.15s, background 0.15s;
}

.fruit-chip:hover,
.fruit-chip:focus-visible {
  border-color: #ffffff;
  background: #152a45;
  outline: 2px solid #ffffff;
  outline-offset: 1px;
}

.fruit-chip .emoji {
  font-size: 1.1rem;
  line-height: 1;
}

/* Animal trait: small, quieter line under the name */
.animal-trait {
  display: block;
  font-size: 0.62rem;
  color: #ffffff; /* White */
  margin-top: 0.1em;
}

.fruits-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
}

/* ----- Stars row ----- */
.stars-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  font-size: 1rem;
  margin-bottom: 0.5rem;
  min-height: 1.4em;
  flex-wrap: wrap;
}

.stars-row .star-off { opacity: 0.25; }

/* ----- Quiz panel ----- */
.quiz-panel { display: none; }
.quiz-panel.quiz-active { display: block; margin-top: 0.5rem; }

.quiz-question {
  font-size: 1.05rem;
  text-align: center;
  margin: 0.4rem 0;
  min-height: 1.6em;
  color: #ffffff; /* White instead of gold */
}

.quiz-score {
  text-align: center;
  font-weight: bold;
  font-size: 0.8rem;
}

.quiz-feedback {
  text-align: center;
  min-height: 1.4em;
  margin-top: 0.25rem;
  font-size: 0.8rem;
}

.quiz-feedback.good { color: #ffffff; font-weight: bold; }
.quiz-feedback.bad  { color: #ffffff; font-weight: bold; } /* All white */

.fruit-chip.quiz-correct { outline: 3px solid #ffffff; outline-offset: 1px; }
.fruit-chip.quiz-wrong   { outline: 3px solid #ffffff; outline-offset: 1px; } /* All white */

/* Turtle (slow speech) button pressed state */
.turtle-btn[aria-pressed="true"] {
  background: #ffffff;
  color: #0d1b2a;
  border-color: #ffffff;
}

.turtle-btn { font-size: 0.75rem; }

/* ----- Notebook panel ----- */
.notebook-textarea {
  width: 100%;
  min-height: 80px;
  resize: vertical;
  padding: 0.5rem;
  background: #050a14; /* Deepest navy for input */
  color: #ffffff;
  border: 1px solid #1e3a5f;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.8rem;
  line-height: 1.4;
}

.notebook-textarea:focus {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

.notebook-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.action-btn {
  padding: 0.35rem 0.6rem;
  font-size: 0.75rem;
  background: #0d1b2a;
  color: #ffffff;
  border: 1px solid #1e3a5f;
  border-radius: 6px;
  cursor: pointer;
}

.action-btn:hover,
.action-btn:focus-visible {
  border-color: #ffffff;
  background: #152a45;
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

.notebook-status {
  font-size: 0.65rem;
  color: #ffffff; /* White */
  text-align: center;
  margin-top: 0.35rem;
  min-height: 1em;
}

/* ============================================================
   FOOTER (privacy, back link)
   ============================================================ */

.site-footer {
  width: 100%;
  max-width: 520px;
  margin: 1rem auto 0;
  padding: 0.75rem 0.6rem 1rem;
  background: #050a14;
  border-top: 1px solid #1e3a5f;
  color: #ffffff;
}

.privacy-note {
  text-align: center;
  font-size: 0.7rem;
  color: #ffffff; /* White */
  line-height: 1.45;
  margin: 0.4rem auto 0.5rem;
  max-width: 420px;
}

.back-link {
  display: block;
  text-align: center;
  font-size: 0.75rem;
  color: #ffffff;
  text-decoration: underline;
  text-underline-offset: 2px;
  margin-top: 0.3rem;
}

.back-link:hover,
.back-link:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
  border-radius: 3px;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 380px) {
  .fruits-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-height: 700px) {
  #game-canvas { max-height: 50dvh; }
  .controls { grid-template-columns: repeat(3, 42px); }
  .controls button { width: 42px; height: 42px; font-size: 1rem; }
  .icon-btn { width: 32px; height: 32px; font-size: 0.95rem; }
}

@media (max-height: 560px) {
  #game-canvas { max-height: 55dvh; }
  .score-board { font-size: 0.95rem; }
}
