/* Game Page Styles */
.game-page-header {
    position: relative;
    height: 260px;
    background-color: #0f1014;
}
.game-page-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.7;
}
.game-page-back {
    position: absolute;
    top: 16px;
    left: 16px;
    background: rgba(0,0,0,0.4);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.1);
    z-index: 10;
    transition: background 0.2s;
}
.game-page-back:active { background: rgba(255,255,255,0.1); }
.game-info-container {
    padding: 16px;
}
.game-title-large {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 4px;
}
.game-creator-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}
.play-btn-large {
    width: 100%;
    background: linear-gradient(180deg, #00c47c 0%, #00a065 100%);
    color: white;
    border: none;
    padding: 16px;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 0 #007a4d, 0 8px 16px rgba(0, 176, 111, 0.3);
    margin-bottom: 24px;
    transition: transform 0.1s, box-shadow 0.1s;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.play-btn-large:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #007a4d, inset 0 2px 4px rgba(0,0,0,0.2);
}
.play-btn-large:active {
    transform: scale(0.98);
}
.comment-section {
    margin-top: 24px;
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 16px;
}
.comment-input-row {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}
.comment-input {
    flex: 1;
    background: rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 10px;
    color: white;
    outline: none;
}
.comment-post-btn {
    background: var(--text-primary);
    color: var(--bg-dark);
    border: none;
    border-radius: 8px;
    padding: 0 16px;
    font-weight: 700;
    cursor: pointer;
}
.comment-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.comment-item {
    display: flex;
    gap: 10px;
}
.comment-avatar {
    width: 32px; 
    height: 32px; 
    border-radius: 50%; 
    background: #444;
    flex-shrink: 0;
}
.comment-content {
    flex: 1;
}
.comment-user {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 2px;
}
.comment-text {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.4;
}
.game-stats-row {
    display: flex;
    gap: 0;
    margin-bottom: 24px;
    padding: 16px 0;
    border-top: 1px solid rgba(255,255,255,0.05);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    justify-content: space-around;
}
.stat-item-lg {
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-items: center;
}
.stat-value {
    font-size: 20px;
    font-weight: 800;
    color: white;
}
.stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Creator Studio Styles */
.creator-container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    touch-action: none; /* Disables native gestures like scroll/zoom for game control */
    -webkit-user-select: none;
    user-select: none;
}

.creator-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    z-index: 10;
}

.creator-header {
    pointer-events: auto;
    background: rgba(20, 21, 25, 0.85);
    backdrop-filter: blur(12px);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.creator-toolbar {
    pointer-events: auto;
    background: rgba(20, 21, 25, 0.85);
    backdrop-filter: blur(12px);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 16px;
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.05);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.toolbar-row {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 4px;
}
.toolbar-row::-webkit-scrollbar { display: none; }

.color-swatch {
    width: 36px; height: 36px;
    border-radius: 8px;
    border: 2px solid rgba(255,255,255,0.1);
    cursor: pointer;
    flex-shrink: 0;
}
.color-swatch.active {
    border-color: white;
    transform: scale(1.1);
    box-shadow: 0 0 8px rgba(255,255,255,0.3);
}

.tool-btn {
    padding: 8px 16px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.05);
    color: #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    min-height: 36px;
}
.tool-btn:hover { background: rgba(255,255,255,0.1); }

@media (max-width: 768px) {
    .tool-btn {
        padding: 0 12px;
        font-size: 13px;
        min-height: 40px;
        white-space: nowrap;
    }
    
    .creator-header {
        overflow-x: auto;
        justify-content: flex-start;
        gap: 12px;
    }
    .creator-header::-webkit-scrollbar { display: none; }
    .creator-header > * { flex-shrink: 0; }
    
    .creator-toolbar {
        padding: 8px;
        gap: 6px;
        width: 100%;
        max-height: 40vh;
        overflow-y: auto;
    }
    
    .toolbar-row {
        gap: 8px;
    }
    
    .color-swatch {
        width: 40px; height: 40px;
    }
}
.tool-btn:active { transform: scale(0.95); }

.tool-btn.active {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 176, 111, 0.4);
}

.tool-btn.danger {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
    color: #ef4444;
}

.tool-btn.primary {
    background: white;
    color: black;
    border-color: white;
}

/* Script Manager & Editor */
.script-manager-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    display: none;
    align-items: center;
    justify-content: center;
}

.script-manager-window {
    width: 90%;
    max-width: 500px;
    height: 400px;
    max-height: 80vh;
    background: #1e1e1e;
    border: 1px solid #333;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    overflow: hidden;
}

.sm-header {
    padding: 12px 16px;
    background: #252526;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.sm-title { font-weight: 700; color: #ccc; }
.sm-close { background: none; border: none; color: #888; cursor: pointer; font-size: 16px; }
.sm-close:hover { color: white; }

.sm-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.sm-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    color: #ccc;
    font-size: 13px;
    border: 1px solid transparent;
}
.sm-item:hover {
    background: #2a2d2e;
}
.sm-item-icon {
    width: 16px; 
    height: 16px;
    display: flex; 
    align-items: center; 
    justify-content: center;
}
.sm-item-name { flex: 1; font-weight: 600; }
.sm-item-type { font-size: 10px; opacity: 0.5; text-transform: uppercase; background: rgba(255,255,255,0.1); padding: 2px 4px; border-radius: 2px; }
.sm-actions { display: flex; gap: 4px; opacity: 0; }
.sm-item:hover .sm-actions { opacity: 1; }
.sm-btn-icon {
    background: none; border: none; color: #888; cursor: pointer; padding: 2px;
}
.sm-btn-icon:hover { color: #fff; }

.sm-footer {
    padding: 12px;
    background: #252526;
    border-top: 1px solid #333;
    display: flex;
    gap: 8px;
}

/* Script Editor */
.script-modal {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 800px;
    height: 80%;
    background: #1e1e1e;
    border: 1px solid #333;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    display: none;
    flex-direction: column;
    z-index: 1000;
    overflow: hidden;
}
.script-header {
    background: #252526;
    padding: 0;
    display: flex;
    border-bottom: 1px solid #333;
}
.script-tab {
    padding: 10px 20px;
    background: transparent;
    color: #888;
    border: none;
    cursor: pointer;
    font-weight: 600;
    border-right: 1px solid #333;
    transition: all 0.2s;
}
.script-tab:hover {
    background: rgba(255,255,255,0.05);
}
.script-tab.active {
    background: #1e1e1e;
    color: white;
    border-top: 2px solid #00b06f;
}
.script-body {
    flex: 1;
    position: relative;
    overflow: hidden;
}
.script-editor-view {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    padding: 16px;
    overflow-y: auto;
}
.script-editor-view.active {
    display: flex;
}
.js-textarea {
    flex: 1;
    background: #111;
    color: #d4d4d4;
    font-family: 'Consolas', 'Monaco', monospace;
    padding: 12px;
    border: 1px solid #333;
    border-radius: 4px;
    resize: none;
    font-size: 13px;
    line-height: 1.5;
    outline: none;
}
.js-textarea:focus {
    border-color: #00b06f;
}
.js-textarea.secure-code {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}
.script-footer {
    padding: 12px;
    border-top: 1px solid #333;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    background: #252526;
}

/* In-Game Chat */
.game-chat-overlay {
    position: absolute;
    top: 120px; /* Below chat button */
    left: 12px;
    width: 300px;
    max-width: 60vw;
    height: 240px;
    display: flex;
    flex-direction: column;
    z-index: 50;
    pointer-events: none; /* Let clicks pass through empty areas */
    transition: opacity 0.2s;
}

.game-chat-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.game-chat-btn {
    position: absolute;
    top: 70px; /* Below header/leave button */
    left: 12px;
    width: 44px;
    height: 44px;
    background: rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 51;
    backdrop-filter: blur(4px);
    pointer-events: auto;
}
.game-chat-btn:active {
    background: rgba(255,255,255,0.2);
}

.game-chat-window {
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    border-radius: 8px;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    pointer-events: auto;
    margin-top: 0;
}

.game-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.3) transparent;
}

.game-chat-msg {
    font-size: 14px;
    color: white;
    text-shadow: 1px 1px 1px rgba(0,0,0,0.8);
    word-wrap: break-word;
    line-height: 1.3;
}
.game-chat-user {
    font-weight: 700;
    color: white;
}
.game-chat-text {
    color: rgba(255,255,255,0.9);
}

.game-chat-input-row {
    padding: 8px;
    background: rgba(0,0,0,0.3);
    display: flex;
    gap: 8px;
}

.game-chat-input {
    flex: 1;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    padding: 6px 10px;
    color: white;
    font-size: 14px;
    outline: none;
}
.game-chat-input::placeholder {
    color: rgba(255,255,255,0.5);
}
.game-chat-input:focus {
    background: rgba(0,0,0,0.5);
    border-color: rgba(255,255,255,0.3);
}

/* Hotbar */
.game-hotbar {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    z-index: 40;
    pointer-events: auto;
}
.hotbar-slot {
    width: 54px;
    height: 54px;
    background: rgba(20, 21, 25, 0.7);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    cursor: pointer;
    position: relative;
    transition: all 0.1s;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.hotbar-slot:hover {
    background: rgba(255,255,255,0.1);
}
.hotbar-slot.active {
    background: rgba(0, 176, 111, 0.2);
    border-color: #00b06f;
    transform: translateY(-6px);
    box-shadow: 0 0 0 2px rgba(0, 176, 111, 0.3), 0 8px 16px rgba(0,0,0,0.4);
}
.hotbar-key {
    position: absolute;
    top: 2px;
    left: 4px;
    font-size: 10px;
    color: rgba(255,255,255,0.7);
    font-weight: bold;
}
.hotbar-name {
    position: absolute;
    bottom: -24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.7);
    color: white;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}
.hotbar-slot:hover .hotbar-name, .hotbar-slot.active .hotbar-name {
    opacity: 1;
}