/* =============================================================
   MODAL OVERLAY
   ============================================================= */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    padding-top: 50px;
    left: 0; top: 0;
    width: 100%; height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.82);
}

/* =============================================================
   GAME-OVER CARD (shared modal card style)
   ============================================================= */
.game-over-card {
    position: relative;
    background-color: var(--surface-1);
    margin: 5% auto;
    padding: 36px;
    border: 1px solid var(--border);
    width: 90%;
    max-width: 540px;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 18px;
    animation: modalPop 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}

.close-game-btn {
    position: absolute;
    top: 12px;
    right: 16px;
    color: var(--text-muted);
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    transition: color var(--transition);
    line-height: 1;
}

.close-game-btn:hover { color: var(--white); }

/* =============================================================
   IMAGE MODAL (full-screen photo)
   ============================================================= */
.modal-image-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: auto;
    width: 80%;
    max-width: 700px;
}

.modal-content {
    display: block;
    width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: var(--radius-md);
    animation: zoom 0.3s;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    background-color: transparent !important;
}

.modal-content, #img01 {
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    background-color: transparent !important;
}

.close {
    position: absolute;
    top: 15px;
    right: 35px;
    color: var(--text-muted);
    font-size: 38px;
    font-weight: bold;
    cursor: pointer;
    transition: color var(--transition);
}

.close:hover, .close:focus { color: var(--white); }

#imageModal   { z-index: 9999 !important; }
#gameOverModal { z-index: 5000; }

/* =============================================================
   GAME-OVER CONTENT
   ============================================================= */
#goTitle {
    font-size: 28px;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--white);
}

.go-image {
    width: 140px;
    height: 140px;
    object-fit: cover;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-hi);
    cursor: pointer;
    transition: transform var(--transition), border-color var(--transition);
}

.go-image:hover {
    transform: scale(1.04);
    border-color: var(--white);
}

/* =============================================================
   DAILY DISTRIBUTION CHART (game-over modal)
   ============================================================= */
.daily-distribution {
    width: 100%;
    text-align: left;
    border-top: 1px solid var(--border);
    padding-top: 14px;
}

.dist-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 10px;
}
.dist-title strong { color: var(--white); }

.dist-row {
    display: grid;
    grid-template-columns: 20px 1fr;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
}

.dist-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--white);
    text-align: right;
}

.dist-bar-outer {
    height: 22px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.dist-bar {
    height: 100%;
    min-width: 22px;
    background: var(--border-hi);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 7px;
    transition: width 0.4s ease;
}

.dist-bar.dist-bar-mine {
    background: var(--purple);
}

.dist-count {
    font-size: 11px;
    font-weight: 700;
    color: var(--white);
    white-space: nowrap;
}

/* =============================================================
   ONBOARDING MODAL
   ============================================================= */
.onboard-clue-guide {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 16px 0;
    text-align: left;
}

.onboard-row {
    display: flex;
    align-items: center;
    gap: 14px;
}

.onboard-box {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    flex-shrink: 0;
    color: var(--white);
}

/* Reuse game.css colour classes: .green .orange .yellow .grey */

.onboard-desc {
    font-size: 14px;
    color: var(--text);
    line-height: 1.4;
}

.onboard-desc strong { color: var(--white); }

.onboard-tip {
    font-size: 12px;
    color: var(--text-muted);
    text-align: left;
    width: 100%;
    margin-bottom: 10px;
    line-height: 1.5;
}

.onboard-skip {
    font-size: 12px;
    opacity: 0.55;
}

/* =============================================================
   CHALLENGE GENERATE MODAL
   ============================================================= */
.challenge-section-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-align: left;
    width: 100%;
}

.challenge-btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    width: 100%;
    margin-bottom: 12px;
}

.challenge-btn-group .menu-btn {
    flex: 1;
    min-width: 80px;
    font-size: 13px;
    padding: 8px 10px;
}

.challenge-cat-btn.selected,
.challenge-diff-btn.selected {
    border-color: var(--purple) !important;
    background: var(--purple-dim);
    color: var(--white);
}

.challenge-url-row {
    display: flex;
    gap: 8px;
    width: 100%;
    align-items: center;
}

.challenge-url-input {
    flex: 1;
    min-width: 0;
    padding: 9px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 11px;
    font-family: inherit;
    outline: none;
    cursor: text;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#goName {
    font-size: 22px;
    color: var(--white);
    font-weight: 700;
    margin: 4px 0 18px 0;
}

/* =============================================================
   COLLECTION DETAIL MODAL
   ============================================================= */
.detail-flex-container {
    display: flex;
    gap: 22px;
    align-items: center;
    justify-content: center;
}

.detail-img {
    width: 210px;
    height: 290px;
    object-fit: cover;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-hi);
    flex-shrink: 0;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    cursor: pointer;
    transition: transform var(--transition), border-color var(--transition);
}

.detail-img:hover {
    transform: scale(1.02);
    border-color: var(--white);
}

.detail-info-box {
    flex: 1;
    background: var(--surface-2);
    padding: 18px;
    border-radius: var(--radius-md);
    font-size: 14px;
    line-height: 1.8;
    height: fit-content;
    border: 1px solid var(--border);
}

/* =============================================================
   COMPARE MODAL
   ============================================================= */
.compare-container {
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: 16px;
    margin-top: 10px;
    min-width: 540px;
}

.compare-column {
    flex: 1;
    background: var(--surface-2);
    padding: 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.compare-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
    color: var(--text-muted);
    width: 36px;
}

.comp-img {
    width: 140px;
    height: 190px;
    object-fit: cover;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-hi);
    margin-bottom: 14px;
    cursor: pointer;
    transition: transform var(--transition);
}

.comp-img:hover { transform: scale(1.04); }

.comp-row {
    width: 100%;
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    padding: 7px 0;
    font-size: 13px;
}

.comp-row strong { color: var(--text-muted); }
.comp-row span   { color: var(--white); font-weight: 700; }

/* =============================================================
   PROFILE MODAL
   ============================================================= */
#profileModal {
    padding-top: 0 !important;
    overflow-y: auto !important;
}

#profileModal .game-over-card {
    margin-top: 3vh !important;
    margin-bottom: 3vh !important;
    position: relative;
    top: 0;
    width: 95%;
    max-width: 1200px;
    height: 92vh;
    min-height: auto;
}

/* =============================================================
   MISC
   ============================================================= */
.modal-high-z      { z-index: 10005; }
.modal-very-high-z { z-index: 10000; }
.modal-alert-z     { z-index: 3000; }

.modal-image-name {
    margin-top: 14px;
    width: 100%;
    text-align: center;
    color: var(--white);
    font-size: 26px;
    font-weight: 700;
    text-shadow: 2px 2px 8px rgba(0,0,0,0.9);
    pointer-events: none;
    letter-spacing: 2px;
}

.bmc-wrapper {
    display: inline-block;
    border-radius: var(--radius-sm);
    transition: transform var(--transition);
    cursor: pointer;
}

.bmc-wrapper:hover {
    transform: scale(1.04);
}

/* =============================================================
   ANIMATIONS
   ============================================================= */
@keyframes zoom {
    from { transform: scale(0); }
    to   { transform: scale(1); }
}

@keyframes popIn {
    0%   { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1);   opacity: 1; }
}

@keyframes modalPop {
    from { opacity: 0; transform: scale(0.9) translateY(-10px); }
    to   { opacity: 1; transform: scale(1)   translateY(0);     }
}

/* =============================================================
   RESPONSIVE
   ============================================================= */
@media (max-width: 700px) {
    .compare-container { flex-direction: column; }
    .compare-divider   { width: 100%; height: 36px; }
}

@media (max-width: 600px) {
    .detail-flex-container { flex-direction: column; text-align: center; }
    .detail-img    { width: 170px !important; height: 260px !important; margin-bottom: 14px; }
    #detailImage   { width: 170px !important; height: 170px !important; margin-bottom: 14px; }
    .game-over-card h2 { text-align: center !important; }
}

/* =============================================================
   COMPARE MODAL
   ============================================================= */
.cmp-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding-bottom: 16px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.cmp-player {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex: 1;
}

.cmp-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-hi);
}

.cmp-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--white);
}

.cmp-level {
    font-size: 11px;
    color: var(--text-muted);
}

.cmp-vs {
    font-size: 22px;
    font-weight: 800;
    color: var(--purple);
    flex-shrink: 0;
}

.cmp-rows {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cmp-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
}

.cmp-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
    white-space: nowrap;
}

.cmp-val {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    text-align: center;
}

.cmp-winner { color: #d4af37; }
.cmp-loser  { color: var(--text-muted); }

/* =============================================================
   POST-GAME MODEL CARD
   ============================================================= */
.go-model-card {
    margin: 14px 0;
    padding: 14px 16px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    text-align: left;
}

.go-model-card-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--purple);
    margin-bottom: 10px;
}

.go-model-attrs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.go-attr-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.go-attr-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.go-attr-val {
    font-size: 14px;
    font-weight: 600;
    color: var(--white);
}

/* =============================================================
   POST-GAME "DID YOU KNOW?" CARD
   ============================================================= */
.go-dyk {
    margin: 10px 0;
    padding: 12px 16px;
    background: var(--purple-dim);
    border: 1px solid rgba(108,92,231,0.3);
    border-left: 3px solid var(--purple);
    border-radius: var(--radius-md);
    text-align: left;
}
.go-dyk.d-none { display: none; }

.go-dyk-label {
    display: block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--purple);
    margin-bottom: 6px;
}

.go-dyk p {
    margin: 0;
    font-size: 13px;
    color: var(--white);
    line-height: 1.55;
}

/* =============================================================
   GAME-OVER SUPPORT LINE (shown every 50 games)
   ============================================================= */
.go-support-line {
    margin: 4px 0 10px;
    text-align: center;
}
.go-support-line.d-none { display: none; }
.go-support-link {
    font-size: 13px;
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}
.go-support-link:hover { color: var(--white); }

/* =============================================================
   FLOATING SUPPORT BUTTON (bottom-right corner)
   ============================================================= */
.float-support-btn {
    position: fixed;
    bottom: max(16px, env(safe-area-inset-bottom, 16px));
    right: max(16px, env(safe-area-inset-right, 16px));
    padding: 8px 14px;
    border-radius: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 14px;
    text-decoration: none;
    z-index: 800;
    transition: transform 0.18s, border-color 0.18s;
    box-shadow: 0 2px 10px rgba(0,0,0,0.35);
    white-space: nowrap;
}
.float-support-btn:hover {
    transform: scale(1.05);
    border-color: var(--border-hi);
}

/* =============================================================
   DAILY LOGIN REWARD MODAL
   ============================================================= */
.login-reward-day {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 4px;
}

.login-reward-xp {
    font-size: 52px;
    font-weight: 900;
    color: var(--white);
    line-height: 1;
    margin-bottom: 8px;
}

.login-reward-shield {
    background: var(--surface-2);
    border: 1px solid var(--purple);
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    font-size: 13px;
    color: var(--text);
    width: 100%;
    text-align: center;
}

/* =============================================================
   HEAD-TO-HEAD RESULT
   ============================================================= */
.h2h-result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.h2h-player-label {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 600;
}

.h2h-player-result {
    font-size: 14px;
    font-weight: 700;
}

.h2h-win  { color: #4a8a45; }
.h2h-lose { color: #c93535; }

.h2h-outcome {
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    color: var(--white);
    margin: 16px 0 0;
}

/* =============================================================
   KEYBOARD SHORTCUTS PANEL
   ============================================================= */

.kb-group {
    margin-bottom: 16px;
    width: 100%;
}

.kb-group-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--purple);
    margin-bottom: 8px;
}

.kb-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 5px 0;
    border-bottom: 1px solid var(--border);
}

.kb-row:last-child { border-bottom: none; }

.kb-key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 52px;
    padding: 3px 8px;
    background: var(--surface-2);
    border: 1px solid var(--border-hi);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 700;
    color: var(--white);
    font-family: monospace;
    flex-shrink: 0;
}

.kb-desc {
    font-size: 13px;
    color: var(--text-muted);
}

/* =============================================================
   REPORT MODAL
   ============================================================= */

.report-field {
    margin-bottom: 12px;
    width: 100%;
}

.report-label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 5px;
}

.report-select,
.report-input,
.report-textarea {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    padding: 8px 10px;
    box-sizing: border-box;
    transition: border-color var(--transition);
    font-family: inherit;
}

.report-select:focus,
.report-input:focus,
.report-textarea:focus {
    outline: none;
    border-color: var(--purple);
}

.report-textarea {
    resize: vertical;
    min-height: 70px;
}

.report-select option { background: var(--surface-1); }

.report-btn {
    font-size: 12px;
    padding: 6px 12px;
}

/* =============================================================
   MODAL OPEN STATE (replaces all JS style.display inline sets)
   ============================================================= */
.modal.is-open {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* =============================================================
   GAME OVER TITLE COLOUR VARIANTS
   ============================================================= */
.go-title-win      { color: var(--white); }
.go-title-lose     { color: #e03b3b; }
.go-title-speedrun { color: var(--purple); }

/* =============================================================
   FEEDBACK MODAL
   ============================================================= */
.feedback-type-tabs {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.feedback-type-btn {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.feedback-type-btn:hover {
    border-color: var(--purple);
    color: var(--white);
}

.feedback-type-btn.active {
    background: var(--purple-dim);
    border-color: var(--purple);
    color: var(--white);
}

.star-rating {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin: 6px 0 14px;
}

.star-rating .star {
    font-size: 30px;
    color: var(--border);
    cursor: pointer;
    transition: color 0.15s;
    line-height: 1;
    -webkit-user-select: none;
    user-select: none;
}

.star-rating .star.active { color: #f5c518; }
