/* ============================================
   NAMEDLE — Simplistic "Wordle-style" Theme
   ============================================ */

/* The user requested a "simplistic Wordle" look with Dark/Light theme */

@font-face {
  font-family: "Twemoji Country Flags";
  unicode-range: U+1F1E6-1F1FF, U+1F3F4, U+E0062-E0063, U+E0065-E0067, U+E006C, U+E006E, U+E0073-E0074, U+E0077, U+E007F;
  src: url("https://cdn.jsdelivr.net/npm/country-flag-emoji-polyfill@0.1/dist/TwemojiCountryFlags.woff2") format("woff2");
}

:root {
  /* Default variables (Light) */
  --bg-main: #ffffff;
  --bg-surface: #ffffff;
  --bg-modal: #ffffff;
  --border-main: #d3d6da;
  --border-heavy: #878a8c;

  --text-main: #121213;
  --text-secondary: #787c7e;

  --green: #6aaa64;
  --yellow: #c9b458;
  --gray: #787c7e;
  --red: #d9534f;

  --btn-bg: #e3e3e1;
  --btn-hover: #d3d6da;
  --btn-text: #121213;

  --font-family: 'Outfit', 'Twemoji Country Flags', 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji', system-ui, sans-serif;
}

[data-theme="dark"] {
  --bg-main: #121213;
  --bg-surface: #121213;
  --bg-modal: #121213;
  --border-main: #3a3a3c;
  --border-heavy: #565758;

  --text-main: #ffffff;
  --text-secondary: #818384;

  --green: #538d4e;
  --yellow: #b59f3b;
  --gray: #3a3a3c;
  --red: #c94a46;

  --btn-bg: #818384;
  --btn-hover: #565758;
  --btn-text: #ffffff;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-family);
  background: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
}

/* === Header === */
.header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  height: 65px;
  border-bottom: 1px solid var(--border-main);
  position: relative;
}

.header__logo {
  font-family: var(--font-family);
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-main);
}

.header__actions {
  position: absolute;
  display: flex;
  gap: 8px;
}

.header__actions--left {
  left: 16px;
}

.header__actions--right {
  right: 16px;
}

.header__btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px;
  transition: all 0.2s ease;
}

.header__btn:hover {
  color: var(--text-main);
  transform: scale(1.1);
}

/* === Mode Toggle === */
.mode-toggle {
  display: flex;
  justify-content: center;
  margin: 16px 0;
}

.mode-toggle__group {
  display: flex;
  border-radius: 4px;
  border: 1px solid var(--border-main);
  background: var(--bg-surface);
  overflow: hidden;
}

.mode-toggle__btn {
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}

.mode-toggle__btn.active {
  background: var(--gray);
  color: #fff;
}

/* === Progress Bar === */
.progress-bar {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin-bottom: 12px;
}

.progress-dot {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  border: 2px solid var(--border-main);
  color: var(--text-secondary);
  background: var(--bg-surface);
}

.progress-dot.active {
  border-color: var(--border-heavy);
  color: var(--text-main);
}

.progress-dot.won {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.progress-dot.lost {
  border-color: var(--gray);
  background: var(--gray);
  color: #fff;
}

/* === Game Info === */
.game-info {
  display: flex;
  justify-content: space-between;
  width: 100%;
  max-width: 500px;
  margin: 0 auto 24px;
  padding: 0 16px;
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: bold;
}

.game-info__item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.game-info__item svg {
  width: 18px;
  height: 18px;
}

/* === Game Container === */
.game-container {
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  padding: 0 16px;
  flex: 1;
}

/* === Name Card === */
.name-card {
  text-align: center;
  margin: 32px 0 40px;
}

.name-card__label {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  font-weight: bold;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.name-card__name {
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.name-card__counter {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* === Hint Cards === */
.hints-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 32px;
  min-height: 100px;
}

.hint-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  text-align: center;
  position: relative;
  transition: all 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ── Hidden placeholder ── */
.hint-card.hint-hidden {
  flex: 0 0 60px;
  height: 80px;
  border: 2px dashed var(--border-main);
  background: transparent;
  opacity: 0.5;
}

.hint-card__lock {
  color: var(--text-secondary);
  opacity: 0.4;
}
.hint-card__lock svg {
  width: 16px;
  height: 16px;
}

/* ── Badge "Hint 1/2/3/4" ── */
.hint-card__badge {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.6rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--green);
  color: #fff;
  white-space: nowrap;
  z-index: 2;
  animation: badgePulse 0.6s ease-out;
}

.hint-card__badge--locked {
  background: var(--border-heavy);
  color: var(--bg-surface);
  animation: none;
}

@keyframes badgePulse {
  0% { transform: translateX(-50%) scale(0.5); opacity: 0; }
  50% { transform: translateX(-50%) scale(1.2); }
  100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* ── Unlocked (revealed) ── */
.hint-card.unlocked {
  flex: 1;
  height: 90px;
  max-width: 120px;
  padding: 14px 6px 8px;
  background: var(--yellow);
  border: 2px solid var(--yellow);
  color: #fff;
  animation: hintReveal 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.hint-card.hint-new {
  animation: hintReveal 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes hintReveal {
  0% {
    transform: translateY(20px) scale(0.7);
    opacity: 0;
    box-shadow: 0 0 0 rgba(0,0,0,0);
  }
  40% {
    opacity: 1;
  }
  70% {
    transform: translateY(-4px) scale(1.06);
    box-shadow: 0 0 20px rgba(181, 155, 57, 0.4);
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
    box-shadow: 0 0 0 rgba(0,0,0,0);
  }
}

.unlocked .hint-card__value,
.unlocked .hint-card__icon,
.unlocked .hint-card__label {
  color: #fff;
}

.hint-card__icon {
  font-size: 1.1rem;
  margin-bottom: 2px;
}

.hint-card__icon svg {
  width: 18px;
  height: 18px;
}

.hint-card__label {
  font-size: 0.55rem;
  text-transform: uppercase;
  font-weight: bold;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.hint-card__value {
  font-size: 0.85rem;
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  color: var(--text-main);
}

/* === Guess Table === */
.guess-table {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 32px;
}

.guess-table__header {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  padding: 0 8px 8px;
  font-size: 0.75rem;
  font-weight: bold;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border-main);
}

.guess-table__row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  align-items: center;
  border: 2px solid var(--border-main);
  border-radius: 4px;
  background: var(--bg-surface);
  font-weight: bold;
  height: 56px;
  padding: 0 12px;
  color: var(--text-main);
  transition: transform 0.1s ease;
}

.guess-table__row.correct-row {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.guess-country {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 8px;
}

.guess-flag {
  font-size: 1.2rem;
}

.guess-distance {
  font-size: 0.9rem;
  text-align: right;
  margin-right: 8px;
}

.guess-direction {
  font-size: 1.2rem;
  text-align: center;
}

/* In a simple variant, we might hide the extra columns for cleanliness, 
   but we'll keep them as simple text if they exist */
.guess-attr {
  display: none;
}

/* Simplified wordle aesthetic */

.guess-empty {
  text-align: center;
  color: var(--text-secondary);
  padding: 16px;
  margin-bottom: 32px;
  font-style: italic;
  font-weight: bold;
  border: 2px solid var(--border-main);
  background: transparent;
}

/* === Input Area === */
.input-wrapper {
  display: flex;
  gap: 8px;
  position: relative;
}

.country-input {
  flex: 1;
  padding: 16px;
  font-size: 1.2rem;
  font-weight: bold;
  font-family: inherit;
  border: 2px solid var(--border-heavy);
  border-radius: 4px;
  background: var(--bg-surface);
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.country-input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(106, 170, 100, 0.2);
}

.submit-btn {
  padding: 0 24px;
  font-size: 1rem;
  font-weight: bold;
  text-transform: uppercase;
  background: var(--btn-bg);
  color: var(--btn-text);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.submit-btn:hover {
  background: var(--btn-hover);
  transform: translateY(-2px);
}

.submit-btn:active {
  transform: translateY(0);
}

/* === Autocomplete === */
.autocomplete {
  position: absolute;
  top: 100%;
  left: 0;
  right: 120px;
  background: var(--bg-surface);
  border: 2px solid var(--border-heavy);
  margin-top: 4px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 10;
  display: none;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.autocomplete.visible {
  display: block;
}

.autocomplete-item {
  padding: 12px;
  cursor: pointer;
  font-weight: bold;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
}

.autocomplete-item:hover,
.autocomplete-item.highlighted {
  background: var(--btn-hover);
}

/* === Reveal Card === */
.reveal-card {
  text-align: center;
  padding: 32px;
  border: 2px solid var(--border-main);
  background: var(--bg-surface);
}

.reveal-win {
  border-color: var(--green);
}

.reveal-lose {
  border-color: var(--gray);
}

.reveal-card__icon {
  font-size: 2.5rem;
  margin-bottom: 16px;
}

.reveal-card__text {
  font-size: 1.2rem;
  font-weight: bold;
  margin-bottom: 16px;
  color: var(--text-main);
}

.reveal-card__answer {
  font-size: 2rem;
  font-weight: bold;
  margin-bottom: 24px;
}

.reveal-card__answer .reveal-country {
  color: var(--green);
}

.reveal-card__meta {
  display: none;
}

.action-buttons {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}

.action-btn {
  padding: 14px 28px;
  font-weight: bold;
  font-size: 1.1rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  background: var(--btn-bg);
  color: var(--btn-text);
  font-family: inherit;
  transition: all 0.2s ease;
}

.action-btn--primary {
  background: var(--green);
  color: #fff;
}

.action-btn:hover {
  background: var(--btn-hover);
  transform: translateY(-2px);
}

.action-btn--primary:hover {
  opacity: 0.9;
  background: var(--green);
}

.action-btn:active {
  transform: translateY(0);
}

/* === Score / Summary === */
.summary-screen {
  max-width: 700px;
  margin: 0 auto;
}

.summary-top-row {
  display: flex;
  align-items: stretch;
  gap: 24px;
  margin-bottom: 8px;
}

.summary-top-row .score-display {
  flex: 0 0 auto;
  min-width: 160px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  margin: 0;
  padding: 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-main);
  border-radius: 8px;
}

.summary-top-row .dist-chart {
  flex: 1;
  margin: 0;
}

.score-display {
  text-align: center;
  margin: 32px 0;
}

.score-display__label {
  font-size: 1rem;
  font-weight: bold;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.score-display__value {
  font-size: 3.5rem;
  font-weight: bold;
  color: var(--text-main);
  margin: 4px 0;
}

.score-display__subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

@media (max-width: 600px) {
  .summary-top-row {
    flex-direction: column;
    gap: 16px;
  }
}

.summary-results__title {
  font-size: 1rem;
  font-weight: bold;
  text-align: center;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--border-main);
  padding-bottom: 8px;
}

.summary-name-row {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-main);
  font-weight: bold;
}

.summary-name {
  flex: 1;
  color: var(--text-main);
}

.summary-answer {
  flex: 1;
  text-align: center;
  color: var(--text-secondary);
}

.summary-result {
  min-width: 40px;
  text-align: right;
}

.summary-result.won {
  color: var(--green);
}

.summary-result.lost {
  color: var(--gray);
}

/* === Distribution Chart === */
.dist-chart {
  margin: 24px 0;
  padding: 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-main);
  border-radius: 8px;
}

.dist-chart__title {
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-main);
  margin-bottom: 4px;
}

.dist-chart__subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.dist-chart__percentile {
  font-size: 0.95rem;
  color: var(--green);
  font-weight: 600;
  margin-bottom: 16px;
}

.dist-bars {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dist-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dist-row--you {
  font-weight: 700;
}

.dist-label {
  min-width: 60px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.dist-row--you .dist-label {
  color: var(--text-main);
}

.dist-bar-track {
  flex: 1;
  height: 18px;
  background: var(--bg-main);
  border-radius: 3px;
  overflow: hidden;
}

.dist-bar-fill {
  height: 100%;
  background: var(--gray);
  border-radius: 3px;
  min-width: 2px;
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.dist-bar-fill--you {
  background: var(--green);
}

.dist-count {
  min-width: 28px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.dist-row--you .dist-count {
  color: var(--text-main);
}

/* === Modals === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  z-index: 1000;
  backdrop-filter: blur(4px);
  transition: opacity 0.2s ease;
}

.modal-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--bg-modal);
  border: 1px solid var(--border-main);
  border-radius: 8px;
  padding: 32px;
  width: 90%;
  max-width: 450px;
  box-shadow: 0 4px 23px 0 rgba(0, 0, 0, 0.2);
  color: var(--text-main);
  transform: translateY(20px);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.visible .modal {
  transform: translateY(0);
}

.modal__title {
  font-size: 1.5rem;
  font-weight: bold;
  text-align: center;
  text-transform: uppercase;
  margin-bottom: 24px;
}

.modal p {
  margin-bottom: 16px;
  line-height: 1.5;
}

.step-list {
  margin: 16px 0;
  padding-left: 16px;
}

.step-item {
  margin-bottom: 8px;
  line-height: 1.5;
}

.step-number {
  display: none;
}

.legend-block {
  margin: 16px 0;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 0.9rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 24px;
}

.stat-card {
  text-align: center;
}

.stat-card__value {
  font-size: 2rem;
  font-weight: bold;
  color: var(--text-main);
}

.stat-card__label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-secondary);
}

/* === Startup Screen === */
.startup-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-main);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.startup-overlay.hidden {
  opacity: 0;
  visibility: hidden;
}

.startup-content {
  text-align: center;
  padding: 24px;
}

.startup-logo {
  font-size: 3.5rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--text-main);
  margin-bottom: 16px;
  animation: float 3s ease-in-out infinite;
}

.startup-intro {
  font-size: 1.5rem;
  color: var(--text-secondary);
  margin-bottom: 40px;
  font-weight: 500;
}

.startup-play {
  font-size: 1.5rem;
  padding: 16px 48px;
  border-radius: 2px;
  text-transform: uppercase;
  letter-spacing: 2px;
  box-shadow: 0 4px 15px rgba(106, 170, 100, 0.4);
}

.startup-play:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 6px 20px rgba(106, 170, 100, 0.6);
}

@keyframes float {
  0% {
    transform: translateY(0px);
  }

  50% {
    transform: translateY(-10px);
  }

  100% {
    transform: translateY(0px);
  }
}

/* === Fact Card === */
.fact-card {
  background: var(--bg-surface);
  border: 2px solid var(--border-main);
  border-radius: 8px;
  padding: 24px;
  margin: 16px 0;
  position: relative;
  overflow: hidden;
}

/* === Utilities === */
.toast {
  position: fixed;
  top: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-main);
  color: var(--bg-main);
  padding: 16px;
  font-weight: bold;
  border-radius: 4px;
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
}

.toast.visible {
  opacity: 1;
}

.shake {
  animation: shake 0.6s cubic-bezier(.36, .07, .19, .97) both;
  transform: translate3d(0, 0, 0);
}

@keyframes shake {

  10%,
  90% {
    transform: translate3d(-1px, 0, 0);
  }

  20%,
  80% {
    transform: translate3d(2px, 0, 0);
  }

  30%,
  50%,
  70% {
    transform: translate3d(-4px, 0, 0);
  }

  40%,
  60% {
    transform: translate3d(4px, 0, 0);
  }
}

.loading {
  text-align: center;
  padding: 40px;
  font-weight: bold;
  color: var(--text-main);
}

.spinner {
  display: none;
}

/* === Confetti === */
.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  top: -20px;
  animation: fall linear forwards;
}

@keyframes fall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }

  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

/* === Responsive === */
@media (max-width: 400px) {
  .hint-card__label {
    font-size: 0.4rem;
  }

  .name-card__name {
    font-size: 2.5rem;
  }
}