@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

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

:root{
  --primary:#6366F1;--secondary:#818CF8;--accent:#F472B6;
  --bg:#111118;--surface:#1C1C27;--surface2:#27273A;
  --text:#F1F0FF;--text-dim:#9290B0;--border:#2E2E44;
  --success:#22C55E;--radius:14px;--font:'Inter',system-ui,sans-serif;
}

html{font-family:var(--font);background:var(--bg);color:var(--text);line-height:1.6}
body{min-height:100vh;display:flex;flex-direction:column;align-items:center;padding:1.5rem}

.header{text-align:center;margin-bottom:2rem}
.header h1{font-size:1.5rem;font-weight:800;background:linear-gradient(135deg,var(--primary),var(--accent));-webkit-background-clip:text;-webkit-text-fill-color:transparent}
.header p{font-size:.82rem;color:var(--text-dim)}

/* Dice selector */
.dice-selector{display:flex;gap:.5rem;margin-bottom:1.5rem;flex-wrap:wrap;justify-content:center}
.dice-btn{padding:.6rem 1.1rem;border-radius:var(--radius);font-size:.82rem;font-weight:700;cursor:pointer;border:1px solid var(--border);background:var(--surface);color:var(--text-dim);transition:all .2s;font-family:var(--font)}
.dice-btn:hover{border-color:var(--primary);color:var(--text);transform:translateY(-2px)}
.dice-btn.active{background:linear-gradient(135deg,var(--primary),var(--accent));color:#fff;border-color:transparent;box-shadow:0 4px 16px rgba(99,102,241,.3)}

/* Dice display area */
.dice-area{display:flex;gap:1rem;justify-content:center;flex-wrap:wrap;margin-bottom:1.5rem;min-height:120px;align-items:center}

.die{width:90px;height:90px;border-radius:16px;background:linear-gradient(145deg,var(--surface2),var(--surface));border:2px solid var(--border);display:flex;align-items:center;justify-content:center;font-size:2rem;font-weight:800;position:relative;transition:transform .2s;cursor:default}
.die.rolling{animation:diceRoll .5s cubic-bezier(.36,.07,.19,.97)}
.die .die-label{position:absolute;top:4px;right:6px;font-size:.55rem;color:var(--text-dim);font-weight:600}

/* Roll/add/clear buttons */
.actions{display:flex;gap:.5rem;margin-bottom:1.5rem;flex-wrap:wrap;justify-content:center}
.btn{padding:.55rem 1.2rem;border-radius:var(--radius);font-size:.85rem;font-weight:700;cursor:pointer;border:none;transition:all .2s;display:inline-flex;align-items:center;gap:.4rem;font-family:var(--font)}
.btn-roll{background:linear-gradient(135deg,var(--primary),var(--accent));color:#fff;font-size:1rem;padding:.7rem 2rem}
.btn-roll:hover{transform:translateY(-2px);box-shadow:0 6px 20px rgba(99,102,241,.3)}
.btn-roll:active{transform:scale(.97)}
.btn-ghost{background:transparent;color:var(--text-dim);border:1px solid var(--border)}
.btn-ghost:hover{background:var(--surface2);color:var(--text)}

/* Total */
.total{font-size:2.5rem;font-weight:800;text-align:center;margin-bottom:1.5rem;background:linear-gradient(135deg,var(--primary),var(--accent));-webkit-background-clip:text;-webkit-text-fill-color:transparent;min-height:3rem}
.total-label{font-size:.72rem;color:var(--text-dim);text-align:center;text-transform:uppercase;letter-spacing:.06em;font-weight:600;margin-bottom:.3rem}

/* History */
.history{width:100%;max-width:400px;margin-top:1rem}
.history h3{font-size:.78rem;font-weight:700;color:var(--text-dim);text-transform:uppercase;letter-spacing:.04em;margin-bottom:.5rem;display:flex;justify-content:space-between;align-items:center}
.history-list{display:flex;flex-direction:column;gap:.35rem;max-height:220px;overflow-y:auto}
.history-item{background:var(--surface);border:1px solid var(--border);border-radius:10px;padding:.5rem .75rem;font-size:.78rem;display:flex;justify-content:space-between;align-items:center;animation:fadeIn .2s}
.history-dice{color:var(--text-dim)}
.history-result{font-weight:700;font-variant-numeric:tabular-nums}
.history-total{color:var(--accent);font-weight:800}

/* Quantity badge */
.dice-count{display:flex;align-items:center;gap:.5rem;margin-bottom:1rem;justify-content:center}
.count-btn{width:32px;height:32px;border-radius:50%;border:1px solid var(--border);background:var(--surface);color:var(--text);font-size:1rem;font-weight:700;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all .15s;font-family:var(--font)}
.count-btn:hover{border-color:var(--primary);color:var(--primary)}
.count-display{font-size:1.1rem;font-weight:700;min-width:28px;text-align:center}

@keyframes diceRoll{
  0%{transform:perspective(400px) rotateX(0deg) rotateY(0deg) scale(1)}
  30%{transform:perspective(400px) rotateX(180deg) rotateY(90deg) scale(1.1)}
  60%{transform:perspective(400px) rotateX(360deg) rotateY(270deg) scale(1.05)}
  100%{transform:perspective(400px) rotateX(720deg) rotateY(360deg) scale(1)}
}
@keyframes fadeIn{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:translateY(0)}}

.sound-toggle{position:fixed;top:1rem;right:1rem;width:36px;height:36px;border-radius:10px;border:1px solid var(--border);background:var(--surface);cursor:pointer;font-size:1rem;display:flex;align-items:center;justify-content:center;transition:all .2s;z-index:10}
.sound-toggle:hover{border-color:var(--primary)}
