:root {
    --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: #1a1a2e;
    color: #ffffff;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
}

.container {
    max-width: 500px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

/* Navigation arrows */
.title-nav-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    width: 100%;
}

.nav-arrow {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    text-decoration: none;
    color: #8b8ba3;
    font-family: 'Pacifico', cursive;
    font-size: 0.85rem;
    padding: 0.4rem 0.6rem;
    border-radius: 8px;
    transition: all 0.2s ease;
    background: transparent;
    min-width: 80px;
}

.nav-arrow.nav-prev {
    justify-content: flex-start;
}

.nav-arrow.nav-next {
    justify-content: flex-end;
}

.nav-arrow:hover {
    color: #ffffff;
    background: rgba(108, 99, 255, 0.2);
}

.nav-arrow-icon {
    font-size: 2.4rem;
    line-height: 1;
    font-weight: 300;
    transform: translateY(-7px);
    background: linear-gradient(135deg, #6c63ff 0%, #ff6b9d 50%, #ffd93d 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-label {
    font-size: 0.9rem;
    opacity: 0.9;
    text-transform: capitalize;
}

.nav-arrow.hidden {
    visibility: hidden;
    pointer-events: none;
}

/* Phones: the title row cannot fit two labelled arrows beside the title, so keep
   only the arrow icons (the links keep their aria-label). */
@media (max-width: 480px) {
    .nav-arrow {
        min-width: 0;
    }

    .nav-label {
        display: none;
    }
}

/* Game title */
.game-title {
    font-family: 'Pacifico', cursive;
    /* 3rem on anything wider than a phone, down to 2rem on narrow screens */
    font-size: clamp(2rem, 9vw, 3rem);
    background: linear-gradient(135deg, #6c63ff 0%, #ff6b9d 50%, #ffd93d 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 4px 20px rgba(108, 99, 255, 0.3);
    letter-spacing: 2px;
    margin-bottom: 4px;
}

/* Game description */
.game-description {
    color: #a0a0b8;
    font-size: 0.95rem;
    text-align: center;
    max-width: 320px;
    line-height: 1.5;
    margin-bottom: 8px;
}

/* Image placeholder */
.image-container {
    width: 100%;
    max-width: 320px;
    aspect-ratio: unset;
    max-height: 300px;  
    background-color: #2d2d44;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #3d3d5c;
}

.image-container img {
    max-width: 100%;
    max-height: 300px;
    height: auto;
    width: auto;
}

.image-placeholder {
    color: #6b6b8d;
    font-size: 14px;
}

/* Input section */
.input-section {
    width: 100%;
    display: flex;
    gap: 12px;
    position: relative;
}

.guess-input {
    flex: 1;
    min-width: 0;
    padding: 14px 18px;
    font-size: 16px;
    border: 2px solid #3d3d5c;
    border-radius: 8px;
    background-color: #2d2d44;
    color: #ffffff;
    outline: none;
    transition: border-color 0.2s;
}

.guess-input::placeholder {
    color: #6b6b8d;
}

.guess-input:focus {
    border-color: #6c63ff;
}

.guess-button {
    padding: 14px 28px;
    font-size: 16px;
    font-weight: 600;
    background-color: #6c63ff;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    white-space: nowrap;
}

.guess-button:hover {
    background-color: #5a52d5;
}

.guess-button:active {
    transform: scale(0.98);
}

/* Icon-only, so narrower than GUESS */
.stats-button {
    padding: 14px 16px;
}

.guess-button:disabled {
    background-color: #4a4a6a;
    cursor: not-allowed;
}

/* Guess counter */
.guess-counter {
    font-size: 14px;
    color: #8b8ba3;
    margin-top: -12px;
}

/* Answer message (game over) */
.answer-message {
    width: 100%;
    padding: 14px 18px;
    background-color: #3a3a55;
    border: 2px solid #e65c44;
    border-radius: 8px;
    text-align: center;
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
    transition: opacity 300ms var(--ease-out), transform 300ms var(--ease-out);
}

@starting-style {
    .answer-message.enter {
        opacity: 0;
        transform: translateY(-8px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .answer-message { transition: opacity 300ms var(--ease-out); }
    @starting-style {
        .answer-message.enter { transform: none; }
    }
}

/* Guess rows */
.guesses-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.guess-row {
    width: 100%;
    padding: 14px 18px;
    background-color: #2d2d44;
    border: 2px solid #3d3d5c;
    border-radius: 8px;
    min-height: 50px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    color: #8b8ba3;
    transition: all 0.2s;
}

.guess-row.filled {
    color: #ffffff;
    border: none;
    padding: 0;
    gap: 5px;
    align-items: stretch;
    background-color: #1a1a2e;
    border-right: 1px solid white;
    border-radius: 15px;
}

.guess-row.active {
    background-color: #5e5e81;
    border-color: #5e5e81;
    font-weight: bold;
    color: #ffffff;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.guess-row.correct {
    border-right: 1px solid #3d7a4d;
    border-radius: 15px;
}

/* Feedback popup overlay */
.feedback-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(10, 10, 24, 0.72);
    backdrop-filter: blur(3px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    z-index: 1000;
}

.feedback-overlay.show {
    opacity: 1;
    visibility: visible;
}

.feedback-circle {
    width: min(33vw, 200px);
    height: min(33vw, 200px);
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #424266 0%, #2d2d44 70%);
    border: 2px solid #3d3d5c;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
    transform: scale(0.8);
    transition: transform 0.3s ease-out, background 0.2s, border-color 0.2s;
}

.feedback-overlay.show .feedback-circle {
    transform: scale(1);
}

.feedback-circle.correct {
    background: radial-gradient(circle at 30% 30%, #3a6f49 0%, #2d5a3d 65%, #22362e 100%);
    border-color: #3d7a4d;
}

.feedback-circle.wrong {
    background: radial-gradient(circle at 30% 30%, #7d3f4f 0%, #5e3140 65%, #402330 100%);
    border-color: #e65c44;
}

.feedback-circle img {
    max-width: 80%;
    max-height: 80%;
    object-fit: contain;
    border-radius: 6px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

/* Filled row child elements */
.guess-item {
    background-color: #3f3f58;
    padding: 12px 10px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid white;
    border-radius: 15px;
}

.guess-item.correct {
    background-color: #2d5a3d;
    border: 2px solid #3d7a4d;
    color: #4ade80;
}

.guess-name {
    flex: 5;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.guess-distance {
    flex: 2;
    font-size: 13px;
}

.guess-direction {
    flex: 1;
    border-right: none;
}



/* Custom Suggestions Dropdown */
#suggestions-container {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    max-height: 200px;
    overflow-y: auto;
    background-color: #2d2d44;
    border: 2px solid #3d3d5c;
    border-radius: 12px;
    box-shadow: 0 6px 18px 0 rgba(0, 0, 0, 0.35);
    display: none;
    z-index: 1000;
}

#suggestions-container.show {
    display: block;
}

.suggestion-item {
    padding: 12px 18px;
    cursor: pointer;
    font-size: 16px;
    color: #e6e7f2;
    background-color: #2d2d44;
    border-bottom: 1px solid #3d3d5c;
    transition: background-color 0.15s;
}

.suggestion-item:first-child {
    border-radius: 10px 10px 0 0;
}

.suggestion-item:last-child {
    border-bottom: none;
    border-radius: 0 0 10px 10px;
}

.suggestion-item:only-child {
    border-radius: 10px;
}

.suggestion-item:hover {
    background-color: #3a3a55;
}

.suggestion-item.selected {
    background-color: #4b4b72;
    color: #ffffff;
}

/* Scrollbar styling for suggestions */
#suggestions-container::-webkit-scrollbar {
    width: 8px;
}

#suggestions-container::-webkit-scrollbar-track {
    background: #25253b;
    border-radius: 4px;
}

#suggestions-container::-webkit-scrollbar-thumb {
    background: #54547a;
    border-radius: 4px;
}

#suggestions-container::-webkit-scrollbar-thumb:hover {
    background: #6a6a94;
}

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

.confetti {
    position: absolute;
    top: -20px;
    opacity: 0;
    animation: confettiFall ease-out forwards;
}

.confetti.square {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.confetti.circle {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.confetti.ribbon {
    width: 4px;
    height: 16px;
    border-radius: 2px;
}

@keyframes confettiFall {
    0% {
        top: -20px;
        opacity: 1;
        transform: translateX(0) rotate(0deg) scale(1);
    }
    25% {
        opacity: 1;
    }
    100% {
        top: 100vh;
        opacity: 0;
        transform: translateX(calc(-50px + 100px * var(--random, 0.5))) rotate(720deg) scale(0.5);
    }
}


.stats-popup-overlay {
  position: fixed;
  inset: 0;
    background: rgba(10, 10, 24, 0.72);
    backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 1000;
  padding: 16px;
}

.stats-popup {
  width: min(720px, 100%);
    background: linear-gradient(180deg, #353552 0%, #2d2d44 100%);
    border: 2px solid #3d3d5c;
  border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  padding: 18px;
    color: #ffffff;
}

.stats-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.stats-popup-title {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.3;
    color: #ffffff;
}

.stats-popup-close {
    border: 1px solid #3d3d5c;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
    background: #3a3a55;
    color: #ffffff;
    transition: background-color 0.2s;
}

.stats-popup-close:hover {
    background: #4b4b72;
}

.stats-popup-summary {
  margin: 6px 0 14px;
    color: #a0a0b8;
}

.stats-chart {
  display: grid;
  gap: 8px;
}

.stats-chart-row {
  display: grid;
  grid-template-columns: 110px 1fr 36px;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
    color: #e6e7f2;
}

.stats-chart-track {
  height: 12px;
  border-radius: 999px;
    background: #1f1f33;
    border: 1px solid #3d3d5c;
  overflow: hidden;
}

.stats-chart-fill {
  height: 100%;
  border-radius: inherit;
    background: linear-gradient(90deg, #6c63ff, #ff6b9d);
  transition: width 220ms ease;
}

.stats-chart-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
    color: #ffffff;
}

@media (max-width: 520px) {
        .feedback-circle {
                width: min(46vw, 170px);
                height: min(46vw, 170px);
                padding: 14px;
        }

        .stats-popup {
                padding: 14px;
        }

        .stats-chart-row {
                grid-template-columns: 84px 1fr 28px;
                gap: 8px;
                font-size: 0.88rem;
        }
}

.stats-popup-tabs {
  display: inline-flex;
  gap: 6px;
  margin: 4px 0 12px;
  padding: 4px;
  border-radius: 10px;
    background: #1f1f33;
    border: 1px solid #3d3d5c;
}

.stats-popup-tab {
    border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 12px;
  background: transparent;
    color: #a0a0b8;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
    transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease;
}

.stats-popup-tab:hover {
    background: #3a3a55;
    color: #e6e7f2;
}

.stats-popup-tab.is-active {
    background: linear-gradient(135deg, #6c63ff 0%, #5a52d5 100%);
    color: #ffffff;
    border-color: #7f78ff;
    box-shadow: 0 4px 12px rgba(108, 99, 255, 0.35);
}

.stats-popup-tab:focus-visible {
    outline: 2px solid #ff6b9d;
  outline-offset: 2px;
}

.stats-popup-kofi {
  display: block;
  margin-top: 14px;
  text-align: center;
}

.stats-popup-kofi img {
  transition: opacity 150ms ease;
}

.stats-popup-kofi:hover img {
  opacity: 0.85;
}
/* Invalid guess feedback */
.guess-error {
    color: #e65c44;
    font-size: 14px;
    text-align: center;
    margin-top: 6px;
}

.guess-error:empty {
    display: none;
}

#guess-input.shake {
    animation: guess-shake 280ms ease-in-out;
}

@keyframes guess-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    60% { transform: translateX(4px); }
    80% { transform: translateX(-2px); }
}

/* Stats popup entrance (closing stays instant) */
.stats-popup-overlay {
    transition: opacity 200ms var(--ease-out);
}

.stats-popup {
    transition: transform 250ms var(--ease-out), opacity 250ms var(--ease-out);
}

@starting-style {
    .stats-popup-overlay { opacity: 0; }
    .stats-popup { opacity: 0; transform: scale(0.96); }
}

@media (prefers-reduced-motion: reduce) {
    #guess-input.shake { animation: none; }
    .stats-popup-overlay { transition-duration: 150ms; }
    .stats-popup { transition: opacity 150ms var(--ease-out); }
    @starting-style {
        .stats-popup { transform: none; }
    }
}
