    * {
        box-sizing: border-box;
    }
    html, body {
        margin: 0;
        padding: 0;
        height: 100%;
        height: 100dvh; /* excludes mobile browser toolbars; fixes bottom clipping */
        overflow: hidden;
    }
    body {
        font-family: 'Roboto', Arial, sans-serif;
        background-color: #111;
        color: white;
        display: flex;
        flex-direction: column;
    }
    .header {
        background: linear-gradient(180deg, #2a2a2a, #1a1a1a);
        padding: 10px 20px;
        box-shadow: 0 4px 10px rgba(0,0,0,0.6);
        border-bottom: 1px solid #333;
        flex-shrink: 0;
    }
    .header-title-container {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 5px 0 10px 0;
        border-bottom: 1px solid #444;
        margin-bottom: 15px;
    }
    .header-title {
        font-family: 'Playfair Display', serif;
        font-size: 2.0rem;
        letter-spacing: 2px;
        color: #eee;
        text-shadow: 0 0 5px rgba(255, 255, 255, 0.2);
        margin: 0;
    }
    .header-title .version-number {
        font-family: 'Roboto', sans-serif;
        font-size: 0.5em;
        color: #999;
        margin-left: 5px;
        font-weight: normal;
    }
    .header-section {
        display: flex;
        align-items: center;
        gap: 15px;
    }
    .header-top, .header-middle, .header-bottom {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 20px;
        padding: 5px 0;
    }
    .header-top {
        justify-content: space-between;
        gap: 10px;
        margin-top: 10px;
        flex-wrap: wrap;
    }
    .header-middle {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 10px 0;
        font-size: 15px;
        font-family: 'Playfair Display', serif;
    }
    .header-middle .win-section {
        align-items: center;
        gap: 8px;
        color: #aaa;
        display: flex;
    }
    .score-section {
        gap: 8px;
    }
    select, button {
        background: #3c3c3c;
        color: #ddd;
        border: 1.5px solid #555;
        padding: 8px 12px;
        border-radius: 8px;
        font-size: 14px;
        cursor: pointer;
        transition: background-color 0.2s, box-shadow 0.2s;
        font-family: 'Roboto', Arial, sans-serif;
    }
    .icon-button {
        background: #3c3c3c;
        color: #ddd;
        border: 1.5px solid #555;
        width: 38px;
        height: 38px;
        padding: 0;
        border-radius: 8px;
        font-size: 16px;
        cursor: pointer;
        transition: background-color 0.2s, box-shadow 0.2s;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .icon-button.top-right-icon {
        margin-left: auto;
    }
    button:hover, select:hover, .icon-button:hover {
        background: #4a4a4a;
        box-shadow: 0 0 5px rgba(255,255,255,0.1);
    }
    .turn-indicator {
        display: flex;
        align-items: center;
        gap: 10px;
    }
    .turn-piece {
        width: 22px;
        height: 22px;
        border-radius: 50%;
        display: inline-block;
        transition: transform 0.3s;
    }
    .turn-piece.black {
        background-color: black;
    }
    .turn-piece.white {
        background-color: white;
        border: 1px solid #777;
    }
    .turn-message {
        font-weight: 600;
        letter-spacing: 0.5px;
        font-size: 16px;
    }
    .turn-message.green {
        color: #00ff00;
    }
    .turn-message.red {
        color: #ff0000;
    }
    .turn-message.dim {
        color: #aaa;
    }
    .score, .win-counts {
        display: flex;
        align-items: center;
        gap: 8px;
        font-weight: bold;
        font-family: 'Roboto', Arial, sans-serif;
    }
    .score .piece, .win-counts .piece {
        width: 20px;
        height: 20px;
        border-radius: 50%;
    }
    .win-counts {
        position: relative;
    }
    .turn-indicator.inactive .turn-piece {
        display: none;
    }
    .header-bottom {
        padding: 10px 0;
    }
    .time-bank-section {
        display: flex;
        gap: 15px;
        transition: opacity 0.3s ease-in-out;
    }
    .time-bank-section.inactive {
        opacity: 0.2;
    }
    .time-bank-section .time {
        display: flex;
        align-items: center;
        gap: 8px;
        font-size: 16px;
        font-weight: bold;
    }
    .time-bank-section .piece {
        width: 22px;
        height: 22px;
        border-radius: 50%;
    }
    .time-bank-section .timer-value {
        transition: color 0.3s;
    }
    .time-bank-section .timer-value.green { color: #00ff00; }
    .time-bank-section .timer-value.yellow { color: #ffff00; }
    .time-bank-section .timer-value.red { color: #ff0000; }

    .game-container {
        flex: 1;
        min-height: 0; /* allow the board to shrink to fit instead of overflowing */
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 12px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
        position: relative;
    }
    canvas {
        background-color: #006400;
        border-radius: 12px;
        box-shadow: 0 0 15px rgba(0,0,0,0.5);
        touch-action: manipulation;
        transition: opacity 0.5s ease-in-out;
    }
    canvas.dimmed {
        opacity: 0.7;
    }
    #game-over-overlay, #info-modal-overlay {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.85);
        display: none;
        z-index: 100;
        backdrop-filter: blur(5px);
        align-items: center;
        justify-content: center;
    }
    .modal-content {
        background: #2a2a2a;
        border: 2px solid #555;
        border-radius: 10px;
        padding: 30px;
        text-align: center;
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
        max-width: 90%;
        max-height: 90%;
        overflow-y: auto;
    }
    #game-over-overlay h2, #info-modal-overlay h2 {
        margin: 0 0 15px;
        font-size: 24px;
        font-family: 'Playfair Display', serif;
    }
    #game-over-overlay p, #info-modal-overlay p {
        font-size: 18px;
        margin: 0;
    }
    #game-over-overlay p.score-line {
        margin-top: 5px;
    }
    .modal-content .button-group {
        margin-top: 20px;
        display: flex;
        justify-content: center;
        gap: 10px;
    }
    #info-modal-overlay h3 {
        margin-top: 20px;
    }
    #info-modal-overlay ul {
        text-align: left;
        margin-top: 20px;
        padding-left: 20px;
    }
    #info-modal-overlay li {
        margin-bottom: 10px;
    }
    .pulsing-dots {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 4px;
    }
    .pulsing-dots span {
        display: inline-block;
        width: 6px;
        height: 6px;
        background-color: #eee;
        border-radius: 50%;
        animation: pulse-dot 1.5s infinite ease-in-out;
    }
    .pulsing-dots span:nth-child(2) {
        animation-delay: 0.2s;
    }
    .pulsing-dots span:nth-child(3) {
        animation-delay: 0.4s;
    }
    @keyframes pulse-dot {
        0%, 80%, 100% { transform: scale(0); opacity: 0; }
        40% { transform: scale(1); opacity: 1; }
    }
    
    .about-header {
        text-align: left;
        margin: -10px 0 20px 0;
        padding-bottom: 16px;
        border-bottom: 1px solid #444;
    }
    .about-header .about-title {
        font-family: 'Playfair Display', serif;
        font-weight: 700;
        font-size: 2rem;
        line-height: 1.1;
        color: #fff;
    }
    .about-header .about-title .about-version {
        font-family: 'Roboto', monospace;
        font-size: 1rem;
        font-weight: 400;
        color: #8a8a8a;
        margin-left: 8px;
    }
    .about-header .about-sub {
        font-family: 'Roboto', monospace;
        font-size: 0.95rem;
        color: #9a9a9a;
        margin-top: 6px;
    }

    .info-content-wrapper {
        text-align: left;
        width: 100%;
    }
    .info-content-wrapper h2, .info-content-wrapper h3 {
        text-align: center;
    }
    .info-content-wrapper hr {
        border: 0;
        height: 1px;
        background: #444;
        margin: 20px 0;
    }
    .version-history-section h4 {
        margin: 10px 0 15px 0;
        font-size: 18px;
    }
    .version-history-section ul {
        margin-top: 0;
    }
    .version-history-section .change-type {
        font-weight: bold;
        font-style: italic;
        margin-right: 5px;
        font-size: 14px;
    }
    #close-info-modal {
        margin-top: 25px;
    }

    /* Landscape Layout */
    @media (orientation: landscape) {
        body {
            flex-direction: row;
        }
        .header {
            width: 400px; /* Increased from 320px to fit controls in one row */
            height: 100%;
            flex-shrink: 0;
            border-bottom: none;
            border-right: 1px solid #333;
            box-shadow: 4px 0 10px rgba(0,0,0,0.6);
            padding: 10px 15px;
            overflow-y: auto;
        }
        .header-title-container {
            flex-direction: row;
            align-items: center;
        }
        .header-title {
            font-size: 2rem;
            margin-right: auto;
        }
        .header-top {
            flex-wrap: wrap;
            justify-content: space-between;
        }
        .game-container {
            margin-top: 0; /* Remove the portrait-only offset in landscape */
        }
    }
