* {
    touch-action: manipulation;
    box-sizing: border-box;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
    -webkit-touch-callout: none !important;
    -webkit-tap-highlight-color: transparent !important;
    outline: none !important;
}

html, body {
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
    -webkit-touch-callout: none !important;
    -webkit-tap-highlight-color: transparent !important;
    margin: 0;
    padding: 0;
    background-color: #000;
    overflow: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    width: 100vw;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    touch-action: pan-x pan-y;
}

audio {
    display: none;
}

#game-container * {
    cursor: default;
}

#game-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 10vh;
    pointer-events: auto !important;
}

.splash-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('assets/images/splash-screen.png');
    background-size: cover;
    background-position: top center;
    background-repeat: no-repeat;
    filter: brightness(0.8);
    pointer-events: none !important;
}

.splash-content {
    position: relative;
    z-index: 2;
    text-align: center;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    padding: 20px;
    max-width: 90vw;
    margin-top: 5vh;
    pointer-events: auto !important;
}

.splash-title {
    font-size: clamp(20px, 5vw, 36px);
    font-weight: bold;
    margin-bottom: 30px;
    font-family: 'Times New Roman', serif;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.splash-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.splash-button {
    padding: 15px 25px;
    border: 3px solid #8B4513;
    border-radius: 10px;
    font-weight: bold;
    font-size: clamp(14px, 3vw, 18px);
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
    text-transform: uppercase;
    letter-spacing: 1px;
    position: relative;
    overflow: hidden;
    pointer-events: auto !important;
}

.splash-button-start {
    background: linear-gradient(45deg, #ffd700, #ffed4e);
    color: #8B0000;
    border-color: #ffd700;
}

.splash-button-rules {
    background: linear-gradient(45deg, #deb887, #f5deb3);
    color: #8B0000;
    border-color: #deb887;
}

.splash-button-sound {
    background: linear-gradient(45deg, #90ee90, #98fb98);
    color: #006400;
    border-color: #90ee90;
}

.splash-button-sound-off {
    background: linear-gradient(45deg, #ff6b6b, #ff8e8e);
    color: #8B0000;
    border-color: #ff6b6b;
}

.splash-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.splash-button:active {
    transform: translateY(1px);
}

.rules-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 10001;
    display: none;
    justify-content: center;
    align-items: center;
}

.rules-content {
    background: linear-gradient(45deg, #deb887, #f5deb3);
    border: 5px solid #8B4513;
    border-radius: 15px;
    padding: 20px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    color: #8B0000;
    position: relative;
}

.rules-title {
    font-size: 24px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 20px;
    text-transform: uppercase;
}

.rules-text {
    font-size: 16px;
    line-height: 1.5;
    margin-bottom: 20px;
}

.rules-text ul {
    margin-left: 20px;
    margin-bottom: 15px;
}

.rules-text li {
    margin-bottom: 8px;
}

.rules-close {
    padding: 10px 20px;
    background: #8B0000;
    color: white;
    border: none;
    border-radius: 5px;
    font-weight: bold;
    cursor: pointer;
    display: block;
    margin: 0 auto;
}

.rules-close:hover {
    background: #a52a2a;
}

.hidden {
    display: none;
}

#game-container {
    width: 100vw;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    background-color: #0A5C36;
    position: relative;
    overflow: hidden;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

.panel {
    background-color: #DEB887;
}

.top-panel {
    position: absolute;
    top: env(safe-area-inset-top, 0px);
    left: 0;
    right: 0;
    height: 14vh;
    display: flex;
    align-items: center;
    padding: 0 10px;
    border-bottom: 3px solid #8B4513;
}

.selected-dice-panel {
    display: flex;
    align-items: center;
    gap: 5px;
    flex: 1;
    height: 50px;
    overflow: hidden;
    padding: 5px;
}

.selected-dice-panel .dice {
    width: 45px !important;
    height: 45px !important;
    min-width: 45px !important;
    min-height: 45px !important;
    margin: 0 2px !important;
}

.score-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-left: auto;
    padding: 5px;
    max-width: 25%;
    min-width: 80px;
}

.score-panel .text-medium {
    font-size: 10px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.submit-score-button {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 100;
    padding: 8px 12px;
    background-color: #FFD700;
    border: 2px solid #8B4513;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    font-size: 12px;
    min-height: 40px;
    display: none;
}

.game-board {
    position: absolute;
    top: calc(14vh + env(safe-area-inset-top, 0px));
    left: 0;
    right: 0;
    height: 66vh;
    background-color: #0A5C36;
    overflow: hidden;
}

.game-board .dice {
    width: 14vw;
    height: 14vw;
    min-width: 50px;
    min-height: 50px;
    max-width: 70px;
    max-height: 70px;
}

.game-board .dice-grid .dot {
    width: 8px;
    height: 8px;
    background-color: black;
    border-radius: 50%;
    margin: auto;
}

.roll-button {
    position: absolute;
    right: 20px;
    bottom: 20px;
    width: 90px;
    height: 90px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 14px;
    padding: 10px;
}

.players-panel {
    position: absolute;
    bottom: env(safe-area-inset-bottom, 0px);
    left: 0;
    right: 0;
    height: 20vh;
    padding: 10px;
    display: flex;
    gap: 10px;
    overflow: hidden;
    flex-wrap: nowrap;
    border-top: 3px solid #8B4513;
    align-items: center;
    justify-content: center;
}

.player-item {
    background-color: gold;
    border: 3px solid #8B4513;
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    min-width: 180px;
    height: 90px;
    flex-shrink: 0;
    position: relative;
    transition: all 0.3s ease;
    gap: 12px;
}

.player-item.current-player {
    border-color: #ff0000;
    border-width: 4px;
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.8);
    min-width: 190px;
    transform: scale(1.08);
    z-index: 1;
}

.player-avatar-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.player-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid #8B0000;
    background-size: cover;
    background-position: center;
    background-color: white;
}

.player-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    flex: 1;
    min-width: 0;
}

.player-name {
    font-weight: bold;
    font-size: 16px;
    margin-bottom: 5px;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.player-score {
    font-size: 22px;
    color: #8B0000;
    font-weight: bold;
    margin-bottom: 5px;
}

.player-status {
    font-size: 12px;
    color: #8B0000;
    font-weight: bold;
    text-align: left;
    line-height: 1.3;
}

.bottom-panel {
    display: none;
}

.current-player-info {
    display: none;
}

.dice {
    background-color: white;
    border: 2px solid black;
    border-radius: 8px;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.dice:hover {
    transform: scale(1.05);
}

.dice-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    width: 100%;
    height: 100%;
    position: relative;
    padding: 6px;
}

.dot {
    width: 8px;
    height: 8px;
    background-color: black;
    border-radius: 50%;
    margin: auto;
}

.dot-hidden {
    visibility: hidden;
}

.button {
    padding: 12px 18px;
    background-color: #FFD700;
    border: 2px solid #8B4513;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    text-align: center;
    transition: background-color 0.2s;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    pointer-events: auto !important;
}

.button:hover {
    background-color: #FFC000;
}

.button:active {
    transform: translateY(2px);
}

.button-green {
    background-color: #90EE90;
}

.button-green:hover {
    background-color: #7CDC7C;
}

.button-disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.button-disabled:hover {
    background-color: #FFD700;
}

.text-bold {
    font-weight: bold;
}

.text-large {
    font-size: 24px;
    color: #A52A2A;
}

.text-medium {
    font-size: 12px;
}

.text-small {
    font-size: 10px;
}

.barrel-icon {
    position: absolute;
    top: calc(10px + env(safe-area-inset-top, 0px));
    left: calc(10px + env(safe-area-inset-left, 0px));
    width: 30px;
    height: 30px;
    background-color: #8B4513;
    border-radius: 5px;
    display: none;
    border: 2px solid #FFD700;
    z-index: 10;
}

.draft-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90vw;
    max-width: 350px;
    background-color: rgba(0, 0, 0, 0.9);
    border: 2px solid #8B4513;
    border-radius: 8px;
    padding: 10px;
    display: none;
    z-index: 100;
}

.draft-content {
    background-color: #DEB887;
    border-radius: 8px;
    padding: 8px;
    text-align: center;
}

.message-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    display: none;
}

.message-content {
    background-color: white;
    padding: 12px;
    border-radius: 8px;
    border: 2px solid #8B4513;
    text-align: center;
    max-width: 90vw;
    width: 350px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.message-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 3px solid #8B4513;
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
}

.message-text {
    flex: 1;
}

.orientation-warning {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    display: none;
}

.orientation-content {
    background-color: #DEB887;
    padding: 15px;
    border-radius: 8px;
    border: 2px solid #8B4513;
    text-align: center;
    max-width: 80vw;
    font-size: 14px;
}

.victory-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 3000;
    flex-direction: column;
}

.victory-content {
    width: 90vw;
    max-width: 600px;
    height: 400px;
    background-image: url('assets/images/victory-screen.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border: 5px solid #ffd700;
    border-radius: 15px;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.7);
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: white;
}

.victory-text {
    background-color: rgba(0, 0, 0, 0.7);
    padding: 20px;
    border-radius: 10px;
    border: 2px solid #8B4513;
    margin-top: 20px;
    max-width: 80%;
}

.victory-button {
    background: linear-gradient(45deg, #ffd700, #ffed4e);
    color: #8B0000;
    border: 3px solid #8B4513;
    border-radius: 8px;
    font-weight: bold;
    font-size: 18px;
    padding: 12px 24px;
    margin-top: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.victory-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.victory-button:active {
    transform: translateY(1px);
}

*:focus {
    outline: none !important;
}

img {
    pointer-events: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
    -webkit-touch-callout: none !important;
}

button, .button, .splash-button {
    pointer-events: auto !important;
}

@media (orientation: landscape) {
    .splash-content {
        margin-top: 2vh !important;
        padding-top: 5vh !important;
        max-width: 95vw !important;
    }
    
    .splash-title {
        font-size: clamp(18px, 4vw, 28px) !important;
        margin-bottom: 20px !important;
    }
    
    .splash-buttons {
        flex-direction: row !important;
        gap: 10px !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        margin-top: 15px !important;
    }
    
    .splash-button {
        min-width: 120px !important;
        padding: 10px 15px !important;
        font-size: clamp(12px, 2vw, 16px) !important;
        min-height: 45px !important;
    }
    
    .top-panel {
        height: 16vh;
        padding: 0 5px;
    }
    
    .game-board {
        height: 54vh;
        top: calc(16vh + env(safe-area-inset-top, 0px));
    }
    
    .game-board .dice {
        width: 12vw;
        height: 12vw;
        min-width: 40px;
        min-height: 40px;
        max-width: 60px;
        max-height: 60px;
    }
    
    .roll-button {
        width: 80px;
        height: 80px;
        font-size: 12px;
        right: 15px;
        bottom: 15px;
    }
    
    .players-panel {
        height: 30vh;
        padding: 8px;
        gap: 12px;
    }
    
    .player-item {
        min-width: 170px;
        height: 80px;
    }
    
    .player-item.current-player {
        min-width: 180px;
    }
    
    .player-avatar {
        width: 45px;
        height: 45px;
    }
    
    .player-name {
        font-size: 15px;
    }
    
    .player-score {
        font-size: 20px;
    }
    
    .player-status {
        font-size: 11px;
    }
    
    .dice {
        width: 10vw;
        height: 10vw;
        min-width: 35px;
        min-height: 35px;
        max-width: 50px;
        max-height: 50px;
    }
    
    .button {
        padding: 10px 15px;
        font-size: 13px;
        min-height: 45px;
    }
    
    .text-large {
        font-size: 20px;
    }
    
    .text-medium {
        font-size: 11px;
    }
    
    .selected-dice-panel {
        height: 45px;
    }
    
    .selected-dice-panel .dice {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        min-height: 40px !important;
    }
    
    .score-panel {
        max-width: 25%;
        min-width: 70px;
    }
    
    .score-panel .text-medium {
        font-size: 9px;
    }
    
    .submit-score-button {
        top: 8px;
        right: 8px;
        padding: 6px 10px;
        font-size: 11px;
        min-height: 35px;
    }
}

@media (orientation: landscape) and (max-height: 600px) {
    .splash-content {
        margin-top: 1vh !important;
        padding-top: 3vh !important;
    }
    
    .splash-title {
        font-size: clamp(16px, 3.5vw, 24px) !important;
        margin-bottom: 15px !important;
    }
    
    .splash-buttons {
        gap: 8px !important;
        margin-top: 10px !important;
    }
    
    .splash-button {
        min-width: 110px !important;
        padding: 8px 12px !important;
        font-size: clamp(11px, 1.8vw, 14px) !important;
        min-height: 40px !important;
    }
    
    .top-panel {
        height: 18vh;
    }
    
    .game-board {
        height: 52vh;
        top: calc(18vh + env(safe-area-inset-top, 0px));
    }
    
    .roll-button {
        width: 70px;
        height: 70px;
        font-size: 11px;
        right: 10px;
        bottom: 10px;
    }
    
    .players-panel {
        height: 30vh;
    }
    
    .player-item {
        min-width: 150px;
        height: 70px;
    }
    
    .player-avatar {
        width: 40px;
        height: 40px;
    }
    
    .player-name {
        font-size: 14px;
    }
    
    .player-score {
        font-size: 18px;
    }
    
    .player-status {
        font-size: 10px;
    }
    
    .game-board .dice {
        min-width: 35px;
        min-height: 35px;
        max-width: 50px;
        max-height: 50px;
    }
    
    .submit-score-button {
        top: 6px;
        right: 6px;
        padding: 5px 8px;
        font-size: 10px;
        min-height: 30px;
    }
}

@media (orientation: landscape) and (max-height: 400px) {
    .splash-content {
        margin-top: 0.5vh !important;
        padding-top: 2vh !important;
    }
    
    .splash-title {
        font-size: clamp(14px, 3vw, 20px) !important;
        margin-bottom: 10px !important;
    }
    
    .splash-buttons {
        gap: 6px !important;
        margin-top: 8px !important;
    }
    
    .splash-button {
        min-width: 100px !important;
        padding: 6px 10px !important;
        font-size: clamp(10px, 1.6vw, 12px) !important;
        min-height: 35px !important;
    }
    
    .top-panel {
        height: 20vh;
    }
    
    .game-board {
        height: 50vh;
        top: calc(20vh + env(safe-area-inset-top, 0px));
    }
    
    .roll-button {
        width: 60px;
        height: 60px;
        font-size: 10px;
        right: 8px;
        bottom: 8px;
    }
    
    .players-panel {
        height: 30vh;
    }
    
    .player-item {
        min-width: 130px;
        height: 60px;
        padding: 10px;
    }
    
    .player-avatar {
        width: 35px;
        height: 35px;
    }
    
    .player-name {
        font-size: 13px;
    }
    
    .player-score {
        font-size: 16px;
    }
    
    .player-status {
        font-size: 9px;
    }
    
    .game-board .dice {
        min-width: 30px;
        min-height: 30px;
        max-width: 40px;
        max-height: 40px;
    }
    
    .submit-score-button {
        top: 4px;
        right: 4px;
        padding: 4px 6px;
        font-size: 9px;
        min-height: 25px;
    }
}

@media (max-width: 768px) and (orientation: portrait) {
    .splash-buttons {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }
    
    .splash-button {
        min-width: 200px;
        padding: 12px 20px;
        min-height: 50px;
    }
    
    .splash-title {
        margin-bottom: 20px;
    }
    
    .splash-content {
        margin-top: 8vh;
    }
    
    .game-board .dice {
        min-width: 55px !important;
        min-height: 55px !important;
    }
    
    .button {
        min-height: 50px;
        padding: 12px 20px;
    }
    
    .players-panel {
        gap: 6px;
        padding: 6px;
        height: 24vh;
    }
    
    .player-item {
        min-width: 95px;
        height: 100px;
        padding: 6px;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        gap: 4px;
    }
    
    .player-item.current-player {
        min-width: 105px;
        transform: scale(1.03);
    }
    
    .player-avatar-container {
        gap: 3px;
    }
    
    .player-avatar {
        width: 40px;
        height: 40px;
    }
    
    .player-info {
        align-items: center;
        text-align: center;
        width: 100%;
    }
    
    .player-name {
        font-size: 11px;
        margin-bottom: 2px;
        text-align: center;
    }
    
    .player-score {
        font-size: 16px;
        margin-bottom: 2px;
    }
    
    .player-status {
        font-size: 9px;
        text-align: center;
        line-height: 1.1;
    }
    
    .orientation-warning {
        display: none !important;
    }
    
    .score-panel {
        max-width: 30%;
        min-width: 70px;
    }
    
    .score-panel .text-medium {
        font-size: 9px;
    }
    
    .submit-score-button {
        top: 5px;
        right: 5px;
        padding: 6px 10px;
        font-size: 11px;
        min-height: 35px;
    }
}

@media (max-width: 480px) and (orientation: portrait) {
    .splash-title {
        font-size: 18px;
        margin-bottom: 15px;
    }
    
    .splash-button {
        min-width: 180px;
        padding: 10px 15px;
        font-size: 14px;
    }
    
    .splash-content {
        margin-top: 10vh;
        padding: 10px;
    }
    
    .players-panel {
        gap: 4px;
        padding: 4px;
        height: 26vh;
    }
    
    .player-item {
        min-width: 85px;
        height: 95px;
        padding: 5px;
    }
    
    .player-item.current-player {
        min-width: 95px;
    }
    
    .player-avatar {
        width: 35px;
        height: 35px;
    }
    
    .player-name {
        font-size: 10px;
    }
    
    .player-score {
        font-size: 14px;
    }
    
    .player-status {
        font-size: 8px;
    }
    
    .submit-score-button {
        top: 4px;
        right: 4px;
        padding: 5px 8px;
        font-size: 10px;
        min-height: 30px;
    }
}

@media (max-width: 380px) and (orientation: portrait) {
    .players-panel {
        gap: 3px;
        padding: 3px;
        height: 28vh;
    }
    
    .player-item {
        min-width: 75px;
        height: 90px;
        padding: 4px;
        gap: 3px;
    }
    
    .player-item.current-player {
        min-width: 85px;
    }
    
    .player-avatar {
        width: 30px;
        height: 30px;
    }
    
    .player-name {
        font-size: 9px;
    }
    
    .player-score {
        font-size: 13px;
    }
    
    .player-status {
        font-size: 7px;
    }
    
    .score-panel {
        max-width: 35%;
        min-width: 60px;
    }
    
    .score-panel .text-medium {
        font-size: 8px;
    }
    
    .submit-score-button {
        top: 3px;
        right: 3px;
        padding: 4px 6px;
        font-size: 9px;
        min-height: 25px;
    }
}

@media (hover: none) and (pointer: coarse) {
    .dice:hover {
        transform: none;
    }
    
    .splash-button:hover {
        transform: none;
        box-shadow: none;
    }
    
    .button:hover {
        background-color: #FFD700;
    }
    
    .button-green:hover {
        background-color: #90EE90;
    }
}