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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #0f0f1a;
    color: #e0e0e0;
    min-height: 100vh;
}

main {
    max-width: 550px;
    margin: 0 auto;
    padding: 1rem;
}

.back-link {
    display: inline-block;
    color: #4ecca3;
    text-decoration: none;
    margin-bottom: 0.5rem;
}

.back-link:hover {
    text-decoration: underline;
}

h1 {
    text-align: center;
    color: #4ecca3;
    margin-bottom: 1rem;
}

.game-container {
    position: relative;
}

/* Dice Area */
.dice-area {
    background: #1a1a2e;
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    text-align: center;
}

.dice-row {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.die {
    width: 50px;
    height: 50px;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s;
}

.die:hover {
    transform: scale(1.05);
}

.die.held {
    box-shadow: 0 0 0 3px #4ecca3;
    transform: translateY(-5px);
}

.die.rolling {
    animation: roll 0.3s ease-out;
}

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

.die-face {
    width: 100%;
    height: 100%;
    position: relative;
}

.dot {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #1a1a2e;
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.roll-info {
    color: #888;
    margin-bottom: 0.5rem;
}

.roll-btn {
    background: #4ecca3;
    color: #0f0f1a;
    border: none;
    padding: 0.75rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.roll-btn:hover:not(:disabled) {
    background: #3db892;
}

.roll-btn:disabled {
    background: #555;
    cursor: not-allowed;
}

/* Setup overlay */
.setup-content {
    min-width: 280px;
}

.setup-content p {
    margin-bottom: 0.75rem;
    font-size: 1rem;
}

.player-count-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 1rem;
}

.overlay-content .player-count-btn {
    width: 50px;
    height: 50px;
    padding: 0;
    font-size: 1.25rem;
    font-weight: 600;
    background: #2a2a4a;
    color: #ccc;
    border: 2px solid #3a3a5a;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.overlay-content .player-count-btn:hover {
    background: #3a3a5a;
}

.overlay-content .player-count-btn.active {
    background: #4ecca3;
    color: #0f0f1a;
    border-color: #4ecca3;
}

.player-names {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.player-name-input {
    padding: 0.75rem;
    font-size: 1rem;
    background: #2a2a4a;
    border: 1px solid #3a3a5a;
    border-radius: 8px;
    color: #fff;
    text-align: center;
}

.player-name-input:focus {
    outline: none;
    border-color: #4ecca3;
}

.player-name-input::placeholder {
    color: #888;
}

/* Current player indicator */
.current-player {
    font-size: 1.1rem;
    font-weight: 600;
    color: #4ecca3;
    margin-bottom: 0.75rem;
    min-height: 1.5rem;
}

/* Scorecard */
.scorecard {
    background: #1a1a2e;
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    overflow-x: auto;
}

.scorecard-header {
    display: flex;
    padding: 0.5rem;
    border-bottom: 2px solid #3a3a5a;
    margin-bottom: 0.5rem;
}

.scorecard-header .player-col {
    font-weight: 600;
    color: #888;
    transition: color 0.2s;
}

.scorecard-header .player-col.active {
    color: #4ecca3;
}

.score-section {
    margin-bottom: 1rem;
}

.score-section h3 {
    color: #4ecca3;
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.score-row {
    display: flex;
    padding: 0.4rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.score-row:hover:not(.subtotal):not(.bonus):not(.total) {
    background: #2a2a4a;
}

.score-row.potential {
    background: rgba(78, 204, 163, 0.1);
}

.score-row.potential .score-value {
    color: #4ecca3;
}

.score-row .score-value.filled {
    color: #fff;
}

.score-row.subtotal,
.score-row.bonus,
.score-row.total {
    cursor: default;
    border-top: 1px solid #3a3a5a;
    margin-top: 0.5rem;
    padding-top: 0.75rem;
}

.score-row.bonus .score-value {
    color: #f5b942;
}

.score-row.total {
    font-weight: 600;
    font-size: 1rem;
}

.score-row.total .score-value {
    color: #4ecca3;
}

.category-col {
    flex: 1;
    color: #ccc;
    font-size: 0.9rem;
}

.player-col {
    width: 50px;
    text-align: center;
    font-size: 0.9rem;
}

.score-value {
    color: #888;
    font-weight: 600;
}

/* Final scores in game over */
.final-scores {
    margin: 1rem 0;
}

.final-scores h3 {
    color: #4ecca3;
    margin-bottom: 0.75rem;
}

.final-score-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    background: #2a2a4a;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.final-score-row:first-child {
    background: rgba(78, 204, 163, 0.2);
    color: #4ecca3;
}

/* Game Over Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.overlay.hidden {
    display: none;
}

.overlay-content {
    background: #1a1a2e;
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
}

.overlay-content h2 {
    color: #4ecca3;
    margin-bottom: 1rem;
}

.overlay-content p {
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
}

.overlay-content button {
    padding: 0.75rem 2rem;
    font-size: 1rem;
    background: #4ecca3;
    color: #0f0f1a;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    margin: 0.25rem;
}

.overlay-content button:hover {
    background: #3db892;
}

.overlay-content .share-btn {
    background: #2a9d8f;
}

.overlay-content .share-btn:hover {
    background: #248c7f;
}

/* Content */
.content {
    background: #1a1a2e;
    padding: 1.5rem;
    border-radius: 12px;
    margin-top: 1.5rem;
    line-height: 1.6;
}

.content h2 {
    color: #4ecca3;
    margin: 1.5rem 0 0.75rem;
    font-size: 1.2rem;
}

.content h2:first-child {
    margin-top: 0;
}

.content p {
    margin-bottom: 1rem;
    color: #ccc;
}

.content ul {
    margin: 0.5rem 0 1rem 1.5rem;
    color: #ccc;
}

.content li {
    margin-bottom: 0.5rem;
}

.related-games {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #3a3a5c;
}

.related-games h3 {
    color: #4ecca3;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.game-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.game-links a {
    background: #2a2a4a;
    color: #4ecca3;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.game-links a:hover {
    background: #3a3a5a;
}

/* Responsive */
@media (max-width: 400px) {
    .die {
        width: 45px;
        height: 45px;
    }

    .dot {
        width: 8px;
        height: 8px;
    }

    .score-row {
        font-size: 0.85rem;
    }

    .category-col {
        font-size: 0.8rem;
    }

    .player-col {
        width: 40px;
        font-size: 0.8rem;
    }

    .overlay-content .player-count-btn {
        width: 42px;
        height: 42px;
        font-size: 1.1rem;
    }

    .scorecard-header .player-col {
        font-size: 0.75rem;
    }
}
