:root {
    --board-bg: #fffef5;
    --square-border: #c9b896;
    --valley-bg: #fef6e8;
    --mountain-bg: #e8f5e8;
    --funding-valley: #ffe8e8;
    --peak-bg: #d5ead5;
    --plateau-bg: #c8e6c9;
    --text-dark: #333333;
    --text-light: #ffffff;
    --mountain-green: #5a8f52;
    --valley-red: #d32f2f;
    --player-blue: #2196f3;
    --player-red: #f44336;
    --player-yellow: #ffc107;
    --player-purple: #9c27b0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background: #f0e9d8;
    min-height: 100vh;
    min-height: -webkit-fill-available;
    color: var(--text-dark);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

html {
    height: -webkit-fill-available;
}

.game-container {
    max-width: 1400px;
    width: 100%;
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.game-header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: linear-gradient(135deg, var(--mountain-green) 0%, var(--peak-bg) 100%);
    border-radius: 15px;
    color: white;
    box-shadow: 0 5px 20px rgba(90, 143, 82, 0.3);
}

.game-header h1 {
    font-size: 2.5em;
    font-weight: bold;
    letter-spacing: 1px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 0.9em;
    color: #ffeeee;
    font-weight: normal;
}

.tagline {
    font-style: italic;
    margin-top: 10px;
    color: #e8f5e8;
    font-size: 0.9em;
}

.game-controls {
    text-align: center;
    margin-bottom: 30px;
}

.player-setup {
    background: #f8f5f0;
    padding: 25px;
    border-radius: 15px;
    border: 2px solid var(--square-border);
}

.player-setup h2 {
    color: var(--text-dark);
    margin-bottom: 20px;
    font-size: 1.8em;
}

.player-options {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 15px;
}

.player-btn {
    padding: 12px 25px;
    font-size: 1.1em;
    background: var(--mountain-green);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: bold;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.player-btn:hover {
    background: var(--peak-bg);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.game-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
}

.current-player {
    font-size: 1.2em;
    color: var(--text-dark);
}

.player-name {
    font-weight: bold;
    color: var(--mountain-green);
    margin-left: 10px;
}

.dice-btn {
    background: var(--valley-red);
    border: none;
    padding: 15px 25px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.dice-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(192, 57, 43, 0.4);
}

.dice-btn:active {
    transform: scale(0.95);
}

/* Touch-friendly hover states for mobile */
@media (hover: none) and (pointer: coarse) {
    .player-btn:hover,
    .dice-btn:hover,
    .new-game-btn:hover {
        transform: none;
        box-shadow: none;
    }
    
    .player-btn:active,
    .dice-btn:active,
    .new-game-btn:active {
        transform: scale(0.95);
    }
}

.dice {
    width: 50px;
    height: 50px;
    background: white;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2em;
    color: var(--valley-floor);
    font-weight: bold;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.2);
}

.dice.rolling {
    animation: diceRoll 0.5s ease-in-out;
}

@keyframes diceRoll {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(180deg); }
    50% { transform: rotate(360deg); }
    75% { transform: rotate(540deg); }
}

.dice-label {
    color: white;
    font-weight: bold;
    text-transform: uppercase;
}

.turn-info {
    margin-top: 10px;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: bold;
    transition: all 0.3s;
}

.turn-info.success {
    background: var(--mountain-green);
    color: white;
}

.turn-info.danger {
    background: var(--valley-red);
    color: white;
}

.board-container {
    display: flex;
    gap: 30px;
    align-items: flex-start;
    width: 100%;
}

.board-wrapper {
    position: relative;
    flex: 1;
    max-width: 800px;
    margin: 0 auto;
}

.board {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    grid-template-rows: repeat(10, 1fr);
    gap: 0;
    background: var(--board-bg);
    padding: 20px;
    border-radius: 15px;
    width: 100%;
    border: 3px solid var(--square-border);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    position: relative;
}

.board::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--board-bg);
    border-radius: 15px;
    z-index: -1;
}

/* SVG layer for mountains and valleys */
.mountains-valleys-svg {
    position: absolute;
    pointer-events: none;
    z-index: 1; /* Between background (-1) and squares (2) */
}

.square {
    aspect-ratio: 1;
    position: relative;
    transition: all 0.3s;
    cursor: pointer;
    overflow: hidden;
}

/* Square background layer */
.square-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    background: white;
}

/* Square content layer */
.square-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9em;
    border: 1px solid var(--square-border);
    z-index: 2;
}

/* Elevation zones */
.square-background.valley-zone {
    background: var(--valley-bg);
}

.square-background.mountain-zone-1 {
    background: var(--mountain-bg);
}

.square-background.funding-valley {
    background: var(--funding-valley);
}

.square-background.mountain-zone-2 {
    background: var(--peak-bg);
}

.square-background.deployment-plateau {
    background: var(--plateau-bg);
}

/* Special squares */
.square-content.mountain {
    border: 3px solid var(--mountain-green);
    box-shadow: inset 0 0 10px rgba(90, 143, 82, 0.3);
}

.square-content.valley {
    border: 3px solid var(--valley-red);
    box-shadow: inset 0 0 10px rgba(192, 57, 43, 0.3);
}


.square-number {
    position: absolute;
    top: 2px;
    left: 5px;
    font-size: 0.75em;
    color: black;
    font-weight: bold;
    z-index: 2;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
}

.square-label {
    font-size: 0.6em;
    text-align: center;
    padding: 2px;
    line-height: 1.1;
    color: black;
    font-weight: normal;
    z-index: 2;
    position: relative;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
}

.start-label, .finish-label {
    font-weight: bold;
}

.start-label {
    font-size: 0.8em;
    color: #2e7d32;
    text-shadow: 1px 1px 3px rgba(255, 255, 255, 0.9);
}

.finish-label {
    font-size: 0.5em;
    color: #d32f2f;
    text-shadow: 1px 1px 3px rgba(255, 255, 255, 0.9);
    line-height: 1.2;
}

/* Player pieces */
.player-piece {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    position: absolute;
    transition: all 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    font-size: 0.9em;
    z-index: 3;
    border: 2px solid white;
}

.player-piece.player-1 { background: var(--player-blue); }
.player-piece.player-2 { background: var(--player-red); }
.player-piece.player-3 { background: var(--player-yellow); }
.player-piece.player-4 { background: var(--player-purple); }

.player-piece.moving {
    animation: bounce 0.5s ease-in-out;
}

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

/* Legend */
.legend {
    background: #f8f5f0;
    padding: 25px;
    border-radius: 15px;
    width: 300px;
    border: 2px solid var(--square-border);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.legend h3 {
    text-transform: uppercase;
    margin-bottom: 20px;
    color: var(--text-dark);
    text-align: center;
    font-size: 1.3em;
}

.legend-section {
    margin-bottom: 20px;
}

.legend-section h4 {
    font-size: 1.1em;
    margin-bottom: 10px;
    color: var(--text-dark);
    font-weight: bold;
}

.legend-section ul {
    list-style: none;
}

.legend-section li {
    margin-bottom: 8px;
    font-size: 0.95em;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-dark);
}

.square-ref {
    background: white;
    padding: 3px 8px;
    border-radius: 5px;
    font-family: monospace;
    white-space: nowrap;
    border: 1px solid var(--square-border);
    font-size: 0.9em;
    color: var(--text-dark);
}

/* Win overlay */
.win-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.win-content {
    background: white;
    padding: 50px;
    border-radius: 20px;
    text-align: center;
    max-width: 500px;
    border: 4px solid var(--mountain-green);
    animation: winAnimation 0.5s ease-out;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

@keyframes winAnimation {
    from {
        transform: scale(0.5);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.win-content h2 {
    color: var(--mountain-green);
    font-size: 2.8em;
    margin-bottom: 20px;
}

.win-player {
    font-size: 1.6em;
    color: var(--text-dark);
    margin-bottom: 20px;
    font-weight: bold;
}

.new-game-btn {
    padding: 15px 40px;
    font-size: 1.2em;
    background: var(--mountain-green);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    text-transform: uppercase;
    font-weight: bold;
    transition: all 0.3s;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.new-game-btn:hover {
    transform: scale(1.05);
    background: var(--peak-bg);
    box-shadow: 0 5px 15px rgba(90, 143, 82, 0.4);
}

/* Utility classes */
.hidden {
    display: none !important;
}

/* Responsive design */
@media (max-width: 1200px) {
    .board-container {
        flex-direction: column;
        align-items: center;
    }
    
    .board-wrapper {
        width: 100%;
    }
    
    .legend {
        width: 100%;
        max-width: 600px;
        margin-top: 20px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .game-container {
        padding: 15px;
    }
    
    .game-header {
        padding: 15px;
        margin-bottom: 20px;
    }
    
    .game-header h1 {
        font-size: 1.5em;
        letter-spacing: 0.5px;
    }
    
    .subtitle {
        font-size: 0.85em;
    }
    
    .tagline {
        font-size: 0.8em;
    }
    
    .board-container {
        flex-direction: column;
    }
    
    .board-wrapper {
        width: 100%;
        max-width: 100%;
    }
    
    .board {
        width: 100%;
        aspect-ratio: 1;
        padding: 10px;
    }
    
    .square {
        font-size: 0.6em;
    }
    
    .square-number {
        font-size: 0.6em;
        top: 1px;
        left: 2px;
    }
    
    .square-label {
        font-size: 0.5em;
        padding: 1px;
    }
    
    .player-piece {
        width: 20px;
        height: 20px;
        font-size: 0.7em;
        border-width: 1px;
    }
    
    .game-status {
        flex-direction: column;
        gap: 10px;
    }
    
    .current-player {
        font-size: 1em;
    }
    
    .dice-btn {
        padding: 10px 20px;
    }
    
    .dice {
        width: 40px;
        height: 40px;
        font-size: 1.5em;
    }
    
    .legend {
        width: 100%;
        padding: 15px;
        margin-top: 15px;
    }
    
    .legend h3 {
        font-size: 1.1em;
        margin-bottom: 15px;
    }
    
    .legend-section h4 {
        font-size: 0.95em;
    }
    
    .legend-section li {
        font-size: 0.85em;
        margin-bottom: 6px;
    }
    
    .square-ref {
        font-size: 0.8em;
        padding: 2px 6px;
    }
}

@media (max-width: 480px) {
    .game-container {
        padding: 10px;
        border-radius: 10px;
    }
    
    .game-header {
        padding: 10px;
        margin-bottom: 15px;
    }
    
    .game-header h1 {
        font-size: 1.2em;
    }
    
    .subtitle {
        font-size: 0.8em;
    }
    
    .tagline {
        font-size: 0.75em;
        margin-top: 5px;
    }
    
    .player-setup h2 {
        font-size: 1.3em;
        margin-bottom: 15px;
    }
    
    .player-options {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .player-btn {
        padding: 10px 15px;
        font-size: 0.9em;
        width: calc(50% - 5px);
    }
    
    .board {
        padding: 8px;
        border-width: 2px;
    }
    
    .square {
        font-size: 0;
    }
    
    .square-number {
        font-size: 0.55em;
    }
    
    .square-label {
        font-size: 0.45em;
        line-height: 1;
    }
    
    .start-label {
        font-size: 0.6em;
    }
    
    .finish-label {
        font-size: 0.4em;
    }
    
    .player-piece {
        width: 16px;
        height: 16px;
        font-size: 0.6em;
    }
    
    .legend {
        padding: 12px;
        font-size: 0.9em;
    }
    
    .legend h3 {
        font-size: 1em;
        margin-bottom: 12px;
    }
    
    .legend-section {
        margin-bottom: 15px;
    }
    
    .legend-section h4 {
        font-size: 0.9em;
        margin-bottom: 8px;
    }
    
    .legend-section li {
        font-size: 0.8em;
        margin-bottom: 5px;
    }
    
    .win-content {
        padding: 30px 20px;
    }
    
    .win-content h2 {
        font-size: 2em;
    }
    
    .win-player {
        font-size: 1.3em;
    }
    
    .win-message {
        font-size: 0.9em;
    }
    
    .new-game-btn {
        padding: 12px 25px;
        font-size: 1em;
    }
}

/* Extra small devices */
@media (max-width: 360px) {
    .board {
        padding: 5px;
    }
    
    .square-number {
        font-size: 0.5em;
    }
    
    .square-label {
        display: none;
    }
    
    .player-piece {
        width: 14px;
        height: 14px;
        font-size: 0.5em;
    }
}