        :root {
            --primary-color: #228B22;
            --accent-color: #FFD700;
            --bg-color: #111;
            --text-color: #fff;
            --panel-bg: #111;
            --nav-height: 60px;
            --header-height: 50px;
            --breadcrumb-height: 30px;
            --bottom-padding: calc(100px + env(safe-area-inset-bottom));
            --top-padding: calc(var(--header-height) + var(--breadcrumb-height) + env(safe-area-inset-top));
        }

        body {
            margin: 0;
            padding: 0;
            background-color: var(--bg-color);
            color: var(--text-color);
            font-family: 'Helvetica Neue', Arial, sans-serif;
            overflow: hidden;
            user-select: none;
            touch-action: none;
            height: 100vh;
            /* Fallback */
            height: 100dvh;
            width: 100vw;
        }

        #app {
            position: relative;
            width: 100%;
            height: 100%;
            overflow: hidden;
        }

        /* Views */
        /* Views */
        .view {
            display: none;
            /* Default hidden */
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            width: 100%;
            height: calc(100% - var(--top-padding) - var(--nav-height) - env(safe-area-inset-bottom));
            top: var(--top-padding);
            padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom));
            background-color: #1a1a1a !important;
            /* Force opaque background */
            overflow-y: auto;
            z-index: 0;
            overscroll-behavior: contain;
            /* Prevent body scroll chaining */
            -webkit-overflow-scrolling: touch;
            /* Smooth scroll on iOS */
        }

        .view.active {
            display: block;
            /* Show when active */
            z-index: 100;
            /* Ensure it's on top */
        }

        /* Specific Flex Views */
        #view-title {
            display: none;
        }

        #view-title.active {
            display: flex;
        }

        #view-match {
            display: none;
        }

        #view-match.active {
            display: flex;
        }

        /* Title View */
        /* Title View */
        #view-title {
            justify-content: center;
            align-items: center;
            flex-direction: column;
            gap: 1.5rem;
            background-image: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)), url('keeper.png');
            background-size: cover;
            background-position: center;
            /* Override global view styles */
            top: 0 !important;
            height: 100% !important;
            padding-bottom: 0 !important;
        }

        #view-title h1 {
            margin-bottom: 2rem;
            text-align: center;
        }

        #view-title .btn {
            min-width: 200px;
            padding: 1rem;
            font-size: 1.2rem;
        }

        /* Match View Rebuild (Strict Responsive) */
        #view-match {
            display: flex;
            flex-direction: column;
            background: #000;
            overflow: hidden;
            width: 100vw;
            height: calc(100vh - var(--top-padding) - var(--nav-height) - env(safe-area-inset-bottom));
            top: var(--top-padding);
        }

        .match-container {
            display: flex;
            flex-direction: column;
            width: 100%;
            height: 100%;
        }

        .match-header {
            flex: 0 0 auto;
            background: #222;
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0.5rem 1rem;
            border-bottom: 1px solid #333;
            box-sizing: border-box;
            z-index: 10;
            height: 60px;
        }

        .match-content {
            flex: 1;
            display: flex;
            flex-direction: column;
            /* Mobile Default */
            overflow: hidden;
            position: relative;
        }

        .canvas-wrapper {
            position: relative;
            /* background rule removed as it is handled by .field-container now and checking usage */
            overflow: hidden;
            display: flex;
            justify-content: center;
            align-items: center;
            flex: 1;
            width: 100%;
            min-height: 200px;
        }

        .controls-wrapper {
            background: #111;
            display: flex;
            flex-direction: column;
            border-top: 1px solid #333;
            box-sizing: border-box;
            padding: 1rem;
            z-index: 10;
            gap: 0.5rem;
            /* Mobile: Auto height based on content */
            flex: 0 0 auto;
            width: 100%;
            overflow-y: auto;
        }

        /* Desktop Layout (Landscape / Large Screen) */
        @media (min-width: 768px) {
            .match-content {
                flex-direction: row;
                /* Side by Side */
            }

            .canvas-wrapper {
                flex: 1;
                /* Take remaining space */
                height: 100%;
                border-right: 1px solid #333;
            }

            .controls-wrapper {
                flex: 0 0 300px;
                /* Fixed width sidebar */
                height: 100%;
                border-top: none;
                border-left: 1px solid #333;
            }
        }

        /* Header Elements */
        .score-board {
            font-size: 1.5rem;
            font-weight: bold;
            color: #fff;
        }

        .round-display {
            font-size: 0.8rem;
            color: #aaa;
        }

        .team-info {
            flex: 1;
            padding: 0 0.5rem;
            font-size: 0.7rem;
            color: #ccc;
            overflow: hidden;
        }

        .team-name {
            font-weight: bold;
            color: #fff;
            font-size: 0.9rem;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .team-stats {
            font-size: 0.7rem;
            color: var(--accent-color);
        }

        .match-center {
            text-align: center;
            flex: 0 0 80px;
        }

        /* Control Elements */
        .message-box {
            text-align: center;
            font-size: 1.2rem;
            font-weight: bold;
            color: var(--accent-color);
            margin-bottom: 1rem;
            height: 1.5em;
            pointer-events: none;
        }

        .gauge-container {
            width: 100%;
            height: 30px;
            background: #333;
            border-radius: 15px;
            position: relative;
            overflow: hidden;
            margin-bottom: 1rem;
            border: 2px solid #555;
        }

        .gauge-bar {
            height: 100%;
            background: linear-gradient(90deg, #ff0000, #ffff00, #00ff00, #ffff00, #ff0000);
            width: 100%;
            transform: translateX(-50%);
            /* Initial position */
        }

        .gauge-marker {
            position: absolute;
            top: 0;
            left: 50%;
            width: 4px;
            height: 100%;
            background: #fff;
            transform: translateX(-50%);
            z-index: 5;
        }

        .action-area {
            display: flex;
            justify-content: center;
            align-items: center;
            flex: 1;
            min-height: 60px;
        }

        .btn-action {
            width: 100%;
            height: 100%;
            font-size: 1.5rem;
            font-weight: bold;
            background: var(--primary-color);
            color: #fff;
            border: none;
            border-radius: 8px;
            cursor: pointer;
        }

        .btn-action:disabled {
            background: #333;
            color: #555;
            cursor: not-allowed;
        }

        .kicker-info-mini {
            display: flex;
            justify-content: space-between;
            color: #aaa;
            font-size: 0.8rem;
            margin-top: 0.5rem;
        }

        /* Canvas */
        #gameCanvas {
            /* Canvas size is controlled by JS, but max size restricted here */
            max-width: 100%;
            max-height: 100%;
            object-fit: contain;
        }

        /* Bottom Navigation */
        .bottom-nav {
            position: fixed;
            bottom: 0;
            left: 0;
            width: 100%;
            height: calc(var(--nav-height) + env(safe-area-inset-bottom));
            padding-bottom: env(safe-area-inset-bottom);
            background: #1a1a1a;
            display: flex;
            justify-content: space-around;
            align-items: center;
            border-top: 1px solid #333;
            z-index: 100;
            box-sizing: border-box;
        }

        .nav-item {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            color: #666;
            font-size: 0.6rem;
            /* Smaller font for 5 items */
            cursor: pointer;
            width: 100%;
            height: 100%;
            transition: color 0.2s, background 0.2s;
            padding: 4px 0;
        }

        .nav-item.active {
            color: var(--accent-color);
            background: #222;
        }

        .nav-icon {
            font-size: 1.5rem;
            margin-bottom: 2px;
        }

        /* Common Layouts */
        .header-bar {
            padding: 1rem;
            padding-top: calc(1rem + env(safe-area-inset-top));
            background: #1a1a1a;
            border-bottom: 1px solid #333;
            text-align: center;
            position: sticky;
            top: 0;
            z-index: 50;
        }

        .header-bar h2 {
            margin: 0;
            font-size: 1.2rem;
            color: #fff;
        }

        .container {
            padding: 1rem;
            padding-bottom: var(--bottom-padding);
            /* Space for bottom nav + safe area */
        }

        .card-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
            gap: 0.8rem;
        }

        .card {
            background: #222;
            border-radius: 8px;
            padding: 1rem;
            border: 1px solid #333;
        }

        .standings-table {
            width: 100%;
            border-collapse: separate;
            border-spacing: 0 0.6rem;
            /* Increased spacing */
            font-size: 0.9rem;
        }

        .standings-table th {
            position: sticky;
            top: 0;
            background: #222;
            z-index: 10;
            padding: 0.8rem 0.5rem;
            text-align: center;
            color: #888;
            font-weight: bold;
            font-size: 0.75rem;
            text-transform: uppercase;
            letter-spacing: 1px;
            border-bottom: 2px solid #333;
        }

        .standings-table tr {
            animation: slideIn 0.5s ease-out forwards;
            opacity: 0;
        }

        /* Staggered animation for rows */
        .standings-table tr:nth-child(1) {
            animation-delay: 0.1s;
        }

        .standings-table tr:nth-child(2) {
            animation-delay: 0.15s;
        }

        .standings-table tr:nth-child(3) {
            animation-delay: 0.2s;
        }

        .standings-table tr:nth-child(4) {
            animation-delay: 0.25s;
        }

        .standings-table tr:nth-child(5) {
            animation-delay: 0.3s;
        }

        .standings-table tr:nth-child(6) {
            animation-delay: 0.35s;
        }

        @keyframes slideIn {
            from {
                opacity: 0;
                transform: translateY(20px);
            }

            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .standings-table td {
            padding: 1rem 0.5rem;
            text-align: center;
            background: linear-gradient(90deg, #1a1a1a, #222);
            border-top: 1px solid #333;
            border-bottom: 1px solid #333;
            color: #ccc;
            transition: transform 0.2s, background 0.2s;
        }

        /* Hover Effect */
        .standings-table tr:hover td {
            background: linear-gradient(90deg, #222, #2a2a2a);
            transform: scale(1.02);
            border-color: #555;
            z-index: 5;
            position: relative;
        }

        .standings-table td:first-child {
            border-left: 1px solid #333;
            border-top-left-radius: 8px;
            border-bottom-left-radius: 8px;
            font-weight: 900;
            color: #666;
            width: 40px;
            font-size: 1.1rem;
            font-style: italic;
        }

        .standings-table td:last-child {
            border-right: 1px solid #333;
            border-top-right-radius: 8px;
            border-bottom-right-radius: 8px;
        }

        /* Rank Colors */
        /* 1st Place - Gold */
        .standings-table tr:nth-child(2) td:first-child {
            color: #FFD700;
            text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
        }

        /* 2nd Place - Silver */
        .standings-table tr:nth-child(3) td:first-child {
            color: #C0C0C0;
            text-shadow: 0 0 10px rgba(192, 192, 192, 0.5);
        }

        /* 3rd Place - Bronze */
        .standings-table tr:nth-child(4) td:first-child {
            color: #CD7F32;
            text-shadow: 0 0 10px rgba(205, 127, 50, 0.5);
        }

        /* Team Name Column */
        .standings-table td:nth-child(2) {
            text-align: left;
            color: #fff;
            font-weight: bold;
            width: 40%;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 100px;
            font-size: 1rem;
            letter-spacing: 0.5px;
        }

        /* Points Column */
        .standings-table td:nth-child(3) {
            color: var(--accent-color);
            font-weight: 900;
            font-size: 1.2rem;
            text-shadow: 0 0 5px rgba(255, 215, 0, 0.3);
        }

        /* Stats Columns (W/L/D) */
        .standings-table td:nth-child(4),
        .standings-table td:nth-child(5),
        .standings-table td:nth-child(6) {
            font-size: 0.8rem;
            color: #666;
            font-family: monospace;
        }

        /* My Team Highlight */
        .standings-table tr.my-team td {
            background: linear-gradient(90deg, rgba(34, 139, 34, 0.2), rgba(34, 139, 34, 0.1));
            border-top: 1px solid var(--primary-color);
            border-bottom: 1px solid var(--primary-color);
            box-shadow: inset 0 0 20px rgba(34, 139, 34, 0.1);
        }

        .standings-table tr.my-team td:first-child {
            border-left: 1px solid var(--primary-color);
            color: #fff;
            text-shadow: 0 0 10px var(--primary-color);
        }

        .standings-table tr.my-team td:last-child {
            border-right: 1px solid var(--primary-color);
        }

        .standings-table tr.my-team:hover td {
            background: linear-gradient(90deg, rgba(34, 139, 34, 0.3), rgba(34, 139, 34, 0.2));
        }

        .btn {
            background: #333;
            color: #fff;
            border: 1px solid #444;
            padding: 0.8rem 1rem;
            /* Larger touch target */
            border-radius: 4px;
            cursor: pointer;
            font-size: 1rem;
            min-height: 44px;
            /* Touch target size */
            display: inline-flex;
            justify-content: center;
            align-items: center;
        }

        .btn-primary {
            background: var(--primary-color);
            border-color: var(--primary-color);
        }

        /* Modal */
        .modal-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.7);
            display: none;
            justify-content: center;
            align-items: center;
            z-index: 1000;
        }

        #modal-overlay {
            align-items: flex-start !important;
            padding-top: 20vh !important;
        }

        #modal-box {
            background: #222;
            padding: 2rem;
            border-radius: 8px;
            border: 1px solid #444;
            text-align: center;
            max-width: 90%;
            width: 320px;
        }

        #modal-message {
            margin-bottom: 1.5rem;
            font-size: 1.1rem;
        }

        .modal-buttons {
            display: flex;
            justify-content: space-around;
            gap: 1rem;
        }

        #notification {
            position: fixed;
            top: 20px;
            left: 50%;
            transform: translateX(-50%);
            background: rgba(34, 139, 34, 0.9);
            color: #fff;
            padding: 10px 20px;
            border-radius: 20px;
            z-index: 2000;
            opacity: 0;
            transition: opacity 0.3s;
            pointer-events: none;
        }

        #notification.show {
            opacity: 1;
        }

        /* Player Menu Modal */
        #player-menu-box {
            background: #222;
            padding: 2rem;
            border-radius: 8px;
            border: 1px solid #444;
            text-align: center;
            width: 300px;
            max-width: 90%;
        }

        #pm-info {
            margin-bottom: 1.5rem;
            color: #ccc;
            font-size: 0.9rem;
        }

        /* Dashboard Redesign */
        .dashboard-container {
            display: flex;
            flex-direction: column;
            gap: 1.5rem;
            height: 100%;
        }

        .stats-bar {
            display: flex;
            justify-content: space-between;
            background: #222;
            padding: 0.8rem 1rem;
            border-radius: 8px;
            border: 1px solid #333;
            font-size: 0.9rem;
            color: #aaa;
        }

        /* Global Header */
        #global-header {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: var(--header-height);
            background: #222;
            border-bottom: 1px solid #333;
            z-index: 200;
            display: flex;
            align-items: center;
            justify-content: space-between;
            /* Changed for Title + Stats */
            padding-top: env(safe-area-inset-top);
            box-sizing: content-box;
            /* To handle padding-top correctly */
        }

        #global-header .app-title {
            font-weight: bold;
            color: #ffd700;
            font-size: 1.1rem;
            padding-left: 1rem;
            white-space: nowrap;
        }

        #global-header .stats-bar {
            width: auto;
            /* Changed from 100% */
            border: none;
            background: transparent;
            padding: 0 1rem;
            align-items: center;
            height: 100%;
            flex: 1;
            justify-content: flex-end;
            /* Align stats to right */
            gap: 1rem;
        }

        .stat-item span {
            color: #fff;
            font-weight: bold;
            margin-left: 0.3rem;
        }

        .stat-item.money span {
            color: #ffd700;
        }

        /* Breadcrumbs */
        .breadcrumbs {
            position: fixed;
            top: calc(var(--header-height) + env(safe-area-inset-top));
            left: 0;
            width: 100%;
            height: var(--breadcrumb-height);
            background: #1a1a1a;
            border-bottom: 1px solid #333;
            display: flex;
            align-items: center;
            padding: 0 1rem;
            font-size: 0.75rem;
            color: #888;
            z-index: 190;
            box-sizing: border-box;
            white-space: nowrap;
            overflow-x: auto;
        }

        .breadcrumbs a {
            color: #aaa;
            text-decoration: none;
            margin-right: 0.5rem;
            transition: color 0.2s;
        }

        .breadcrumbs a:hover {
            color: var(--primary-color);
        }

        .breadcrumbs span.separator {
            margin-right: 0.5rem;
            color: #555;
            font-size: 0.7rem;
        }

        .breadcrumbs span.current {
            color: #fff;
            font-weight: bold;
        }

        .hero-section {
            background: linear-gradient(135deg, #1a1a1a 0%, #0d0d0d 100%);
            border: 1px solid #333;
            border-radius: 12px;
            padding: 2rem 1rem;
            text-align: center;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
            position: relative;
            overflow: hidden;
        }

        .hero-section::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 4px;
            background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
        }

        .hero-title {
            font-size: 0.8rem;
            letter-spacing: 2px;
            color: #666;
            margin-bottom: 1.5rem;
            text-transform: uppercase;
        }

        .match-up {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 1rem;
            margin-bottom: 2rem;
            width: 100%;
        }

        .team-box {
            font-size: 1.2rem;
            font-weight: bold;
            color: #fff;
            text-align: center;
            flex: 1;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .team-box.home {
            color: var(--primary-color);
        }

        .vs-badge {
            font-size: 1.5rem;
            font-weight: 900;
            color: #333;
            background: #111;
            width: 40px;
            height: 40px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            border: 2px solid #333;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
        }

        .btn-kickoff {
            background: linear-gradient(180deg, var(--primary-color) 0%, #006400 100%);
            color: #fff;
            border: none;
            padding: 1rem 3rem;
            font-size: 1.2rem;
            font-weight: bold;
            border-radius: 30px;
            cursor: pointer;
            box-shadow: 0 4px 0 #004d00, 0 10px 10px rgba(0, 0, 0, 0.3);
            transition: transform 0.1s, box-shadow 0.1s;
            text-transform: uppercase;
            letter-spacing: 1px;
            min-height: 50px;
            width: 80%;
            max-width: 300px;
        }

        .btn-kickoff:active {
            transform: translateY(4px);
            box-shadow: 0 0 0 #004d00, 0 0 0 rgba(0, 0, 0, 0);
        }

        .standings-section {
            background: #222;
            border-radius: 8px;
            border: 1px solid #333;
            padding: 1rem;
            flex: 1;
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }

        .standings-section h3 {
            margin: 0 0 1rem 0;
            font-size: 1rem;
            color: #aaa;
            text-transform: uppercase;
            letter-spacing: 1px;
            text-align: center;
            border-bottom: 1px solid #333;
            padding-bottom: 0.5rem;
        }

        .standings-wrapper {
            overflow-y: auto;
            flex: 1;
            /* Custom Scrollbar */
            scrollbar-width: thin;
            scrollbar-color: #444 #222;
        }

        .field-container {
            flex: 1;
            display: flex;
            justify-content: center;
            align-items: center;
            background: url('pk_bg.png') no-repeat center center;
            background-size: cover;
            width: 100%;
            overflow: hidden;
            position: relative;
        }

        /* Match Screen Styles */
        .match-container {
            display: flex;
            flex-direction: column;
            height: 100%;
            background: #1a1a1a;
        }

        .match-hud {
            padding: 1rem;
            background: rgba(0, 0, 0, 0.8);
            /* backdrop-filter removed */
            border-bottom: 1px solid #333;
            z-index: 10;
        }

        .hud-top {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 0.5rem;
        }

        .btn-icon {
            background: rgba(255, 255, 255, 0.1);
            border: 1px solid rgba(255, 255, 255, 0.2);
            color: #fff;
            width: 40px;
            height: 40px;
            border-radius: 50%;
            display: flex;
            justify-content: center;
            align-items: center;
            cursor: pointer;
        }

        .score-display {
            display: flex;
            align-items: center;
            gap: 1rem;
            flex: 1;
            justify-content: center;
        }

        .team-info {
            display: flex;
            flex-direction: column;
            align-items: center;
            width: 80px;
        }

        .team-name {
            font-weight: bold;
            font-size: 0.9rem;
            color: #fff;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 100%;
        }

        .team-strength {
            font-size: 0.7rem;
            color: #aaa;
        }

        .score-main {
            font-size: 2rem;
            font-weight: 900;
            color: #ffd700;
            text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
            font-family: monospace;
            letter-spacing: 2px;
        }

        .match-message {
            text-align: center;
            color: #fff;
            font-size: 1rem;
            font-weight: bold;
            min-height: 1.5rem;
            text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
        }

        /* Field Pattern & Duplicate Container Removed */

        /* Small Button for language toggle */
        .btn-sm {
            background: transparent;
            border: 1px solid rgba(255, 255, 255, 0.3);
            color: #fff;
            padding: 0.2rem 0.5rem;
            border-radius: 4px;
            font-size: 0.8rem;
            cursor: pointer;
            transition: all 0.2s;
            min-width: 60px;
            text-align: center;
        }

        .btn-sm:hover {
            background: rgba(255, 255, 255, 0.1);
            border-color: #ffd700;
            color: #ffd700;
        }