:root {
  --bg: #16101f;
  --bg-soft: #221733;
  --panel: #2a1d3e;
  --text: #f3ecfa;
  --text-dim: #b9a8cf;
  --pink: #ff4fa3;
  --pink-soft: #ff8ac4;
  --purple: #8b5cf6;
  --gold: #f5c542;
  --correct: #1fa35c;
  --partial: #c9a227;
  --wrong: #a33445;
  --radius: 10px;
  --cell: 92px;
}

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

body {
  background: radial-gradient(1200px 600px at 50% -100px, #3a2455 0%, var(--bg) 60%);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Header ---------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 18px 16px 8px;
}

.logo {
  font-size: 2.6rem;
  letter-spacing: 0.12em;
  font-weight: 800;
  background: linear-gradient(90deg, var(--pink), var(--purple), var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-align: center;
}
.logo span { font-weight: 300; }

.icon-btn {
  background: var(--panel);
  color: var(--text);
  border: 1px solid #4a3568;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}
.icon-btn:hover { transform: scale(1.08); border-color: var(--pink); }

main {
  flex: 1;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 12px 40px;
}

.tagline {
  text-align: center;
  color: var(--text-dim);
  margin-bottom: 20px;
}

/* ---------- Mode toggle ---------- */
.mode-toggle {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
}
.mode-btn {
  background: var(--panel);
  color: var(--text-dim);
  border: 1px solid #4a3568;
  border-radius: 999px;
  padding: 8px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, color 0.15s;
}
.mode-btn:hover { transform: scale(1.05); border-color: var(--pink); }
.mode-btn.active {
  background: linear-gradient(90deg, var(--purple), var(--pink));
  color: white;
  border-color: transparent;
}

/* ---------- Input & autocomplete ---------- */
.guess-input-area { display: flex; flex-direction: column; align-items: center; gap: 6px; }

.autocomplete-wrap { position: relative; width: min(420px, 100%); }

#guess-input {
  width: 100%;
  padding: 14px 18px;
  font-size: 1.05rem;
  border-radius: var(--radius);
  border: 2px solid #4a3568;
  background: var(--bg-soft);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#guess-input:focus { border-color: var(--pink); box-shadow: 0 0 0 3px rgba(255, 79, 163, 0.25); }
#guess-input::placeholder { color: var(--text-dim); }

.suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--panel);
  border: 1px solid #4a3568;
  border-radius: var(--radius);
  list-style: none;
  max-height: 300px;
  overflow-y: auto;
  z-index: 30;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}
.suggestions li {
  padding: 10px 16px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.suggestions li .sub { color: var(--text-dim); font-size: 0.85rem; }
.suggestions li:hover, .suggestions li.active { background: rgba(255, 79, 163, 0.18); }

.guess-count { color: var(--text-dim); font-size: 0.9rem; min-height: 1.2em; }

/* ---------- Hint ---------- */
.hint-area { text-align: center; margin-top: 14px; }
.hint-btn {
  background: linear-gradient(90deg, var(--purple), var(--pink));
  border: none;
  color: white;
  font-size: 1rem;
  padding: 10px 22px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.15s;
}
.hint-btn:hover { transform: scale(1.05); }
.hint-text {
  margin-top: 10px;
  color: var(--gold);
  font-size: 1.05rem;
}

/* ---------- Board ---------- */
.board-wrap { overflow-x: auto; margin-top: 26px; padding-bottom: 8px; }

.board { width: max-content; margin: 0 auto; }

.board-header, .guess-row {
  display: grid;
  grid-template-columns: repeat(8, var(--cell));
  gap: 6px;
  margin-bottom: 6px;
}

.hcell {
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  border-bottom: 2px solid #4a3568;
  padding-bottom: 6px;
  align-self: end;
}

.cell {
  width: var(--cell);
  height: var(--cell);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-weight: 700;
  font-size: 1rem;
  text-align: center;
  padding: 4px;
  background: var(--panel);
  opacity: 0;
  animation: flip-in 0.5s ease forwards;
  overflow: hidden;
}
.cell .small { font-size: 0.72rem; font-weight: 500; line-height: 1.15; }
.cell .arrow { font-size: 0.85rem; opacity: 0.9; }

.cell.correct { background: var(--correct); }
.cell.partial { background: var(--partial); color: #201a05; }
.cell.wrong   { background: var(--wrong); }

@keyframes flip-in {
  0%   { opacity: 0; transform: rotateX(90deg); }
  100% { opacity: 1; transform: rotateX(0deg); }
}

/* Queen cell with photo */
.cell.queen-cell { position: relative; padding: 0; background: var(--bg-soft); }
.cell.queen-cell img,
.cell.queen-cell .placeholder {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cell.queen-cell .placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.9);
}
.cell.queen-cell .name-tag {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.72);
  font-size: 0.68rem;
  font-weight: 600;
  padding: 3px 4px;
  line-height: 1.15;
}

/* ---------- Win panel ---------- */
.win-panel { margin-top: 30px; display: flex; justify-content: center; }
.win-inner {
  background: linear-gradient(160deg, var(--panel), #3b2758);
  border: 1px solid var(--gold);
  border-radius: 16px;
  padding: 28px 34px;
  text-align: center;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.5);
}
.win-inner h2 { color: var(--gold); margin-bottom: 6px; }
.win-name { font-size: 1.5rem; font-weight: 800; color: var(--pink-soft); }
.win-detail { color: var(--text-dim); margin: 6px 0 16px; }

.win-photo {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  overflow: hidden;
  margin: 0 auto 14px;
  border: 3px solid var(--gold);
  position: relative;
}
.win-photo .photo-holder { width: 100%; height: 100%; }
.win-photo img, .win-photo .placeholder {
  width: 100%; height: 100%;
  object-fit: cover;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.2rem; font-weight: 800; color: rgba(255,255,255,0.9);
}

.share-btn {
  background: var(--correct);
  border: none;
  color: white;
  font-size: 1.05rem;
  font-weight: 700;
  padding: 12px 26px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.15s;
}
.share-btn:hover { transform: scale(1.05); }
.share-btn.again { background: linear-gradient(90deg, var(--purple), var(--pink)); margin-left: 8px; }
.share-feedback { color: var(--gold); margin-top: 8px; font-size: 0.9rem; }

.countdown { margin-top: 18px; color: var(--text-dim); display: flex; flex-direction: column; gap: 2px; }
.countdown-time { font-size: 1.6rem; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- Modals ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 5, 18, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal {
  background: var(--panel);
  border: 1px solid #4a3568;
  border-radius: 16px;
  max-width: 520px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 28px;
  position: relative;
}
.modal h2 { margin-bottom: 12px; color: var(--pink-soft); }
.modal h3 { margin: 16px 0 8px; color: var(--text); }
.modal p { margin-bottom: 10px; line-height: 1.5; color: var(--text-dim); }
.modal-close {
  position: absolute;
  top: 12px; right: 16px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.6rem;
  cursor: pointer;
}
.modal-close:hover { color: var(--pink); }

.legend, .explain { list-style: none; margin: 10px 0; display: flex; flex-direction: column; gap: 8px; color: var(--text-dim); }
.explain li { line-height: 1.4; }
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 5px;
  vertical-align: middle;
  margin-right: 6px;
  font-size: 0.8rem;
}
.chip.correct { background: var(--correct); }
.chip.partial { background: var(--partial); }
.chip.wrong { background: var(--wrong); }
.chip.arrow { background: var(--bg-soft); border: 1px solid #4a3568; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 10px;
}
.stat-box {
  background: var(--bg-soft);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.stat-box .num { font-size: 1.9rem; font-weight: 800; color: var(--pink-soft); }
.stat-box .lbl { font-size: 0.82rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }

/* ---------- Footer ---------- */
.site-footer {
  text-align: center;
  color: #6d5a8a;
  font-size: 0.78rem;
  padding: 18px 12px;
}

.hidden { display: none !important; }

@media (max-width: 600px) {
  :root { --cell: 74px; }
  .logo { font-size: 2rem; }
  .cell { font-size: 0.9rem; }
}
