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

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: #f5f0eb;
  color: #3a2a1a;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== Header ===== */
header {
  background: #fff8f2;
  border-bottom: 2px solid #d4a87a;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: #7b3f00;
  text-decoration: none;
}

.logo img { width: 36px; height: 36px; }

.header-btns { display: flex; gap: 0.5rem; }

.header-btn {
  background: none;
  border: 2px solid #d4a87a;
  border-radius: 8px;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: #7b3f00;
  font-weight: 600;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  text-decoration: none;
  line-height: 1;
}
.header-btn:hover {
  background: #f5e6d3;
  text-decoration: none;
}

.header-btn[aria-current="page"] {
  background: #7b3f00;
  border-color: #7b3f00;
  color: #fff;
}

/* ===== Main Layout ===== */
main {
  flex: 1;
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

/* ===== Game Title ===== */
.game-title {
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: #7b3f00;
  margin-bottom: 1.25rem;
  letter-spacing: 0.03em;
}

/* ===== Clues Card ===== */
.card-flip {
  perspective: 1000px;
  margin-bottom: 1.25rem;
}

.card-flip-inner {
  position: relative;
  transition: transform 0.6s ease;
  transform-style: preserve-3d;
}

.card-flip-inner.flipped { transform: rotateY(180deg); }

.card-face {
  backface-visibility: hidden;
  background: #fff8f2;
  border: 2px solid #d4a87a;
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
}

.card-back {
  position: absolute;
  top: 0; left: 0; width: 100%;
  transform: rotateY(180deg);
  background: #fff8f2;
  border: 2px solid #2196F3;
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  min-height: 100%;
}

.card-back h3 {
  color: #1565c0;
  margin-bottom: 0.75rem;
  font-size: 1rem;
}

.card-back p {
  font-size: 0.95rem;
  line-height: 1.6;
  color: #3a2a1a;
}

.section-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #a06030;
  margin-bottom: 0.5rem;
}

.clue-list { list-style: none; }

.clue-item {
  padding: 0.6rem 0;
  font-size: 0.95rem;
  line-height: 1.55;
  border-bottom: 1px solid #f0e0cc;
  transition: opacity 0.3s;
}

.clue-item:last-child { border-bottom: none; }

.clue-item.locked {
  color: #ccc;
  font-style: italic;
  user-select: none;
}

.clue-item.revealed {
  animation: flipIn 0.5s ease forwards;
}

@keyframes flipIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== Anki Buttons ===== */
.anki-row {
  display: none;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.anki-btn {
  background: #e8f4fd;
  border: 1.5px solid #2196F3;
  border-radius: 6px;
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  color: #1565c0;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
}
.anki-btn:hover { background: #bbdefb; }

/* ===== Input Area ===== */
.input-area {
  position: relative;
  margin-bottom: 0.75rem;
}

.input-row {
  display: flex;
  gap: 0.5rem;
}

#guess-input {
  flex: 1;
  padding: 0.65rem 1rem;
  border: 2px solid #d4a87a;
  border-radius: 8px;
  font-size: 0.95rem;
  background: #fff;
  color: #3a2a1a;
  outline: none;
  transition: border-color 0.2s;
}
#guess-input:focus { border-color: #7b3f00; }
#guess-input:disabled { background: #f0e0cc; cursor: not-allowed; color: #999; }

#submit-btn {
  padding: 0.65rem 1.25rem;
  background: #7b3f00;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}
#submit-btn:hover:not(:disabled) { background: #5a2d00; }
#submit-btn:disabled { background: #c0a080; cursor: not-allowed; }

/* ===== Autocomplete ===== */
#suggestions {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 5rem;
  background: #fff;
  border: 2px solid #d4a87a;
  border-radius: 8px;
  z-index: 50;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.suggestion-item {
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s;
}
.suggestion-item:hover { background: #f5e6d3; }
.suggestion-item.already-guessed { color: #aaa; cursor: not-allowed; font-style: italic; }

/* ===== Result Message ===== */
#result-msg {
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  min-height: 1.5rem;
  margin-bottom: 0.5rem;
}
#result-msg.correct { color: #2e7d32; }
#result-msg.incorrect { color: #c62828; }
#result-msg.info { color: #e65100; }

/* ===== Guess History ===== */
#guess-history {
  margin-bottom: 1rem;
}

.guess-history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  margin-bottom: 0.3rem;
  font-size: 0.88rem;
  font-weight: 600;
}
.guess-history-item.correct { background: #e8f5e9; color: #2e7d32; }
.guess-history-item.wrong   { background: #ffebee; color: #c62828; }
.guess-history-item.skip    { background: #f5f5f5; color: #757575; }

.guess-history-icon { font-size: 1rem; }

/* ===== Summary Button ===== */
#summary-btn {
  display: none;
  width: 100%;
  padding: 0.7rem;
  background: #2196F3;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 0.75rem;
  transition: background 0.2s;
}
#summary-btn:hover { background: #1565c0; }

/* ===== Modal ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal-box {
  background: #fff8f2;
  border-radius: 16px;
  padding: 1.75rem;
  max-width: 480px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

.modal-close {
  position: absolute;
  top: 0.75rem; right: 1rem;
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: #7b3f00;
  line-height: 1;
}

#modal-body { font-size: 0.95rem; line-height: 1.6; }

.modal-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

.btn-share {
  flex: 1;
  padding: 0.65rem;
  background: #2e7d32;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-share:hover { background: #1b5e20; }

#copy-confirm {
  display: none;
  text-align: center;
  color: #2e7d32;
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 0.4rem;
}

/* ===== Stats ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin: 1rem 0;
}
.stat-item { text-align: center; }
.stat-number { font-size: 1.6rem; font-weight: 700; color: #7b3f00; }
.stat-label { font-size: 0.7rem; color: #888; }

.dist-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
  font-size: 0.85rem;
}
.dist-label { width: 12px; text-align: center; font-weight: 700; color: #7b3f00; }
.dist-bar-wrap { flex: 1; background: #f0e0cc; border-radius: 4px; height: 20px; }
.dist-bar { height: 100%; background: #7b3f00; border-radius: 4px; min-width: 8px; display: flex; align-items: center; justify-content: flex-end; padding-right: 6px; transition: width 0.4s; }
.dist-bar.highlight { background: #2e7d32; }
.dist-bar span { color: #fff; font-size: 0.75rem; font-weight: 700; }

/* ===== Cookie Banner ===== */
#cookie-banner {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #fff8f2;
  border-top: 2px solid #d4a87a;
  padding: 1rem 1.5rem;
  z-index: 300;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.1);
}

#cookie-banner p { flex: 1; font-size: 0.88rem; min-width: 200px; }

.cookie-btns { display: flex; gap: 0.5rem; }

.btn-accept {
  padding: 0.45rem 1rem;
  background: #7b3f00;
  color: #fff;
  border: none;
  border-radius: 7px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-decline {
  padding: 0.45rem 1rem;
  background: none;
  border: 2px solid #d4a87a;
  border-radius: 7px;
  font-size: 0.88rem;
  cursor: pointer;
  color: #7b3f00;
}

/* ===== Footer ===== */
footer {
  text-align: center;
  padding: 1rem;
  font-size: 0.78rem;
  color: #a07050;
  border-top: 1px solid #e8d5be;
  background: #fff8f2;
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  #cookie-banner { flex-direction: column; }
}
