/*
 * Spelling Dungeon
 * 
 * This work is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License.
 * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/4.0/
 * 
 * Copyright (c) 2026 The Spelling Dungeon Authors
 */

.menu-row {
    display: flex;
    gap: 1rem;
    width: 100%;
}

.menu-content-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transform: scale(var(--ui-scale));
    transform-origin: center;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.menu-content-wrapper>* {
    pointer-events: auto;
}

.menu-row .menu-btn {
    flex: 1;
    padding: 1rem 0.5rem;
}

.menu-btn.danger {
    color: #ff6a6a !important;
    border-color: rgba(150, 50, 50, 0.4) !important;
}

.menu-btn.danger:hover {
    background: linear-gradient(180deg, rgba(80, 20, 20, 0.9) 0%, rgba(50, 10, 10, 0.95) 100%) !important;
    border-color: #ff4a4a !important;
    box-shadow: 0 0 15px rgba(255, 74, 74, 0.2) !important;
}

.danger-text {
    color: #ff4444 !important;
}

.menu-btn.primary {
    background: linear-gradient(180deg, rgba(60, 50, 40, 0.9) 0%, rgba(45, 35, 25, 0.95) 100%) !important;
    border-color: rgba(180, 150, 100, 0.4) !important;
    color: #ffe4c4 !important;
}

.menu-btn.primary:hover {
    border-color: #ffaa00 !important;
    box-shadow: 0 0 15px rgba(255, 170, 0, 0.3) !important;
}

/* ── Space Saving Layout Refinements ────────────────────────────────────── */
.menu-title {
    margin-bottom: 1.5rem !important;
    font-size: 4.2rem !important;
}

.menu-options {
    gap: 0.8rem !important;
}

/* ── Enhanced High Scores ────────────────────────────────────────────────── */
#scores-list {
    width: 650px;
    max-width: 95vw;
    max-height: 65vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.4);
    box-sizing: border-box;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
}

.score-item {
    display: flex !important;
    align-items: center !important;
    background: rgba(30, 25, 20, 0.6) !important;
    border: 1px solid rgba(130, 100, 70, 0.3) !important;
    border-radius: 6px !important;
    padding: 0.8rem 1.2rem !important;
    margin-bottom: 0.8rem !important;
    gap: 1.5rem !important;
    width: 100% !important;
    box-sizing: border-box !important;
    border: 1px solid rgba(130, 100, 70, 0.3) !important;
}

.score-rank {
    font-size: 1.5rem !important;
    font-weight: 900 !important;
    color: #ffaa00 !important;
    width: 30px !important;
    text-align: center !important;
}

.score-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.score-row-top,
.score-row-bot {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.score-name {
    font-size: 1.2rem !important;
    font-weight: bold !important;
    color: #ffe4c4 !important;
}

.score-value {
    font-size: 1.1rem !important;
    color: #ff9200 !important;
    font-weight: bold !important;
    text-align: right !important;
}

.score-meta {
    font-size: 0.8rem;
    color: #a0927e;
    text-transform: uppercase;
    letter-spacing: 0.05rem;
}

/* ── Character Profile Cards ─────────────────────────────────────────── */
#profiles-list {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    justify-content: center;
    padding: 1rem;
    perspective: 1000px;
}

.profile-card {
    position: relative;
    width: 280px;
    background: rgba(20, 15, 10, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(8px);
    overflow: hidden;
    color: #e0d0b0;
}

.profile-card:hover {
    transform: translateY(-5px) scale(1.02);
    background: rgba(30, 25, 20, 0.85);
    border-color: var(--profile-color);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 15px var(--profile-color);
}

.profile-card.active-profile {
    border-color: var(--profile-color);
    background: linear-gradient(135deg, rgba(30, 25, 20, 0.9) 0%, rgba(10, 10, 20, 0.95) 100%);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.1), inset 0 0 15px rgba(255, 255, 255, 0.05);
}

.profile-card-inner {
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.profile-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.8rem;
}

.profile-name {
    margin: 0;
    font-size: 1.3rem;
    color: #ffe4c4;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    letter-spacing: 0.05rem;
}

.profile-meta {
    font-size: 0.75rem;
    color: #a0927e;
    text-transform: uppercase;
    letter-spacing: 0.05rem;
    margin-top: 0.2rem;
}

.profile-room-badge {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 170, 0, 0.4);
    border-radius: 4px;
    padding: 0.3rem 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 50px;
}

.badge-label {
    font-size: 0.55rem;
    font-weight: bold;
    color: #ffaa00;
}

.badge-value {
    font-size: 1.1rem;
    font-weight: 900;
    color: #fff;
}

.profile-stats-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
}

.p-stat-box {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.p-stat-icon {
    font-size: 0.9rem;
    filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.5));
}

.p-stat-val {
    font-weight: bold;
    color: #ffcc00;
}

.profile-progress-section {
    margin-top: 0.5rem;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #a0927e;
    margin-bottom: 0.3rem;
    text-transform: uppercase;
}

.progress-bar-bg {
    height: 6px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.progress-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.8s ease-out;
    box-shadow: 0 0 8px var(--profile-color);
}

.progress-subtext {
    font-size: 0.65rem;
    color: #887a68;
    margin-top: 0.3rem;
    text-align: right;
    font-style: italic;
}

.profile-card-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

.delete-profile-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: #662222;
    padding: 5px;
    transition: all 0.2s;
    opacity: 0.5;
}

.delete-profile-btn:hover {
    color: #ff4444;
    opacity: 1;
    transform: scale(1.2);
    filter: drop-shadow(0 0 5px rgba(255, 68, 68, 0.5));
}

.active-ribbon {
    position: absolute;
    top: 10px;
    left: -30px;
    background: var(--profile-color);
    color: #000;
    font-weight: 900;
    font-size: 0.65rem;
    padding: 4px 30px;
    transform: rotate(-45deg);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    letter-spacing: 0.1rem;
    text-transform: uppercase;
    border: 1px solid rgba(0, 0, 0, 0.2);
}

.active-profile .profile-name {
    color: #fff;
    text-shadow: 0 0 10px var(--profile-color);
}

/* ── Ko-fi Widget Behavior ─────────────────────────────────────────────── */
/* BROAD SELECTORS to catch the widget even if internal classes change */
[class*="floatingchat-container"],
[id*="kofi-widget"],
.floatingchat-container-wrap,
iframe[id^="kofi-widget"],
.floating-chat-kofi-popup-wrapper,
[class*="kofi-widget"],
[id*="kofi-widget"],
[class*="floating-chat"],
[class*="floating-chat-kofi"] {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Show widget in ALL MENUS, but hide during active gameplay */
body:not(.state-playing):not(.state-mcq) [class*="floatingchat-container"],
body:not(.state-playing):not(.state-mcq) [id*="kofi-widget"],
body:not(.state-playing):not(.state-mcq) .floatingchat-container-wrap,
body:not(.state-playing):not(.state-mcq) iframe[id^="kofi-widget"],
body:not(.state-playing):not(.state-mcq) .floating-chat-kofi-popup-wrapper,
body:not(.state-playing):not(.state-mcq) [class*="kofi-widget"],
body:not(.state-playing):not(.state-mcq) [class*="floating-chat"],
body:not(.state-playing):not(.state-mcq) [class*="floating-chat-kofi"] {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Surgical hiding of independent artifacts injected by Ko-fi */
[class*="floatingchat"]>[class*="close"],
[class*="kofi"]>[class*="close"],
[class*="kofi"]>[class*="button-close"],
.floatingchat-container-wrap>[class*="close"],
.kofi-img-link,
[class*="kofi-link"],
body>a[href*="ko-fi.com"],
body>a[href*="tidbittutoring"],
a[href*="ko-fi.com/tidbittutoring"],
#game-ui+a[href*="ko-fi.com"],
#game-ui+a[href*="tidbittutoring"] {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    max-height: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
    position: absolute !important;
    left: -9999px !important;
}

.floatingchat-container,
.floating-chat-kofi-popup-wrapper,
[id^="kofi-widget"] {
    visibility: visible !important;
    opacity: 1 !important;
}

body:not(.state-playing):not(.state-mcq) .floatingchat-container-wrap,
body:not(.state-playing):not(.state-mcq) [class*="floatingchat-container"] {
    display: flex !important;
}

body .floatingchat-container-wrap,
body [class*="floatingchat-container"],
body iframe[id^="kofi-widget"],
body .floating-chat-kofi-popup-wrapper,
body [class*="kofi-widget"],
body [class*="floating-chat"] {
    left: auto !important;
    right: 20px !important;
    bottom: 20px !important;
}

/* ── Secondary Overlay Scaling ────────────────────────────────────────── */

#toast-container {
    transform: translateX(-50%) scale(var(--ui-scale)) !important;
    transform-origin: top center !important;
}

#roulette-wheel-container {
    transform: translate(-50%, -50%) scale(var(--ui-scale)) !important;
    transform-origin: center !important;
}

#branch-choice-overlay {
    /* The one inside #game-ui at line 100 */
    transform: scale(var(--ui-scale)) !important;
    transform-origin: center !important;
}

#branch-choice-overlay>div {
    /* Inner centering div should also respect scale if needed, 
       but parent scaling is usually enough. Adding here for safety. */
    transform: translate(-50%, -50%) scale(var(--ui-scale)) !important;
    transform-origin: center !important;
}

#item-drop-display {
    transform: scale(var(--ui-scale)) !important;
    transform-origin: center !important;
    /* If it uses fixed positioning with translate, we need to combine them */
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) scale(var(--ui-scale)) !important;
}

#skip-chest-btn {
    transform: scale(var(--ui-scale)) !important;
    transform-origin: top right !important;
}

#puzzle-keyboard {
    /* Ensure puzzle keyboard is centered properly with scale */
    transform: translateX(-50%) scale(var(--ui-scale)) !important;
    transform-origin: bottom center !important;
}