:root {
            --bg: #f4e7c5;
            --panel: rgba(98, 53, 27, 0.95);
            --text: #fff;
            --accent: #d9a441;
            --green: #37b24d;
            --red: #d94841;
            --blue: #4c8bf5;
            --wood: #d9af67;
            --line: #6e3f18;
            --black-piece: #222;
            --red-piece: #b02020;
        }

        * {
            box-sizing: border-box;
            -webkit-tap-highlight-color: transparent;
        }

        html, body {
            margin: 0;
            padding: 0;
            width: 100%;
            min-height: 100%;
            font-family: Arial, Helvetica, sans-serif;
            background: linear-gradient(180deg, #e8d3a4, #f8edd3);
            color: #222;
        }

        body {
            overflow-x: hidden;
        }

        .screen {
            min-height: 100vh;
            width: 100%;
        }

        #bootScreen {
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 42px;
            font-weight: 900;
            color: #5e3419;
        }

        #appScreen {
            display: none;
        }

        #appTopBar {
            position: sticky;
            top: 0;
            z-index: 10;
            background: rgba(83, 43, 20, 0.96);
            color: #fff;
            border-bottom: 1px solid rgba(255,255,255,0.08);
            backdrop-filter: blur(6px);
        }

        .topInner {
            width: min(1200px, 96vw);
            margin: 0 auto;
            padding: 12px 0;
            display: flex;
            gap: 12px;
            justify-content: space-between;
            align-items: center;
            flex-wrap: wrap;
        }

        .badgeGroup {
            display: flex;
            gap: 10px;
            flex-wrap: wrap;
        }

        .badge {
            background: rgba(255,255,255,0.12);
            padding: 10px 14px;
            border-radius: 12px;
            font-weight: 800;
        }

        button, a.topLink {
            border: none;
            cursor: pointer;
            border-radius: 12px;
            padding: 12px 16px;
            font-size: 15px;
            font-weight: 900;
            color: #fff;
            text-decoration: none;
            display: inline-flex;
            align-items: center;
            justify-content: center;
        }

        .btn-green { background: linear-gradient(180deg, #3acb54, #2ca544); }
        .btn-blue { background: linear-gradient(180deg, #62a4ff, #387cf0); }
        .btn-red { background: linear-gradient(180deg, #ec5c5c, #cf3e3e); }
        .btn-yellow { background: linear-gradient(180deg, #f6c35d, #dfa132); color: #fff; }
        .btn-gray { background: linear-gradient(180deg, #8f8f8f, #6f6f6f); }

        #appContent {
            width: min(1200px, 96vw);
            margin: 20px auto 40px;
            display: grid;
            grid-template-columns: 360px 1fr;
            gap: 18px;
        }

        .panel {
            background: rgba(96, 53, 27, 0.95);
            color: #fff;
            border-radius: 18px;
            padding: 16px;
            box-shadow: 0 12px 28px rgba(0,0,0,0.14);
        }

        .panel h2, .panel h3 {
            margin: 0 0 12px;
        }

        .roomCreateRow {
            display: flex;
            gap: 10px;
            margin-bottom: 12px;
        }

        .roomCreateRow input {
            flex: 1;
            border: none;
            outline: none;
            border-radius: 10px;
            padding: 12px;
            font-size: 14px;
        }

        #roomList {
            display: flex;
            flex-direction: column;
            gap: 10px;
            max-height: 520px;
            overflow: auto;
            padding-right: 4px;
        }

        .roomItem {
            background: rgba(255,255,255,0.1);
            border-radius: 14px;
            padding: 12px;
        }

        .roomItemTitle {
            font-size: 16px;
            font-weight: 900;
            margin-bottom: 8px;
        }

        .roomMeta {
            font-size: 13px;
            line-height: 1.5;
            opacity: 0.95;
            margin-bottom: 10px;
        }

        #gameArea {
            min-height: 720px;
            position: relative;
        }

        #lobbyEmpty {
            display: flex;
            align-items: center;
            justify-content: center;
            min-height: 660px;
            text-align: center;
            color: rgba(255,255,255,0.88);
            font-size: 22px;
            font-weight: 800;
            background: rgba(255,255,255,0.06);
            border-radius: 16px;
        }

        #roomArea {
            display: none;
        }

        #roomHeader {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 12px;
            flex-wrap: wrap;
            margin-bottom: 12px;
        }

        #roomStatusLine {
            font-size: 15px;
            font-weight: 800;
            color: #ffe7ae;
        }

        #boardWrap {
            position: relative;
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 8px 0 16px;
        }

        canvas#boardCanvas {
            width: min(72vw, 540px);
            height: auto;
            max-width: 540px;
            aspect-ratio: 9 / 10;
            background: #ddb56f;
            border-radius: 16px;
            box-shadow: inset 0 0 0 3px rgba(110,63,24,0.45), 0 12px 22px rgba(0,0,0,0.18);
            touch-action: none;
        }

        #effectOverlay {
            position: absolute;
            inset: 0;
            pointer-events: none;
            display: flex;
            align-items: center;
            justify-content: center;
            overflow: hidden;
        }

        #centerBanner {
            position: absolute;
            padding: 14px 28px;
            border-radius: 18px;
            font-size: clamp(28px, 4vw, 52px);
            font-weight: 900;
            color: #fff6d8;
            background: linear-gradient(180deg, rgba(191,30,30,0.94), rgba(129,13,13,0.94));
            border: 2px solid rgba(255,232,160,0.85);
            box-shadow: 0 0 0 3px rgba(255,255,255,0.1), 0 14px 40px rgba(0,0,0,0.28);
            opacity: 0;
            transform: scale(0.7);
            transition: all 0.25s ease;
            text-shadow: 0 2px 4px rgba(0,0,0,0.35);
        }

        #centerBanner.show {
            opacity: 1;
            transform: scale(1);
        }

        #gameInfo {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 12px;
            margin-top: 10px;
        }

        .infoBlock {
            background: rgba(255,255,255,0.1);
            border-radius: 14px;
            padding: 12px;
        }

        .infoBlock strong {
            display: block;
            margin-bottom: 8px;
            color: #ffe4ad;
        }

        #movesList {
            max-height: 180px;
            overflow: auto;
            font-size: 14px;
            line-height: 1.6;
            white-space: pre-wrap;
        }

        #roomActions {
            display: flex;
            gap: 10px;
            flex-wrap: wrap;
            margin-top: 14px;
        }

        #gameMessage {
            min-height: 24px;
            margin-top: 10px;
            font-weight: 800;
            color: #fff1b6;
        }

        .smallText {
            font-size: 13px;
            opacity: 0.9;
        }

        @media (max-width: 980px) {
            #appContent {
                grid-template-columns: 1fr;
            }

            #gameArea {
                min-height: auto;
            }

            #lobbyEmpty {
                min-height: 220px;
            }

            #gameInfo {
                grid-template-columns: 1fr;
            }

}