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

:root {
  --green:    #00693E;
  --green-dk: #004f2d;
  --white:    #ffffff;
  --cream:    #f5f0e8;
  --gold:     #f0c040;
  --mint:     #bfd686;
  --red:      #cc3333;
  --radius:   8px;
}

body {
  font-family: "Inter", "Helvetica Neue", sans-serif;
  background: var(--green);
  color: var(--white);
  min-height: 100vh;
}

/* ════════════════════════════════
   SCREENS
════════════════════════════════ */
.screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-bottom: 60px;
}

.hidden { display: none !important; }

/* ════════════════════════════════
   ENTRY SCREEN
════════════════════════════════ */
.entry-inner {
  width: 100%;
  max-width: 480px;
  padding: 32px 24px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.hero-icon {
  width: 37px;
  height: 48px;
  margin-bottom: 24px;
  opacity: 0.92;
  user-select: none;
  flex-shrink: 0;
  display: block;
}

.main-title {
  margin-top: 16px;
  font-family: "Playfair Display", Georgia, serif;
  font-size: 27px;
  font-weight: 700;
  letter-spacing: 2px;
  text-align: center;
  margin-top: 0;
  margin-bottom: 4px;
}

.subtitle {
  font-size: 13px;
  opacity: 0.7;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 28px;
}

/* ════════════════════════════════
   INPUTS
════════════════════════════════ */
.input-group {
  width: 100%;
  position: relative;
  margin-bottom: 16px;
}

.input-label {
  display: block;
  font-size: 12px;
  opacity: 0.75;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 14px 16px;
  background: rgba(255,255,255,0.12);
  border: 1.5px solid rgba(255,255,255,0.25);
  border-radius: var(--radius);
  color: var(--white);
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

input[type="text"]:focus,
input[type="password"]:focus {
  border-color: rgba(255,255,255,0.7);
}

input::placeholder { color: rgba(255,255,255,0.4); }

/* ════════════════════════════════
   AUTOCOMPLETE
════════════════════════════════ */
.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--green-dk);
  border: 1.5px solid rgba(255,255,255,0.2);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  z-index: 100;
  max-height: 220px;
  overflow-y: auto;
}

.autocomplete-item {
  padding: 12px 16px;
  cursor: pointer;
  font-size: 15px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  transition: background 0.15s;
}

.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover,
.autocomplete-item.active { background: rgba(255,255,255,0.15); }

/* ════════════════════════════════
   BUTTONS
════════════════════════════════ */
.primary-btn {
  width: 100%;
  padding: 14px;
  margin-top: 4px;
  background: var(--white);
  color: var(--green);
  font-weight: 700;
  font-size: 16px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: opacity 0.2s, transform 0.1s;
}

.primary-btn:hover { opacity: 0.92; }
.primary-btn:active { transform: scale(0.98); }

.restart-btn {
  background: transparent;
  border: 1.5px solid rgba(255,255,255,0.35);
  color: rgba(255,255,255,0.7);
  padding: 10px 18px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  margin-top: 12px;
  transition: border-color 0.2s, color 0.2s;
}

.restart-btn:hover {
  border-color: rgba(255,255,255,0.7);
  color: var(--white);
}

/* ════════════════════════════════
   ERROR
════════════════════════════════ */
.error-msg {
  color: #ffaaaa;
  font-size: 13px;
  margin-top: 8px;
  text-align: center;
}

/* ════════════════════════════════
   LEADERBOARD
════════════════════════════════ */
.leaderboard-wrap {
  width: 100%;
  margin-top: 32px;
}

#leaderboard {
  background: rgba(0,0,0,0.2);
  border-radius: var(--radius);
  padding: 16px;
  width: 100%;
}

#leaderboard h3 {
  font-family: "Playfair Display", Georgia, serif;
  font-size: 15px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--white);
  opacity: 1;
  text-align: center;
  margin-bottom: 4px;
  padding-bottom: 0;
}

#leaderboard .lb-subtitle {
  font-size: 11px;
  color: var(--mint);
  opacity: 0.85;
  text-align: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.15);
  letter-spacing: 0.3px;
}

.lb-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.lb-row:last-child { border-bottom: none; }

.lb-rank {
  opacity: 0.5;
  font-size: 12px;
  width: 24px;
}

.lb-name { flex: 1; padding: 0 8px; }

.lb-score {
  font-weight: 600;
  color: var(--mint);
}

/* ════════════════════════════════
   WELCOME FLASH SCREEN
════════════════════════════════ */
.welcome-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 40px 24px;
  gap: 20px;
  text-align: center;
}

.welcome-photo-wrap {
  width: 180px;
  height: 220px;
  border-radius: 12px;
  overflow: hidden;
  border: 3px solid rgba(255,255,255,0.4);
  box-shadow: 0 8px 32px rgba(0,0,0,0.35);
  animation: popIn 0.4s ease-out;
}

.welcome-photo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.welcome-name {
  font-family: "Playfair Display", Georgia, serif;
  font-size: 28px;
  animation: fadeUp 0.4s ease-out 0.3s both;
}

.welcome-msg {
  font-size: 16px;
  opacity: 0.75;
  animation: fadeUp 0.4s ease-out 0.5s both;
}

.countdown {
  font-size: 20px;
  font-weight: 600;
  color: var(--mint);
  animation: fadeUp 0.4s ease-out 0.7s both;
}

.countdown span {
  display: inline-block;
  min-width: 24px;
  text-align: center;
}

@keyframes popIn {
  from { transform: scale(0.8); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

@keyframes fadeUp {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ════════════════════════════════
   GAME SCREEN
════════════════════════════════ */
.game-header {
  width: 100%;
  max-width: 480px;
  padding: 16px 24px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sub-header {
  font-size: 12px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  opacity: 0.55;
}

.game-meta {
  font-size: 12px;
  opacity: 0.55;
  letter-spacing: 0.5px;
}

.game-instructions {
  text-align: center;
  padding: 16px 24px 8px;
  width: 100%;
  max-width: 480px;
}

.big {
  font-family: "Playfair Display", Georgia, serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.small {
  font-size: 12px;
  opacity: 0.65;
}

.photo-wrap {
  width: 100%;
  max-width: 340px;
  margin: 12px auto;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 6px 28px rgba(0,0,0,0.35);
  background: rgba(0,0,0,0.2);
  aspect-ratio: 3/4;
}

#photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.4s ease;
}

#photo.reveal { opacity: 1; }

.guess-area {
  width: 100%;
  max-width: 480px;
  padding: 0 24px;
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.guess-area input {
  flex: 1;
}

.guess-area .primary-btn {
  width: auto;
  padding: 14px 20px;
  flex-shrink: 0;
  margin-top: 0;
}

.feedback {
  width: 100%;
  max-width: 480px;
  padding: 12px 24px;
  font-size: 15px;
  line-height: 1.5;
  min-height: 56px;
  text-align: center;
}

.name-highlight {
  font-weight: 700;
  color: var(--mint);
}

/* ════════════════════════════════
   RESTART / DIFFICULTY
════════════════════════════════ */
.restart-wrap {
  width: 100%;
  max-width: 480px;
  padding: 16px 24px;
  text-align: center;
  border-top: 1px solid rgba(255,255,255,0.1);
  margin-top: 8px;
}

.difficulty-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  opacity: 0.65;
  margin-bottom: 10px;
}

.diff-checks {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.diff-checks label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.15s;
}

.diff-checks label:hover { opacity: 1; }

.diff-checks input[type="radio"] {
  width: auto;
  height: auto;
  padding: 0;
  background: none;
  border: none;
  accent-color: var(--mint);
}

/* ════════════════════════════════
   END / GRADE SCREEN
════════════════════════════════ */
.end-inner {
  width: 100%;
  max-width: 480px;
  padding: 40px 24px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.game-title {
  font-family: "Playfair Display", Georgia, serif;
  font-size: 24px;
  opacity: 0.5;
  letter-spacing: 1px;
}

.report-card-msg {
  font-size: 14px;
  opacity: 0.65;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-top: 8px;
}

.grade-letter {
  font-family: "Playfair Display", Georgia, serif;
  font-size: 120px;
  font-weight: 700;
  line-height: 1;
  color: var(--white);
  text-shadow: 0 4px 20px rgba(255,255,255,0.3);
  margin: 8px 0;
}

.grade-main {
  font-size: 22px;
  font-weight: 600;
  font-family: "Playfair Display", Georgia, serif;
}

.grade-sub {
  font-size: 15px;
  opacity: 0.75;
  max-width: 320px;
  line-height: 1.5;
}

.play-again-wrap {
  width: 100%;
  margin-top: 24px;
  padding: 20px;
  background: rgba(0,0,0,0.2);
  border-radius: var(--radius);
}

.play-again-btn {
  margin-top: 12px;
}

/* ════════════════════════════════
   FOOTER
════════════════════════════════ */
.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 11px;
  opacity: 0.3;
  padding: 10px;
  background: linear-gradient(transparent, rgba(0,80,40,0.8));
  pointer-events: none;
}

/* ════════════════════════════════
   RESPONSIVE
════════════════════════════════ */

/* ════════════════════════════════
   GRADE ANIMATIONS
════════════════════════════════ */
@keyframes spinGrow {
  0%   { transform: rotate(-180deg) scale(0.2); opacity: 0; }
  40%  { transform: rotate(15deg) scale(1.15); opacity: 1; }
  60%  { transform: rotate(-8deg) scale(1.05); }
  75%  { transform: rotate(4deg) scale(1.08); }
  88%  { transform: rotate(-2deg) scale(1.02); }
  100% { transform: rotate(0deg) scale(1); }
}

@keyframes spinGrowA {
  0%   { transform: rotate(-180deg) scale(0.2); opacity: 0; }
  40%  { transform: rotate(15deg) scale(1.15); opacity: 1; }
  60%  { transform: rotate(-8deg) scale(1.05); }
  75%  { transform: rotate(4deg) scale(1.1); }
  88%  { transform: rotate(-2deg) scale(1.04); }
  100% { transform: rotate(0deg) scale(1.15); }
}

.grade-spin-grow {
  animation: spinGrow 3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.grade-spin-grow-a {
  animation: spinGrowA 3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@media (max-width: 400px) {
  .main-title {
  margin-top: 16px; font-size: 28px; }
  .grade-letter { font-size: 90px; }
  .welcome-photo-wrap { width: 150px; height: 185px; }
}

.optional-tag {
  font-size: 10px;
  opacity: 0.5;
  font-weight: normal;
  text-transform: none;
  letter-spacing: 0;
}
