/* ============================================
   NICHEDLE — Designer Fashion Guessing Game
   Dark theme, mobile-first, fashion aesthetic
   ============================================ */

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

:root {
    --bg: #0a0a0a;
    --bg-card: #141414;
    --bg-card-hover: #1a1a1a;
    --text: #f0f0f0;
    --text-muted: #888;
    --border: #2a2a2a;
    --accent: #fff;
    --correct: #22c55e;
    --wrong: #ef4444;
    --tier-1: #a0a0a0;
    --tier-2: #cd7f32;
    --tier-3: #ffd700;
    --tier-4: #b9f2ff;
    --radius: 8px;
    --transition: 0.2s ease;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

html, body {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    scrollbar-width: none;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar,
main::-webkit-scrollbar {
    display: none;
}

main {
    scrollbar-width: none;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    display: flex;
    flex-direction: column;
    line-height: 1.5;
}

a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--text);
}

/* --- Header --- */
header {
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 1.5rem;
    flex-shrink: 0;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.3rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.3em;
    color: var(--text);
    text-decoration: none;
}

h1.logo {
    margin: 0;
}

nav {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.3rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

nav a.active {
    color: var(--text);
    border-bottom: 1px solid var(--text);
}

.btn-support {
    background: #ffdd00;
    color: #0a0a0a;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    transition: background var(--transition);
}

.btn-support:hover {
    background: #ffe94d;
    color: #0a0a0a;
}

/* --- Lives Display --- */
#lives-display {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.lives-count {
    font-size: 1.5rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.lives-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-right: 0.5rem;
}

.tier-badge {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    padding: 0.2rem 0.6rem;
    border-radius: 100px;
    font-weight: 600;
}

/* --- Main Game Area --- */
main {
    flex: 1;
    padding: 0.75rem 1.5rem;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

main.result-scrollable {
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

main.result-scrollable::-webkit-scrollbar {
    display: none;
}

#prompt {
    text-align: center;
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    font-weight: 300;
    letter-spacing: 0.05em;
    order: 1;
    flex-shrink: 0;
}

#round-counter {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* --- Item Cards --- */
#cards-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    order: 3;
    flex: 1;
    min-height: 0;
    align-content: start;
    align-items: start;
}

#cards-container.revealed {
    flex: 0 0 auto;
}

@media (min-width: 600px) {
    #cards-container {
        gap: 1.5rem;
    }
}

.item-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.item-card:hover {
    transform: translateY(-2px);
    border-color: #444;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.item-card:active {
    transform: translateY(0);
}

.revealed .item-card {
    cursor: default;
}

.revealed .card-expand {
    pointer-events: auto;
}

.card-image-wrapper {
    height: clamp(180px, 42vh, 480px);
    overflow: hidden;
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.item-card:hover .card-image-wrapper img {
    transform: scale(1.03);
}

.card-info {
    padding: 0.5rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    flex-shrink: 0;
}

.card-brand {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--text-muted);
    font-weight: 600;
}

.card-name {
    font-size: 0.9rem;
    font-weight: 400;
    line-height: 1.3;
}

.card-price {
    font-size: 1.1rem;
    font-weight: 700;
    margin-top: 0.25rem;
    font-variant-numeric: tabular-nums;
}

.card-price.hidden {
    display: none;
}

.card-source {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    background: rgba(10, 10, 10, 0.8);
    padding: 0.15rem 0.5rem;
    border-radius: 100px;
}

/* --- Card Expand (About / Similar) --- */
.card-expand {
    padding: 0 0.75rem 0.5rem;
    flex-shrink: 0;
}

.card-expand-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 0.65rem;
    cursor: pointer;
    width: 100%;
    padding: 0.3rem;
    text-align: center;
    transition: border-color var(--transition), color var(--transition);
}

.card-expand-btn:hover {
    border-color: #555;
    color: var(--text);
}

.card-expand-content {
    padding-top: 0.4rem;
}

.card-expand-content.hidden {
    display: none;
}

.card-tabs {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.3rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.2rem;
}

.card-tab {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.15rem 0;
    border-bottom: 2px solid transparent;
    transition: color var(--transition), border-color var(--transition);
}

.card-tab:hover {
    color: var(--text);
}

.card-tab.active {
    color: var(--text);
    border-bottom-color: var(--text);
}

.card-tab-panel {
    font-size: 0.65rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.card-tab-panel.hidden {
    display: none;
}

.card-tab-panel p {
    margin: 0;
}

.card-buy-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.6rem;
    border: 1px solid var(--tier-3);
    border-radius: 4px;
    color: var(--tier-3);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.card-buy-link:hover {
    background: var(--tier-3);
    border-color: var(--tier-3);
    color: #0a0a0a;
}

/* --- Result Area --- */
.result-area {
    text-align: center;
    padding: 0.7rem 0.8rem;
    margin: 0 0 0.65rem;
    border-radius: var(--radius);
    animation: fadeIn 0.3s ease;
    order: 2;
}

.result-area.hidden {
    display: none;
}

.result-area.correct {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.result-area.wrong {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.result-area.game-over {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 0.75rem 1rem;
    margin-top: 0.5rem;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.result-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.result-icon {
    font-size: 2rem;
}

.result-text {
    font-size: 1.05rem;
    font-weight: 600;
}

.result-prices {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.result-lives {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.result-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 0.45rem;
    flex-wrap: wrap;
}

.revealed .item-card {
    width: min(100%, 360px);
    justify-self: center;
}

.revealed .card-image-wrapper {
    background: var(--bg-card);
}

.revealed .card-image-wrapper img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
}

.revealed .card-info {
    padding: 0.5rem 0.75rem;
    gap: 0.15rem;
}

.revealed .card-brand {
    font-size: 0.62rem;
}

.revealed .card-name {
    font-size: 0.75rem;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 0;
}

.revealed .card-price {
    font-size: 1rem;
    margin-top: 0.15rem;
}

/* --- Game Over --- */
.game-over-content {
    max-width: 400px;
    margin: 0 auto;
}

.game-over-content h2 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.game-over-content p {
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
}

.countdown {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 0.3rem;
}

.countdown-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-muted);
}

.countdown-time {
    font-size: 1.4rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.1em;
    color: var(--tier-3);
}

.game-over-stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin: 0.3rem 0;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.stat-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-muted);
}

.tier-description {
    font-style: italic;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.game-over-actions {
    display: flex;
    gap: 0.4rem;
    justify-content: center;
    margin-top: 0.4rem;
    flex-wrap: wrap;
}

.game-over-actions .btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.65rem;
}

/* --- Round Summary Chart (vertical columns) --- */
.round-chart {
    margin: 0.4rem 0;
    padding: 0.4rem 0.5rem;
}

.round-chart-cols {
    display: flex;
    justify-content: center;
    gap: 0.8rem;
}

.round-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
}

.round-col-pct {
    font-size: 0.6rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

.round-col-track {
    width: 24px;
    height: 40px;
    background: #1a1a1a;
    border-radius: 3px;
    overflow: hidden;
    display: flex;
    align-items: flex-end;
}

.round-col-fill {
    width: 100%;
    border-radius: 3px;
    min-height: 2px;
    transition: height 0.6s ease;
}

.round-col-label {
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.2rem;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    font-family: inherit;
}

.btn:hover {
    background: var(--bg-card-hover);
    border-color: #444;
}

.btn-share-x {
    background: #000;
    border-color: #333;
}

.btn-share-x:hover {
    background: #1a1a1a;
}

.btn-share-copy {
    background: transparent;
}

.btn-leaderboard {
    background: transparent;
    border-color: var(--tier-3);
    color: var(--tier-3);
}

.btn-secondary {
    background: transparent;
    color: var(--text-muted);
    border-color: transparent;
}

.btn-secondary:hover {
    color: var(--text);
}

/* --- Rules Page --- */
.rules-page {
    max-width: 600px;
    overflow: hidden;
}

.rules-page h2 {
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
}

.rules-section {
    margin-bottom: 0.5rem;
}

.rules-section h3 {
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text);
    margin-bottom: 0.3rem;
}

.rules-section p {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin-bottom: 0.25rem;
}

.rules-section p strong {
    color: var(--text);
}

.rules-section p code {
    color: var(--tier-3);
    font-size: 0.7rem;
}

.rules-section ul {
    list-style: none;
    padding: 0;
    margin: 0.2rem 0;
}

.rules-section ul li {
    font-size: 0.82rem;
    color: var(--text-muted);
    padding: 0.1rem 0 0.1rem 0.8rem;
    position: relative;
}

.rules-section ul li::before {
    content: "-";
    position: absolute;
    left: 0;
    color: var(--text-muted);
}

.rules-section ul li strong {
    color: var(--text);
}

.tier-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
    margin-top: 0.3rem;
}

.tier-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid;
    border-radius: var(--radius);
    padding: 0.4rem 0.5rem;
    margin-bottom: 0;
}

.tier-header {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-bottom: 0.15rem;
    font-size: 0.76rem;
}

.tier-header .tier-lives {
    margin-left: auto;
    font-size: 0.68rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

.tier-card p {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-bottom: 0;
    font-style: italic;
    line-height: 1.3;
}

.rules-cta {
    text-align: center;
    margin: 0.5rem 0;
}

/* --- Legal Pages --- */
.legal-page {
    max-width: 760px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 1rem;
}

.legal-page::-webkit-scrollbar {
    display: none;
}

.legal-page h2 {
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    margin-bottom: 0.25rem;
}

.legal-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 0.9rem;
    letter-spacing: 0.04em;
}

.legal-section {
    margin-bottom: 0.9rem;
}

.legal-section h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text);
    margin-bottom: 0.35rem;
}

.legal-section p {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.45;
    margin-bottom: 0.35rem;
}

.legal-section p strong {
    color: var(--text);
}

.legal-section p code {
    color: var(--tier-3);
}

.legal-list {
    list-style: none;
    margin: 0.2rem 0 0.4rem;
    padding: 0;
}

.legal-list li {
    position: relative;
    padding: 0.1rem 0 0.1rem 0.85rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    line-height: 1.4;
}

.legal-list li::before {
    content: "-";
    position: absolute;
    left: 0;
    color: var(--text-muted);
}

.legal-list li strong {
    color: var(--text);
}

@media (max-height: 760px) {
    .rules-page h2 {
        font-size: 1.1rem;
    }

    .rules-section h3,
    .rules-section p,
    .rules-section ul li {
        font-size: 0.75rem;
    }

    .tier-header {
        font-size: 0.7rem;
    }

    .tier-header .tier-lives {
        font-size: 0.6rem;
    }

    .tier-card p {
        font-size: 0.6rem;
    }
}

/* --- Leaderboard --- */
.leaderboard-page {
    max-width: 600px;
    overflow-y: auto;
}

.leaderboard-page h2 {
    font-size: 1.3rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    margin-bottom: 1rem;
}

.your-rank {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 0.8rem 1rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.your-rank.hidden {
    display: none;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
}

.leaderboard-table th {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-muted);
    text-align: left;
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--border);
}

.leaderboard-table td {
    padding: 0.7rem 0.8rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.leaderboard-table .rank {
    width: 50px;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
}

.leaderboard-table .lives {
    width: 80px;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.tier-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.highlight-row {
    background: rgba(255, 255, 255, 0.05);
}

.highlight-row td {
    color: var(--text);
    font-weight: 600;
}

/* --- Modals --- */
#username-modal,
#info-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

#username-modal.hidden,
#info-modal.hidden {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
}

.modal-content {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.modal-content h3 {
    margin-bottom: 0.5rem;
}

.modal-content p {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.modal-content input {
    width: 100%;
    padding: 0.7rem 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
    text-align: center;
    letter-spacing: 0.05em;
    outline: none;
    transition: border-color var(--transition);
}

.modal-content input:focus {
    border-color: #555;
}

.modal-content input.error {
    border-color: var(--wrong);
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 1rem;
}

/* --- Post-Game Modal --- */
.postgame-modal {
    max-width: 420px;
}

.postgame-modal h3 {
    font-size: 1.1rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.postgame-token-info {
    margin-top: 1.2rem;
    padding: 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-align: left;
}

.postgame-token-info .token-note {
    font-size: 0.8rem;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.postgame-token-info .token-note strong {
    color: var(--tier-3);
    font-family: monospace;
    letter-spacing: 0.05em;
}

.postgame-token-info .token-hint {
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 0;
}

.postgame-modal > .btn-secondary {
    display: block;
    width: 100%;
    margin-top: 1rem;
    text-align: center;
}

/* --- Flag Picker --- */
.flag-picker-section {
    margin-top: 1rem;
}

.flag-picker-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.4rem;
}

.flag-picker {
    position: relative;
}

.flag-picker-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    transition: border-color var(--transition);
}

.flag-picker-btn:hover {
    border-color: #555;
}

.flag-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #1a1a1a;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-top: 0.25rem;
    z-index: 150;
    max-height: 250px;
    display: flex;
    flex-direction: column;
}

.flag-dropdown.hidden {
    display: none;
}

.flag-search {
    padding: 0.5rem 0.75rem;
    background: var(--bg);
    border: none;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font-size: 0.8rem;
    font-family: inherit;
    outline: none;
    border-radius: var(--radius) var(--radius) 0 0;
}

.flag-list {
    overflow-y: auto;
    max-height: 200px;
}

.flag-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s ease;
}

.flag-option:hover {
    background: #2a2a2a;
    color: var(--text);
}

.flag-icon {
    width: 20px;
    height: 15px;
    object-fit: cover;
    border-radius: 1px;
    vertical-align: middle;
}

.flag-icon-lg {
    width: 24px;
    height: 18px;
    object-fit: cover;
    border-radius: 2px;
}

/* Leaderboard username with flag */
.leaderboard-table .username {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* --- Info Modal --- */
.info-content {
    max-width: 450px;
    text-align: left;
    max-height: 85vh;
    overflow-y: auto;
}

.info-content h3 {
    text-align: center;
    font-size: 1.2rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    margin-bottom: 1rem;
}

.info-content h4 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text);
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.info-rules p {
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.info-rules p strong {
    color: var(--text);
}

.info-rules ul {
    list-style: none;
    padding: 0;
    margin-bottom: 0.5rem;
}

.info-rules ul li {
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 0.3rem 0;
    padding-left: 1rem;
    position: relative;
}

.info-rules ul li::before {
    content: "-";
    position: absolute;
    left: 0;
    color: var(--text-muted);
}

.info-rules ul li strong {
    color: var(--text);
}

.info-rules .tier-list li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-left: 0;
}

.info-rules .tier-list li::before {
    display: none;
}

.info-rules .tier-list .tier-dot {
    flex-shrink: 0;
}

.info-content > .btn {
    display: block;
    width: 100%;
    margin-top: 1.5rem;
    text-align: center;
}

#btn-info {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0;
}

/* --- Toast --- */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--text);
    color: var(--bg);
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 200;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* --- Loading --- */
.loading {
    text-align: center;
    padding: 4rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

/* --- Footer --- */
footer {
    border-top: 1px solid var(--border);
    padding: 0.5rem 1rem;
    flex-shrink: 0;
}

.footer-content {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
}

.footer-links {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.9rem;
    flex-wrap: wrap;
}

.footer-content > .footer-links:only-child {
    width: 100%;
    justify-content: center;
}

.footer-links > a {
    color: var(--text-muted);
}

.footer-links > a:hover {
    color: var(--text);
}

.footer-legal {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-left: 0.9rem;
    border-left: 1px solid var(--border);
}

.footer-legal a {
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}

.footer-legal a:hover {
    color: var(--text);
}

.footer-legal a.active {
    color: var(--text);
    border-bottom: 1px solid var(--text);
}

.token-section {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.player-identity {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 18px;
    margin-bottom: 0.25rem;
    font-size: 0.85rem;
}

.player-identity.hidden {
    visibility: hidden;
}

.identity-name {
    display: inline-block;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
    font-weight: 500;
    letter-spacing: 0.03em;
}

.identity-admin {
    display: inline-flex;
    align-items: center;
    padding: 0.08rem 0.42rem;
    border-radius: 999px;
    border: 1px solid #ffdd00;
    color: #ffdd00;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.token-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
}

.token-info code {
    font-size: 0.85rem;
    color: var(--tier-3);
    letter-spacing: 0.05em;
}

.btn-icon {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius);
    font-size: 0.65rem;
    cursor: pointer;
    font-family: inherit;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: all var(--transition);
}

.btn-icon:hover {
    color: var(--text);
    border-color: #444;
}

.x-fab {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    width: 44px;
    height: 44px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    color: #fff;
    border: 1px solid #2a2a2a;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1;
    z-index: 180;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
    transition: transform var(--transition), border-color var(--transition), background var(--transition);
}

.x-fab:hover {
    background: #111;
    border-color: #555;
    color: #fff;
    transform: translateY(-1px);
}

.token-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-small {
    padding: 0.35rem 0.8rem;
    font-size: 0.7rem;
}

.import-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.import-form.hidden {
    display: none;
}

.import-form input {
    padding: 0.35rem 0.6rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.8rem;
    font-family: monospace;
    width: 140px;
    outline: none;
    transition: border-color var(--transition);
}

.import-form input:focus {
    border-color: #555;
}

.import-form input.error {
    border-color: var(--wrong);
}

/* --- Ad Slot Placeholder --- */
.ad-slot {
    text-align: center;
    padding: 1rem;
    margin: 1rem 0;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* --- Animations --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* --- Responsive --- */
@media (max-width: 599px) {
    header {
        padding: 0.4rem 0.75rem;
    }

    .logo {
        font-size: 1.1rem;
    }

    nav {
        margin-top: 0.2rem;
        gap: 1rem;
        font-size: 0.7rem;
    }

    main {
        padding: 0.5rem;
    }

    #prompt {
        font-size: 0.95rem;
        margin-bottom: 0.5rem;
    }

    .card-info {
        padding: 0.35rem 0.5rem;
    }

    .card-brand {
        font-size: 0.55rem;
    }

    .card-name {
        font-size: 0.65rem;
    }

    .card-price {
        font-size: 0.85rem;
    }

    .card-source {
        font-size: 0.5rem;
        padding: 0.1rem 0.35rem;
    }

    .result-area {
        padding: 0.5rem 0.5rem;
        margin-bottom: 0.4rem;
    }

    .result-icon {
        font-size: 1.4rem;
    }

    .result-text {
        font-size: 0.9rem;
    }

    .result-prices,
    .result-lives {
        font-size: 0.7rem;
    }

    .result-actions {
        gap: 0.4rem;
        margin-top: 0.25rem;
    }

    .result-actions .btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.65rem;
    }

    .revealed .item-card {
        width: min(100%, 180px);
    }

    .revealed .card-image-wrapper img {
        object-fit: contain;
    }

    .revealed .card-info {
        padding: 0.3rem 0.5rem;
    }

    .revealed .card-brand {
        font-size: 0.5rem;
    }

    .revealed .card-name {
        font-size: 0.6rem;
        line-height: 1.2;
        min-height: 0;
    }

    .revealed .card-price {
        font-size: 0.8rem;
        margin-top: 0.1rem;
    }

    footer {
        padding: 0.4rem 0.75rem;
    }

    .footer-content {
        flex-direction: column;
        gap: 0.4rem;
        text-align: center;
    }

    .footer-links {
        justify-content: center;
        gap: 0.55rem;
    }

    .footer-legal {
        border-left: 0;
        padding-left: 0;
    }

    .identity-name {
        max-width: 140px;
    }

    .card-image-wrapper {
        height: clamp(140px, 35vh, 350px);
    }

    .game-over-stats {
        gap: 1.5rem;
        margin: 0.4rem 0;
    }

    .stat-value {
        font-size: 1.2rem;
    }

    .stat-label {
        font-size: 0.55rem;
    }

    .game-over-content h2 {
        font-size: 1rem;
        margin-bottom: 0.2rem;
    }

    .game-over-content p {
        margin-bottom: 0.3rem;
        font-size: 0.75rem;
    }

    .countdown {
        margin-bottom: 0.3rem;
    }

    .countdown-label {
        font-size: 0.55rem;
    }

    .countdown-time {
        font-size: 1.1rem;
    }

    .tier-description {
        font-size: 0.7rem;
    }

    .game-over-actions {
        margin-top: 0.4rem;
        gap: 0.35rem;
    }

    .game-over-actions .btn {
        padding: 0.35rem 0.7rem;
        font-size: 0.6rem;
    }

    .x-fab {
        width: 40px;
        height: 40px;
        right: 0.75rem;
        bottom: 0.75rem;
        font-size: 0.95rem;
    }

    .round-chart {
        margin: 0.3rem 0;
        padding: 0.3rem 0.4rem;
    }

    .round-col-track {
        width: 20px;
        height: 30px;
    }

    .round-col-pct {
        font-size: 0.5rem;
    }

    .round-col-label {
        font-size: 0.5rem;
    }

    .round-chart-cols {
        gap: 0.6rem;
    }
}

/* --- Practice Mode --- */

.practice-main {
    --practice-image-height: clamp(140px, 24vh, 280px);
    overflow-y: auto;
    scrollbar-width: none;
}

.practice-main::-webkit-scrollbar {
    display: none;
}

.practice-header-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-right: 0.4rem;
}

#practice-image-container {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
    order: 3;
}

.practice-image-card {
    max-width: 100%;
    width: 100%;
    cursor: default;
    pointer-events: auto;
}

#practice-image-container .card-image-wrapper {
    aspect-ratio: auto;
    flex: 1;
    min-height: 0;
    height: var(--practice-image-height);
}

#practice-image-container .card-info {
    padding: 0.45rem 0.6rem;
    gap: 0.1rem;
}

#practice-image-container .card-brand {
    font-size: 0.6rem;
}

#practice-image-container .card-name {
    font-size: 0.72rem;
    line-height: 1.25;
}

#practice-image-container .card-expand {
    padding: 0 0.6rem 0.45rem;
}

#practice-image-container .practice-postvote-info.hidden {
    display: none;
}

#practice-image-container .card-image-wrapper img {
    object-fit: contain;
    object-position: center;
}

#practice-options-shell {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    max-width: 600px;
    margin: 0 auto;
    order: 4;
}

#practice-options {
    display: contents;
}

#practice-options-shell + #result-area {
    order: 2;
}

#practice-options-shell + #result-area:not(.game-over) {
    padding: 0.55rem 0.65rem;
    margin-bottom: 0.6rem;
}

#practice-options-shell + #result-area:not(.game-over) .result-content {
    gap: 0.2rem;
}

#practice-options-shell + #result-area:not(.game-over) .result-icon {
    font-size: 1.5rem;
}

#practice-options-shell + #result-area:not(.game-over) .result-text {
    font-size: 0.95rem;
}

#practice-options-shell + #result-area:not(.game-over) .result-actions {
    margin-top: 0.35rem;
}

.practice-brand-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
    padding: 1.5rem 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-family: inherit;
    color: var(--text);
    min-height: 0;
}

.practice-brand-card:hover {
    transform: translateY(-2px);
    border-color: #444;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.practice-brand-card:active {
    transform: translateY(0);
}

.practice-brand-name {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    line-height: 1.4;
}

.practice-brand-card.practice-correct {
    border-color: var(--correct);
    background: rgba(34, 197, 94, 0.1);
}

.practice-brand-card.practice-wrong-option {
    opacity: 0.35;
}

.btn-practice {
    border-color: var(--tier-2);
    color: var(--tier-2);
}

@media (min-width: 700px) {
    .practice-main {
        --practice-image-height: clamp(130px, 20vh, 240px);
        display: grid;
        grid-template-columns: minmax(260px, 360px) minmax(260px, 360px);
        grid-template-areas:
            "prompt prompt"
            "image options"
            "result result";
        column-gap: 0.9rem;
        row-gap: 0.7rem;
        justify-content: center;
        justify-items: stretch;
        align-content: start;
    }

    .practice-main #prompt {
        grid-area: prompt;
        margin-bottom: 0.2rem;
    }

    #practice-image-container {
        grid-area: image;
        margin-bottom: 0;
        align-self: start;
        width: min(100%, 360px);
    }

    #practice-options {
        display: flex;
        flex-direction: column;
        height: 100%;
        width: 100%;
    }

    #practice-options-shell {
        grid-area: options;
        display: flex;
        flex-direction: column;
        gap: 0;
        max-width: 360px;
        width: 100%;
        margin: 0;
        height: auto;
        min-height: 0;
        align-self: start;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        background: var(--bg-card);
        overflow: hidden;
    }

    #practice-options .practice-brand-card {
        border: 0;
        border-radius: 0;
        border-left: 0;
        border-top: 1px solid var(--border);
        width: 100%;
        min-height: 0;
        height: auto;
        flex: 1 1 0;
        padding: 0.7rem 0.8rem;
        box-shadow: none;
        transform: none;
        background: transparent;
    }

    #practice-options .practice-brand-card:first-child {
        border-top: 0;
    }

    #practice-options .practice-brand-card:hover {
        transform: none;
        box-shadow: none;
        background: var(--bg-card-hover);
    }

    #practice-options .practice-brand-card:active {
        transform: none;
    }

    #practice-options .practice-brand-name {
        font-size: 0.68rem;
        letter-spacing: 0.11em;
        line-height: 1.25;
    }

    #practice-options-shell + #result-area {
        grid-area: result;
        width: min(100%, 730px);
        justify-self: center;
    }
}

@media (max-width: 599px) {
    .practice-main {
        --practice-image-height: clamp(140px, 24vh, 220px);
    }

    .practice-brand-card {
        padding: 0.8rem 0.65rem;
        min-height: 56px;
        flex: 0 0 auto;
    }

    .practice-brand-name {
        font-size: 0.65rem;
    }

    #practice-image-container .practice-image-card {
        max-width: min(100%, 210px);
        width: min(100%, 210px);
    }

    #practice-image-container .card-image-wrapper {
        height: var(--practice-image-height);
    }

    #practice-image-container .card-info {
        padding: 0.35rem 0.5rem;
    }

    #practice-image-container .card-brand {
        font-size: 0.5rem;
    }

    #practice-image-container .card-name {
        font-size: 0.62rem;
    }

    #practice-options-shell {
        gap: 0.55rem;
    }

    #practice-options-shell + #result-area:not(.game-over) {
        padding: 0.5rem 0.55rem;
        margin-bottom: 0.5rem;
    }

    #practice-options-shell + #result-area:not(.game-over) .result-icon {
        font-size: 1.35rem;
    }

    #practice-options-shell + #result-area:not(.game-over) .result-text {
        font-size: 0.88rem;
    }
}

/* --- Settings gear button --- */
.btn-settings {
    font-size: 1.1rem;
    line-height: 1;
    padding: 0.2rem 0.4rem;
    cursor: pointer;
}

/* --- Settings modal --- */
.settings-modal {
    max-width: 320px;
}

.settings-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.settings-actions .btn {
    width: 100%;
}

/* --- Game over inline username input --- */
.game-over-username {
    margin-top: 0.6rem;
    padding: 0.6rem 0.8rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.game-over-username-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    text-align: center;
}

.game-over-username-row {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.game-over-username-row input {
    flex: 1;
    padding: 0.45rem 0.6rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.8rem;
    font-family: inherit;
    letter-spacing: 0.03em;
    outline: none;
    transition: border-color var(--transition);
}

.game-over-username-row input:focus {
    border-color: #555;
}

.game-over-username-row input.error {
    border-color: var(--wrong);
}

.game-over-username-row .btn {
    padding: 0.45rem 0.8rem;
    font-size: 0.65rem;
    white-space: nowrap;
}

.game-over-flag {
    margin-top: 0.5rem;
    padding: 0.5rem 0.8rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.game-over-flag-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    text-align: center;
}
