        /* إخفاء شريط التمرير */
        ::-webkit-scrollbar { display: none; }
        html { -ms-overflow-style: none; scrollbar-width: none; }

        :root {
            /* Deep Ocean Tactical Theme */
            --primary-color: #00f2ff; /* Cyan Neon */
            --secondary-color: #ffd700; /* Gold */
            --accent-color: #ff0055; /* Alert Red */
            --background-start: #02111b; /* Deep Dark Blue */
            --background-end: #0c2d48; /* Navy */
            --surface-color: rgba(255, 255, 255, 0.05); /* Glassy */
            --hit-color: #ff3838;
            --miss-color: #a4b0be;
            --sunk-color: #2d3436;
            --font-family: 'AAGalaxy', sans-serif;
            --border-radius: 16px;
            --glass-border: 1px solid rgba(255, 255, 255, 0.1);
            --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
        }

        body {
            box-sizing: border-box;
            font-family: var(--font-family);
            background: linear-gradient(135deg, #02111b 0%, #14283b 50%, #0c2d48 100%);
            /* background-attachment: fixed; تم إيقاف هذا السطر لمنع مشاكل العرض في وضع ملئ الشاشة */
            margin: 0;
            padding: 20px;
            color: #ecf0f1;
            min-height: 100vh;
            overflow-x: hidden;
            overflow-y: auto;
        }

        /* Glassmorphism Common Class */
        .glass-panel {
            background: var(--surface-color);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: var(--glass-border);
            box-shadow: var(--glass-shadow);
            border-radius: var(--border-radius);
        }

        .game-container {
            max-width: 1400px;
            margin: 0 auto;
        }

        .game-header {
            text-align: center;
            margin-bottom: 40px;
            position: relative;
        }

        .game-title {
            font-size: 3.5rem;
            font-weight: 800;
            margin-bottom: 10px;
            color: transparent;
            background: linear-gradient(to right, #00f2ff, #00c6ff);
            -webkit-background-clip: text;
            background-clip: text;
            text-shadow: 0 0 30px rgba(0, 242, 255, 0.3);
            animation: float 6s ease-in-out infinite;
        }

        @keyframes float {
            0% { transform: translateY(0px); }
            50% { transform: translateY(-10px); }
            100% { transform: translateY(0px); }
        }

        /* New Style for Copyright Notice */
        .copyright-notice {
            font-size: 0.9rem;
            color: rgba(255, 255, 255, 0.5);
            margin-top: 40px;
            text-align: center;
            letter-spacing: 1px;
        }

        .game-status {
            font-size: 1.3rem;
            margin-bottom: 25px;
            padding: 15px 30px;
            background: rgba(0, 242, 255, 0.1);
            border-radius: 50px;
            display: inline-block;
            transition: all 0.3s ease;
            border: 1px solid rgba(0, 242, 255, 0.3);
            box-shadow: 0 0 15px rgba(0, 242, 255, 0.1);
        }

        .admin-controls {
            background: rgba(16, 32, 48, 0.85); /* Darker casing for "device" look */
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            border: 1px solid rgba(255, 255, 255, 0.15);
            box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6), inset 0 1px 1px rgba(255, 255, 255, 0.1);
            border-radius: 12px; /* Tighter radius for "block" feel */
            padding: 4px;
            margin: 0 auto 20px auto;
            width: fit-content; /* Reset to fit content for cohesive look */
            max-width: 98%; 
            display: flex; /* Changed from inline-flex to flex to allow margin:auto to center it */
            justify-content: flex-start; /* Changed to allow scrolling */
            gap: 2px; /* Tiny gap between segments */
            align-items: stretch;
            transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
            min-height: 54px;
            /* overflow: hidden; removed to allow internal scrollbar to work properly */
        }

        .admin-controls.collapsed {
            width: 54px; /* Collapse to square/circle */
            padding: 4px;
            border-radius: 12px; /* Match expanded shape */
            background: rgba(255, 255, 255, 0.1);
        }

        .controls-content {
            display: flex;
            align-items: stretch; /* Full height buttons */
            gap: 1px; /* Divider line gap */
            padding: 0;
            opacity: 1;
            width: 100%; /* Force it to take space */
            transition: all 0.4s ease;
            flex: 1;
            min-width: 0;
            overflow-x: auto;
            overflow-y: hidden;
            white-space: nowrap;
            background: rgba(0, 0, 0, 0.2); /* Darker inner track */
            border-radius: 8px; /* Inner radius */
            margin-left: 2px;
            scrollbar-width: none; /* Hide scrollbar for cleaner look */
            -ms-overflow-style: none;  /* IE and Edge */
            -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
            touch-action: pan-x; /* Explicitly tell browser to handle horizontal panning */
        }
        
        .controls-content::-webkit-scrollbar {
            display: none; /* Hide scrollbar for Chrome/Safari/Opera */
        }

        .admin-controls .neumorphic-btn {
            width: auto;
            flex-shrink: 0; /* Prevent buttons from shrinking */
            height: 46px; /* Match container inner height */
            padding: 0 20px;
            border-radius: 0; /* Square edges for connection */
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 10px;
            background: transparent; /* Transparent to show track */
            border: none;
            border-left: 1px solid rgba(255, 255, 255, 0.05); /* Subtle separator */
            color: rgba(255, 255, 255, 0.8);
            font-size: 0.9rem;
            font-weight: 600;
            text-shadow: none;
            box-shadow: none;
            white-space: nowrap;
            transition: all 0.2s ease;
            position: relative;
        }

        .admin-controls .neumorphic-btn:first-child {
            border-left: none;
        }

        .admin-controls .neumorphic-btn:hover {
            background: rgba(255, 255, 255, 0.1);
            color: #fff;
            transform: none; /* No movement, just light up */
            box-shadow: inset 0 0 15px rgba(0, 242, 255, 0.1);
        }

        .admin-controls .neumorphic-btn:active {
            background: rgba(0, 242, 255, 0.15);
            box-shadow: inset 0 2px 5px rgba(0,0,0,0.3);
        }

        /* Active indicator line */
        .admin-controls .neumorphic-btn::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 2px;
            background: #00f2ff;
            opacity: 0;
            transition: opacity 0.2s;
        }

        .admin-controls .neumorphic-btn:hover::after {
            opacity: 0.5;
        }

        .toggle-controls-btn {
            width: 46px;
            height: 46px;
            flex-shrink: 0;
            border-radius: 8px; /* Match inner radius */
            border: none;
            background: rgba(255, 255, 255, 0.05);
            color: rgba(255, 255, 255, 0.7);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.3s ease;
        }

        .toggle-controls-btn:hover {
            background: rgba(255, 255, 255, 0.15);
            color: #fff;
            box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.1);
        }

        .admin-controls.collapsed .toggle-controls-btn {
            background: transparent;
            margin: 0;
            width: 100%;
            height: 100%;
        }
        
        .toggle-icon {
             transition: transform 0.5s ease;
        }
        
        .admin-controls.collapsed .toggle-icon {
            transform: rotate(180deg);
        }

        
        .icon-btn {
            background: var(--surface-color);
            color: white;
            border: 1px solid rgba(255, 255, 255, 0.1);
            padding: 10px 20px;
            border-radius: 8px;
            cursor: pointer;
            font-size: 0.9rem;
            transition: all 0.3s ease;
            display: inline-flex;
            align-items: center;
            gap: 8px;
        }
        .icon-btn svg {
            width: 18px;
            height: 18px;
            fill: none;
            stroke: currentColor;
            stroke-width: 2;
            stroke-linecap: round;
            stroke-linejoin: round;
        }
        .icon-btn:hover {
            background-color: var(--primary-color);
            color: white;
            transform: translateY(-2px);
            box-shadow: 0 4px 15px rgba(0, 168, 255, 0.3);
        }
        .icon-btn:disabled {
            opacity: 0.5;
            cursor: not-allowed;
            background-color: var(--surface-color);
            transform: none;
            box-shadow: none;
        }

        .icon-btn.active {
            background-color: #27ae60;
            box-shadow: 0 0 15px rgba(39, 174, 96, 0.7);
        }
        
        /* --- New Ability Button Styles --- */
        .ability-btn {
            position: relative;
            border: none;
            background: transparent;
            padding: 0;
            cursor: pointer;
            outline-offset: 4px;
            transition: filter 250ms;
            user-select: none;
            touch-action: manipulation;
            flex-shrink: 0;
        }
        .ability-btn .shadow {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            border-radius: 12px;
            background: hsl(0deg 0% 0% / 0.25);
            will-change: transform;
            transform: translateY(2px);
            transition: transform 600ms cubic-bezier(.3, .7, .4, 1);
        }
        .ability-btn .edge {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            border-radius: 12px;
        }
        .ability-btn .front {
            display: flex; /* Use flexbox */
            align-items: center; /* Center items vertically */
            gap: 8px; /* Space between icon and text */
            position: relative;
            padding: 12px 20px;
            border-radius: 12px;
            font-size: 1rem;
            color: white;
            will-change: transform;
            transform: translateY(-4px);
            transition: transform 600ms cubic-bezier(.3, .7, .4, 1), box-shadow 300ms ease;
        }
         .ability-btn .front svg {
            width: 20px;
            height: 20px;
            flex-shrink: 0;
            overflow: visible;
        }
        .ability-btn:hover { filter: brightness(110%); }
        .ability-btn:hover .front {
            transform: translateY(-6px);
            transition: transform 250ms cubic-bezier(.3, .7, .4, 1.5);
        }
        .ability-btn:active .front {
            transform: translateY(-2px);
            transition: transform 34ms;
        }
        .ability-btn:hover .shadow {
            transform: translateY(4px);
            transition: transform 250ms cubic-bezier(.3, .7, .4, 1.5);
        }
        .ability-btn:active .shadow {
            transform: translateY(1px);
            transition: transform 34ms;
        }
        .ability-btn:focus:not(:focus-visible) { outline: none; }
        
        /* Color Variants */
        .ability-btn.radar .edge { background: linear-gradient( to left, hsl(195deg 100% 16%) 0%, hsl(195deg 100% 32%) 8%, hsl(195deg 100% 32%) 92%, hsl(195deg 100% 16%) 100% );}
        .ability-btn.radar .front { background: hsl(195deg 100% 47%); }
        
        .ability-btn.double-shot .edge { background: linear-gradient( to left, hsl(140deg 100% 16%) 0%, hsl(140deg 100% 32%) 8%, hsl(140deg 100% 32%) 92%, hsl(140deg 100% 16%) 100% );}
        .ability-btn.double-shot .front { background: hsl(140deg 100% 47%); }

        /* States */
        .ability-btn.active .front {
            transform: translateY(-6px);
            box-shadow: 0 0 15px 3px var(--secondary-color);
        }
        .ability-btn.used {
            filter: grayscale(1);
            cursor: not-allowed;
            pointer-events: none; /* Make it unclickable */
        }
        .ability-btn.used .front { transform: translateY(-2px); }
        .ability-btn.used .shadow { transform: translateY(1px); }
        .ability-btn.used:hover .front, .ability-btn.used:active .front { transform: translateY(-2px); }
        .ability-btn.used:hover .shadow, .ability-btn.used:active .shadow { transform: translateY(1px); }

        .cloud-slots-container {
            display: flex;
            flex-direction: column;
            gap: 15px;
            padding: 20px;
        }
        .cloud-slot {
            background: rgba(255, 255, 255, 0.05);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 12px;
            padding: 15px;
            display: flex;
            flex-direction: column; /* Changed to column for card layout */
            gap: 12px;
            transition: all 0.3s ease;
        }
        .cloud-slot:hover {
            background: rgba(255, 255, 255, 0.1);
            border-color: rgba(0, 242, 255, 0.3);
            transform: translateY(-2px);
        }
        .slot-info {
            width: 100%;
        }
        .slot-header-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 8px;
        }
        .slot-title {
            font-weight: bold;
            font-size: 1.1rem;
            color: var(--primary-color);
            display: flex;
            align-items: center;
            gap: 8px;
        }
        .slot-status-badge {
            font-size: 0.75rem;
            padding: 2px 8px;
            border-radius: 10px;
            background: rgba(255,255,255,0.1);
            color: #94a3b8;
        }
        .slot-status-badge.active {
            background: rgba(74, 222, 128, 0.2);
            color: #4ade80;
        }
        .slot-details-box {
            background: rgba(0,0,0,0.2);
            padding: 10px;
            border-radius: 6px;
            font-size: 0.85rem;
            color: rgba(255,255,255,0.7);
            line-height: 1.4;
            border-left: 3px solid transparent;
        }
        .slot-details-box.has-data {
            border-left-color: var(--secondary-color);
        }
        .slot-actions-row {
            display: flex;
            justify-content: flex-end;
            gap: 10px;
            width: 100%;
            border-top: 1px solid rgba(255,255,255,0.05);
            padding-top: 10px;
        }
        .small-btn {
            padding: 5px 12px;
            font-size: 0.85rem;
        }

        
        /* Neumorphic Button Style */
        .neumorphic-btn {
            color: #ecf0f1;
            padding: 10px 20px;
            font-size: 0.95rem;
            border-radius: 30px;
            background: rgba(255, 255, 255, 0.05);
            cursor: pointer;
            border: 2px solid rgba(255, 255, 255, 0.6); /* Clearer border */
            transition: all 0.3s ease;
            font-weight: bold;
            display: inline-flex;
            align-items: center;
            gap: 8px;
            font-family: var(--font-family);
            backdrop-filter: blur(5px);
        }


        
        .neumorphic-btn svg {
             width: 22px;
            height: 22px;
            stroke: currentColor;
            stroke-width: 2; /* Reduced to avoid clipping */
            overflow: visible;
        }

        .turn-switch-btn {
            background: rgba(255, 255, 255, 0.1);
            border: 2px solid rgba(255, 255, 255, 0.6);
            border-radius: 20px;
            color: white;
            padding: 5px 12px;
            font-size: 0.85rem;
            cursor: pointer;
            display: none; /* Hidden by default */
            align-items: center;
            gap: 6px;
            transition: all 0.3s ease;
            margin: 0 10px;
            font-family: var(--font-family);
            box-shadow: 0 0 5px rgba(0,0,0,0.2);
        }

        body.battle-phase .turn-switch-btn {
            display: inline-flex;
        }

        .turn-switch-btn:hover {
            background: rgba(255, 255, 255, 0.2);
            border-color: var(--primary-color);
            transform: translateY(-2px);
            box-shadow: 0 0 10px rgba(0, 242, 255, 0.3);
        }

        .turn-switch-btn:active {
            transform: translateY(0);
        }

        .turn-switch-btn svg {
            width: 16px;
            height: 16px;
            stroke-width: 2;
            overflow: visible;
        }

        .team-section.current-turn-highlight .turn-switch-btn {
            background: linear-gradient(135deg, #2ecc71, #27ae60);
            border-color: #2ecc71;
            box-shadow: 0 0 15px rgba(46, 204, 113, 0.5);
            animation: pulse-green-btn 2s infinite;
        }

        @keyframes pulse-green-btn {
            0% { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.7); }
            70% { box-shadow: 0 0 0 8px rgba(46, 204, 113, 0); }
            100% { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0); }
        }


        .neumorphic-btn:hover {
            background: rgba(0, 242, 255, 0.1);
            border-color: var(--primary-color);
            color: var(--primary-color);
            box-shadow: 0 0 15px rgba(0, 242, 255, 0.3);
            transform: translateY(-2px);
        }

        .neumorphic-btn:active {
            transform: translateY(1px);
        }


        .turn-control-panel {
            background: var(--surface-color);
            backdrop-filter: blur(12px);
            border: var(--glass-border);
            box-shadow: var(--glass-shadow);
            border-radius: var(--border-radius);
            padding: 25px;
            margin-bottom: 25px;
        }
        .turn-tools-row {
            margin-top: 15px;
            padding: 10px 15px;
            border-radius: 16px;
            background: rgba(0,0,0,0.25);
            border: 1px solid rgba(255,255,255,0.08);
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            justify-content: center;
            gap: 10px 18px;
        }
        .turn-tools-group {
            display: flex;
            align-items: center;
            gap: 8px;
        }
        .shots-segment {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            padding: 4px;
            border-radius: 999px;
            background: rgba(0,0,0,0.35);
            border: 1px solid rgba(255,255,255,0.12);
        }
        .shots-pill {
            min-width: 26px;
            height: 26px;
            border-radius: 999px;
            border: none;
            cursor: pointer;
            font-size: 0.8rem;
            font-weight: bold;
            color: #ecf0f1;
            background: transparent;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s ease;
        }
        .shots-pill.active {
            background: linear-gradient(135deg, #2ecc71, #27ae60);
            box-shadow: 0 0 10px rgba(46, 204, 113, 0.5);
        }
        .auto-advance-toggle {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 4px 10px;
            border-radius: 999px;
            background: rgba(0,0,0,0.35);
            border: 1px solid rgba(255,255,255,0.12);
            color: #ecf0f1;
            font-size: 0.8rem;
        }
        .auto-advance-toggle .switch {
            width: 36px;
            height: 18px;
            border-radius: 999px;
            background: rgba(255,255,255,0.2);
            position: relative;
            transition: background 0.2s ease;
        }
        .auto-advance-toggle .thumb {
            position: absolute;
            top: 2px;
            left: 2px;
            width: 14px;
            height: 14px;
            border-radius: 50%;
            background: #ecf0f1;
            transition: transform 0.2s ease;
        }
        .auto-advance-toggle input:checked + .switch {
            background: linear-gradient(135deg, #2ecc71, #27ae60);
        }
        .auto-advance-toggle input:checked + .switch .thumb {
            transform: translateX(16px);
        }

        .panel-order-btn {
            position: absolute;
            top: 0;
            left: 0;
            border-radius: 999px;
            border: 1px solid rgba(255,255,255,0.4);
            background: rgba(0,0,0,0.35);
            color: #ecf0f1;
            font-size: 0.7rem;
            padding: 2px 8px;
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            gap: 4px;
            transition: all 0.2s ease;
        }
        .panel-order-btn:hover {
            background: rgba(0, 242, 255, 0.15);
            border-color: var(--primary-color);
            transform: translateY(-1px);
        }
        .turn-control-title {
            position: relative;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            font-size: 1.3rem;
            font-weight: bold;
            margin-bottom: 20px;
            color: var(--primary-color);
            text-transform: uppercase;
            letter-spacing: 2px;
        }
      
        .timer-display {
            background: rgba(0,0,0,0.4);
            border-radius: 15px;
            padding: 20px;
            text-align: center;
            border: 2px solid #27ae60;
            transition: all 0.3s ease;
            min-width: 140px;
            box-shadow: 0 0 20px rgba(39, 174, 96, 0.2);
        }
        .timer-value {
            font-size: 3rem;
            font-weight: bold;
            color: #27ae60;
            margin-bottom: 5px;
            font-family: 'Courier New', monospace;
            text-shadow: 0 0 10px rgba(39, 174, 96, 0.5);
        }
        .timer-label {
            font-size: 0.9rem;
            opacity: 0.8;
            letter-spacing: 1px;
        }
        .timer-warning {
            animation: pulse 1s infinite;
            border-color: #f39c12 !important;
            box-shadow: 0 0 20px rgba(243, 156, 18, 0.2);
        }
        .timer-warning .timer-value { color: #f39c12 !important; text-shadow: 0 0 10px rgba(243, 156, 18, 0.5); }
        .timer-danger {
            animation: pulse 0.5s infinite;
            border-color: var(--hit-color) !important;
            box-shadow: 0 0 20px rgba(255, 56, 56, 0.3);
        }
        .timer-danger .timer-value { color: var(--hit-color) !important; text-shadow: 0 0 10px rgba(255, 56, 56, 0.5); }
        .timer-expired {
            background: rgba(231, 76, 60, 0.3) !important;
            border-color: #c0392b !important;
        }
        .current-player-display {
            background: rgba(0, 242, 255, 0.1);
            border-radius: 15px;
            padding: 20px;
            text-align: center;
            color: white;
            flex-grow: 1;
            border: 1px solid rgba(0, 242, 255, 0.2);
            box-shadow: 0 0 20px rgba(0, 242, 255, 0.1);
        }
        .current-player-name {
            font-size: 2rem;
            font-weight: bold;
            margin-bottom: 5px;
            text-shadow: 0 0 10px rgba(0, 242, 255, 0.5);
        }
        .current-player-status { font-size: 1rem; opacity: 0.9; }
        .turn-actions {
            display: flex;
            justify-content: center;
            gap: 15px;
            flex-wrap: wrap;
        }
        .turn-btn {
            color: white;
            border-radius: 50px;
            background: rgba(255, 255, 255, 0.1);
            cursor: pointer;
            border: 1px solid rgba(255, 255, 255, 0.2);
            transition: all 0.3s;
            font-weight: bold;
            font-family: var(--font-family);
            margin: 0;
            padding: 10px 25px;
            backdrop-filter: blur(5px);
        }
        .turn-btn:hover {
            transform: translateY(-2px);
            background: rgba(255, 255, 255, 0.2);
        }
        .turn-btn:active {
            transform: translateY(1px);
        }
        .turn-btn.success {
            background: linear-gradient(135deg, #2ecc71, #27ae60);
            border: none;
            box-shadow: 0 5px 15px rgba(46, 204, 113, 0.3);
        }
        .turn-btn.success:hover {
            box-shadow: 0 8px 20px rgba(46, 204, 113, 0.5);
        }
        .turn-btn.danger {
            background: linear-gradient(135deg, #e74c3c, #c0392b);
            border: none;
            box-shadow: 0 5px 15px rgba(231, 76, 60, 0.3);
        }
        .turn-btn.danger:hover {
            box-shadow: 0 8px 20px rgba(231, 76, 60, 0.5);
        }
        .turn-btn.warning {
            background: linear-gradient(135deg, #f1c40f, #f39c12);
            color: #000;
            border: none;
            box-shadow: 0 5px 15px rgba(241, 196, 15, 0.3);
        }
        .turn-btn.warning:hover {
            box-shadow: 0 8px 20px rgba(241, 196, 15, 0.5);
        }

        .setting-group { margin-bottom: 15px; }
        .setting-label {
            display: block;
            margin-bottom: 8px;
            font-weight: bold;
            font-size: 0.9rem;
            text-align: center;
            color: var(--secondary-color);
        }
        .setting-input {
            width: 70px; /* Reduced width */
            margin: 0 auto; /* Center it */
            padding: 8px 5px;
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 8px;
            background: rgba(0,0,0,0.4);
            color: var(--primary-color);
            font-size: 1rem;
            text-align: center;
            font-weight: bold;
            transition: all 0.3s ease;
        }
        .setting-input:focus {
            outline: none;
            background: rgba(0,0,0,0.6);
            border-color: var(--primary-color);
            box-shadow: 0 0 10px rgba(0, 242, 255, 0.3);
        }

        .turn-history {
            background: rgba(0,0,0,0.3);
            border-radius: 10px;
            padding: 15px;
            max-height: 200px;
            overflow-y: auto;
            margin-top: 20px;
            border: 1px solid rgba(255, 255, 255, 0.05);
        }
        .turn-history-item {
            padding: 10px;
            margin-bottom: 8px;
            background: rgba(255,255,255,0.05);
            border-radius: 6px;
            font-size: 0.85rem;
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-left: 3px solid var(--primary-color);
        }
        .auto-advance-indicator {
            display: inline-block;
            width: 10px;
            height: 10px;
            border-radius: 50%;
            background: #2ecc71;
            margin-left: 10px;
            animation: blink 1s infinite;
            box-shadow: 0 0 10px #2ecc71;
        }

        /* New Turn Control Panel Layout */
        .main-turn-display {
            display: flex;
            justify-content: space-around;
            align-items: center;
            gap: 20px;
            margin-bottom: 20px;
        }
        .main-actions {
            display: grid;
            grid-template-columns: 1fr 1.5fr 1fr;
            gap: 10px;
            margin-bottom: 20px;
        }
        .main-actions .turn-btn {
            padding: 15px 10px;
            font-size: 1rem;
            font-weight: bold;
        }
        #startTimer, #pauseTimer {
            grid-column: 2 / 3; /* Center button */
            background: var(--secondary-color);
            color: #1c252c;
            border-color: #b34a00;
        }
        #startTimer:hover, #pauseTimer:hover {
            background: #d35400;
            color: white !important;
            border-color: #d35400 !important;
        }
        
        .secondary-controls-wrapper {
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 10px;
            margin-top: 20px;
            min-height: 50px; /* Prevent layout shift */
        }



        .setting-input[type="number"] {
            width: 90px;
        }
        .secondary-actions {
            margin-bottom: 0;
            display: flex;
            gap: 10px;
            align-items: flex-end;
        }
        .secondary-actions .neumorphic-btn {
            padding: 8px 15px;
            font-size: 0.9rem;
            white-space: nowrap; /* Prevent button text from wrapping */
        }

        .scoreboard {
            background: rgba(0, 0, 0, 0.2);
            border-radius: var(--border-radius);
            padding: 20px;
            margin-bottom: 20px;
            border: 1px solid rgba(255, 255, 255, 0.1);
        }
        .scoreboard-title {
            position: relative;
            text-align: center;
            font-size: 1.4rem;
            font-weight: bold;
            margin-bottom: 15px;
            color: var(--secondary-color);
        }
        .scores-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 15px;
        }
        .score-card {
            background: rgba(0,0,0,0.3);
            border-radius: 10px;
            padding: 15px;
            text-align: center;
            border-left: 4px solid;
            transition: transform 0.3s ease;
        }
        .score-card:hover { transform: scale(1.03); }
        .score-card.rank-1 { border-left-color: var(--secondary-color); }
        .score-card.rank-2 { border-left-color: var(--miss-color); }
        .score-card.rank-3 { border-left-color: #e67e22; }

        .team-score-name { font-size: 1.1rem; font-weight: bold; margin-bottom: 10px; }
        .team-total-score {
            font-size: 2rem;
            font-weight: bold;
            color: var(--secondary-color);
            margin-bottom: 10px;
        }
        .score-details {
            font-size: 0.8rem;
            opacity: 0.8;
            line-height: 1.4;
        }

        .teams-container {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
            gap: 30px;
            margin-bottom: 30px;
        }

        /* Simplified layout for teams on large screens */
        @media (min-width: 1200px) {
             body.teams-2 .teams-container {
                grid-template-columns: repeat(2, 1fr);
            }
             body.teams-3 .teams-container {
                grid-template-columns: repeat(3, 1fr);
            }
             body.compact-layout.teams-3 .teams-container {
                grid-template-columns: repeat(2, 1fr);
            }
             body.teams-4 .teams-container {
                grid-template-columns: repeat(2, 1fr);
            }
             body.teams-5 .teams-container {
                grid-template-columns: repeat(2, 1fr);
            }
             body.compact-layout.teams-5 .teams-container {
                grid-template-columns: repeat(3, 1fr);
            }
             body.teams-6 .teams-container {
                grid-template-columns: repeat(3, 1fr);
            }
        }

        .team-section {
            background: var(--surface-color);
            backdrop-filter: blur(12px);
            border: var(--glass-border);
            box-shadow: var(--glass-shadow);
            border-radius: var(--border-radius);
            padding: 10px; /* Reduced padding from 20px */
            transition: all 0.3s ease;
            border-left: 5px solid rgba(255, 255, 255, 0.2);
            position: relative;
            overflow: hidden;
        }
        .team-section::before {
            content: '';
            position: absolute;
            top: 0; left: 0; right: 0; height: 100%;
            background: linear-gradient(180deg, rgba(255,255,255,0.05) 0%, transparent 100%);
            pointer-events: none;
        }
        .team-section:hover {
            transform: translateY(-5px);
            box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
            border-color: rgba(255, 255, 255, 0.3);
        }
        .team-section.current-turn-highlight {
            box-shadow: 0 0 30px rgba(255, 215, 0, 0.3);
            border-color: var(--secondary-color) !important;
            background: rgba(255, 215, 0, 0.05);
        }
        .team-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            padding-bottom: 10px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        }
        .team-name { font-size: 1.5rem; font-weight: 800; letter-spacing: 1px; }
        .ships-status { font-size: 0.9rem; opacity: 0.7; font-family: monospace; }
        
        /* .switch-turn-btn removed, replaced by .turn-indicator-circle */

        .abilities-container {
            display: none;
            justify-content: center;
            gap: 15px;
            margin-top: 20px;
            padding-top: 20px;
            border-top: 1px solid rgba(255, 255, 255, 0.1);
        }
        .team-section.current-turn-highlight .abilities-container {
            display: flex;
        }

        .grid-container {
            display: flex;
            flex-direction: column;
            margin-bottom: 15px;
        }
        .grid-header {
            display: grid;
            grid-template-columns: 20px repeat(var(--grid-width, 7), 1fr); /* Reduced label width */
            gap: 2px; /* Reduced gap */
            margin-bottom: 4px; /* Reduced margin */
            padding: 0 5px; /* Reduced padding */
        }
        .grid-header-cell {
            height: 20px; /* Reduced height */
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            font-size: 0.85rem; /* Slightly smaller font */
            color: var(--primary-color);
            text-shadow: 0 0 5px rgba(0, 242, 255, 0.5);
        }
        .grid-with-labels {
            display: grid;
            grid-template-columns: 20px 1fr; /* Reduced label column width */
            gap: 4px; /* Reduced gap */
            background: rgba(0,0,0,0.1); /* Reduced background opacity */
            padding: 5px; /* Significantly reduced padding from 15px */
            border-radius: 12px; /* Adjusted radius */
            border: 1px solid rgba(255, 255, 255, 0.05);
        }
        .grid-labels {
            display: flex;
            flex-direction: column;
            gap: 2px; /* Reduced gap */
        }
        .grid-label {
            flex-grow: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            font-size: 0.85rem; /* Slightly smaller font */
            color: var(--primary-color);
            text-shadow: 0 0 5px rgba(0, 242, 255, 0.5);
        }
        .grid {
            display: grid;
            grid-template-columns: repeat(var(--grid-width, 7), 1fr);
            gap: 2px; /* Reduced gap from 4px */
        }

        .cell {
            aspect-ratio: 1;
            /* Optimized for performance: Solid color instead of complex gradient/shadows */
            background: rgba(0, 100, 170, 0.4); 
            border: 1px solid rgba(0, 191, 255, 0.25);
            cursor: pointer;
            /* Optimized transition */
            transition: scale 0.2s ease, transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            border-radius: 2px; /* Reduced radius from 6px */
            position: relative;
            overflow: hidden;
        }
        .cell:hover {
            scale: 1.05; /* Reduced scale slightly */
            background: rgba(0, 140, 200, 0.6);
            box-shadow: 0 0 10px rgba(0, 242, 255, 0.3); /* Reduced shadow spread */
            z-index: 10;
            border-color: var(--primary-color);
        }
        .cell.ship, .cell.mine { background: rgba(255, 255, 255, 0.05); }
        
        .cell.hit { 
            background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.6), rgba(255,140,0,0.3), transparent 70%);
            box-shadow: inset 0 0 22px var(--hit-color);
            border-color: var(--hit-color);
            animation: hitPulse 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
        }
        .cell.hit::after {
            content: '💥';
            font-size: 1.6rem;
            display: flex;
            align-items: center;
            justify-content: center;
            width: 100%;
            height: 100%;
        }
        
        .cell.miss {
            background: rgba(0, 80, 140, 0.3);
            box-shadow: inset 0 0 10px var(--miss-color);
            border-color: var(--miss-color);
        }
        .cell.miss::after {
            content: '';
            position: absolute;
            left: 50%;
            top: 50%;
            width: 20%;
            height: 20%;
            border-radius: 50%;
            border: 2px solid var(--miss-color);
            background: transparent;
            transform: translate(-50%, -50%) scale(0.4);
            opacity: 0.9;
            animation: missRipple 0.6s ease-out forwards;
        }

        .cell.sunk { 
            background: rgba(45, 52, 54, 0.8);
            border-color: #000;
            animation: sunkPulse 2s infinite;
        }
        .cell.sinking-ship { animation: sinkingShip 1.5s ease forwards; }
        .cell.ship.sunk.ship-reveal,
        .cell.ship.ship-reveal {
            animation: shipReveal 0.45s ease-out forwards;
        }
        .cell.mine.mine-reveal::after {
            content: '';
            position: absolute;
            left: 50%;
            top: 50%;
            width: 30%;
            height: 30%;
            border-radius: 50%;
            border: 3px solid rgba(255, 255, 255, 0.8);
            background: radial-gradient(circle, rgba(255, 255, 255, 0.55), transparent 70%);
            transform: translate(-50%, -50%) scale(0.4);
            opacity: 0.9;
            pointer-events: none;
            animation: mineReveal 0.7s ease-out forwards;
        }
        .cell.shark.shark-reveal::before {
            content: '';
            position: absolute;
            left: 50%;
            top: 50%;
            width: 40%;
            height: 40%;
            border-radius: 50%;
            border: 2px solid rgba(255, 0, 0, 0.85);
            transform-origin: center;
            transform: translate(-50%, -50%) scale(0.7);
            pointer-events: none;
            box-shadow: 0 0 10px rgba(255, 0, 0, 0.8);
            animation: sharkPulse 0.55s ease-out 3;
        }
        
        .cell.radar-reveal.water { animation: radarPulseWater 1.5s infinite; background: rgba(0, 242, 255, 0.1); }
        .cell.radar-reveal.hit { animation: radarPulseHit 1.5s infinite; background: rgba(255, 0, 0, 0.2); }
        .cell.radar-preview {
            background-color: rgba(0, 242, 255, 0.2) !important;
            box-shadow: 0 0 20px var(--primary-color);
            border-color: var(--primary-color);
        }

        /* Define Animations */
        @keyframes hitPulse {
            0% { transform: scale(1); box-shadow: inset 0 0 0 rgba(255, 255, 255, 0.8), 0 0 0 rgba(255, 255, 255, 0.5); }
            35% { transform: scale(1.12); box-shadow: inset 0 0 26px var(--hit-color), 0 0 18px rgba(255, 255, 255, 0.9); }
            100% { transform: scale(1); box-shadow: inset 0 0 14px var(--hit-color); }
        }
        @keyframes missRipple {
            0% { transform: translate(-50%, -50%) scale(0.4); opacity: 0.9; }
            100% { transform: translate(-50%, -50%) scale(1.8); opacity: 0; }
        }
        @keyframes shipReveal {
            0% { transform: scale(0.95); filter: brightness(1.1); box-shadow: 0 0 0 var(--ship-wave-color, #ffffff); }
            40% { transform: scale(1.08); filter: brightness(1.4); box-shadow: 0 0 18px var(--ship-wave-color, #ffffff); }
            100% { transform: scale(1); filter: brightness(1); box-shadow: 0 0 6px rgba(0,0,0,0.4); }
        }
        @keyframes mineReveal {
            0% { transform: translate(-50%, -50%) scale(0.4); opacity: 0.9; }
            100% { transform: translate(-50%, -50%) scale(2.1); opacity: 0; }
        }
        @keyframes sharkPulse {
            0% { transform: translate(-50%, -50%) scale(0.7); opacity: 0.9; box-shadow: 0 0 10px rgba(255,0,0,0.85); }
            100% { transform: translate(-50%, -50%) scale(1.9); opacity: 0; box-shadow: 0 0 22px rgba(255,0,0,0); }
        }

        .controls { text-align: center; margin-bottom: 25px; }
        .btn {
            background: linear-gradient(135deg, var(--primary-color), #0097e6);
            color: #02111b;
            border: none;
            padding: 12px 35px;
            border-radius: 50px;
            cursor: pointer;
            font-size: 1.1rem;
            font-weight: 800;
            margin: 0 10px;
            transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
            box-shadow: 0 5px 20px rgba(0, 242, 255, 0.3);
            text-transform: uppercase;
            letter-spacing: 1px;
        }
        .btn:hover {
            transform: translateY(-4px) scale(1.05);
            box-shadow: 0 10px 30px rgba(0, 242, 255, 0.5);
            filter: brightness(1.1);
        }
        .btn:disabled {
            opacity: 0.5;
            cursor: not-allowed;
            transform: none;
            filter: grayscale(1);
            background: var(--surface-color);
            color: #aaa;
            box-shadow: none;
        }

        .ships-dock {
            background: var(--surface-color);
            backdrop-filter: blur(12px);
            border: var(--glass-border);
            box-shadow: var(--glass-shadow);
            border-radius: var(--border-radius);
            padding: 25px;
            margin-bottom: 25px;
            text-align: center;
        }
        .dock-title { font-size: 1.2rem; font-weight: bold; margin-bottom: 15px; color: var(--secondary-color); }
        .ships-container {
            display: flex;
            justify-content: center;
            gap: 20px;
            flex-wrap: wrap;
        }
        .ship-item-container {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 8px;
        }
        .counter-controls {
            display: flex;
            align-items: center;
            gap: 10px;
        }
        .count-arrow {
            background: var(--surface-color);
            color: white;
            border: 1px solid rgba(255,255,255,0.2);
            border-radius: 50%;
            width: 24px;
            height: 24px;
            cursor: pointer;
            font-size: 1rem;
            line-height: 1;
            transition: all 0.2s ease;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .count-arrow:hover {
            background-color: var(--primary-color);
        }
        .count-arrow:disabled {
            opacity: 0.3;
            cursor: not-allowed;
            background-color: var(--surface-color);
        }
        .ship-counter {
            background: rgba(0, 0, 0, 0.6);
            color: var(--secondary-color);
            font-weight: bold;
            padding: 3px 12px;
            border-radius: 20px;
            font-size: 1rem;
            border: 1px solid rgba(255, 255, 255, 0.1);
        }

        .draggable-ship {
            display: flex;
            gap: 2px;
            cursor: grab;
            transition: all 0.3s ease;
            padding: 5px;
            border-radius: 8px;
            background: rgba(0, 0, 0, 0.5);
            border: 2px solid transparent;
        }
        .draggable-ship:hover { transform: scale(1.1); border-color: var(--secondary-color); }
        .draggable-ship.dragging { cursor: grabbing; opacity: 0.7; transform: rotate(5deg); }
        .draggable-ship.vertical { flex-direction: column; }
        .draggable-ship.placed {
            opacity: 0.3;
            cursor: not-allowed;
            pointer-events: none;
        }
        .ship-part {
            width: 30px;
            height: 30px;
            background-color: var(--surface-color);
            border: 1px solid var(--background-start);
            border-radius: 3px;
            transition: transform 0.3s ease;
        }
        .draggable-ship.vertical .ship-part {
            transform: rotate(90deg);
        }
        .cell.vertical-ship-part, .cell.shark.vertical-ship-part {
            transform: rotate(90deg) !important;
        }
        .ship-part, .cell.ship, .cell.shark {
            background-size: contain;
            background-repeat: no-repeat;
            background-position: center;
            background-color: transparent;
        }

        .ship-part.single-ship, .cell.ship.single-ship { background-image: url('https://i.postimg.cc/hG9FCk67/image.png'); }
        
        .ship-part.ship-2-part-1, .cell.ship.ship-2-part-1 { background-image: url('https://i.postimg.cc/Y0Sgj3M9/3.png'); }
        .ship-part.ship-2-part-2, .cell.ship.ship-2-part-2 { background-image: url('https://i.postimg.cc/gj0RrDm9/4.png'); }
        
        .ship-part.ship-3-part-1, .cell.ship.ship-3-part-1 { background-image: url('https://i.postimg.cc/8cZTK7zj/4.png'); }
        .ship-part.ship-3-part-2, .cell.ship.ship-3-part-2 { background-image: url('https://i.postimg.cc/Y0dtnvCm/3.png'); }
        .ship-part.ship-3-part-3, .cell.ship.ship-3-part-3 { background-image: url('https://i.postimg.cc/90Lc8DQw/2.png'); }

        .ship-part.ship-4-part-1, .cell.ship.ship-4-part-1 { background-image: url('https://i.postimg.cc/T1nWhY4K/14.png'); }
        .ship-part.ship-4-part-2, .cell.ship.ship-4-part-2 { background-image: url('https://i.postimg.cc/0j7Jr2Bb/13.png'); }
        .ship-part.ship-4-part-3, .cell.ship.ship-4-part-3 { background-image: url('https://i.postimg.cc/Xq9yX7zX/12.png'); }
        .ship-part.ship-4-part-4, .cell.ship.ship-4-part-4 { background-image: url('https://i.postimg.cc/Kz6MZgJ8/11.png'); }
        
        .ship-part.ship-5-part-1, .cell.ship.ship-5-part-1 { background-image: url('https://i.postimg.cc/B6SJG7BP/6.png'); }
        .ship-part.ship-5-part-2, .cell.ship.ship-5-part-2 { background-image: url('https://i.postimg.cc/LXx24kx9/7.png'); }
        .ship-part.ship-5-part-3, .cell.ship.ship-5-part-3 { background-image: url('https://i.postimg.cc/sXTsfPT2/8.png'); }
        .ship-part.ship-5-part-4, .cell.ship.ship-5-part-4 { background-image: url('https://i.postimg.cc/j5Mtq6ML/9.png'); }
        .ship-part.ship-5-part-5, .cell.ship.ship-5-part-5 { background-image: url('https://i.postimg.cc/G2Xd3PXB/10.png'); }

        .mine-image {
            width: 100%;
            height: 100%;
            display: block;
            object-fit: contain;
        }


        .rotate-btn {
            background: #e67e22;
            color: white;
            border: none;
            padding: 5px 10px;
            border-radius: 15px;
            cursor: pointer;
            font-size: 0.8rem;
            margin-top: 5px;
            transition: all 0.2s ease;
        }
        .rotate-btn:hover { background: #d35400; transform: scale(1.05); }

        .cell.drag-over { background: #f39c12 !important; }
        .cell.invalid-drop { background: var(--hit-color) !important; }

        .modal {
            display: none;
            position: fixed;
            z-index: 1000;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0,0,0,0.8);
            backdrop-filter: blur(5px);
            animation: fadeIn 0.3s ease;
        }
        .modal-content {
            background: rgba(2, 17, 27, 0.9);
            background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.05), rgba(2, 17, 27, 0.95));
            margin: 5% auto;
            padding: 30px;
            border-radius: 15px;
            width: 90%;
            max-width: 800px;
            max-height: 85vh;
            overflow-y: auto;
            color: var(--text-color);
            animation: slideInUp 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
            border: 1px solid rgba(0, 242, 255, 0.2);
            box-shadow: 0 0 50px rgba(0, 0, 0, 0.8), 0 0 15px rgba(0, 242, 255, 0.1);
            backdrop-filter: blur(15px);
            -webkit-backdrop-filter: blur(15px);
        }

        /* Show scrollbar for modal content */
        .modal-content::-webkit-scrollbar {
            display: block;
            width: 8px;
        }
        .modal-content::-webkit-scrollbar-track {
            background: rgba(0, 0, 0, 0.2);
            border-radius: 4px;
        }
        .modal-content::-webkit-scrollbar-thumb {
            background: rgba(0, 242, 255, 0.3);
            border-radius: 4px;
        }
        .modal-content::-webkit-scrollbar-thumb:hover {
            background: rgba(0, 242, 255, 0.5);
        }
        /* For Firefox */
        .modal-content {
            scrollbar-width: thin;
            scrollbar-color: rgba(0, 242, 255, 0.3) rgba(0, 0, 0, 0.2);
        }
        .modal-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            border-bottom: 2px solid var(--secondary-color);
            padding-bottom: 10px;
        }
        .modal-title { font-size: 1.5rem; font-weight: bold; color: var(--secondary-color); }
        .close { color: #aaa; font-size: 28px; font-weight: bold; cursor: pointer; transition: color 0.3s; }
        .close:hover { color: white; }

        /* --- START: How to Play Modal Styles --- */
        .modal-body-how-to-play {
            line-height: 1.7;
            font-size: 1.1rem;
        }
        .modal-body-how-to-play h2 {
            color: var(--secondary-color);
            font-size: 1.4rem;
            border-bottom: 1px solid var(--primary-color);
            padding-bottom: 5px;
            margin-top: 20px;
        }
        .modal-body-how-to-play h3 {
            color: var(--primary-color);
            font-size: 1.2rem;
            margin-top: 15px;
        }
        .modal-body-how-to-play ul {
            list-style-type: '🚢';
            padding-right: 30px; /* Space for custom bullet */
        }
        .modal-body-how-to-play li {
            margin-bottom: 10px;
            padding-right: 10px; /* Space between bullet and text */
        }
        .modal-body-how-to-play li::marker {
            font-size: 1.2em;
        }
        .modal-body-how-to-play .points-list-pro {
            list-style-type: '👍';
        }
        .modal-body-how-to-play .points-list-con {
            list-style-type: '👎';
        }
        .modal-body-how-to-play .highlight {
            color: var(--secondary-color);
            font-weight: bold;
        }
         /* --- END: How to Play Modal Styles --- */


        .confirm-actions {
            text-align: center;
            margin-top: 25px;
            display: flex;
            justify-content: center;
            gap: 15px;
        }
        .btn-yes { background-image: linear-gradient(to right, #44bd32, #4cd137); }
        .btn-yes:hover { box-shadow: 0 10px 30px rgba(76, 209, 55, 0.4); }
        .btn-no { background-image: linear-gradient(to right, var(--hit-color), #c23616); }
        .btn-no:hover { box-shadow: 0 10px 30px rgba(232, 65, 24, 0.4); }


        .settings-section { margin-bottom: 25px; background: rgba(0,0,0,0.2); padding: 20px; border-radius: 10px; }
        .settings-title { font-size: 1.2rem; font-weight: bold; margin-bottom: 15px; color: var(--primary-color); }
        .form-group { margin-bottom: 20px; text-align: right; }
        .form-label { display: block; margin-bottom: 8px; font-weight: bold; color: #ccc; }
        .form-input {
            width: 100%;
            padding: 10px 12px;
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 8px;
            background: rgba(0,0,0,0.2);
            color: white;
            font-size: 1rem;
            text-align: right;
            display: block;
            box-sizing: border-box;
        }
        .form-input[type="number"] {
            width: 100%;
            text-align: center;
        }
        .team-settings-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
            gap: 15px;
        }
        .team-card {
            background: rgba(255, 255, 255, 0.05);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 12px;
            padding: 15px;
            display: flex;
            flex-direction: column;
            gap: 12px;
            position: relative;
            transition: transform 0.2s, border-color 0.2s;
        }
        .team-card:hover {
            transform: translateY(-2px);
            border-color: rgba(255, 255, 255, 0.3);
        }
        
        /* Victory Modal Styles */
        .modal-content.victory-modal-content {
            background: linear-gradient(135deg, rgba(20, 30, 48, 0.95), rgba(36, 59, 85, 0.95));
            border: 2px solid var(--primary-color);
            text-align: center;
            padding: 40px;
            max-width: 500px;
            box-shadow: 0 0 50px rgba(0, 242, 255, 0.3);
        }
        .victory-icon { font-size: 5rem; margin-bottom: 20px; animation: bounce 2s infinite; }
        .victory-title { font-size: 2.5rem; color: var(--primary-color); margin-bottom: 10px; text-shadow: 0 0 10px rgba(0, 242, 255, 0.5); }
        .victory-team-name { font-size: 2rem; font-weight: bold; margin-bottom: 20px; color: white; }
        .victory-message { font-size: 1.2rem; color: #ccc; margin-bottom: 30px; }
        .victory-actions { display: flex; gap: 15px; justify-content: center; }
        @keyframes bounce { 0%, 20%, 50%, 80%, 100% {transform: translateY(0);} 40% {transform: translateY(-20px);} 60% {transform: translateY(-10px);} }
        #confetti-container { position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 9999; overflow: hidden; }
        .confetti { position: absolute; width: 10px; height: 10px; background: #f00; animation: fall linear forwards; }
        @keyframes fall { to { transform: translateY(100vh) rotate(720deg); } }

        /* Media Queries */
        .team-card-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 5px;
        }
        .team-card-title {
            font-size: 0.9rem;
            color: #aaa;
            font-weight: bold;
        }
        .team-color-indicator-large {
            width: 20px;
            height: 20px;
            border-radius: 50%;
            border: 2px solid rgba(255, 255, 255, 0.2);
            box-shadow: 0 0 10px rgba(0,0,0,0.2);
        }
        .team-colors-row {
            display: flex;
            gap: 8px;
            flex-wrap: wrap;
            justify-content: center;
            margin-top: 5px;
            padding-top: 10px;
            border-top: 1px solid rgba(255, 255, 255, 0.05);
        }
        .form-input:focus { outline: none; border-color: var(--primary-color); }
        .color-picker { width: 50px; height: 40px; border: none; border-radius: 5px; cursor: pointer; }

        .ships-config { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; }
        .ship-config { background: rgba(0,0,0,0.3); padding: 15px; border-radius: 8px; position: relative; }
        .remove-ship-btn {
            position: absolute;
            top: 5px;
            left: 5px;
            background: var(--hit-color);
            color: white;
            border: none;
            border-radius: 50%;
            width: 22px;
            height: 22px;
            cursor: pointer;
            font-weight: bold;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s;
        }
        .remove-ship-btn:hover { background: #c23616; transform: scale(1.1); }

        .presenter-tools-grid {
            display: flex;
            flex-direction: column;
            gap: 20px;
            padding: 15px 0;
        }
        .tool-item {
            display: flex;
            align-items: center;
            gap: 15px;
        }
        .tool-item .btn {
            flex-shrink: 0;
            width: 150px;
            margin: 0;
            padding: 10px 20px;
        }
        .tool-description {
            font-size: 0.9rem;
            color: #bdc3c7;
            text-align: right;
            margin: 0;
        }

        .legend { display: flex; justify-content: center; gap: 20px; margin-top: 20px; flex-wrap: wrap; }
        .legend-item { display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,0.2); padding: 8px 12px; border-radius: 20px; }
        .legend-color { width: 20px; height: 20px; border-radius: 3px; }

        #toast-container { position: fixed; top: 20px; right: 20px; z-index: 2000; }
        .toast {
            background-color: var(--surface-color);
            color: white;
            padding: 15px 20px;
            border-radius: 10px;
            margin-bottom: 10px;
            box-shadow: 0 5px 15px rgba(0,0,0,0.3);
            border-left: 5px solid var(--primary-color);
            animation: slideInRight 0.5s ease, fadeOut 0.5s ease 2.5s forwards;
        }
        .toast.success { border-left-color: #44bd32; }
        .toast.error { border-left-color: var(--hit-color); }
        
        .winner-title { font-size: 2.5rem; text-align: center; color: var(--secondary-color); margin-bottom: 20px; }
        .final-scores { text-align: center; }

        .cannonball {
            position: fixed;
            z-index: 9999;
            width: 18px;
            height: 18px;
            background: radial-gradient(circle at 30% 30%, var(--cannon-color), #7f8c8d 40%, #2c3e50);
            border-radius: 50%;
            pointer-events: none;
            left: 0;
            top: 0;
            opacity: 0;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.7);
            transform-origin: center;
            --cannon-color: #dcdde1;
        }

        .particle {
            position: fixed;
            width: 6px;
            height: 6px;
            background: #192a56;
            z-index: 10001;
            pointer-events: none;
            border-radius: 50%;
            animation: explode 0.7s ease-out forwards;
        }

        .trail-particle {
            position: fixed;
            width: 6px;
            height: 6px;
            border-radius: 50%;
            background: radial-gradient(circle, rgba(220, 220, 220, 0.85), rgba(120, 120, 120, 0.7), transparent 70%);
            z-index: 9998;
            pointer-events: none;
            opacity: 0.95;
            animation: cannonTrail 0.6s ease-out forwards;
        }

        /* --- New Admin Panel UI --- */
        .tab-container {
            width: 100%;
        }
        .tab-buttons {
            display: flex;
            gap: 10px;
            border-bottom: 1px solid var(--surface-color);
            margin-bottom: 20px;
        }
        .tab-button {
            background-color: transparent;
            border: none;
            outline: none;
            cursor: pointer;
            padding: 14px 16px;
            transition: 0.3s;
            font-size: 1rem;
            font-weight: bold;
            color: var(--miss-color);
            border-bottom: 3px solid transparent;
            position: relative;
            top: 1px;
        }
        .tab-button:hover {
            color: white;
        }
        .tab-button.active {
            color: var(--primary-color);
            border-bottom-color: var(--primary-color);
        }
        .tab-content {
            display: none;
            padding: 6px 12px;
            animation: fadeIn 0.5s;
        }
        .tab-content.active {
            display: block;
        }

        /* --- New Custom Select Dropdown --- */
        .custom-select-container select {
            display: none; /* Hide the original select box */
        }
        .custom-select-container {
            position: relative;
            width: 100%;
        }
        .select-selected {
            background-color: rgba(0,0,0,0.2);
            color: white;
            padding: 10px 12px;
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 8px;
            cursor: pointer;
            user-select: none;
            transition: all 0.3s ease;
            text-align: right;
        }
        .select-selected:after {
            position: absolute;
            content: "";
            top: 18px;
            left: 15px;
            width: 0;
            height: 0;
            border: 6px solid transparent;
            border-color: #fff transparent transparent transparent;
        }
        .select-selected.select-arrow-active:after {
            border-color: transparent transparent #fff transparent;
            top: 12px;
        }
        .select-selected:hover {
            border-color: var(--primary-color);
        }
        .select-items {
            position: absolute;
            background-color: var(--surface-color);
            top: 100%;
            left: 0;
            right: 0;
            z-index: 99;
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 5px;
            max-height: 200px;
            overflow-y: auto;
        }
        .select-hide {
            display: none;
        }
        .select-items div {
            color: white;
            padding: 10px;
            cursor: pointer;
            transition: background-color 0.2s ease;
        }
        .select-items div:hover, .same-as-selected {
            background-color: rgba(0, 0, 0, 0.3);
        }

        /* Custom Checkbox */
        .checkbox-container {
          display: inline-flex;
          align-items: center;
          position: relative;
          padding-right: 35px; /* RTL Support */
          padding-left: 0;
          margin-bottom: 0px;
          cursor: pointer;
          font-size: 1rem;
          user-select: none;
          height: 45px; /* Match button height for alignment */
        }

        .custom-checkbox {
          position: absolute;
          opacity: 0;
          cursor: pointer;
          height: 0;
          width: 0;
        }

        .checkmark {
          position: absolute;
          top: 50%;
          transform: translateY(-50%);
          right: 0; /* RTL Support */
          left: auto;
          height: 25px;
          width: 25px;
          background-color: var(--surface-color);
          border-radius: 4px;
          transition: background-color 0.3s;
          box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
        }

        .checkmark:after {
          content: "";
          position: absolute;
          display: none;
          left: 9px;
          top: 5px;
          width: 5px;
          height: 10px;
          border: solid white;
          border-width: 0 3px 3px 0;
          transform: rotate(45deg);
        }

        .custom-checkbox:checked ~ .checkmark {
          background-color: var(--primary-color);
          box-shadow: 0 3px 7px rgba(0, 168, 255, 0.3);
        }

        .custom-checkbox:checked ~ .checkmark:after {
          display: block;
        }

        @keyframes checkAnim {
          0% { height: 0; }
          100% { height: 10px; }
        }

        .custom-checkbox:checked ~ .checkmark:after {
          animation: checkAnim 0.2s forwards;
        }


        /* Animations */
        @keyframes fireCannonball {
            0% {
                transform: translate(var(--start-x), var(--start-y)) scale(0.4, 0.7);
                box-shadow: 0 0 6px rgba(0, 0, 0, 0.8);
                opacity: 1;
            }
            40% {
                transform: translate(var(--mid-x), var(--mid-y)) scale(1.05, 0.95);
                box-shadow: 0 0 14px rgba(0, 0, 0, 0.9);
            }
            100% {
                transform: translate(var(--end-x), var(--end-y)) scale(0.7, 0.9);
                box-shadow: 0 0 4px rgba(0, 0, 0, 0.6);
                opacity: 1;
            }
        }
        @keyframes explode {
            0% {
                transform: translate(-50%, -50%) scale(1);
                opacity: 1;
            }
            100% {
                transform: translate(var(--x), var(--y)) scale(0);
                opacity: 0;
            }
        }
        @keyframes cannonTrail {
            0% {
                transform: translate(-50%, -50%) scale(0.8);
                opacity: 0.9;
            }
            100% {
                transform: translate(-50%, -50%) scale(2);
                opacity: 0;
            }
        }
        @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
        @keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
        @keyframes fadeInDown { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
        @keyframes slideInUp { from { transform: translateY(50px); } to { transform: translateY(0); } }
        @keyframes slideInRight { from { transform: translateX(100%); } to { transform: translateX(0); } }
        @keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }
        @keyframes blink { 0%, 50% { opacity: 1; } 51%, 100% { opacity: 0.3; } }

        @keyframes sunkPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }
        @keyframes sinkingShip {
            0% { transform: scale(1) rotate(0deg); opacity: 1; }
            50% { transform: scale(1.1) rotate(-5deg); opacity: 0.8; }
            100% { transform: scale(0.8) rotate(10deg); opacity: 0.4; }
        }
        @keyframes radarPulseWater {
            0% { box-shadow: 0 0 0 0 rgba(0, 168, 255, 0.7); }
            70% { box-shadow: 0 0 0 15px rgba(0, 168, 255, 0); }
            100% { box-shadow: 0 0 0 0 rgba(0, 168, 255, 0); }
        }
        @keyframes radarPulseHit {
            0% { box-shadow: 0 0 0 0 rgba(0, 255, 0, 0.7); }
            70% { box-shadow: 0 0 0 15px rgba(0, 255, 0, 0); }
            100% { box-shadow: 0 0 0 0 rgba(0, 255, 0, 0); }
        }


        @media (max-width: 1200px) { 
            .teams-container { 
                /* Ensures single column on smaller screens unless overridden */
                grid-template-columns: 1fr; 
            }
        }
        @media (max-width: 768px) {
            .game-title { font-size: 2rem; }
            .grid { gap: 1px; padding: 5px; }
            .scores-grid { grid-template-columns: 1fr; }
            .turn-controls { grid-template-columns: 1fr; }
            .turn-actions { flex-direction: column; align-items: center; }
        }

        /* --- Visual Improvements --- */
        /* Moving Ocean Background */
        @keyframes oceanMove {
            0% { background-position: 0 0; }
            100% { background-position: 100% 100%; }
        }

        body::before {
            content: '';
            position: fixed;
            top: 0; left: 0; width: 200%; height: 200%;
            background-image: url("data:image/svg+xml,%3Csvg width='100' height='20' viewBox='0 0 100 20' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M21.184 20c.357-.13.72-.264 1.088-.402l1.768-.661C33.64 15.347 39.647 14 50 14c10.271 0 15.362 1.222 24.629 4.928.955.383 1.869.74 2.75 1.072h6.225c-2.51-.73-5.139-1.691-8.233-2.928C65.888 12.327 60.562 10 50 10c-10.626 0-16.855 2.397-26.66 6.339-4.595 1.848-7.853 3.033-11.45 3.66L21.184 20zM0 20c1.67-.32 3.167-.796 4.463-1.408l.942-.45c.958-.458 1.933-.945 2.927-1.428C16.855 12.72 23.11 10 33.74 10c10.56 0 15.896 2.327 25.372 6.071C63.09 17.643 68.097 19 78.448 19c10.352 0 15.36-1.222 24.627-4.928.955-.383 1.87-.74 2.75-1.072h-6.225c-2.51.73-5.139 1.691-8.233 2.928C81.888 20.673 76.562 23 66 23c-10.626 0-16.855-2.397-26.66-6.339-4.595-1.848-7.853-3.033-11.45-3.66L21.184 10c-.357.13-.72.264-1.088.402l-1.768.661C8.74 14.003 2.733 15.35 0 15.35v4.65z' fill='%23ffffff' fill-opacity='0.05' fill-rule='evenodd'/%3E%3C/svg%3E");
            animation: oceanMove 60s linear infinite;
            pointer-events: none;
            z-index: -1;
            opacity: 0.3;
        }

        /* Screen Shake */
        .shake {
            animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
        }

        .shake-hard {
            animation: shakeHard 0.8s cubic-bezier(.36,.07,.19,.97) both;
        }
        @keyframes shakeHard {
            10%, 90% { transform: translate3d(-2px, 2px, 0) rotate(1deg); }
            20%, 80% { transform: translate3d(4px, -4px, 0) rotate(-2deg); }
            30%, 50%, 70% { transform: translate3d(-8px, 6px, 0) rotate(3deg); }
            40%, 60% { transform: translate3d(8px, -6px, 0) rotate(-3deg); }
        }

        .shake-horizontal {
            animation: shakeHorizontal 0.6s cubic-bezier(.36,.07,.19,.97) both;
        }
        @keyframes shakeHorizontal {
            10%, 90% { transform: translate3d(-5px, 0, 0); }
            20%, 80% { transform: translate3d(10px, 0, 0); }
            30%, 50%, 70% { transform: translate3d(-15px, 0, 0); }
            40%, 60% { transform: translate3d(15px, 0, 0); }
        }
        
        .flash-overlay {
            position: fixed;
            top: 0; left: 0; width: 100%; height: 100%;
            background: radial-gradient(circle, rgba(255, 69, 0, 0.4), transparent 90%);
            z-index: 9999;
            pointer-events: none;
            opacity: 0;
            animation: flashAnim 0.8s ease-out;
        }
        @keyframes flashAnim {
            0% { opacity: 1; transform: scale(1); }
            100% { opacity: 0; transform: scale(1.5); }
        }

        @keyframes shake {
            10%, 90% { transform: translate3d(-1px, 0, 0); }
            20%, 80% { transform: translate3d(2px, 0, 0); }
            30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
            40%, 60% { transform: translate3d(4px, 0, 0); }
        }

        /* Radar Scan Overlay */
        .grid-container { position: relative; overflow: hidden; }
        .radar-scan-line {
            position: absolute;
            top: 0; left: 0;
            width: 100%; height: 2px;
            background: rgba(0, 242, 255, 0.8);
            box-shadow: 0 0 10px rgba(0, 242, 255, 1);
            animation: scanDown 3s linear infinite;
            pointer-events: none;
            z-index: 5;
            opacity: 0;
            transition: opacity 0.3s;
        }
        .team-section.current-turn-highlight .radar-scan-line { opacity: 0.3; }

        @keyframes scanDown {
            0% { top: 0; }
            100% { top: 100%; }
        }
        /* Control Center Styles */
        .control-center-modal .modal-content {
            max-width: 900px;
            width: 95%;
            display: flex;
            flex-direction: column;
            padding: 0;
            overflow: hidden;
            height: 80vh;
            max-height: 700px;
            background: linear-gradient(135deg, #0f2027, #203a43, #2c5364);
            border: 1px solid rgba(0, 242, 255, 0.2);
        }

        .control-center-body {
            display: flex;
            flex: 1;
            overflow: hidden;
        }

        .control-sidebar {
            width: 250px;
            background: rgba(0, 0, 0, 0.3);
            padding: 20px 0;
            border-left: 1px solid rgba(255, 255, 255, 0.1);
            display: flex;
            flex-direction: column;
            gap: 10px;
        }

        .control-sidebar h3 {
            margin: 0 20px 20px;
            color: var(--primary-color);
            font-size: 1.2rem;
            border-bottom: 2px solid var(--primary-color);
            padding-bottom: 10px;
            white-space: normal;
        }

        .sidebar-btn {
            background: transparent;
            border: none;
            color: rgba(255, 255, 255, 0.7);
            padding: 12px 20px;
            text-align: right;
            cursor: pointer;
            font-size: 1rem;
            transition: all 0.3s ease;
            width: 100%;
            display: flex;
            align-items: center;
            justify-content: flex-start;
            gap: 10px;
            border-bottom: none;
            border-radius: 0;
        }

        .sidebar-btn:hover, .sidebar-btn.active {
            background: rgba(0, 242, 255, 0.1);
            color: var(--primary-color);
            border-right: 3px solid var(--primary-color);
            border-bottom: none;
        }

        .control-main {
            flex: 1;
            padding: 30px;
            overflow-y: auto;
            background: rgba(255, 255, 255, 0.02);
        }

        .control-tab {
            display: none;
            animation: fadeIn 0.3s ease;
        }

        .control-tab.active {
            display: block;
        }

        .control-footer {
            padding: 15px 30px;
            background: rgba(0, 0, 0, 0.5);
            display: flex;
            justify-content: flex-end;
            gap: 15px;
            border-top: 1px solid rgba(255, 255, 255, 0.1);
        }

        .control-section {
            background: rgba(255, 255, 255, 0.05);
            padding: 20px;
            border-radius: 12px;
            margin-bottom: 20px;
        }

        .control-section-title {
            font-size: 1.1rem;
            color: var(--secondary-color);
            margin-bottom: 15px;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .control-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 15px;
        }

        .team-input-row {
            display: flex;
            align-items: center;
            gap: 10px;
            margin-bottom: 10px;
            padding: 10px;
            background: rgba(0,0,0,0.2);
            border-radius: 8px;
        }

        .team-color-indicator {
            width: 24px;
            height: 24px;
            border-radius: 50%;
            border: 2px solid white;
        }

        /* Leaderboard Styles */
        #finalScores {
            display: flex;
            flex-direction: column;
            gap: 12px;
            margin: 20px 0;
            max-height: 400px;
            overflow-y: auto;
            padding: 5px; /* For box-shadow visibility */
        }

        .leaderboard-card {
            background: rgba(255, 255, 255, 0.05);
            border-radius: 12px;
            padding: 15px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            border: 1px solid rgba(255, 255, 255, 0.1);
            transform: translateY(20px);
            opacity: 0;
            animation: slideInUp 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
        }

        .leaderboard-card.rank-1 {
            background: linear-gradient(135deg, rgba(255, 215, 0, 0.15), rgba(255, 215, 0, 0.05));
            border-color: rgba(255, 215, 0, 0.5);
            box-shadow: 0 0 15px rgba(255, 215, 0, 0.2);
            transform: scale(1.02);
            z-index: 10;
        }

        .leaderboard-card.rank-2 {
            background: linear-gradient(135deg, rgba(192, 192, 192, 0.15), rgba(192, 192, 192, 0.05));
            border-color: rgba(192, 192, 192, 0.5);
        }

        .leaderboard-card.rank-3 {
            background: linear-gradient(135deg, rgba(205, 127, 50, 0.15), rgba(205, 127, 50, 0.05));
            border-color: rgba(205, 127, 50, 0.5);
        }

        .rank-badge {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.2rem;
            font-weight: bold;
            background: rgba(0, 0, 0, 0.3);
            margin-left: 15px;
            flex-shrink: 0;
        }

        .rank-1 .rank-badge { background: #FFD700; color: #000; box-shadow: 0 0 10px #FFD700; }
        .rank-2 .rank-badge { background: #C0C0C0; color: #000; }
        .rank-3 .rank-badge { background: #CD7F32; color: #000; }

        .team-info-leaderboard {
            flex: 1;
            text-align: right;
        }

        .team-name-leaderboard {
            font-size: 1.2rem;
            font-weight: bold;
            color: white;
            margin-bottom: 5px;
        }

        .team-stats-leaderboard {
            display: flex;
            gap: 15px;
            font-size: 0.85rem;
            color: rgba(255, 255, 255, 0.7);
            flex-wrap: wrap;
        }

        .stat-item {
            display: flex;
            align-items: center;
            gap: 5px;
        }

        .stat-item i { font-style: normal; }

        .total-score-leaderboard {
            font-size: 1.5rem;
            font-weight: bold;
            color: var(--secondary-color);
            min-width: 80px;
            text-align: center;
        }

        @keyframes slideInUp {
            from {
                opacity: 0;
                transform: translateY(30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
/* --- Victory Modal & Confetti --- */
#gameOverModal {
    background: radial-gradient(circle at center, rgba(20, 25, 40, 0.95), rgba(0, 0, 0, 0.98));
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    overflow: hidden; /* Prevent scrolling on the modal container itself */
    padding: 10px; /* Reduced padding */
    height: 100vh; /* Full viewport height */
    width: 100vw;
    position: fixed;
    top: 0;
    left: 0;
}

.victory-modal-content {
    background: rgba(0, 0, 0, 0.4); 
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    color: white;
    text-align: center;
    padding: 20px; /* Compact padding */
    position: relative;
    overflow: hidden; /* Contain children */
    max-width: 1800px; /* Max width */
    width: 98%; 
    height: 95vh; /* Take up most of the screen height */
    max-height: 95vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between; /* Distribute space vertically */
    margin: auto;
}

/* Podium Styles */
.podium-container {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 20px; 
    margin-bottom: 0; /* Remove bottom margin */
    flex: 1; /* Allow to take available space */
    width: 100%;
    padding-top: 20px; /* Reduced from 60px to bring everything closer to center if needed, but flex-end handles it */
    padding-bottom: 20px; /* Add bottom padding */
    flex-wrap: nowrap; 
    overflow: visible; /* Allow spillover for ribbons */
}

.podium-place {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    opacity: 0;
    transform: translateY(50px);
    transition: all 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    flex: 1;
    max-width: 33%; /* Ensure 3 columns fit */
    height: 100%; /* Fill container height */
}

/* Replaces podium-avatar */
.podium-team-title {
    --team-color: #fff; /* Default fallback */
    font-size: 1.2rem;
    font-weight: bold;
    text-align: center;
    margin-bottom: -25px;
    padding: 8px 25px;
    background: linear-gradient(135deg, rgba(0,0,0,0.95), rgba(40,40,40,0.9));
    border-radius: 4px; /* Slight round for ribbon feel */
    border: 2px solid var(--team-color);
    border-left-width: 5px; /* Accent on sides */
    border-right-width: 5px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.4), 0 0 10px var(--team-color);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s ease 0.2s;
    white-space: nowrap;
    max-width: 140%; 
    width: auto;
    min-width: 100px;
    overflow: visible; /* Allow pseudo-elements */
    text-overflow: ellipsis;
    z-index: 20; 
    position: relative;
    color: var(--team-color) !important; /* Force team color text */
}

/* Ribbon Ends Effect */
.podium-team-title::before,
.podium-team-title::after {
    content: '';
    position: absolute;
    bottom: -10px;
    width: 20px;
    height: 20px;
    background: var(--team-color);
    z-index: -1;
    filter: brightness(0.6); /* Darker shade for fold */
}
.podium-team-title::before {
    left: 5px;
    transform: skewX(45deg);
}
.podium-team-title::after {
    right: 5px;
    transform: skewX(-45deg);
}

/* Shimmer Animation for First Place */
@keyframes shimmerEffect {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
.podium-place.first .podium-team-title {
    background: linear-gradient(90deg, 
        rgba(0,0,0,0.9) 0%, 
        rgba(0,0,0,0.9) 40%, 
        rgba(255,255,255,0.4) 50%, 
        rgba(0,0,0,0.9) 60%, 
        rgba(0,0,0,0.9) 100%);
    background-size: 200% 100%;
    animation: shimmerEffect 4s infinite linear, floatTitle 3s ease-in-out infinite;
    font-size: 1.5rem;
    padding: 10px 35px;
    margin-bottom: -30px;
    border-width: 3px;
    border-left-width: 8px;
    border-right-width: 8px;
}

.podium-place.second .podium-team-title {
    background: linear-gradient(90deg, 
        rgba(0,0,0,0.9) 0%, 
        rgba(0,0,0,0.9) 40%, 
        rgba(192,192,192,0.4) 50%, 
        rgba(0,0,0,0.9) 60%, 
        rgba(0,0,0,0.9) 100%);
    background-size: 200% 100%;
    animation: shimmerEffect 4s infinite linear, floatTitle 3s ease-in-out infinite;
    font-size: 1.3rem;
    padding: 10px 30px;
    margin-bottom: -30px;
    border-width: 3px;
    border-left-width: 8px;
    border-right-width: 8px;
}

.podium-place.third .podium-team-title {
    background: linear-gradient(90deg, 
        rgba(0,0,0,0.9) 0%, 
        rgba(0,0,0,0.9) 40%, 
        rgba(205,127,50,0.4) 50%, 
        rgba(0,0,0,0.9) 60%, 
        rgba(0,0,0,0.9) 100%);
    background-size: 200% 100%;
    animation: shimmerEffect 4s infinite linear, floatTitle 3s ease-in-out infinite;
    font-size: 1.2rem;
    padding: 10px 25px;
    margin-bottom: -30px;
    border-width: 3px;
    border-left-width: 8px;
    border-right-width: 8px;
}

.podium-place.reveal-visible .podium-team-title {
    opacity: 1;
    transform: translateY(0);
}

.podium-rank-display {
    font-size: 4rem;
    font-weight: 900;
    margin-bottom: 0;
    line-height: 1;
    background: linear-gradient(to bottom, rgba(255,255,255,0.9), rgba(255,255,255,0.4));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 5px rgba(0,0,0,0.5));
}

.podium-place.first .podium-rank-display {
    background: linear-gradient(to bottom, #ffd700, #fff8dc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 15px rgba(255, 215, 0, 0.6));
    font-size: 5rem;
}
.podium-place.second .podium-rank-display {
    background: linear-gradient(to bottom, #c0c0c0, #f5f5f5);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.podium-place.third .podium-rank-display {
    background: linear-gradient(to bottom, #cd7f32, #f4a460);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.podium-bar {
    width: 90%; 
    height: 0; /* Start at 0 for animation */
    /* max-height removed to prevent clamping equal heights */
    border-radius: 20px 20px 0 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 20px;
    padding-bottom: 10px;
    position: relative;
    color: white;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    transition: height 2s cubic-bezier(0.34, 1.56, 0.64, 1); /* Slower animation */
    overflow: hidden; 
}

.podium-name {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 5px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 5px;
    opacity: 0;
    transition: opacity 0.5s 0.2s; /* Reveal quickly */
}

.podium-bar .score-val {
    margin-top: 5px;
    font-weight: 900;
    font-size: 2rem;
    color: #fff;
    text-shadow: 0 0 15px currentColor;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.5s 0.2s; /* Reveal quickly */
}

.podium-place.reveal-visible .podium-name,
.podium-place.reveal-visible .podium-bar .score-val {
    opacity: 1;
}

.podium-stats {
    font-size: 0.9rem;
    display: flex;
    gap: 5px;
    margin-top: auto;
    background: rgba(0,0,0,0.4);
    padding: 5px 10px;
    border-radius: 15px;
    border: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 10px; /* Add some bottom spacing inside bar */
    opacity: 0;
    transition: opacity 0.5s 1.2s;
    flex-direction: column;
    text-align: center;
}
.podium-place.reveal-visible .podium-stats {
    opacity: 1;
}

/* First Place - The Winner - CENTER */
.podium-place.first {
    z-index: 10;
    order: 2; 
    margin: 0 10px; 
}
/* Sea Background Effect */
.sea-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    background: radial-gradient(circle at 50% 30%, #003366, #001133, #000000);
    overflow: hidden;
    pointer-events: none;
}
.bubble {
    position: absolute;
    bottom: -20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    animation: rise 10s infinite ease-in;
}
@keyframes rise {
    0% { bottom: -20px; transform: translateX(0); opacity: 0; }
    10% { opacity: 0.5; }
    50% { transform: translateX(20px); }
    100% { bottom: 110%; transform: translateX(-20px); opacity: 0; }
}

.stats-extra {
    font-size: 0.85em; 
    opacity: 0.9; 
    height: 0; 
    overflow: hidden; 
    transition: all 0.3s ease; 
    border-top: 1px solid rgba(255,255,255,0.2); 
    margin-top: 0px;
}

.podium-place:hover .stats-extra { 
    height: 25px; 
    margin-top: 5px; 
}

/* Specific styles for non-first places to keep stats compact */
.podium-place:not(.first) .podium-stats {
    font-size: 0.75rem;
    padding: 3px 8px;
    gap: 2px;
    margin-bottom: 5px;
    border-radius: 10px;
}

.podium-place:not(.first):hover .stats-extra {
    height: 20px;
    margin-top: 3px;
    font-size: 0.8em;
}

/* Hover Details */
.podium-bar {
    cursor: pointer; /* Indicate interactivity */
}
.podium-bar:hover .podium-stats {
    background: rgba(0, 0, 0, 0.85);
    transform: scale(1.1) translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.6);
    border-color: rgba(255,255,255,0.4);
}
/* Reduce hover scale for non-first places */
.podium-place:not(.first) .podium-bar:hover .podium-stats {
    transform: scale(1.02) translateY(-2px);
    background: rgba(0, 0, 0, 0.7); /* Slightly less opaque */
}
.podium-bar:hover {
    filter: brightness(1.1);
}

.podium-place.first .podium-bar {
    background: linear-gradient(to bottom, rgba(255, 215, 0, 0.2), rgba(0,0,0,0.6));
    border-top: 6px solid #ffd700;
    box-shadow: 0 0 80px rgba(255, 215, 0, 0.3);
}
.podium-place.first.reveal-visible .podium-bar {
    height: 50vh; 
}
/* Removed duplicate .podium-place.first .podium-team-title block */

@keyframes floatTitle {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* Second Place - RIGHT (in RTL) */
.podium-place.second {
    z-index: 5;
    order: 1; /* First in visual order (Right) */
}
.podium-place.second .podium-bar {
    background: linear-gradient(to bottom, rgba(192, 192, 192, 0.2), rgba(0,0,0,0.6));
    border-top: 6px solid #c0c0c0;
}
.podium-place.second.reveal-visible .podium-bar {
    height: 35vh; /* Reduced height for 2nd place to create gap */
}

/* Third Place - LEFT (in RTL) */
.podium-place.third {
    z-index: 5;
    order: 3; /* Last in visual order (Left) */
}
.podium-place.third .podium-bar {
    background: linear-gradient(to bottom, rgba(205, 127, 50, 0.2), rgba(0,0,0,0.6));
    border-top: 6px solid #cd7f32;
}
.podium-place.third.reveal-visible .podium-bar {
    height: 25vh; /* Reduced height for 3rd place */
}

/* Animations classes */
.reveal-visible {
    opacity: 1;
    transform: translateY(0);
}

.reveal-pop {
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.victory-title {
    font-size: 3rem; /* Slightly smaller title to save space */
    margin-bottom: 0.5rem;
    background: linear-gradient(to bottom, #ffd700, #fff, #ffd700);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 900;
    filter: drop-shadow(0 0 25px rgba(255, 215, 0, 0.8));
    opacity: 0;
    transition: opacity 0.5s;
    letter-spacing: -2px;
    text-align: center;
    line-height: 1.2;
    margin-top: 20px;
}

.victory-message {
    font-size: 1.6rem;
    color: #ccc;
    margin-bottom: 2rem;
    opacity: 0.9;
}

.victory-actions {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-top: 10px;
    margin-bottom: 20px;
    opacity: 0;
    transition: opacity 1s;
    z-index: 100;
}

.close-modal {
    position: absolute;
    top: 20px;
    right: 20px;
    left: auto;
    width: 40px; /* Smaller close button */
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    color: #fff;
    transition: all 0.3s;
    z-index: 1000;
    border: 2px solid rgba(255,255,255,0.2);
}
.close-modal:hover { background: rgba(255,255,255,0.3); transform: rotate(90deg); border-color: white; }

/* Confetti */
#confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden;
}
.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #f00;
    top: -10px;
    animation: fall linear forwards;
}
@keyframes fall {
    to { transform: translateY(100vh) rotate(720deg); }
}

/* --- Responsive adjustments --- */
@media (max-width: 900px) {
    .victory-modal-content {
        padding: 10px;
        width: 98%;
        height: 98vh;
        max-height: 98vh;
        justify-content: space-between;
        border-radius: 15px;
    }

    .victory-title {
        font-size: 1.8rem;
        margin-top: 40px; /* Space for close button */
        margin-bottom: 10px;
    }

    .podium-container {
        flex-direction: row; /* Keep row layout */
        align-items: flex-end;
        gap: 5px;
        padding-top: 40px;
        height: auto;
        flex: 1;
        width: 100%;
        margin-bottom: 0;
    }
    
    /* Keep order logic from desktop (RTL: 2nd-1st-3rd) */
    .podium-place { 
        width: 32%;
        max-width: 32%;
        margin: 0;
        transform: none;
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
    }
    
    /* Adjust bar heights for mobile to fit */
    .podium-place.first.reveal-visible .podium-bar { height: 28vh; }
    .podium-place.second.reveal-visible .podium-bar { height: 18vh; }
    .podium-place.third.reveal-visible .podium-bar { height: 15vh; }

    .podium-bar {
        width: 100%;
        max-width: none;
        flex-direction: column;
        padding: 5px;
        justify-content: flex-end;
        border-radius: 8px 8px 0 0;
        border-top: none;
        border-left: none;
    }
    
    /* Restore background/borders from desktop styles */
    .podium-place.first .podium-bar { background: linear-gradient(to bottom, rgba(255, 215, 0, 0.4), rgba(255, 215, 0, 0.1)); border-top: 4px solid #ffd700; }
    .podium-place.second .podium-bar { background: linear-gradient(to bottom, rgba(192, 192, 192, 0.4), rgba(192, 192, 192, 0.1)); border-top: 4px solid #c0c0c0; }
    .podium-place.third .podium-bar { background: linear-gradient(to bottom, rgba(205, 127, 50, 0.4), rgba(205, 127, 50, 0.1)); border-top: 4px solid #cd7f32; }

    .podium-avatar {
        width: 45px;
        height: 45px;
        font-size: 1.2rem;
        position: absolute;
        top: -25px;
        left: 50%;
        transform: translateX(-50%);
        margin: 0;
        border-width: 2px;
    }
    
    .podium-place.first .podium-avatar {
        width: 60px;
        height: 60px;
        top: -35px;
        font-size: 1.5rem;
    }

    .podium-name {
        text-align: center;
        font-size: 0.8rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        width: 100%;
        margin-bottom: 2px;
    }
    
    .podium-bar .score-val {
        font-size: 1.1rem;
        margin-top: 0;
    }
    
    .podium-stats {
        display: flex;
        flex-direction: column;
        gap: 1px;
        padding: 2px;
    }
    
    .stat-item {
        font-size: 0.6rem;
        padding: 2px;
    }

    .victory-actions {
        margin-top: 5px;
        margin-bottom: 10px;
        gap: 10px;
    }
    
    .btn.primary-btn, .btn.secondary-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
        min-width: auto;
    }
    
    #gameOverModal {
        align-items: center;
        padding: 0;
    }
}

/* Stats Table Styles */
.stats-table {
    width: 100%;
    border-collapse: collapse;
    color: #fff;
    font-size: 0.9rem;
}
.stats-table th, .stats-table td {
    padding: 10px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.stats-table th {
    background: rgba(255,255,255,0.1);
    font-weight: bold;
    color: var(--primary-color);
}
.stats-table tr:last-child td {
    border-bottom: none;
}
.stats-table tr:hover {
    background: rgba(255,255,255,0.05);
}

