:root {
    --bg-gradient: radial-gradient(circle at center, #0a0a15 0%, #000000 100%);
    --primary-color: #00f0ff;
    --primary-hover: #00c3d9;
    --secondary-color: #ff003c;
    --secondary-hover: #d90033;
    --danger-color: #ff00a0;
    --danger-hover: #d90088;
    --text-main: #ffffff;
    --text-light: #a0a0b8;
    --card-bg: rgba(10, 10, 20, 0.85);
    --card-shadow: 0 8px 32px rgba(0, 0, 0, 0.8);
    --neon-glow: 0 0 5px #fff, 0 0 10px #fff, 0 0 20px var(--primary-color), 0 0 40px var(--primary-color), 0 0 80px var(--primary-color);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    scrollbar-color: rgba(0, 240, 255, 0.5) rgba(10, 10, 20, 0.5);
    scrollbar-width: thin;
}

/* Custom Scrollbar for Webkit */
::-webkit-scrollbar {
    width: 10px;
}
::-webkit-scrollbar-track {
    background: rgba(10, 10, 20, 0.5);
    border-left: 1px solid rgba(0, 240, 255, 0.1);
}
::-webkit-scrollbar-thumb {
    background: rgba(0, 240, 255, 0.3);
    border-radius: 5px;
    border: 1px solid rgba(0, 240, 255, 0.5);
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 240, 255, 0.6);
}

body {
    font-family: 'Inter', 'Outfit', 'Noto Sans JP', sans-serif;
    background: var(--bg-gradient);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: var(--text-main);
    overflow-y: auto;
    overflow-x: hidden;
}

.container {
    width: 100%;
    max-width: 500px;
    background: var(--card-bg);
    border-radius: 16px;
    padding: 40px;
    box-shadow: var(--card-shadow), 0 0 20px rgba(0, 240, 255, 0.1);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(0, 240, 255, 0.3);
    min-height: 500px;
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 95vh;
    margin: 20px;
    transition: max-width 0.5s ease;
}

/* Adjust container width when in title screen */
body:has(#title-screen:not(.hidden)) .container,
.container.title-mode {
    max-width: 900px;
}

#title-screen .input-group,
#title-screen .btn {
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

/* Adjust container width when in game screen */
body:has(#game-screen:not(.hidden)) .container,
.container.game-mode {
    max-width: 1320px;
    padding: 20px;
}

/* Adjust container width when in lobby screen */
body:has(#lobby-screen:not(.hidden)) .container,
.container.lobby-mode {
    max-width: 1000px;
    padding: 20px 40px;
}

.screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    animation: fadeIn 0.4s ease-out;
}

/* Toast Notifications */
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 1000; }
.toast { background: rgba(0, 0, 0, 0.8); color: white; padding: 10px 20px; margin-bottom: 10px; border-radius: 4px; border-left: 4px solid var(--primary-color); animation: slideIn 0.3s, fadeOut 0.3s 2.7s; }
.toast.success { border-left: 4px solid #4cd137; }
.toast.error { border-left: 4px solid var(--danger-color); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

.hidden {
    display: none !important;
}

/* Audio Control Sliding Tab */
.audio-control-wrapper {
    position: fixed;
    top: 20px;
    right: -200px;
    display: flex;
    align-items: center;
    z-index: 2000;
    transition: right 0.3s ease;
}

.audio-control-wrapper:hover {
    right: 0;
}

.audio-control-tab {
    background: rgba(0, 0, 0, 0.7);
    color: var(--text-main);
    padding: 15px 8px;
    border-radius: 8px 0 0 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-right: none;
    cursor: pointer;
    box-shadow: -2px 0 10px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.audio-control-tab span {
    writing-mode: vertical-rl;
    text-orientation: upright;
    letter-spacing: 2px;
    font-size: 0.9rem;
    color: var(--primary-color);
    font-weight: bold;
}

.audio-control-panel {
    background: rgba(0, 0, 0, 0.7);
    padding: 15px;
    border-radius: 0 0 0 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-right: none;
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 200px;
    box-sizing: border-box;
}

.audio-control-panel label {
    font-size: 0.9rem;
    color: #fff;
    width: 55px;
}

.audio-control-panel input[type="range"] {
    accent-color: var(--primary-color);
    width: 100px;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

.game-title {
    font-size: 2.8rem;
    font-weight: 800;
    margin-bottom: 5px;
    color: #fff;
    text-shadow: var(--neon-glow);
    text-align: center;
    letter-spacing: 2px;
}

.subtitle {
    font-size: 1rem;
    color: var(--text-light);
    margin-bottom: 40px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 3px;
}

.screen-heading {
    font-size: 1.8rem;
    margin-bottom: 30px;
    color: #fff;
    text-align: center;
    text-shadow: 0 0 10px rgba(255,255,255,0.3);
}

.input-group {
    width: 100%;
    margin-bottom: 25px;
    display: flex;
    flex-direction: column;
}

.input-group label {
    font-size: 0.9rem;
    font-weight: bold;
    margin-bottom: 8px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.input-group input {
    width: 100%;
    padding: 14px 15px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    outline: none;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    box-shadow: inset 0 0 5px rgba(0,0,0,0.5);
}

.input-group input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.3);
}

.game-set-text {
    font-size: 6rem;
    font-weight: 900;
    font-style: italic;
    color: #fff;
    text-shadow: 0 0 20px var(--primary-color), 0 0 40px var(--danger-color), 0 0 60px var(--danger-color);
    animation: zoomFadeIn 2.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes zoomFadeIn {
    0% {
        opacity: 0;
        transform: scale(0.1);
    }
    15% {
        opacity: 1;
        transform: scale(1.1);
    }
    30% {
        opacity: 1;
        transform: scale(1.0);
    }
    100% {
        opacity: 1;
        transform: scale(1.0);
    }
}

.team-result-block {
    transition: all 0.3s ease;
    box-shadow: 0 0 15px rgba(255,255,255,0.2);
}

.team-result-done {
    filter: brightness(0.4);
    transform: scale(0.95);
    box-shadow: none;
}

.team-result-winner {
    filter: brightness(1.2);
    transform: scale(1.15);
    box-shadow: 0 0 30px currentColor;
    z-index: 10;
}

.winner-reveal {
    opacity: 1 !important;
    transform: scale(1) !important;
}

.bonus-reveal {
    opacity: 1 !important;
    transform: translate(-50%, -50%) scale(1) !important;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.btn {
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.primary-btn {
    background-color: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.4), inset 0 0 10px rgba(0, 240, 255, 0.2);
    text-shadow: 0 0 5px var(--primary-color);
}

.primary-btn:hover {
    background-color: rgba(0, 240, 255, 0.15);
    transform: translateY(-2px);
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.8), inset 0 0 20px rgba(0, 240, 255, 0.5);
    text-shadow: 0 0 8px #fff;
}

.secondary-btn {
    background-color: transparent;
    color: #fff;
    border: 1px solid var(--primary-color);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.2) inset;
}

.secondary-btn:hover {
    background-color: rgba(0, 240, 255, 0.1);
    transform: translateY(-2px);
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.4) inset, 0 0 15px rgba(0, 240, 255, 0.4);
}

.danger-btn {
    background-color: transparent;
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
}

.danger-btn:hover {
    background-color: rgba(255, 0, 160, 0.1);
    box-shadow: 0 0 15px rgba(255, 0, 160, 0.4) inset, 0 0 15px rgba(255, 0, 160, 0.4);
}

.text-btn {
    background: transparent;
    color: var(--text-light);
    box-shadow: none;
    font-size: 0.9rem;
}

.text-btn:hover {
    color: #fff;
    text-shadow: 0 0 5px rgba(255,255,255,0.5);
}

.mt-1 { margin-top: 10px; }
.mt-2 { margin-top: 20px; }

/* Lobby */
.room-info-card {
    background: rgba(0, 0, 0, 0.4);
    padding: 10px 15px;
    border-radius: 8px;
    text-align: center;
    margin-bottom: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-weight: bold;
    font-size: 1.1rem;
    color: #fff;
}

.selectable {
    user-select: text;
    letter-spacing: 3px;
    color: var(--primary-color);
    text-shadow: 0 0 8px rgba(0, 240, 255, 0.5);
}

.team-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    width: 100%;
    margin-bottom: 15px;
}

.team-frame {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    transition: all 0.2s ease;
}

.team-header {
    font-size: 1rem;
    font-weight: bold;
    text-align: center;
    padding-bottom: 5px;
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.team-players {
    flex-grow: 1;
    list-style: none;
    min-height: 40px;
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.team-players li {
    padding: 3px 0;
    display: flex;
    justify-content: space-between;
}

.team-actions {
    display: flex;
    gap: 5px;
    justify-content: center;
}

.team-actions button {
    padding: 6px 10px;
    font-size: 0.85rem;
    border-radius: 4px;
    cursor: pointer;
    background: transparent;
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
    transition: all 0.2s;
    white-space: nowrap;
}

.team-actions button:hover {
    background: rgba(255,255,255,0.1);
}

.player-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.05);
}

.player-icon {
    font-size: 1.2rem;
    margin-right: 10px;
}

.player-name {
    font-weight: bold;
    flex-grow: 1;
    color: #fff;
}

.host-badge {
    background: linear-gradient(45deg, #ffd700, #ff8c00);
    color: #000;
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 12px;
    font-weight: bold;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.4);
}

/* Game Screen */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 10px;
}

.status-bar {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--primary-color);
    text-shadow: 0 0 8px rgba(0, 240, 255, 0.5);
}

.game-content {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0,0,0,0.9), 0 0 25px rgba(0, 240, 255, 0.3);
    border: 2px solid rgba(0, 240, 255, 0.5);
    background: #000;
}

#game-canvas {
    display: block;
    width: 100%;
    height: auto;
    background: #111;
}

.overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
    z-index: 10;
}

#overlay-title {
    font-size: 4rem;
    color: var(--danger-color);
    text-shadow: 0 0 20px rgba(255, 0, 160, 0.6);
    margin-bottom: 20px;
    text-transform: uppercase;
}

#overlay-text {
    font-size: 2rem;
    color: #fff;
}

/* Radio button and Checkbox styling for game settings */
.mode-label {
    color: #fff;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    transition: all 0.3s ease;
}

.mode-label input {
    display: none; /* Hide default radio/checkbox */
}

input[type="radio"]:checked + .mode-text,
input[type="checkbox"]:checked + .mode-text {
    color: var(--primary-color);
    text-shadow: 0 0 10px var(--primary-color), 0 0 20px var(--primary-color);
    transform: scale(1.1);
    display: inline-block;
    transition: all 0.3s ease;
}

input[type="radio"]:not(:checked) + .mode-text {
    opacity: 0.4;
    transition: all 0.3s ease;
}

input[type="checkbox"]:not(:checked) + .mode-text {
    opacity: 0.4;
    transition: all 0.3s ease;
}

/* Stage Card Styling */
.stage-card {
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 20px;
    width: 220px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.stage-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.5);
    transform: translateY(-5px);
}

.stage-card.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 15px var(--primary-color);
    background: rgba(0, 240, 255, 0.1);
}

.stage-card h3 {
    margin-top: 0;
    color: var(--primary-color);
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.stage-card p {
    color: #fff;
    font-size: 1rem;
    margin: 0;
}

@keyframes blink {
    0% { opacity: 1; }
    50% { opacity: 0; }
    100% { opacity: 1; }
}
