/* General Page Styling */
body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(135deg, #6ab7f5, #004aad);
    color: #ffffff;
    text-align: center;
    margin: 0;
    padding: 70px 12px 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    min-height: 100vh;
    height: auto;
    overflow-y: auto;
    box-sizing: border-box;
}

/* Main column: grows so footer sits at viewport bottom; bottom padding separates game/results from footer */
.page-stack {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    min-width: 0;
    min-height: 0;
    padding-bottom: clamp(2.5rem, 8vh, 5rem);
}

/* --- Site footer: minimal icon strip (game HUD, not marketing buttons) --- */
.site-footer {
    margin-top: 0;
    flex-shrink: 0;
    margin-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    width: min(92vw, 740px);
    padding: 5px 10px;
    box-sizing: border-box;
    background: transparent;
    border: none;
    box-shadow: none;
    border-radius: 0;
    overflow: visible;
}

.site-footer__nav {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    justify-content: center;
    gap: 10px;
    width: min(100%, 22rem);
    margin: 0 auto;
    overflow: visible;
}

/* Footer icon links — same 3D / glossy treatment as Enter & primary buttons */
.site-footer__link {
    position: relative;
    font-family: 'Poppins', sans-serif;
    font-weight: bold;
    font-size: 1em;
    color: #ffffff;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 12px;
    flex: 1 1 0;
    min-width: 0;
    min-height: 44px;
    box-sizing: border-box;
    line-height: 1;
    cursor: pointer;
    border: none;
    border-radius: 14px;
    background: linear-gradient(145deg, #1a73e8, #1453a8);
    box-shadow:
        5px 5px 10px rgba(0, 0, 0, 0.2),
        -3px -3px 7px rgba(255, 255, 255, 0.1);
    transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease, color 0.2s ease;
}

/* Custom tooltip (native title cannot be styled) */
.site-footer__link[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 12px);
    left: 50%;
    transform: translateX(-50%) translateY(6px);
    padding: 8px 14px;
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    font-size: 0.8125rem;
    letter-spacing: 0.03em;
    color: #ffffff;
    background: rgba(0, 34, 102, 0.96);
    border-radius: 10px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    white-space: normal;
    max-width: min(260px, 88vw);
    text-align: center;
    line-height: 1.35;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
    z-index: 200;
}

.site-footer__link[data-tooltip]:hover::after,
.site-footer__link[data-tooltip]:focus-visible::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.site-footer__link:hover {
    background: linear-gradient(145deg, #1453a8, #1a73e8);
    transform: translateY(-2px);
    box-shadow:
        6px 6px 12px rgba(0, 0, 0, 0.3),
        -3px -3px 8px rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

/* Pressed / click: darker fill + inset depth (clear feedback before navigation) */
.site-footer__link:active {
    transform: translateY(1px);
    background: linear-gradient(145deg, #0c3d7a, #082a54);
    color: rgba(255, 255, 255, 0.92);
    box-shadow:
        inset 0 3px 10px rgba(0, 0, 0, 0.38),
        0 1px 0 rgba(255, 255, 255, 0.12);
}

@media (prefers-reduced-motion: reduce) {
    .site-footer__link,
    .site-footer__link[data-tooltip]::after {
        transition-duration: 0.01ms;
    }
}

.site-footer__link:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.9);
    outline-offset: 3px;
    color: #ffffff;
}

.site-footer__icon {
    font-size: 1.05rem;
    pointer-events: none;
    color: inherit;
}

.site-footer__icon--emoji {
    font-size: 1.15rem;
    line-height: 1;
    display: inline-block;
}

.site-footer__label {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    pointer-events: none;
    white-space: nowrap;
}

/* Larger star only — label text size unchanged */
.site-footer__star {
    font-size: 1.55em;
    line-height: 1;
    display: inline-block;
    transform: translateY(-0.04em);
}

.site-footer__label-text {
    font-size: 1em;
    line-height: 1;
}

/* Keep floating result mascot above footer + safe area */
@media (max-width: 600px) {
    .result-image {
        bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    }
}

/* Logo: smaller, rounded, soft “cloud” halo (fits blue gradient page) */
.logo-container {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 101;
    line-height: 0;
    padding: 5px;
    border-radius: 18px;
    background: radial-gradient(
        130% 110% at 50% 0%,
        rgba(255, 255, 255, 0.5),
        rgba(255, 255, 255, 0.14) 42%,
        rgba(255, 255, 255, 0.05) 68%,
        transparent 88%
    );
    box-shadow:
        0 12px 32px rgba(0, 45, 110, 0.42),
        0 4px 18px rgba(255, 255, 255, 0.22),
        inset 0 1px 2px rgba(255, 255, 255, 0.55);
    filter: drop-shadow(0 5px 14px rgba(0, 40, 95, 0.38));
}

.logo-container .logo {
    display: block;
    width: 72px;
    max-width: min(72px, 20vw);
    height: auto;
    border-radius: 14px;
    object-fit: contain;
    box-shadow:
        0 4px 16px rgba(0, 30, 80, 0.38),
        inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}

/* Extra air above footer on end / results flows */
.game #play-again-btn,
.game #back-btn {
    margin-bottom: clamp(0.85rem, 3vw, 1.35rem);
}

.result.end-screen {
    margin-bottom: clamp(1rem, 3.5vw, 1.75rem);
}

.game .collapsible:last-of-type {
    margin-bottom: clamp(0.85rem, 2.5vw, 1.35rem);
}

/* Heading */
h1 {
    font-size: 3em;
    margin: 10px 0 18px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

/* Name Input Section */
.name-input {
    margin-bottom: 20px;
}

.name-input label {
    font-size: 1.2em;
}

.name-input input {
    font-size: 1em;
    padding: 10px;
    margin-left: 10px;
    border-radius: 5px;
    border: 1px solid #004aad;
    outline: none;
}

/* Button Styles */
button {
    font-family: 'Poppins', sans-serif;
    font-size: 1em;
    font-weight: bold;
    color: #ffffff;
    background: linear-gradient(145deg, #1a73e8, #1453a8);
    border: none;
    border-radius: 14px;
    padding: 12px 22px;
    cursor: pointer;
    box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.2), -3px -3px 7px rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease-in-out;
}

button:hover {
    background: linear-gradient(145deg, #1453a8, #1a73e8);
    transform: translateY(-2px);
    box-shadow: 6px 6px 12px rgba(0, 0, 0, 0.3), -3px -3px 8px rgba(255, 255, 255, 0.2);
}

/* Start Game Button */
#start-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 50px;
    font-size: 1.2em;
}

#start-btn i {
    font-size: 1.5em;
}

/* Game Section */
.game {
    margin-top: 20px;
}

.category-selection {
    margin: 20px 0;
}

.category-selection label {
    font-size: 1.1em;
    margin-right: 10px;
}

.category-selection select {
    font-size: 1em;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    outline: none;
    backdrop-filter: blur(6px);
}

.collapsible select.leaderboard-category-select {
    font-size: 0.95em;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    outline: none;
}

.collapsible select.leaderboard-category-select option {
    color: #001a33;
}

.category-selection option {
    color: #001a33;
}

.game-controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    align-items: center;
    margin: 14px 0 18px; /* more vertical spacing before Hear Phrase */
    flex-wrap: wrap;
}

.game-controls button,
#play-again-btn,
#view-results-btn,
#back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px; /* icon ↔ text spacing */
}

.game-controls button,
#hear-phrase-btn,
#play-again-btn {
    min-height: 44px; /* iOS-ish tap target */
}

.game-controls button i,
#play-again-btn i,
#hear-phrase-btn i,
#view-results-btn i,
#back-btn i {
    margin-right: 2px;
}

#round-progress-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 44px;
}

/* View results pinned bottom-right */
#view-results-btn {
    position: fixed;
    right: 16px;
    top: 16px;
    z-index: 1100;
    margin-top: 0 !important;
    border-radius: 999px;
    padding: 12px 18px;
    box-shadow: 0 16px 34px rgba(0, 0, 0, 0.28);
}

#pause-btn {
    background: linear-gradient(145deg, #7b61ff, #4d3bd6);
}

#pause-btn:hover {
    background: linear-gradient(145deg, #4d3bd6, #7b61ff);
}

#stop-btn {
    background: linear-gradient(145deg, #ff4d4d, #c62828);
}

#stop-btn:hover {
    background: linear-gradient(145deg, #c62828, #ff4d4d);
}

.scoreboard {
    box-sizing: border-box;
    /* Single width avoids WebKit ignoring max-width on table boxes (misaligned vs .top-result). */
    width: min(92vw, 740px);
    margin: 18px auto 0;
    border-collapse: collapse;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.22);
    font-size: 0.92em;
}

.scoreboard th,
.scoreboard td {
    padding: 12px 14px;
    text-align: center;
}

.player-summary-table th:first-child,
.player-summary-table td:first-child {
    text-align: left;
}

.scoreboard th {
    background: rgba(0, 0, 0, 0.2);
    font-weight: 600;
}

.scoreboard tr + tr td {
    border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.scoreboard .muted {
    opacity: 0.85;
}

.game-over-title {
    font-weight: 700;
    letter-spacing: 0.2px;
    color: #77ff66;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
    font-size: 1.15em;
    margin-top: 6px;
}

.section-title {
    color: #77ff66;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
}

.section-title i {
    color: #77ff66;
}

.end-screen {
    color: #ffffff;
}

.end-screen .top-result-lines {
    font-size: 1.08em;
}

.end-screen .scoreboard {
    font-size: 0.98em;
}

.end-screen .leaderboard-title {
    font-size: 1.05em;
}

.top-result {
    box-sizing: border-box;
    width: min(92vw, 740px);
    margin: 14px auto 0;
    padding: 14px 14px 12px;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 16px;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.22);
}

.top-result-title {
    font-weight: 700;
    margin-bottom: 8px;
}

.top-result-lines {
    line-height: 1.55;
    font-size: 0.98em;
}

.leaderboard-title {
    width: min(92vw, 740px);
    margin: 14px auto 0;
    font-weight: 700;
}

.leaderboard-table .rank {
    width: 44px;
}

.collapsible {
    width: min(92vw, 740px);
    margin: 12px auto 0;
}

.collapsible details {
    background: rgba(255, 255, 255, 0.10);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.18);
}

.collapsible summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-weight: 600;
}

.collapsible summary .chevron {
    margin-left: 20px;
    margin-right: 26px;
    flex: 0 0 auto;
}

.collapsible summary::-webkit-details-marker {
    display: none;
}

.collapsible .chevron {
    transition: transform 0.2s ease;
    opacity: 0.9;
}

.collapsible details[open] .chevron {
    transform: rotate(180deg);
}

.collapsible .details-body {
    padding: 0 12px 12px;
}

.lb-scroll-area {
    max-height: 220px;
    width: 100%;
    overflow-y: auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.leaderboard-table {
    width: 100%;
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    z-index: 1000;
}

.modal-card {
    width: min(520px, 92vw);
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 16px;
    padding: 18px 18px 16px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(10px);
}

.modal-title {
    font-size: 1.25em;
    font-weight: 600;
    margin-bottom: 8px;
}

.modal-text {
    opacity: 0.95;
    margin-bottom: 14px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

#stop-end-btn {
    background: linear-gradient(145deg, #ff4d4d, #c62828);
}

#stop-end-btn:hover {
    background: linear-gradient(145deg, #c62828, #ff4d4d);
}

.question {
    font-size: 1.75em;
    margin: 20px 0;
}

.question .instruction {
    display: block;
    font-size: 0.75em;
    font-weight: 400;
    opacity: 0.78;
    margin-bottom: 6px;
}

.question .prompt {
    display: block;
    font-size: 1em;
    font-weight: 600;
    opacity: 0.98;
}

/* Answer Buttons */
.choices button {
    margin: 10px;
    padding: 10px 20px;
    font-size: 1.2em;
    cursor: pointer;
}

/* Hear Phrase Button */
#hear-phrase-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 12px 30px;
    background: linear-gradient(145deg, #2bb3a7, #1f7f78);
    color: white;
    border: none;
    border-radius: 50px; /* Fully rounded */
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease-in-out; /* Smooth transition */
    box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.2), -4px -4px 10px rgba(255, 255, 255, 0.2);
}

/* Button Hover Effect */
#hear-phrase-btn:hover {
    background: linear-gradient(145deg, #1f7f78, #2bb3a7); /* Reverse gradient on hover */
    transform: translateY(-2px); /* Slight lift effect */
    box-shadow: 6px 6px 15px rgba(0, 0, 0, 0.3), -4px -4px 12px rgba(255, 255, 255, 0.3);
}


/* Button Feedback */
.choices button.correct {
    background-color: #4CAF50;
    color: #fff;
    border: 2px solid #388E3C;
}

.choices button.incorrect {
    background-color: #F44336;
    color: #fff;
    border: 2px solid #D32F2F;
}

/* Result Feedback */
.result {
    font-size: 1.5em;
    margin: 20px 0;
}

/* Result Image */
.result-image {
    position: fixed;
    bottom: calc(28px + env(safe-area-inset-bottom, 0px));
    right: 20px;
    width: 230px;
    height: auto;
    z-index: 100;
}

/* Correct Answer Feedback */
.result.correct {
    color: #4CAF50;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background-image: url('img/pass.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    padding: 20px;
}

.result.correct::before {
    content: "✔";
    font-size: 1.5em;
}

/* Incorrect Answer Feedback */
.result.incorrect {
    color: #F44336;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.result.incorrect::before {
    content: "✖";
    font-size: 1.5em;
}
