@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Rajdhani:wght@500;600;700&display=swap');

:root {
    --bg-obsidian: #0b0b0f;
    --bg-panel: rgba(20, 20, 28, 0.7);
    --neon-cyan: #00f0ff;
    --neon-magenta: #ff007f;
    --neon-yellow: #ffdd00;
    --neon-purple: #9d00ff;
    --neon-green: #39ff14;
    --text-main: #f5f5fa;
    --text-muted: #8e8e9f;
    --glow-cyan: 0 0 10px rgba(0, 240, 255, 0.5), 0 0 20px rgba(0, 240, 255, 0.3);
    --glow-magenta: 0 0 10px rgba(255, 0, 127, 0.5), 0 0 20px rgba(255, 0, 127, 0.3);
    --glow-green: 0 0 10px rgba(57, 255, 20, 0.5), 0 0 20px rgba(57, 255, 20, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-obsidian);
    background-image: 
        radial-gradient(at 0% 0%, rgba(157, 0, 255, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(0, 240, 255, 0.1) 0px, transparent 50%);
    color: var(--text-main);
    font-family: 'Rajdhani', sans-serif;
    font-size: 18px;
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Base Layout */
.app-container {
    display: grid;
    grid-template-columns: 1fr 350px;
    min-height: 100vh;
}

@media (max-width: 1024px) {
    .app-container {
        grid-template-columns: 1fr;
    }
}

.app-container.sidebar-hidden #sidebar-player-title,
.app-container.sidebar-hidden #test-rig-panel {
    display: none;
}

.history-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.sidebar .history-panel {
    flex: 1;
}

.history-panel .history-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    max-height: none;
}

@media (min-width: 1025px) {
    .sidebar {
        height: 100vh;
        position: sticky;
        top: 0;
    }
}

/* Dashboard Panel (Main Screen) */
.dashboard {
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
}

.header {
    text-align: center;
    margin-bottom: 30px;
}

.header h1 {
    font-family: 'Orbitron', sans-serif;
    font-size: 3.5rem;
    font-weight: 900;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 4px;
    text-shadow: 0 0 10px var(--neon-cyan), 0 0 20px var(--neon-cyan), 0 0 30px var(--neon-purple);
    animation: pulse 3s infinite alternate;
}

.header p {
    color: var(--neon-cyan);
    font-size: 1.2rem;
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* Dice Container and Geometry */
.dice-table {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
    flex-wrap: wrap;
    margin: 40px 0;
    perspective: 1000px;
}

.cube-container {
    width: 80px;
    height: 80px;
    perspective: 500px;
}

.cube {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 2s cubic-bezier(0.2, 0.8, 0.25, 1.1);
    will-change: transform;
}

.face {
    position: absolute;
    width: 80px;
    height: 80px;
    background: rgba(15, 15, 22, 0.95);
    border: 2px solid var(--neon-cyan);
    box-shadow: inset 0 0 15px rgba(0, 240, 255, 0.2), 0 0 10px rgba(0, 240, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    font-family: 'Orbitron', sans-serif;
    font-size: 2.2rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 8px #fff, 0 0 15px var(--neon-cyan);
    backface-visibility: hidden;
}

/* Face positions for 80px cube (translateZ is 40px) */
.front  { transform: rotateY(0deg) translateZ(40px); }
.back   { transform: rotateY(180deg) translateZ(40px); }
.right  { transform: rotateY(90deg) translateZ(40px); }
.left   { transform: rotateY(-90deg) translateZ(40px); }
.top    { transform: rotateX(90deg) translateZ(40px); }
.bottom { transform: rotateX(-90deg) translateZ(40px); }

/* Apply different borders or text shadow colors to make them look distinct */
.face {
    border-color: var(--neon-cyan);
}
.cube-container:nth-child(even) .cube .face {
    border-color: var(--neon-magenta);
    text-shadow: 0 0 8px #fff, 0 0 15px var(--neon-magenta);
    box-shadow: inset 0 0 15px rgba(255, 0, 127, 0.2), 0 0 10px rgba(255, 0, 127, 0.2);
}

/* Panels */
.panel {
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 240, 255, 0.15);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    padding: 24px;
    width: 100%;
}

/* Result Display */
.result-panel {
    max-width: 600px;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    border: 2px dashed rgba(0, 240, 255, 0.3);
    transition: all 0.3s ease;
}

.result-panel.win {
    border-color: var(--neon-green);
    box-shadow: 0 0 15px rgba(57, 255, 20, 0.2);
}

.result-panel.fail {
    border-color: var(--neon-magenta);
    box-shadow: 0 0 15px rgba(255, 0, 127, 0.2);
}

.result-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 2rem;
    font-weight: 900;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.result-description {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.result-action {
    margin-top: 15px;
    font-size: 1.3rem;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

/* Sidebar / Test-Rig */
.sidebar {
    background: rgba(15, 15, 22, 0.9);
    border-left: 1px solid rgba(0, 240, 255, 0.15);
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    gap: 30px;
    overflow-y: auto;
}

.sidebar-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.4rem;
    font-weight: bold;
    text-transform: uppercase;
    color: var(--neon-cyan);
    border-bottom: 2px solid rgba(0, 240, 255, 0.2);
    padding-bottom: 10px;
    letter-spacing: 1px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.form-group label {
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.form-control {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #fff;
    padding: 12px 16px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.1rem;
    outline: none;
    transition: all 0.3s ease;
}

.form-control:focus {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 8px rgba(0, 240, 255, 0.3);
    background: rgba(0, 240, 255, 0.02);
}

select.form-control option {
    background-color: var(--bg-obsidian);
    color: var(--text-main);
}

/* Buttons */
.btn-neon {
    background: transparent;
    border: 2px solid var(--neon-cyan);
    border-radius: 8px;
    color: var(--neon-cyan);
    cursor: pointer;
    font-family: 'Orbitron', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    padding: 14px 20px;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: var(--glow-cyan);
    box-shadow: var(--glow-cyan);
    transition: all 0.3s ease;
    width: 100%;
}

@media (hover: hover) {
    .btn-neon:hover {
        background: var(--neon-cyan);
        color: #000;
        box-shadow: 0 0 20px var(--neon-cyan), 0 0 40px var(--neon-cyan);
        text-shadow: none;
    }
}

.btn-neon:active {
    transform: scale(0.98);
}

.btn-magenta {
    border-color: var(--neon-magenta);
    color: var(--neon-magenta);
    text-shadow: var(--glow-magenta);
    box-shadow: var(--glow-magenta);
}

@media (hover: hover) {
    .btn-magenta:hover {
        background: var(--neon-magenta);
        color: #fff;
        box-shadow: 0 0 20px var(--neon-magenta), 0 0 40px var(--neon-magenta);
    }
}

/* History Log list */
.history-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 300px;
    overflow-y: auto;
}

.history-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.95rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-item.win {
    border-left: 3px solid var(--neon-green);
}

.history-item.fail {
    border-left: 3px solid var(--neon-magenta);
}

.history-time {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Timer styles */
.timer-container {
    margin-top: 20px;
    width: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

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

.timer-progress {
    width: 100%;
    height: 100%;
    background: var(--neon-yellow);
    box-shadow: 0 0 8px var(--neon-yellow);
    transition: width 1s linear;
}

.timer-text {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--neon-yellow);
    text-shadow: 0 0 8px var(--neon-yellow);
}

/* Animations */
@keyframes pulse {
    0% {
        text-shadow: 0 0 10px var(--neon-cyan), 0 0 20px var(--neon-cyan);
    }
    100% {
        text-shadow: 0 0 15px var(--neon-cyan), 0 0 30px var(--neon-cyan), 0 0 40px var(--neon-purple);
    }
}

/* Landing page overlay */
#landing-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(11, 11, 15, 0.95);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.landing-panel {
    width: 100%;
    max-width: 480px;
    border: 2px solid var(--neon-cyan);
    box-shadow: var(--glow-cyan);
    padding: 35px 30px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Mobile Dice Layout — physically smaller cubes (50px) instead of scale() which flattens 3D */
.mobile-dice-table {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin: 15px 0;
}

.mobile-dice-table .cube-container {
    width: 50px;
    height: 50px;
    perspective: 300px;
}

.mobile-dice-table .face {
    width: 50px;
    height: 50px;
    font-size: 1.4rem;
    border-radius: 8px;
}

/* Face positions for 50px cube (translateZ = half = 25px) */
.mobile-dice-table .front  { transform: rotateY(0deg) translateZ(25px); }
.mobile-dice-table .back   { transform: rotateY(180deg) translateZ(25px); }
.mobile-dice-table .right  { transform: rotateY(90deg) translateZ(25px); }
.mobile-dice-table .left   { transform: rotateY(-90deg) translateZ(25px); }
.mobile-dice-table .top    { transform: rotateX(90deg) translateZ(25px); }
.mobile-dice-table .bottom { transform: rotateX(-90deg) translateZ(25px); }

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(11, 11, 15, 0.95);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.modal-panel {
    width: 100%;
    max-width: 550px;
    border: 2px solid var(--neon-cyan);
    box-shadow: var(--glow-cyan);
    padding: 30px 25px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--bg-panel);
}

.form-group-row {
    display: flex;
    flex-direction: column;
    text-align: left;
    gap: 4px;
    width: 100%;
}

.form-group-row label {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8rem;
    color: var(--neon-cyan);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.form-group-row .form-control {
    width: 100%;
}

/* Custom scrollbar for modal body */
.modal-body::-webkit-scrollbar {
    width: 6px;
}
.modal-body::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
}
.modal-body::-webkit-scrollbar-thumb {
    background: rgba(0, 240, 255, 0.3);
    border-radius: 3px;
}
.modal-body::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 240, 255, 0.5);
}

/* Smartphone Media Query Overrides (under 600px width) */
@media (max-width: 600px) {
    .header h1 {
        font-size: 2.2rem;
        letter-spacing: 2px;
        margin-bottom: 5px;
    }
    .header p {
        font-size: 0.95rem;
    }
    .dashboard {
        padding: 15px 10px;
    }
    .panel {
        padding: 15px;
    }
    
    /* Mobile fluid 3D dice table */
    .dice-table {
        gap: 8px;
        margin: 20px 0;
    }
    .dice-table .cube-container {
        width: 50px;
        height: 50px;
        perspective: 300px;
    }
    .dice-table .face {
        width: 50px;
        height: 50px;
        font-size: 1.4rem;
        border-radius: 8px;
    }
    /* Adjusted 3D translation for 50px cube (translateZ = 25px) */
    .dice-table .front  { transform: rotateY(0deg) translateZ(25px); }
    .dice-table .back   { transform: rotateY(180deg) translateZ(25px); }
    .dice-table .right  { transform: rotateY(90deg) translateZ(25px); }
    .dice-table .left   { transform: rotateY(-90deg) translateZ(25px); }
    .dice-table .top    { transform: rotateX(90deg) translateZ(25px); }
    .dice-table .bottom { transform: rotateX(-90deg) translateZ(25px); }
}

/* Bottom Navigation Tabs Styles */
#mobile-nav-tabs {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background: rgba(11, 11, 15, 0.95);
    border-top: 1px solid rgba(0, 240, 255, 0.25);
    box-shadow: 0 -5px 15px rgba(0, 240, 255, 0.1);
    z-index: 9999;
    display: flex;
    justify-content: space-around;
    align-items: center;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

#mobile-nav-tabs .tab-btn {
    flex: 1;
    height: 100%;
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    transition: all 0.2s ease;
}

#mobile-nav-tabs .tab-btn .tab-icon {
    font-size: 1.2rem;
    transition: transform 0.2s ease;
}

#mobile-nav-tabs .tab-btn.active {
    color: var(--neon-cyan);
    text-shadow: 0 0 5px rgba(0, 240, 255, 0.5);
    background: rgba(0, 240, 255, 0.03);
}

#mobile-nav-tabs .tab-btn.active .tab-icon {
    transform: scale(1.1);
}

/* Hide collapsible toggle button on desktop */
#toggle-connection-panel-btn {
    display: none;
}

/* Responsive Overrides under 1024px */
@media (max-width: 1024px) {
    #mobile-nav-tabs {
        display: flex; /* Show tabs on mobile/tablet */
    }

    body {
        padding-bottom: 60px; /* Space for the bottom navbar */
    }

    #toggle-connection-panel-btn {
        display: block; /* Show collapse button on mobile/tablet */
    }

    /* Tab-based switching logic below 1024px */
    .app-container .sidebar {
        display: none !important; /* Hide sidebar by default on mobile */
        width: 100%;
    }

    .app-container .dashboard {
        display: flex !important; /* Show dashboard by default */
        width: 100%;
        padding-bottom: 40px;
    }

    /* If show-history class is present on app-container */
    .app-container.show-history .dashboard {
        display: none !important;
    }
    .app-container.show-history .sidebar {
        display: flex !important;
        flex-direction: column;
        padding: 20px;
        min-height: calc(100vh - 60px);
    }
    .app-container.show-history .sidebar #history-panel {
        display: block !important;
    }
    .app-container.show-history .sidebar #sidebar-player-title,
    .app-container.show-history .sidebar #test-rig-panel {
        display: none !important;
    }

    /* If show-test-rig class is present on app-container */
    .app-container.show-test-rig .dashboard {
        display: none !important;
    }
    .app-container.show-test-rig .sidebar {
        display: flex !important;
        flex-direction: column;
        padding: 20px;
        min-height: calc(100vh - 60px);
    }
    .app-container.show-test-rig .sidebar #history-panel {
        display: none !important;
    }
    .app-container.show-test-rig .sidebar #sidebar-player-title,
    .app-container.show-test-rig .sidebar #test-rig-panel {
        display: block !important;
    }
}

/* Blink/highlight animation for active host player turn */
#test-rig-panel.active-turn {
    border-color: var(--neon-green) !important;
    box-shadow: 0 0 15px rgba(0, 255, 102, 0.4), inset 0 0 15px rgba(0, 255, 102, 0.1) !important;
    animation: turn-pulse 2s infinite ease-in-out;
}

@keyframes turn-pulse {
    0%, 100% {
        box-shadow: 0 0 15px rgba(0, 255, 102, 0.4), inset 0 0 15px rgba(0, 255, 102, 0.1);
        border-color: var(--neon-green);
    }
    50% {
        box-shadow: 0 0 5px rgba(0, 255, 102, 0.1), inset 0 0 5px rgba(0, 255, 102, 0.05);
        border-color: rgba(0, 255, 102, 0.3);
    }
}

/* Soundboard Button Active State */
#soundboard-panel .sound-btn:active {
    transform: scale(0.95);
    box-shadow: 0 0 15px currentColor !important;
}
