/* ===================================
   Mensch Ärger Dich Nicht - Styles
   Modern Glassmorphism Design
   =================================== */

/* --- Import Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Nunito:wght@400;600;700&display=swap');

/* --- CSS Variables --- */
:root {
    /* Player Colors */
    --red: #e53935;
    --red-dark: #b71c1c;
    --red-light: #ff6f60;

    --blue: #1e88e5;
    --blue-dark: #0d47a1;
    --blue-light: #62b4ff;

    --green: #43a047;
    --green-dark: #1b5e20;
    --green-light: #76d275;

    --yellow: #fdd835;
    --yellow-dark: #c6a700;
    --yellow-light: #ffff6b;

    /* Glass Design Tokens */
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: 1px solid rgba(255, 255, 255, 0.12);
    --glass-blur: blur(20px);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);

    /* Board */
    --board-bg: rgba(255, 255, 255, 0.04);
    --board-border: rgba(255, 255, 255, 0.15);
    --field-light: rgba(255, 255, 255, 0.08);
    --field-border: rgba(255, 255, 255, 0.15);
}

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

html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Nunito', sans-serif;
    background-color: var(--body-bg-color, #0B1020);
    background-image: var(--body-bg-image,
            radial-gradient(at 0% 0%, hsla(253, 60%, 25%, 0.4) 0px, transparent 50%),
            radial-gradient(at 100% 100%, hsla(280, 70%, 30%, 0.5) 0px, transparent 50%));
    background-attachment: fixed;
    color: var(--text-color, white);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px;
}

/* --- Page Title --- */
#page-title {
    font-family: 'Fredoka One', cursive;
    font-size: 2.5rem;
    background: linear-gradient(135deg, var(--primary, #a24cff), var(--akzent, #ffc800));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 20px;
    text-align: center;
    animation: titleBounce 0.6s ease-out;
}

@keyframes titleBounce {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* --- Dialog Box --- */
.dialog-box {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: var(--glass-border);
    border-radius: 20px;
    padding: 25px;
    max-width: min(550px, 98vw);
    width: 100%;
    box-shadow: var(--glass-shadow);
    text-align: center;
    max-height: 95vh;
    overflow-y: auto;
}

.dialog-box h2 {
    font-family: 'Fredoka One', cursive;
    color: var(--text-color, white);
    margin-bottom: 20px;
    font-size: 1.8rem;
}

/* --- Mode Selection Buttons --- */
.mode-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 10px;
}

.mode-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 15px;
    color: var(--text-color, white);
    padding: 20px 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    min-width: 120px;
}

.mode-btn i {
    font-size: 2rem;
    color: var(--primary, #a24cff);
}

.mode-btn small {
    font-size: 0.7rem;
    opacity: 0.7;
}

.mode-btn:hover {
    transform: translateY(-3px);
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary, #a24cff);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.mode-btn.active {
    background: rgba(162, 76, 255, 0.2);
    border-color: var(--primary, #a24cff);
    box-shadow: 0 0 20px rgba(162, 76, 255, 0.3);
}

/* --- Mode Options Container --- */
.mode-options {
    animation: fadeIn 0.3s ease;
}

.mode-options h6 {
    color: var(--text-color, white);
    font-weight: 700;
    margin-bottom: 15px;
}

/* --- Player Selection Buttons --- */
.player-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.player-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 15px;
    color: var(--text-color, white);
    padding: 15px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
    min-width: 80px;
}

.player-btn .player-num {
    font-family: 'Fredoka One', cursive;
    font-size: 1.8rem;
    line-height: 1;
}

.player-btn:hover {
    transform: translateY(-3px);
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary, #a24cff);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.player-btn.active {
    background: rgba(162, 76, 255, 0.2);
    border-color: var(--primary, #a24cff);
    box-shadow: 0 0 20px rgba(162, 76, 255, 0.3);
}

/* --- Online Mode Styles --- */
.lobby-actions {
    margin-top: 20px;
    background: rgba(255, 255, 255, 0.04);
    padding: 15px;
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-online {
    background: linear-gradient(135deg, var(--primary, #a24cff), rgba(162, 76, 255, 0.7));
    border: none;
    border-radius: 15px;
    color: white;
    padding: 15px 30px;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-online:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(162, 76, 255, 0.4);
    filter: brightness(1.1);
}

.or-divider {
    color: rgba(255, 255, 255, 0.4);
    margin: 15px 0;
    font-weight: 600;
}

.join-section {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.game-code-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 12px 15px;
    font-family: 'Fredoka One', cursive;
    font-size: 1.2rem;
    text-transform: uppercase;
    text-align: center;
    letter-spacing: 3px;
    color: var(--text-color, white);
    outline: none;
    transition: border-color 0.3s ease;
}

.game-code-input::placeholder {
    color: rgba(255, 255, 255, 0.35);
    letter-spacing: 1px;
}

.game-code-input:focus {
    border-color: var(--primary, #a24cff);
}

.btn-join {
    background: linear-gradient(135deg, var(--primary, #a24cff), rgba(162, 76, 255, 0.7));
    border: none;
    border-radius: 12px;
    color: white;
    padding: 12px 20px;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn-join:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(162, 76, 255, 0.4);
}

/* --- Lobby Styles --- */
.game-code-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 20px 0;
}

.game-code-display span {
    color: rgba(255, 255, 255, 0.6);
    font-weight: 600;
}

.code-box {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--primary, #a24cff);
    border-radius: 10px;
    padding: 10px 20px;
    font-family: 'Fredoka One', cursive;
    font-size: 1.5rem;
    letter-spacing: 4px;
    color: var(--akzent, #ffc800);
}

.btn-copy {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: var(--text-color, white);
    padding: 10px 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-copy:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--primary, #a24cff);
}

.players-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin: 20px 0;
}

.player-slot {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.04);
    padding: 12px 15px;
    border-radius: 10px;
    border: 1px dashed rgba(255, 255, 255, 0.15);
    transition: all 0.3s ease;
}

.player-slot.occupied {
    background: rgba(255, 255, 255, 0.08);
    border-style: solid;
    border-color: rgba(255, 255, 255, 0.2);
}

.slot-color {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid rgba(0, 0, 0, 0.2);
}

.player-slot[data-color="red"] .slot-color {
    background: var(--red);
}

.player-slot[data-color="blue"] .slot-color {
    background: var(--blue);
}

.player-slot[data-color="green"] .slot-color {
    background: var(--green);
}

.player-slot[data-color="yellow"] .slot-color {
    background: var(--yellow);
}

.slot-name {
    color: rgba(255, 255, 255, 0.8);
    font-weight: 600;
}

.lobby-hint {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.9rem;
    margin-bottom: 15px;
}

/* --- Color Selection --- */
.color-selection h6 {
    color: var(--text-color, white);
    font-weight: 700;
    margin-bottom: 15px;
}

.color-toggles {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.color-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.06);
    padding: 8px 15px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-color, white);
    font-weight: 600;
}

.color-toggle:hover {
    background: rgba(255, 255, 255, 0.12);
}

.color-toggle input {
    display: none;
}

.color-toggle input:checked+.color-box {
    transform: scale(1.2);
    box-shadow: 0 0 10px currentColor;
}

.color-toggle input:disabled+.color-box {
    opacity: 0.7;
}

.color-box {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.3);
    transition: all 0.2s;
}

.color-box.red {
    background: var(--red);
}

.color-box.blue {
    background: var(--blue);
}

.color-box.green {
    background: var(--green);
}

.color-box.yellow {
    background: var(--yellow);
}

/* --- Buttons --- */
.btn-start {
    background: linear-gradient(135deg, var(--primary, #a24cff), rgba(162, 76, 255, 0.7));
    border: none;
    border-radius: 15px;
    color: white;
    padding: 15px 40px;
    font-family: 'Fredoka One', cursive;
    font-size: 1.3rem;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 25px;
    display: inline-flex;
    align-items: center;
}

.btn-start:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 25px rgba(162, 76, 255, 0.4);
    filter: brightness(1.1);
}

.btn-start:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-back {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    margin-top: 20px;
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-radius: 12px !important;
    color: rgba(255, 255, 255, 0.7) !important;
    padding: 10px 25px !important;
    text-decoration: none !important;
    font-family: 'Nunito', sans-serif !important;
    font-weight: 700 !important;
    font-size: 1rem !important;
    transition: all 0.3s ease !important;
    cursor: pointer !important;
    outline: none !important;
}

.btn-back:hover {
    background: rgba(255, 255, 255, 0.12) !important;
    transform: translateY(-2px) !important;
    color: var(--text-color, white) !important;
    border-color: var(--primary, #a24cff) !important;
}

.btn-back:active {
    transform: translateY(1px) !important;
}

.btn-back i {
    margin-right: 8px;
    font-size: 1.2rem;
}

/* --- Lobby Actions --- */
.lobby-actions {
    margin-top: 25px;
    background: rgba(255, 255, 255, 0.04);
    padding: 20px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-lobby {
    background: rgba(255, 255, 255, 0.08) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 12px !important;
    color: var(--text-color, white) !important;
    padding: 12px 10px !important;
    font-family: 'Nunito', sans-serif !important;
    font-weight: 700 !important;
    font-size: 0.9rem !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-lobby:hover {
    transform: translateY(-2px) !important;
    background: rgba(255, 255, 255, 0.15) !important;
    border-color: var(--primary, #a24cff) !important;
}

.btn-lobby:active {
    transform: translateY(1px) !important;
}

/* --- Status Display --- */
.status-display {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: var(--glass-border);
    border-radius: 15px;
    padding: 12px 25px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: 'Fredoka One', cursive;
    font-size: 1.3rem;
    box-shadow: var(--glass-shadow);
}

.turn-indicator {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 10px currentColor;
}

/* --- Game Container --- */
.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    flex: 1;
    width: 100%;
    max-width: 800px;
}

/* --- Game Board --- */
#game-board {
    display: grid;
    grid-template-columns: repeat(11, 1fr);
    grid-template-rows: repeat(11, 1fr);
    gap: 2px;
    padding: 12px;
    background: var(--board-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--board-border);
    border-radius: 16px;
    box-shadow: var(--glass-shadow);
    width: min(90vw, calc(100vh - 220px), 600px);
    height: min(90vw, calc(100vh - 220px), 600px);
}

/* --- Board Cells --- */
.cell {
    aspect-ratio: 1;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.2s;
}

/* Empty cells - invisible */
.cell.empty {
    background: transparent;
    border: none;
}

/* Path cells */
.cell.path {
    background: var(--field-light);
    border: 1px solid var(--field-border);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.15);
    border-radius: 50%;
}

.cell.path:hover {
    transform: scale(1.05);
    z-index: 10;
}

/* Center field */
.cell.center {
    background: linear-gradient(145deg, rgba(162, 76, 255, 0.4), rgba(162, 76, 255, 0.2));
    border: 2px solid rgba(162, 76, 255, 0.5);
    border-radius: 50%;
    box-shadow: 0 0 15px rgba(162, 76, 255, 0.3);
}

/* Home Areas */
.cell.home-red {
    background: rgba(229, 57, 53, 0.3);
    border: 1px solid rgba(229, 57, 53, 0.5);
    border-radius: 50%;
}

.cell.home-blue {
    background: rgba(30, 136, 229, 0.3);
    border: 1px solid rgba(30, 136, 229, 0.5);
    border-radius: 50%;
}

.cell.home-green {
    background: rgba(67, 160, 71, 0.3);
    border: 1px solid rgba(67, 160, 71, 0.5);
    border-radius: 50%;
}

.cell.home-yellow {
    background: rgba(253, 216, 53, 0.3);
    border: 1px solid rgba(253, 216, 53, 0.5);
    border-radius: 50%;
}

/* Goal Areas */
.cell.goal-red {
    background: linear-gradient(145deg, rgba(255, 111, 96, 0.4), rgba(229, 57, 53, 0.3));
    border: 1px solid rgba(229, 57, 53, 0.5);
    border-radius: 50%;
}

.cell.goal-blue {
    background: linear-gradient(145deg, rgba(98, 180, 255, 0.4), rgba(30, 136, 229, 0.3));
    border: 1px solid rgba(30, 136, 229, 0.5);
    border-radius: 50%;
}

.cell.goal-green {
    background: linear-gradient(145deg, rgba(118, 210, 117, 0.4), rgba(67, 160, 71, 0.3));
    border: 1px solid rgba(67, 160, 71, 0.5);
    border-radius: 50%;
}

.cell.goal-yellow {
    background: linear-gradient(145deg, rgba(255, 255, 107, 0.4), rgba(253, 216, 53, 0.3));
    border: 1px solid rgba(253, 216, 53, 0.5);
    border-radius: 50%;
}

/* Start fields - on the main path but colored */
.cell.start-red {
    background: rgba(229, 57, 53, 0.5);
    border: 2px solid rgba(229, 57, 53, 0.7);
    border-radius: 50%;
}

.cell.start-blue {
    background: rgba(30, 136, 229, 0.5);
    border: 2px solid rgba(30, 136, 229, 0.7);
    border-radius: 50%;
}

.cell.start-green {
    background: rgba(67, 160, 71, 0.5);
    border: 2px solid rgba(67, 160, 71, 0.7);
    border-radius: 50%;
}

.cell.start-yellow {
    background: rgba(253, 216, 53, 0.5);
    border: 2px solid rgba(253, 216, 53, 0.7);
    border-radius: 50%;
}

/* Start field markers */
.cell.start-red::after,
.cell.start-blue::after,
.cell.start-green::after,
.cell.start-yellow::after {
    content: '★';
    position: absolute;
    font-size: 0.6em;
    opacity: 0.7;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* --- Pieces --- */
.piece {
    width: 70%;
    height: 70%;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 100 !important;
    box-shadow:
        0 3px 8px rgba(0, 0, 0, 0.4),
        inset 0 -3px 6px rgba(0, 0, 0, 0.3),
        inset 0 3px 6px rgba(255, 255, 255, 0.4);
    position: relative;
    z-index: 5;
}

.piece::after {
    content: '';
    position: absolute;
    top: 15%;
    left: 25%;
    width: 30%;
    height: 20%;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
}

.piece:hover {
    transform: scale(1.15);
    box-shadow:
        0 6px 15px rgba(0, 0, 0, 0.5),
        0 0 20px currentColor;
}

.piece.red {
    background: linear-gradient(145deg, var(--red-light) 0%, var(--red) 50%, var(--red-dark) 100%);
}

.piece.blue {
    background: linear-gradient(145deg, var(--blue-light) 0%, var(--blue) 50%, var(--blue-dark) 100%);
}

.piece.green {
    background: linear-gradient(145deg, var(--green-light) 0%, var(--green) 50%, var(--green-dark) 100%);
}

.piece.yellow {
    background: linear-gradient(145deg, var(--yellow-light) 0%, var(--yellow) 50%, var(--yellow-dark) 100%);
}

.piece.selectable {
    animation: pulse 1s infinite;
}

@keyframes pulse {

    0%,
    100% {
        box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4), 0 0 0 0 rgba(162, 76, 255, 0.7);
    }

    50% {
        box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4), 0 0 0 10px rgba(162, 76, 255, 0);
    }
}

/* --- Dice --- */
#dice-container {
    text-align: center;
    position: relative;
    z-index: 50;
}

.dice {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.dice:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    border-color: var(--primary, #a24cff);
}

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

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

@keyframes diceRoll {
    0% {
        transform: rotate(0deg) scale(1);
    }

    25% {
        transform: rotate(90deg) scale(1.2);
    }

    50% {
        transform: rotate(180deg) scale(1);
    }

    75% {
        transform: rotate(270deg) scale(1.2);
    }

    100% {
        transform: rotate(360deg) scale(1);
    }
}

.dice.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.dice-face {
    width: 100%;
    height: 100%;
    display: grid;
    padding: 12px;
    gap: 4px;
}

.dot {
    width: 12px;
    height: 12px;
    background: var(--text-color, white);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Dice face layouts */
.dice-face[data-value="1"] {
    place-content: center;
    place-items: center;
}

.dice-face[data-value="2"] {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.dice-face[data-value="2"] .dot:nth-child(1) {
    grid-area: 1 / 1;
    align-self: start;
    justify-self: start;
}

.dice-face[data-value="2"] .dot:nth-child(2) {
    grid-area: 2 / 2;
    align-self: end;
    justify-self: end;
}

.dice-face[data-value="3"] {
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
}

.dice-face[data-value="3"] .dot:nth-child(1) {
    grid-area: 1 / 1;
}

.dice-face[data-value="3"] .dot:nth-child(2) {
    grid-area: 2 / 2;
    justify-self: center;
    align-self: center;
}

.dice-face[data-value="3"] .dot:nth-child(3) {
    grid-area: 3 / 3;
    justify-self: end;
    align-self: end;
}

.dice-face[data-value="4"] {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    align-items: center;
    justify-items: center;
}

.dice-face[data-value="5"] {
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
}

.dice-face[data-value="5"] .dot:nth-child(1) {
    grid-area: 1 / 1;
}

.dice-face[data-value="5"] .dot:nth-child(2) {
    grid-area: 1 / 3;
    justify-self: end;
}

.dice-face[data-value="5"] .dot:nth-child(3) {
    grid-area: 2 / 2;
    justify-self: center;
    align-self: center;
}

.dice-face[data-value="5"] .dot:nth-child(4) {
    grid-area: 3 / 1;
    align-self: end;
}

.dice-face[data-value="5"] .dot:nth-child(5) {
    grid-area: 3 / 3;
    justify-self: end;
    align-self: end;
}

.dice-face[data-value="6"] {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
    align-items: center;
    justify-items: center;
}

.dice-hint {
    margin-top: 10px;
    color: var(--primary, #a24cff);
    font-weight: 600;
    font-size: 0.9rem;
}

/* --- Game Controls --- */
.game-controls {
    display: flex;
    gap: 15px;
    margin-top: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.btn-control {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.8);
    padding: 12px 25px;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
}

/* Mobile Dice Fix */
@media (max-width: 768px) {
    .dice-container {
        transform: scale(0.8);
    }

    .game-controls {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }

    .btn-control {
        width: 100%;
        justify-content: center;
    }
}

/* Auto Roll Switch */
.auto-roll-container {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-color, white);
    font-weight: bold;
    background: rgba(255, 255, 255, 0.06);
    padding: 8px 15px;
    border-radius: 20px;
    margin-left: 10px;
}

/* Toggle Switch Style */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.15);
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--primary, #a24cff);
}

input:focus+.slider {
    box-shadow: 0 0 1px var(--primary, #a24cff);
}

input:checked+.slider:before {
    transform: translateX(18px);
}

.btn-control:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--primary, #a24cff);
    color: var(--text-color, white);
}

/* --- Winner Modal --- */
.winner-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.winner-content {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 25px;
    padding: 40px;
    text-align: center;
    max-width: 400px;
    animation: popIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes popIn {
    from {
        transform: scale(0.5);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.trophy {
    font-size: 5rem;
    margin-bottom: 20px;
    animation: trophyBounce 0.6s ease infinite alternate;
}

@keyframes trophyBounce {
    from {
        transform: translateY(0);
    }

    to {
        transform: translateY(-10px);
    }
}

.winner-content h2 {
    font-family: 'Fredoka One', cursive;
    color: var(--akzent, #ffc800);
    font-size: 2rem;
    margin-bottom: 10px;
}

.winner-content p {
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.1rem;
    margin-bottom: 25px;
}

.winner-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.btn-winner {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary, #a24cff), rgba(162, 76, 255, 0.7));
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-winner:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(162, 76, 255, 0.4);
    filter: brightness(1.1);
}

.btn-winner.secondary {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-winner.secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* --- Responsive --- */
@media (max-width: 600px) {
    #page-title {
        font-size: 1.8rem;
    }

    .dialog-box {
        padding: 20px;
        margin: 10px;
    }

    .player-btn {
        padding: 15px 20px;
    }

    #game-board {
        width: min(95vw, 400px);
        height: min(95vw, 400px);
        padding: 10px;
    }

    .dice {
        width: 60px;
        height: 60px;
    }

    .status-display {
        font-size: 1rem;
        padding: 10px 15px;
    }
}

@media (min-width: 900px) {
    .game-container {
        flex-direction: row;
        gap: 40px;
        align-items: flex-start;
    }

    #dice-container {
        order: 1;
    }
}

/* --- Modals & Overlays --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: rgba(30, 30, 50, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    color: var(--text-color, white);
}

.modal-content h3 {
    font-family: 'Fredoka One', cursive;
    margin-bottom: 20px;
    color: var(--text-color, white);
}

.modal-content p {
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 1.5rem;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.btn-modal {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    color: white;
    padding: 10px 25px;
    font-size: 0.9rem;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-modal:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--primary, #a24cff);
}

.friends-invite-list {
    max-height: 300px;
    overflow-y: auto;
    text-align: left;
    padding: 5px;
    color: var(--text-color, white);
}

.friends-invite-list::-webkit-scrollbar {
    width: 6px;
}

.friends-invite-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

/* --- Large Screens (2K/4K) --- */
@media (min-height: 1081px),
(min-width: 2000px) {
    .game-container {
        max-width: 1600px;
        gap: 60px;
    }

    #game-board {
        width: min(90vw, calc(100vh - 250px), 1000px);
        height: min(90vw, calc(100vh - 250px), 1000px);
        padding: 20px;
        gap: 4px;
    }

    .cell {
        border-radius: 8px;
    }

    .dice {
        width: 120px;
        height: 120px;
    }

    .dice-hint {
        font-size: 1.2rem;
    }

    .btn-control {
        font-size: 1.2rem;
        padding: 15px 35px;
    }

    .dialog-box {
        max-width: 700px;
    }

    .dialog-box h2 {
        font-size: 2.5rem;
    }

    .player-btn .player-num {
        font-size: 2.5rem;
    }
}