:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #16213e;
    --accent: #e94560;
    --accent-glow: rgba(233, 69, 96, 0.4);
    --text-primary: #eee;
    --text-secondary: #8892b0;
    --border: #233554;
    --dice-bg: #0a3d62;
    --dice-face: #e94560;
    --success: #4ecca3;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
}

.container {
    max-width: 640px;
    width: 100%;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 2rem;
}
header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.subtitle {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

/* Dice Area */
.dice-area {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    min-height: 180px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 24px;
    margin-bottom: 1.5rem;
    transition: all 0.3s ease;
}
.dice-placeholder {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Individual Die */
.die {
    width: 72px;
    height: 72px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent);
    position: relative;
    transition: transform 0.3s ease, border-color 0.3s ease;
}
.die.rolling {
    animation: diceRoll 0.12s infinite linear;
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent-glow);
}
.die.landed {
    animation: diceLand 0.4s ease-out;
    border-color: var(--success);
    box-shadow: 0 0 12px rgba(78, 204, 163, 0.3);
}
.die .sides-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--accent);
    color: #fff;
    font-size: 0.55rem;
    font-weight: 600;
    padding: 2px 5px;
    border-radius: 6px;
    line-height: 1;
}

@keyframes diceRoll {
    0%   { transform: rotate(0deg) scale(1); }
    25%  { transform: rotate(8deg) scale(1.05); }
    50%  { transform: rotate(0deg) scale(1); }
    75%  { transform: rotate(-8deg) scale(1.05); }
    100% { transform: rotate(0deg) scale(1); }
}
@keyframes diceLand {
    0%   { transform: scale(1.2) rotate(10deg); }
    40%  { transform: scale(0.95) rotate(-3deg); }
    70%  { transform: scale(1.03) rotate(1deg); }
    100% { transform: scale(1) rotate(0deg); }
}

/* Roll Button */
.roll-btn {
    display: block;
    width: 100%;
    padding: 16px;
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
    background: var(--accent);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1.5rem;
}
.roll-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px var(--accent-glow);
}
.roll-btn:active {
    transform: translateY(0);
}
.roll-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Settings */
.settings {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 1.5rem;
    overflow: hidden;
}
.settings summary {
    padding: 14px 18px;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-secondary);
    user-select: none;
    transition: color 0.2s;
    list-style: none;
}
.settings summary::-webkit-details-marker { display: none; }
.settings summary::before {
    content: '▸';
    display: inline-block;
    margin-right: 8px;
    transition: transform 0.2s;
}
.settings[open] summary::before {
    transform: rotate(90deg);
}
.settings[open] summary {
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
}
.settings-grid {
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.setting label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.range-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}
.range-wrap input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 3px;
    background: var(--border);
    outline: none;
}
.range-wrap input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    transition: box-shadow 0.2s;
}
.range-wrap input[type="range"]::-webkit-slider-thumb:hover {
    box-shadow: 0 0 10px var(--accent-glow);
}
.range-value {
    min-width: 28px;
    text-align: center;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--accent);
}

/* Results */
.results-area {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 1.5rem;
}
.results-area h2 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 14px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.throw-card {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 10px;
}
.throw-card:last-child { margin-bottom: 0; }
.throw-header {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
}
.throw-dice {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.throw-die {
    width: 48px;
    height: 48px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--success);
}

/* Footer */
footer {
    margin-top: auto;
    padding-top: 2rem;
    text-align: center;
}
footer a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.8rem;
    transition: color 0.2s;
}
footer a:hover { color: var(--accent); }

/* Error message */
.error-msg {
    background: rgba(233, 69, 96, 0.15);
    border: 1px solid var(--accent);
    border-radius: 10px;
    padding: 14px;
    color: var(--accent);
    text-align: center;
    font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 480px) {
    .container { padding: 1rem; }
    header h1 { font-size: 1.6rem; }
    .die { width: 56px; height: 56px; font-size: 1.4rem; }
}