/* ===== Kurt Blast Styles ===== */

/* Base container matching 2048 layout structure */
body {
    margin: 0 !important;
    padding: 0 !important;
    background-color: var(--body-bg-color, #0B1020) !important;
    color: var(--text-color, #ffffff) !important;
    overflow: hidden !important;
    height: 100dvh !important;
}

main {
    margin: 0 !important;
    margin-top: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    height: 100% !important;
    flex: none !important;
}

.game-section {
    display: none;
    width: 100%;
    height: 100%;
}

.game-section.active {
    display: block;
}

.app-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 10px;
    box-sizing: border-box;
    gap: 8px;
    max-width: 600px;
    margin: 0 auto;
}

/* ===================== GLASS CONTAINERS ===================== */
.glass-container {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 2rem;
    margin: 1rem 0;
}

/* ===================== HEADER ===================== */
.game-header {
    flex-shrink: 0;
    position: static !important;
    transform: none !important;
    left: auto !important;
    margin-top: 0 !important;
    width: auto !important;
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
    padding: 5px 0 !important;
}

.header-top {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    margin-bottom: 5px;
    width: 100%;
}

.header-top > *:last-child {
    justify-self: end;
}

.header-top .game-title {
    text-align: center;
    white-space: nowrap;
}

.back-btn, .back-btn-link {
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.85rem;
    opacity: 0.7;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: opacity 0.2s;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
}

.back-btn:hover, .back-btn-link:hover {
    opacity: 1;
}

.game-title {
    margin: 0 !important;
    font-size: 1.6rem !important;
    font-weight: 800 !important;
    letter-spacing: 3px !important;
    background: linear-gradient(135deg, #ff00cc, #3333ff) !important;
    -webkit-background-clip: text !important;
    background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: var(--text-color);
    font-size: 1.1rem;
    cursor: pointer;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(90deg);
}

/* ===================== MENU SCREEN ===================== */
.menu-box {
    margin-top: 2rem;
}

.mode-buttons {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.mode-btn {
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.06);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.mode-btn:hover {
    border-color: #ff00cc;
    background: rgba(255, 0, 204, 0.1);
    transform: translateY(-3px);
}

.mode-btn-icon {
    font-size: 2.5rem;
}

.mode-btn-label {
    font-size: 0.85rem;
    opacity: 0.6;
}

/* ===================== LOBBY / WAITING ROOM ===================== */
.lobby-container, .waiting-container, .results-container {
    text-align: center;
}

.name-input, .code-input {
    width: 100%;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    color: white;
    font-size: 1rem;
    text-align: center;
    margin-bottom: 1.5rem;
}

.code-input {
    letter-spacing: 0.5rem;
    font-weight: bold;
    text-transform: uppercase;
}

.or-divider {
    margin: 1.5rem 0;
    opacity: 0.5;
}

.join-group {
    display: flex;
    gap: 10px;
}

.room-code-area {
    margin-bottom: 2rem;
}

.room-code-badge {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: 0.5rem;
    color: #ff00cc;
    display: block;
    margin-bottom: 1rem;
}

.room-code-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.copy-btn {
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: white;
    cursor: pointer;
}

.players-list {
    margin: 2rem 0;
    text-align: left;
}

.player-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 0.8rem 1.2rem;
    border-radius: 10px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
}

.host-tag {
    font-size: 0.7rem;
    background: #ff00cc;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

/* ===================== BUTTONS ===================== */
.btn-primary-kb {
    background: linear-gradient(135deg, #ff00cc, #3333ff);
    color: white;
    border: none;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 700;
    border-radius: 12px;
    cursor: pointer;
    width: 100%;
    transition: all 0.2s;
}

.btn-primary-kb:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 0, 204, 0.4);
}

.btn-secondary-kb {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 1rem 2rem;
    border-radius: 12px;
    cursor: pointer;
    width: 100%;
    margin-top: 10px;
}

/* ===================== SCORE PANEL ===================== */
.score-panel {
    display: flex;
    gap: 8px;
}

.score-box {
    flex: 1;
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    padding: 6px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.score-label {
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-grey, #a0a0a0);
}

.score-value {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text-color, white);
    font-variant-numeric: tabular-nums;
}

/* ===================== GAME BOARD ===================== */
.board-wrapper {
    flex: 1 1 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 0;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    position: relative;
}

#game-canvas {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    background-color: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    touch-action: none;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.spectator-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 40px;
    z-index: 10;
    border-radius: 12px;
    pointer-events: none;
}

.spectator-msg {
    background: rgba(30, 30, 40, 0.9);
    padding: 15px 25px;
    border-radius: 15px;
    border: 1px solid #ff00cc;
    text-align: center;
    box-shadow: 0 0 20px rgba(255, 0, 204, 0.4);
}

.spectator-msg h3 { margin: 0; color: #ff00cc; font-size: 1.1rem; }
.spectator-msg p { margin: 5px 0 0; font-size: 0.85rem; opacity: 0.8; }

.controls-hint {
    flex-shrink: 0;
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
    padding: 2px 0;
    font-size: 0.8rem;
}

/* ===================== MODALS ===================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: rgba(30, 30, 38, 0.8);
    backdrop-filter: blur(20px);
    padding: 30px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    text-align: center;
    box-shadow: 0 20px 60px rgba(255, 0, 204, 0.3);
    max-width: 90%;
    width: 350px;
}

.modal-content h2 {
    font-size: 2rem;
    margin-bottom: 10px;
    color: #ff00cc;
}

.modal-actions {
    margin-top: 20px;
}

/* Friends Modal */
.friends-list {
    max-height: 300px;
    overflow-y: auto;
    margin: 1.5rem 0;
}

.friend-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.friend-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
}

.friend-name { flex: 1; text-align: left; }

.invite-btn-small {
    padding: 4px 12px;
    background: rgba(255, 0, 204, 0.2);
    border: 1px solid #ff00cc;
    color: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
}

/* Ranking List */
.ranking-list {
    margin-bottom: 2rem;
}

.rank-item {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 1.25rem 1.5rem;
    border-radius: 18px;
    margin-bottom: 12px;
    gap: 15px;
    transition: transform 0.2s, background 0.2s;
}

.rank-item:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(5px);
}

.rank-number { 
    font-size: 1.5rem; 
    font-weight: 800; 
    color: #ff00cc; 
    min-width: 40px; 
    text-align: center;
}

.rank-info { 
    flex: 1; 
    text-align: left; 
}

.rank-name { 
    font-weight: 700; 
    display: block; 
    font-size: 1.1rem;
}

.rank-score { 
    font-size: 1.2rem; 
    font-weight: 800;
    color: #ff00cc;
}

/* ===================== RESPONSIVE (DESKTOP) ===================== */
@media (min-width: 800px) {
    /* Only apply the side-by-side layout during the actual game */
    #screen-game .app-container {
        display: grid !important;
        grid-template-columns: 1fr auto 1fr !important;
        grid-template-rows: 1fr auto auto 1fr !important;
        justify-content: center !important;
        align-items: center !important;
        padding: 15px;
        gap: 15px 30px;
        max-width: 1400px;
        margin: 0 auto;
    }

    #screen-game .game-header {
        grid-column: 1 !important;
        grid-row: 2 !important;
        width: 100% !important;
        max-width: 260px;
        justify-self: end !important;
    }

    #screen-game .header-top {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px;
        margin-bottom: 15px;
    }

    #screen-game .score-panel {
        flex-direction: column;
    }

    #screen-game .board-wrapper {
        grid-column: 2 !important;
        grid-row: 1 / span 4 !important;
        height: calc(100dvh - 40px);
        max-height: 850px;
        aspect-ratio: 1 / 1.35;
    }

    #screen-game .controls-hint {
        grid-column: 1 !important;
        grid-row: 3 !important;
        width: 100% !important;
        max-width: 260px;
        justify-self: end !important;
        text-align: left;
    }

    #screen-game .blast-meter-container {
        grid-column: 1 !important;
        grid-row: 4 !important;
        width: 100% !important;
        max-width: 260px;
        justify-self: end !important;
        align-self: start;
    }

    /* Menu & Lobby centering on desktop */
    #screen-menu .app-container,
    #screen-mp-lobby .app-container,
    #screen-mp-waiting .app-container,
    #screen-results-multi .app-container,
    #screen-leaderboard .app-container {
        justify-content: center;
        max-width: 500px;
    }
}

/* ===================== GAME OVER IMPROVEMENTS ===================== */
@keyframes recordBounce {
    0%   { transform: scale(0.5); opacity: 0; }
    60%  { transform: scale(1.15); opacity: 1; }
    80%  { transform: scale(0.95); }
    100% { transform: scale(1); }
}

@keyframes recordGlow {
    0%, 100% { box-shadow: 0 0 10px rgba(255, 215, 0, 0.5); }
    50%       { box-shadow: 0 0 25px rgba(255, 215, 0, 0.9); }
}

.record-banner {
    background: linear-gradient(135deg, #ffd700, #ff8c00);
    color: #000;
    font-weight: 900;
    font-size: 1rem;
    letter-spacing: 2px;
    padding: 8px 16px;
    border-radius: 10px;
    margin-bottom: 12px;
    animation: recordBounce 0.5s ease-out, recordGlow 1.5s ease-in-out 0.5s infinite;
}

.gameover-score-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 12px 0 6px;
}

.gameover-score-label {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 3px;
    color: rgba(255,255,255,0.5);
}

.gameover-score-value {
    font-size: 3.2rem;
    font-weight: 900;
    background: linear-gradient(135deg, #ff00cc, #3333ff);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.gameover-stats {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.45);
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

/* ===================== GOAL TEXT ===================== */
.goal-text {
    display: block;
    color: rgba(255,255,255,0.35);
    font-size: 0.72rem;
    margin-top: 2px;
}

/* ===================== BLAST METER ===================== */
.blast-meter-container {
    flex-shrink: 0;
    padding: 8px 4px 2px;
}

.blast-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.blast-meter-label {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: rgba(255,255,255,0.5);
}

.blast-meter-bar {
    width: 100%;
    height: 8px;
    background: rgba(255,255,255,0.08);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.1);
}

.blast-meter-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #3333ff, #ff00cc);
    border-radius: 4px;
    transition: width 0.3s ease;
}

@keyframes blastPulse {
    0%, 100% { box-shadow: 0 0 8px rgba(255,0,204,0.5); }
    50%       { box-shadow: 0 0 18px rgba(255,0,204,1); }
}

.blast-btn {
    width: 100%;
    margin-top: 8px;
    padding: 7px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    color: rgba(255,255,255,0.3);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 2px;
    cursor: not-allowed;
    transition: all 0.2s;
}

.blast-btn.blast-ready {
    background: linear-gradient(135deg, #ff00cc, #3333ff);
    border-color: transparent;
    color: white;
    cursor: pointer;
    animation: blastPulse 1.2s ease-in-out infinite;
}

.blast-btn.blast-ready:hover {
    transform: scale(1.04);
}

.help-btn {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.5);
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

.help-btn:hover {
    background: rgba(255,255,255,0.15);
    color: white;
}

/* ===================== OPPONENT TICKER ===================== */
@keyframes tickerFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.opponent-ticker {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(30, 30, 50, 0.92);
    border: 1px solid rgba(255, 0, 204, 0.5);
    border-radius: 20px;
    padding: 5px 14px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #ff00cc;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 5;
}

.opponent-ticker.visible {
    opacity: 1;
    animation: tickerFadeIn 0.25s ease-out;
}

/* ===================== PUBLIC ROOMS ===================== */
.public-rooms-section {
    margin-top: 0.5rem;
}

.refresh-rooms-btn {
    padding: 0.5rem 1rem !important;
    font-size: 0.85rem !important;
    margin-bottom: 10px;
}

.public-room-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 8px;
}

.room-host-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.room-host-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.room-code-small {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.4);
    letter-spacing: 2px;
}

.btn-small-kb {
    padding: 5px 12px;
    background: linear-gradient(135deg, #ff00cc, #3333ff);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}

.no-rooms {
    text-align: center;
    color: rgba(255,255,255,0.3);
    font-size: 0.85rem;
    padding: 10px 0;
}

/* ===================== COPY LINK BUTTON ===================== */
.copy-link-btn {
    background: rgba(255, 0, 204, 0.12) !important;
    border-color: rgba(255, 0, 204, 0.4) !important;
    color: #ff00cc !important;
    font-weight: 600;
}

/* ===================== TUTORIAL MODAL ===================== */
.tutorial-content {
    max-width: 420px !important;
    width: 92% !important;
    text-align: left !important;
}

.tutorial-content h2 {
    text-align: center;
    margin-bottom: 1.2rem;
}

.tutorial-steps {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.tutorial-step {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 10px;
    background: rgba(255,255,255,0.04);
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.08);
}

.tutorial-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
    line-height: 1.3;
}

.tutorial-step strong {
    font-size: 0.9rem;
    display: block;
    margin-bottom: 2px;
}

.tutorial-step small {
    color: rgba(255,255,255,0.55);
    font-size: 0.78rem;
    line-height: 1.4;
}

/* ===================== LEADERBOARD BUTTON ===================== */
#leaderboard-btn {
    padding: 0.8rem 1rem;
    flex-direction: row;
    gap: 1rem;
    border-radius: 15px;
    margin-top: 0.5rem;
}

#leaderboard-btn .mode-btn-icon {
    font-size: 1.5rem;
}

#leaderboard-btn .mode-btn-label {
    display: none;
}

#leaderboard-btn span:not(.mode-btn-icon) {
    font-size: 1rem;
    font-weight: 600;
}
