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

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

body {
    font-family: Arial, sans-serif;
    background-color: #f0f0f0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    min-height: 100vh;
}

.container {
    background-color: white;
    padding: 1rem;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    text-align: center;
    width: min(90%, 600px);
    margin: 1rem auto;
}

h1 {
    color: #333;
    margin-bottom: 1.5rem;
    font-size: clamp(1.2rem, 4vw, 2rem);
}

.mahjong-table {
    aspect-ratio: 1;
    width: 400px;
    margin: 2rem auto;
    position: relative;
    background-color: #35654d;
    border-radius: 10px;
}

@media (max-width: 480px) {
    .mahjong-table {
        width: min(280px, 72vw);
    }
}

.player {
    position: absolute;
    padding: clamp(0.5rem, 2vw, 1rem);
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 5px;
    font-weight: bold;
    font-size: clamp(0.8rem, 3vw, 1rem);
    white-space: nowrap;
}

.player.active {
    background-color: #ffeb3b;
    box-shadow: 0 0 15px rgba(255, 235, 59, 0.5);
}

.top {
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
}

.bottom {
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
}

.left {
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.right {
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.dice-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    gap: clamp(0.3rem, 1.5vw, 0.8rem);
}

.dice {
    width: clamp(25px, 6vw, 45px);
    height: clamp(25px, 6vw, 45px);
    background-color: white;
    border-radius: 8px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    padding: clamp(2px, 0.8vw, 4px);
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}

.dot {
    width: clamp(3px, 1.2vw, 6px);
    height: clamp(3px, 1.2vw, 6px);
    background-color: black;
    border-radius: 50%;
    margin: auto;
}

button {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: clamp(0.6rem, 2vw, 1rem) clamp(1.2rem, 4vw, 2rem);
    font-size: clamp(0.9rem, 2.5vw, 1.2rem);
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
    margin: 1rem 0;
}

button:hover {
    background-color: #45a049;
}

.results {
    margin-top: 1rem;
    text-align: center;
}

#diceResult {
    font-size: clamp(0.9rem, 2.5vw, 1.2rem);
    margin-bottom: 0.8rem;
}

#drawSequence {
    max-height: 150px;
    overflow-y: auto;
    padding: 0.8rem;
    background-color: #f9f9f9;
    border-radius: 5px;
    line-height: 1.6;
    font-size: clamp(0.8rem, 2.2vw, 1rem);
    margin: 0 auto;
    width: 90%;
}

.dice.rolling {
    animation: rollDice 0.5s ease;
}

@keyframes rollDice {
    0% { transform: rotate(0deg) scale(1); }
    25% { transform: rotate(90deg) scale(0.8); }
    50% { transform: rotate(180deg) scale(1.1); }
    75% { transform: rotate(270deg) scale(0.9); }
    100% { transform: rotate(360deg) scale(1); }
}
