/* --- GAME LAYOUT OVERRIDES --- */
.game-page-layout {
    text-align: center;
    position: relative;
    padding-bottom: 2rem;
}

.game-page-layout h1 {
    margin-top: 0;
    color: var(--color-text-dark);
}

.game-page-layout > p {
    margin-bottom: 2rem;
    color: var(--color-text-muted);
}

/* --- THE GAME BOX CONTAINER --- */
#game-container {
    position: relative;
    width: 100%;
    min-height: 600px; 
    background-color: #050505;
    border: 1px solid #000; 
    border-radius: 12px;
    box-shadow: inset 0 0 40px rgba(0,0,0,0.9);
    overflow: hidden; 
    margin-bottom: 2rem;
    margin-left: auto; 
    margin-right: auto;
    z-index: 10;
}

/* Desktop: Allow wide aspect ratio if space permits */
@media (min-width: 769px) {
    #game-container {
        aspect-ratio: 16 / 9; 
        height: 65vh;
        min-height: 500px; 
    }
}

/* --- FULL SCREEN STATE --- */
#game-container.fullscreen-active {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    /* CHANGE FROM 100vw/100vh TO 100% */
    width: 100%;
    height: 100%;
    height: 100dvh;
    max-width: none;
    max-height: none;
    aspect-ratio: unset; 
    border-radius: 0;
    border: none;
    margin: 0;
    z-index: 99999; 
    background-color: #050505; 
    
    /* Safe Areas */
    padding-top: env(safe-area-inset-top);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
}

/* --- GAME CANVAS --- */
canvas { 
    display: block; 
    width: 100%; 
    height: 100%; 
    outline: none;
    touch-action: none; 
}

/* Hidden Utility */
.hidden-controls, .hidden, .hidden-glyph {
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
    display: none !important;
}

/* --- UI CONTROLS --- */

/* 1. Exit Button */
#fs-toggle-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(30, 30, 30, 0.6);
    backdrop-filter: blur(4px);
    border: 1px solid #555;
    color: #fff;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.2s ease;
    margin-top: env(safe-area-inset-top, 0px);
}
#fs-toggle-btn:hover { 
    background: var(--color-logo-red); 
    border-color: var(--color-logo-red); 
    transform: scale(1.1);
}

/* 2. End Cycle (Surrender) Button */
#btn-surrender {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: transparent;
    border: 1px solid #666;
    color: #888;
    font-size: 0.85rem;
    padding: 6px 14px;
    border-radius: 20px;
    cursor: pointer;
    z-index: 100;
    transition: all 0.3s ease;
    margin-bottom: env(safe-area-inset-bottom, 0px);
    backdrop-filter: blur(2px);
}
#btn-surrender:hover {
    background: rgba(255, 50, 50, 0.1);
    color: #ff8888;
    border-color: #ff8888;
}

/* 3. Moves Counter (Top Left) */
#moves-display {
    position: absolute;
    top: 20px;
    left: 20px;
    color: #ccc;
    font-family: monospace;
    font-size: 1rem;
    pointer-events: none;
    z-index: 100;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(2px);
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.15);
    margin-top: env(safe-area-inset-top, 0px);
}
#moves-display span { color: var(--color-accent-jade); font-weight: bold; }

/* 4. Sidebar / Tools Overlay */
#sidebar-overlay {
    position: absolute;
    z-index: 90;
    display: flex;
    gap: 15px;
}

/* DESKTOP LAYOUT */
@media (min-width: 769px) {
    #sidebar-overlay {
        left: 30px; 
        top: 50%;
        transform: translateY(-50%);
        flex-direction: column;
        width: 60px;
    }
}

/* MOBILE LAYOUT */
@media (max-width: 768px) {
    #sidebar-overlay {
        left: 50%;
        bottom: 20px;
        top: auto;
        transform: translateX(-50%);
        flex-direction: row;
        width: auto;
        margin-bottom: env(safe-area-inset-bottom, 10px);
    }
    
    .tool-btn {
        width: 55px;
        height: 55px;
    }
}

.tool-btn {
    background: rgba(20, 20, 20, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 12px;
    width: 50px;
    height: 50px;
    padding: 10px;
    color: #ccc;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.tool-btn:hover:not(:disabled) {
    border-color: var(--color-accent-jade);
    background: rgba(58, 138, 123, 0.3);
    color: #fff;
    transform: scale(1.05);
}
.tool-btn svg { width: 100%; height: 100%; fill: currentColor; }
.tool-btn:disabled { opacity: 0.3; cursor: not-allowed; transform: none; }

.cooldown {
    position: absolute; bottom: 0; left: 0; height: 3px; width: 0%;
    background: var(--color-accent-jade); transition: width 0.1s linear;
}

/* --- OVERLAYS --- */
.overlay {
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    background: rgba(0, 0, 0, 0.85); 
    backdrop-filter: blur(10px);
    z-index: 150; 
    display: flex; 
    align-items: center; 
    justify-content: center;
    transition: opacity 0.5s ease, visibility 0.5s ease;
    opacity: 1;
    visibility: visible;
    overflow-y: auto; 
    padding: 20px 0;
}

.overlay-content {
    text-align: center; 
    max-width: 480px; 
    width: 90%;
    background: rgba(25,25,25,0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 2.5rem; 
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.8);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: auto; 
}

.overlay-content h1, 
.overlay-content h2 { 
    color: var(--color-accent-jade); 
    margin: 0 0 0.75rem 0; 
    font-size: 2rem; 
}
.start-subtitle { color: #bbb; font-size: 1.1rem; margin-bottom: 2rem; }

/* Instructions Box */
.instructions-box {
    text-align: left; 
    font-size: 0.95rem; 
    margin-bottom: 2rem; 
    background: rgba(255,255,255,0.05); 
    padding: 15px 20px; 
    border-radius: 10px;
    border-left: 3px solid var(--color-accent-jade);
    width: 100%;
}
.instructions-box p { margin: 0 0 8px; color: #ddd; }
.instructions-box p:last-child { margin: 0; }

/* Mode Selection Styles */
.mode-select-container {
    width: 100%;
    margin-bottom: 1.5rem;
}

.mode-select-container h3 {
    color: #ddd;
    font-size: 1rem;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.mode-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.mode-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #444;
    border-radius: 12px;
    padding: 15px;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mode-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.mode-btn.active {
    background: rgba(58, 138, 123, 0.15);
    border-color: var(--color-accent-jade);
    box-shadow: 0 0 15px rgba(58, 138, 123, 0.2);
}

.mode-icon-svg {
    width: 40px;
    height: 40px;
    margin-bottom: 0.5rem;
    color: var(--color-accent-jade);
}
.mode-icon-svg svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
}

.mode-name {
    color: #fff;
    font-weight: bold;
    margin-bottom: 0.25rem;
}

.mode-desc {
    color: #aaa;
    font-size: 0.8rem;
    line-height: 1.2;
}

.start-options { 
    display: flex; 
    gap: 1rem; 
    justify-content: center; 
    flex-wrap: wrap; 
    width: 100%;
}

.action-btn {
    background: var(--color-logo-red); 
    color: white;
    border: none; 
    padding: 14px 30px; 
    font-size: 1rem;
    border-radius: 50px;
    cursor: pointer; 
    font-weight: bold;
    text-transform: uppercase; 
    letter-spacing: 1.5px;
    margin-top: 1rem;
    box-shadow: 0 5px 20px rgba(0,0,0,0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    margin-right: auto;
}

.action-btn:hover { 
    transform: translateY(-2px); 
    box-shadow: 0 8px 25px rgba(0,0,0,0.5);
}

.primary-start { 
    background: var(--color-accent-jade); 
    box-shadow: 0 5px 20px rgba(58, 138, 123, 0.3); 
}
.primary-start:hover { background: #2e6b5f; }

.secondary-start { 
    background: transparent; 
    border: 1px solid #666; 
}
.secondary-start:hover { 
    background: rgba(255,255,255,0.1); 
    border-color: #fff;
}

/* --- INTENTION SCREEN --- */
.ether-box-container {
    position: relative;
    margin-bottom: 2.5rem;
    width: 100%;
}

#intention-input {
    background: transparent;
    border: none;
    border-bottom: 2px solid rgba(255,255,255,0.3);
    color: #fff;
    font-size: 1.5rem;
    padding: 15px 5px;
    width: 100%;
    text-align: center;
    transition: all 0.5s ease;
}
#intention-input:focus {
    outline: none;
    border-bottom-color: var(--color-accent-jade);
    text-shadow: 0 0 15px rgba(58, 138, 123, 0.6);
}
.dissolve-text {
    opacity: 0;
    transform: translateY(-30px) scale(1.1);
    filter: blur(12px);
    letter-spacing: 10px;
}

/* --- READING --- */
.reading-header { 
    color: var(--color-accent-jade); 
    margin-top: 0; 
    text-transform: uppercase; 
    letter-spacing: 2px; 
    font-size: 0.9rem; 
}

/* NEW: Large Glyph in Reading */
.oracle-glyph-large {
    width: 120px;
    height: 120px;
    object-fit: contain;
    margin: 15px auto;
    display: block;
    filter: drop-shadow(0 0 10px var(--color-bg-content));
    animation: fadeInGlyph 1s ease forwards;
}

@keyframes fadeInGlyph {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

#oracle-title { 
    margin-top: 0.5rem; 
    color: #fff; 
    font-size: 2.5rem; 
}
#oracle-text { 
    color: #eee; 
    font-size: 1.3rem; 
    margin: 1.5rem 0; 
    font-style: italic; 
    line-height: 1.5;
}
#oracle-shadow { 
    color: #999; 
    font-size: 0.95rem; 
    border-top: 1px solid rgba(255,255,255,0.1); 
    padding-top: 1.5rem; 
    width: 100%;
}

.game-disclaimer {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border-light);
    font-size: 0.85rem;
    color: var(--color-text-muted);
}
.game-disclaimer a { color: var(--color-accent-jade); text-decoration: none; }