﻿:root{
  --bg:#050608;
  --panel:rgba(14,16,21,.92);
  --panel-soft:rgba(22,24,32,.88);
  --line:rgba(255,255,255,.08);
  --text:#e7e0d4;
  --muted:#a6a0a4;
  --gold:#c8a05a;
  --red:#7b0d10;
  --red2:#d12226;
  --red3:#9b1014;
  --shadow:0 24px 70px rgba(0,0,0,.55);
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:Georgia, "Times New Roman", Times, serif;
  color:var(--text);
  background:
    radial-gradient(circle at 15% 10%, rgba(200,160,90,.10), transparent 24%),
    radial-gradient(circle at 85% 0%, rgba(168,124,255,.10), transparent 20%),
    linear-gradient(180deg, #040507 0%, #050608 40%, #020203 100%);
}
.background{
  position:fixed;
  inset:0;
  pointer-events:none;
  background-image:
    radial-gradient(circle at 12px 18px, rgba(255,255,255,.16) 0 1px, transparent 1px),
    radial-gradient(circle at 80px 60px, rgba(255,255,255,.08) 0 1px, transparent 1px),
    radial-gradient(circle at 180px 120px, rgba(255,255,255,.1) 0 1px, transparent 1px);
  background-size:220px 220px;
  opacity:.35;
}
.shell{
  width:min(1180px, calc(100vw - 24px));
  margin:12px auto;
  background:linear-gradient(180deg, rgba(18,20,27,.88), rgba(8,9,13,.96));
  border:1px solid var(--line);
  border-radius:18px;
  box-shadow:var(--shadow);
  overflow:hidden;
}
.hero{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:20px;
  padding:28px 28px 22px;
  border-bottom:1px solid var(--line);
  background:linear-gradient(180deg, rgba(220,35,35,.20), rgba(220,35,35,.08));
}
.kicker{
  color:var(--gold);
  letter-spacing:.22em;
  text-transform:uppercase;
  font-size:.82rem;
  margin-bottom:10px;
}
h1{
  margin:0;
  font-size:clamp(2.2rem, 4vw, 4.2rem);
  line-height:.95;
}
.hero-copy p{
  margin:12px 0 0;
  color:var(--muted);
  font-size:1.05rem;
  line-height:1.55;
}
.hero-badge{
  width:120px;
  height:120px;
  flex:0 0 auto;
  display:grid;
  place-items:center;
  border-radius:50%;
  background:linear-gradient(180deg, rgba(255,255,255,.06), rgba(0,0,0,.20));
  border:1px solid rgba(255,255,255,.08);
  color:#fff;
  font-size:2.2rem;
  box-shadow:inset 0 0 36px rgba(0,0,0,.25);
  overflow:hidden;
}
.hero-logo{
  width:100%;
  height:100%;
  object-fit:cover;
  border-radius:50%;
  display:block;
  filter:drop-shadow(0 2px 6px rgba(0,0,0,.35));
}
.control-bar{
  display:grid;
  gap:14px;
  padding:18px 28px;
  border-bottom:1px solid var(--line);
}
.toolbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
}
.toolbar h2{margin:0}
.toolbar .summary{margin-top:6px}
.toolbar-actions{
  display:flex;
  align-items:center;
  gap:10px;
}
.line-list{
  display:grid;
  gap:12px;
}
.line-card{
  display:grid;
  grid-template-columns:minmax(120px, 1fr) minmax(140px, 1fr) auto minmax(140px, 1fr) auto;
  gap:12px;
  align-items:end;
  padding:14px;
  border:1px solid rgba(255,255,255,.08);
  border-radius:16px;
  background:rgba(255,255,255,.02);
}
.line-card label{
  display:grid;
  gap:8px;
}
.line-card span{
  color:var(--text);
  font-size:.98rem;
}
.line-color input[type="color"]{
  width:46px;
  height:46px;
  padding:3px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.10);
  background:var(--panel-soft);
  cursor:pointer;
}
.line-color input[type="color"]:disabled{
  opacity:.35;
  cursor:not-allowed;
}
.line-status{
  min-height:46px;
  display:flex;
  align-items:center;
  justify-content:flex-start;
  padding:0 14px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.08);
  background:rgba(255,255,255,.02);
  color:var(--muted);
}
select,
input[type="number"]{
  width:100%;
  min-height:46px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.10);
  background:var(--panel-soft);
  color:var(--text);
  padding:0 14px;
  font:inherit;
  appearance:auto;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button{
  opacity:1;
  height:26px;
}
button{
  min-height:46px;
  border-radius:12px;
  border:1px solid rgba(200,160,90,.35);
  background:linear-gradient(180deg, #2a2b33, #12131a);
  color:#fff;
  font:inherit;
  font-size:1rem;
  padding:0 18px;
  cursor:pointer;
}
button:hover{border-color:rgba(200,160,90,.7)}
.primary{
  background:linear-gradient(180deg, var(--red2), var(--red));
  border-color:rgba(255,255,255,.12);
  color:#fff;
  font-weight:700;
}
.ghost{
  background:transparent;
  color:var(--muted);
}
.secondary{
  background:linear-gradient(180deg, rgba(200,160,90,.22), rgba(200,160,90,.08));
  border-color:rgba(200,160,90,.55);
  color:var(--text);
  font-weight:700;
}
.secondary:hover{border-color:rgba(200,160,90,.85)}
.line-action{
  width:46px;
  padding:0;
  display:grid;
  place-items:center;
  font-size:1.2rem;
}
.results,.history{
  padding:24px 28px 28px;
}
.results-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:14px;
}
h2{
  margin:0;
  font-size:1.05rem;
  letter-spacing:.14em;
  text-transform:uppercase;
  color:var(--gold);
}
.summary{
  color:var(--muted);
  font-size:.98rem;
}
.dice-stage{
  position:relative;
  width:100%;
  height:clamp(260px, 42vw, 420px);
  margin-bottom:16px;
  border-radius:18px;
  overflow:hidden;
  border:1px solid rgba(255,255,255,.08);
  background:
    radial-gradient(circle at 50% 0%, rgba(200,160,90,.10), transparent 55%),
    radial-gradient(circle at 50% 100%, rgba(0,0,0,.5), transparent 60%),
    linear-gradient(180deg, #0c0d12 0%, #06070a 100%);
  box-shadow:inset 0 0 0 1px rgba(255,255,255,.03), inset 0 30px 60px rgba(0,0,0,.5);
}
.dice-stage canvas{
  position:absolute;
  inset:0;
  width:100% !important;
  height:100% !important;
  display:block;
}
.dice-stage-hint{
  position:absolute;
  inset:0;
  display:grid;
  place-items:center;
  color:var(--muted);
  font-size:.98rem;
  letter-spacing:.04em;
  pointer-events:none;
  z-index:1;
}
.dice-stage-hint[hidden]{display:none}
.dice-box-canvas{transition:opacity .4s}
.dice-box-canvas--hide{opacity:0}
.primary.is-rolling{
  opacity:.75;
  cursor:progress;
}
.dice-stage-footer{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  flex-wrap:wrap;
  margin-bottom:14px;
}
.dice-stage-note{
  margin:0;
  color:var(--muted);
  font-size:.85rem;
  line-height:1.4;
}
.dice-grid{
  display:grid;
  gap:14px;
  min-height:120px;
}
.roll-group{
  padding:14px;
  border:1px solid rgba(255,255,255,.08);
  border-radius:16px;
  background:rgba(255,255,255,.02);
}
.roll-group-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:12px;
  color:var(--text);
}
.roll-group-head strong{
  color:var(--gold);
}
.roll-group-dice{
  display:flex;
  flex-wrap:wrap;
  gap:12px;
  justify-content:flex-start;
}
.empty-state{
  padding:18px;
  border:1px dashed rgba(255,255,255,.12);
  border-radius:14px;
  color:var(--muted);
}
.die{
  width:92px;
  height:92px;
  display:grid;
  place-items:center;
  position:relative;
  overflow:hidden;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.10);
  background:
    radial-gradient(circle at 50% 18%, rgba(255,255,255,.10), transparent 44%),
    linear-gradient(180deg, rgba(255,255,255,.05), rgba(0,0,0,.20)),
    linear-gradient(180deg, var(--red2) 0%, var(--red3) 100%);
  box-shadow:0 16px 36px rgba(0,0,0,.36), inset 0 0 0 1px rgba(255,255,255,.04);
  color:#fff;
  font-weight:700;
}
.die::before{
  content:attr(data-label);
  position:absolute;
  inset:0;
  display:grid;
  place-items:center;
  color:rgba(255,255,255,.16);
  font-size:1.15rem;
  letter-spacing:.16em;
  text-transform:uppercase;
  transform:translateY(2px);
}
.die::after{
  content:"";
  position:absolute;
  inset:0;
  background:linear-gradient(180deg, transparent 0 54%, rgba(0,0,0,.12) 54% 100%);
}
.die-value{
  position:relative;
  z-index:2;
  font-size:clamp(1.9rem, 4vw, 3rem);
  line-height:1;
  text-shadow:0 2px 0 rgba(0,0,0,.16);
}
.die--d4{--red2:#8b1317;--red3:#4f0709}
.die--d6{--red2:#9b1720;--red3:#5a0b10}
.die--d8{--red2:#af1b22;--red3:#661015}
.die--d10{--red2:#bc2126;--red3:#6d0f13}
.die--d12{--red2:#cb2730;--red3:#760f15}
.die--d20{--red2:#da2d34;--red3:#7f1014}
.die--d100{
  width:132px;
  height:92px;
  --red2:#9f141a;
  --red3:#56090d;
}
.die--d100 .die-value{font-size:1.85rem; letter-spacing:.04em}
.history-list{
  display:grid;
  gap:10px;
}
.history-item{
  display:flex;
  justify-content:space-between;
  gap:16px;
  padding:14px 16px;
  border:1px solid var(--line);
  border-radius:14px;
  background:rgba(255,255,255,.02);
  color:var(--text);
}
.history-item small{
  color:var(--muted);
}
@media (max-width: 900px){
  .hero,.control-bar,.results,.history{padding-left:16px;padding-right:16px}
  .hero{flex-direction:column;align-items:flex-start}
  .toolbar{flex-direction:column;align-items:flex-start}
  .toolbar-actions{width:100%}
  .toolbar-actions button{flex:1}
  .line-card{grid-template-columns:1fr 1fr}
  .line-status{grid-column:1 / -1}
  .line-action{width:100%}
  .hero-badge{width:90px;height:90px;font-size:1.7rem}
}
@media (max-width: 640px){
  .line-card{grid-template-columns:1fr}
}
