body {
            font-family: 'Arial', sans-serif;
            margin: 0;
            padding: 20px;
            background: linear-gradient(135deg, #fbdaa8, #fbdaa8);
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: flex-start;
            font-family: "Didact Gothic", sans-serif;
            font-weight: 400;
            font-style: normal;
            gap: 20px;
        }

        .main-layout {
            display: flex;
            gap: 20px;
            max-width: 1400px;
            width: 100%;
            align-items: flex-start;
            justify-content: center;
        }

        .shape-reference {
            background: rgba(255, 245, 230, 0.9);
            border-radius: 15px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.2);
            padding: 20px;
            width: 200px;
            min-width: 200px;
            border: 0px solid #ffac71;
            backdrop-filter: blur(10px);
            height: fit-content;
            position: sticky;
            top: 20px;
        }

        .shape-reference h3 {
            text-align: center;
            color: #8b4513;
            margin-bottom: 20px;
            font-size: 1.2em;
            text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
        }

        .dice-shape-group {
            margin-bottom: 0;
            background: none;
            padding: 0;
            border: none;
        }

        .dice-number {
            text-align: center;
            font-size: 24px;
            font-weight: bold;
            color: #ff4500;
            margin-bottom: 10px;
            background: #fff5e6;
            border-radius: 8px;
            padding: 5px;
        }

        .reference-shapes {
            display: flex;
            flex-direction: column;
            gap: 8px;
            align-items: center;
        }

        .reference-shape {
            width: 60px;
            height: 60px;
            border:0px solid #d2691e;
            border-radius: 8px;
            position: relative;
            background: #faead2;
            transition: all 0.2s;
        }

        .reference-shape:hover {
            transform: scale(1.05);
            background: #fbc09b;
        }

        .reference-fence {
            position: absolute;
            background: #8b4513;
        }

        .game-container {
            background: #fff5e6;
            border-radius: 15px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.2);
            padding: 30px;
            max-width: 800px;
            width: 100%;
            border: 0px solid #d2691e;
            flex-shrink: 0;
        }

        h1 {
            text-align: center;
            color: #8b4513;
            margin-bottom: 30px;
            font-size: 2.5em;
            text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
        }

        .game-board {
            width: 440px;
            height: 440px;
            margin: 20px auto;
            background: #ffeedd;
            border-radius: 10px;
            position: relative;
            padding: 10px;
            border: solid 2px #d2691e;
            box-shadow: 0 4px 8px rgba(0,0,0,0.2);
        }

        .cell {
            width: 60px;
            height: 60px;
            background: transparent;
            border: none;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 24px;
            position: absolute;
            cursor: pointer;
            transition: background-color 0.2s;
        }

        .grid-point {
            position: absolute;
            width: 8px;
            height: 8px;
            z-index: 6;
        }

        .grid-point::before {
            content: '';
            position: absolute;
            width: 8px;
            height: 2px;
            background: #8b4513;
            top: 3px;
            left: 0;
        }

        .grid-point::after {
            content: '';
            position: absolute;
            width: 2px;
            height: 8px;
            background: #8b4513;
            top: 0;
            left: 3px;
        }

        .cell:hover {
            background: rgba(255, 140, 66, 0.3);
        }

        .cell.invalid-placement {
            background: rgba(255, 69, 0, 0.3) !important;
            animation: shake 0.5s;
        }

        @keyframes shake {
            0%, 100% { transform: translateX(0); }
            25% { transform: translateX(-2px); }
            75% { transform: translateX(2px); }
        }

        .sheep {
            font-size: 28px;
            animation: bounce 2s infinite;
        }

        @keyframes bounce {
            0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
            40% { transform: translateY(-5px); }
            60% { transform: translateY(-3px); }
        }

        .fence {
            position: absolute;
            background: #8b4513;
            z-index: 10;
        }

        .fence-horizontal {
            height: 4px;
            width: 60px;
        }

        .fence-vertical {
            width: 4px;
            height: 60px;
        }

        .fence-preview {
            position: absolute;
            background: rgba(139, 69, 19, 0.4);
            z-index: 8;
            border: 2px dashed rgba(139, 69, 19, 0.8);
        }

        .fence-preview-horizontal {
            height: 4px;
            width: 60px;
        }

        .fence-preview-vertical {
            width: 4px;
            height: 60px;
        }

        .fence-preview-invalid {
            background: rgba(255, 69, 0, 0.4) !important;
            border: 2px dashed rgba(255, 69, 0, 0.8) !important;
        }

        .controls {
            display: flex;
            justify-content: center;
            align-items: center;
            margin: 20px 0;
            flex-wrap: wrap;
            gap: 20px;
        }

        .dice-section {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 10px;
        }

        .dice {
            width: 80px;
            height: 80px;
            background: #fff5e6;
            border: 3px solid #d2691e;
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 36px;
            font-weight: bold;
            color: #ff4500;
            box-shadow: 0 4px 8px rgba(0,0,0,0.2);
            cursor: pointer;
            transition: transform 0.1s;
            margin-bottom: 1rem;
        }

        .dice:hover {
            transform: scale(1.05);
            background: #ffebcc;
        }

        .dice:active {
            animation: roll 0.5s;
        }

        @keyframes roll {
            0% { transform: rotate(0deg); }
            25% { transform: rotate(90deg); }
            50% { transform: rotate(180deg); }
            75% { transform: rotate(270deg); }
            100% { transform: rotate(360deg); }
        }

        .btn {
            color: white;
            padding: 12px 24px;
            border-radius: 20px;
            font-family: "Didact Gothic", sans-serif;
            font-weight: bold;
            font-size: 16px;
            cursor: pointer;
            transition: all 0.3s;
            box-shadow: 0 4px 8px rgba(0,0,0,0.2);
            margin-top: 3rem;
            display: inline-block;
            text-align: center;
            margin: 20px 0;
            background: linear-gradient(135deg, #fd7d4e, #fb642e);
            border-radius: 25px;
            display: inline-block;
            border: 2px solid rgba(255, 255, 255, 0.2);
            backdrop-filter: blur(10px);
        }

        .btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 12px rgba(0,0,0,0.3);
            background: linear-gradient(135deg, #ff7f2a, #ff5722);
        }

        .fence-shapes {
            display: flex;
            gap: 15px;
            flex-wrap: wrap;
            justify-content: center;
        }

        .shape-option {
            width: 80px;
            height: 80px;
            border: 0px solid #d2691e;
            border-radius: 30px;
            cursor: pointer;
            position: relative;
            background: #fde0b5;
            transition: all 0.3s;
        }

        .shape-option:hover {
            border-color: #ff8c42;
            transform: scale(1.05);
            background: #fbc09b;
        }

        .shape-option.selected {
            border-color: #ff4500;
            background: #ffe4b5;
            box-shadow: 0 0 15px rgba(255, 69, 0, 0.4);
        }

        .shape-fence {
            position: absolute;
            background: #8b4513;
        }

        .status {
            text-align: center;
            margin: 20px 0;
            font-size: 18px;
            font-weight: bold;
            color: #8b4513;
        }

        .protected-count {
            background: linear-gradient(135deg, #ff8c42, #ff6b35);
            color: white;
            padding: 10px 20px;
            border-radius: 20px;
            display: inline-block;
            margin: 10px;
            box-shadow: 0 4px 8px rgba(0,0,0,0.2);
            border: 2px solid rgba(255, 255, 255, 0.3);
        }

        .rolls-remaining {
            text-align: center;
            margin: 20px 0;
            font-size: 18px;
            font-weight: bold;
            color: white;
            background: linear-gradient(135deg, #ff6b35, #ff6b35);
            padding: 12px 24px;
            border-radius: 25px;
            display: inline-block;
            box-shadow: 0 4px 8px rgba(0,0,0,0.2);
            border: 2px solid rgba(255, 255, 255, 0.2);
            backdrop-filter: blur(10px);
        }

        .rolls-container {
            text-align: center;
            margin: 15px 0;
        }

        .instructions {
            background: #fff5e6;
            padding: 20px;
            border-radius: 10px;
            margin: 20px 0;
            border-left: 5px solid #ff8c42;
            border: 2px solid #ffe4b5;
        }

        .error-message {
            background: rgba(255, 69, 0, 0.1);
            color: #cc2900;
            padding: 10px;
            border-radius: 5px;
            margin: 10px 0;
            border-left: 3px solid #ff4500;
            display: none;
        }

        .bush-line {
            position: absolute;
            background: none;
            border: 2px dotted #ffeedd;
            z-index: 5;
        }

        .bush-line::before {
            content: '🌳';
            position: absolute;
            font-size: 20px;
            z-index: 7;
            pointer-events: none;
        }

        .bush-horizontal {
            height: 0;
            width: 60px;
        }

        .bush-horizontal::before {
            top: -12px;
            left: 50%;
            transform: translateX(-50%);
        }

        .bush-vertical {
            width: 0;
            height: 60px;
        }

        .bush-vertical::before {
            left: -12px;
            top: 50%;
            transform: translateY(-50%);
        }

        .sheep.protected::before {
            content: '❌';
            position: absolute;
            background: #ffffff00;
            color: white;
            border-radius: 0%;
            width: 30px;
            height: 30px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 25px;
            font-weight: bold;
            z-index: 15;
        }

        .header-section {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
        }

        .how-to-play-btn, .new-game-btn, .replay-game-btn, .print-board-btn {
            background: linear-gradient(135deg, #ff8c42, #ff6b35);
            color: white;
            border: none;
            padding: 12px 24px;
            border-radius: 8px;
            font-family: "Didact Gothic", sans-serif;
            font-weight: bold;
            font-size: 16px;
            cursor: pointer;
            transition: all 0.3s;
            box-shadow: 0 4px 8px rgba(0,0,0,0.2);
            border: 0px solid #d2691e;
            margin: 10px;
            display: inline-block;
        }

        .how-to-play-btn:hover, .new-game-btn:hover, .replay-game-btn:hover, .print-board-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 12px rgba(0,0,0,0.3);
            background: linear-gradient(135deg, #ff7f2a, #ff5722);
        }

        .button-container {
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 15px;
            margin: 20px 0;
            flex-wrap: wrap;
        }

        .modal {
            display: none;
            position: fixed;
            z-index: 1000;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.5);
            backdrop-filter: blur(5px);
        }

        .modal-content {
            background: #fff5e6;
            margin: 5% auto;
            padding: 30px;
            border: 3px solid #d2691e;
            border-radius: 15px;
            width: 90%;
            max-width: 600px;
            max-height: 80vh;
            position: relative;
            box-shadow: 0 15px 40px rgba(0,0,0,0.3);
            animation: modalSlideIn 0.3s ease-out;
            overflow-y: auto;
        }

        @keyframes modalSlideIn {
            from {
                opacity: 0;
                transform: translateY(-50px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .close {
            color: #8b4513;
            float: right;
            font-size: 28px;
            font-weight: bold;
            cursor: pointer;
            position: absolute;
            top: 15px;
            right: 20px;
            transition: color 0.3s;
        }

        .close:hover {
            color: #ff4500;
        }

        .modal h2 {
            color: #8b4513;
            margin-bottom: 20px;
            font-size: 2em;
            text-align: center;
        }

        .instructions-content {
            color: #5d4037;
            line-height: 1.6;
            font-size: 16px;
        }

        .instructions-content h3 {
            color: #ff6b35;
            margin-top: 20px;
            margin-bottom: 10px;
        }

        .instructions-content ul {
            margin-left: 20px;
        }

        .instructions-content li {
            margin-bottom: 8px;
        }

        .emoji-section {
            background: #ffebcc;
            padding: 15px;
            border-radius: 10px;
            margin: 15px 0;
            border-left: 4px solid #ff8c42;
        }

        .all-dice-shapes-reference {
            display: flex;
            flex-wrap: wrap;
            gap: 20px;
            justify-content: center;
            align-items: flex-start;
            background: rgba(255, 235, 204, 0.8);
            padding: 20px;
            border-radius: 15px;
            margin-bottom: 25px;
            width: 100%;
        }

        .all-dice-shapes-reference h3 {
            width: 100%;
            text-align: center;
            color: #8b4513;
            margin-bottom: 20px;
            font-size: 1.2em;
            text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
        }

        .all-dice-shapes-reference .reference-shapes {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 8px;
            min-width: 90px;
        }

        @media (max-width: 1400px) {
            .all-dice-shapes-reference {
                flex-direction: row;
                flex-wrap: wrap;
                justify-content: center;
                align-items: flex-start;
                width: 100%;
            }
        }

        @media (max-width: 768px) {
            .all-dice-shapes-reference {
                flex-direction: column;
                align-items: center;
                padding: 10px;
            }
            .all-dice-shapes-reference .reference-shapes {
                flex-direction: row;
                gap: 10px;
                min-width: unset;
            }
        }

        /* Responsive design */
        @media (max-width: 1400px) {
            .main-layout {
                flex-direction: column;
                align-items: center;
            }
            
            .shape-reference {
                width: 100%;
                max-width: 800px;
                position: static;
            }
            
            .dice-shape-group {
                display: flex;
                gap: 15px;
                align-items: center;
                flex-wrap: wrap;
                justify-content: center;
            }
            
            .reference-shapes {
                flex-direction: row;
                gap: 10px;
            }
        }

        @media (max-width: 768px) {
            body {
                padding: 10px;
            }
            
            .shape-reference {
                padding: 15px;
            }
            
            .game-container {
                padding: 20px;
            }
            
            .dice-shape-group {
                flex-wrap: wrap;
                justify-content: center;
            }
            
            .button-container {
                flex-wrap: wrap;
            }
        }

        .dice-shapes-row {
            display: flex;
            flex-direction: row;
            gap: 24px;
            justify-content: center;
            align-items: flex-start;
            margin: 30px 0 10px 0;
            flex-wrap: wrap;
        }

        .dice-shapes-row .reference-shapes {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 8px;
            min-width: 90px;
        }

        .dice-shapes-row .dice-number {
            text-align: center;
            font-size: 24px;
            font-weight: bold;
            color: #ff4500;
            margin-bottom: 10px;
            background: #fff5e6;
            border-radius: 8px;
            padding: 5px;
        }

        @media (max-width: 900px) {
            .dice-shapes-row {
                flex-wrap: wrap;
                gap: 12px;
            }
            .dice-shapes-row .reference-shapes {
                min-width: 70px;
            }
        }

        @media (max-width: 600px) {
            .dice-shapes-row {
                flex-direction: row !important;
                align-items: flex-start;
                gap: 6px;
                flex-wrap: wrap;
            }
            .dice-shapes-row .reference-shapes {
                flex-direction: column !important;
                min-width: 60px;
                gap: 4px;
            }
        }

        @media (max-width: 600px) {
            body {
                background: #fff5e6 !important;
            }
            .game-container {
                background: #fff5e6 !important;
                border: none;
                box-shadow: none;
                padding: 10px;
            }
        }

        @media (max-width: 600px) {
            .game-container > *:not(.game-board) {
                margin-left: 20vw;
            }
        }

        @media (max-width: 600px) {
    /* Protected sheep and rolls remaining side by side */
    .rolls-container, .protected-count {
        display: inline-block;
        vertical-align: middle;
        margin: 0 4px 10px 0;
    }
    .rolls-container {
        margin-bottom: 0;
    }
    .protected-rolls-row {
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 8px;
        margin-bottom: 10px;
    }
    /* Replay and new random board side by side */
    .replay-new-row {
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 8px;
        margin-bottom: 10px;
    }
    /* How to play and download printable board side by side */
    .howto-download-row {
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 8px;
        margin-bottom: 10px;
    }
    /* Remove extra vertical spacing for these button rows */
    .button-container {
        flex-direction: column;
        gap: 0;
    }
    .replay-new-row button,
    .howto-download-row button {
        min-width: 36vw;
        font-size: 0.95em;
        padding: 8px 0;
    }
    .protected-rolls-row > * {
        min-width: 32vw;
        font-size: 0.95em;
        padding: 8px 0;
    }
}

.undo-fence-btn {
    background: linear-gradient(135deg, #ffb347, #ff7f50);
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 20px;
    font-family: "Didact Gothic", sans-serif;
    font-weight: bold;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    margin: 10px 0 0 0;
    display: block;
    width: 100%;
    max-width: 220px;
    margin-left: auto;
    margin-right: auto;
}
.undo-fence-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
@media (max-width: 600px) {
    .undo-fence-btn {
        min-width: 36vw;
        font-size: 1em;
        padding: 10px 0;
        margin: 8px auto 0 auto;
        max-width: 90vw;
    }
}

