* { margin: 0; padding: 0; box-sizing: border-box; }
body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Georgia', 'Trebuchet MS', serif;
  background: #080403;
}

#gameContainer {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(ellipse at center, rgba(146, 73, 26, .35) 0%, rgba(13, 6, 4, 0) 48%),
    linear-gradient(180deg, #1b0b06 0%, #080403 100%);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

#ui-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
#ui-layer > * { pointer-events: auto; }

/* ROLL BUTTON */
.roll-btn {
  position: absolute;
  left: 50%;
  bottom: 10%;
  transform: translateX(-50%);
  min-width: min(18rem, 72vw);
  min-height: 4.7rem;
  padding: 1rem 3.4rem;
  font-size: clamp(1.45rem, 3vw, 2.15rem);
  font-weight: 900;
  font-family: 'Georgia', serif;
  letter-spacing: 0.26rem;
  color: #fff5c4;
  background:
    linear-gradient(180deg, rgba(255,255,255,.42) 0%, rgba(255,255,255,.12) 32%, rgba(255,255,255,0) 46%),
    radial-gradient(circle at 50% 0%, rgba(255,160,132,.35), transparent 52%),
    linear-gradient(180deg, #f04438 0%, #b81617 48%, #650708 100%);
  border: 5px solid #ffd86b;
  border-radius: 18px;
  cursor: pointer;
  box-shadow:
    0 0 38px rgba(255, 205, 70, 0.72),
    inset 0 3px 10px rgba(255, 255, 255, 0.36),
    inset 0 -9px 16px rgba(0, 0, 0, 0.48),
    0 10px 0 #4d0c08,
    0 18px 32px rgba(0, 0, 0, 0.7);
  text-shadow:
    0 2px 0 rgba(75, 20, 0, 0.9),
    0 0 12px rgba(255, 230, 130, 0.45);
  transition: transform 0.1s, box-shadow 0.2s, filter 0.2s;
  z-index: 20;
}
.roll-btn:hover:not(:disabled) {
  transform: translateX(-50%) translateY(-2px);
  box-shadow:
    0 0 52px rgba(255, 225, 92, 0.98),
    inset 0 4px 12px rgba(255, 255, 255, 0.46),
    inset 0 -9px 16px rgba(0, 0, 0, 0.46),
    0 10px 0 #4d0c08,
    0 18px 30px rgba(0, 0, 0, 0.7);
  filter: saturate(1.12) brightness(1.05);
}
.roll-btn:active:not(:disabled) {
  transform: translateX(-50%) translateY(5px);
  box-shadow:
    0 0 22px rgba(255, 220, 80, 0.66),
    inset 0 3px 10px rgba(255, 255, 255, 0.22),
    inset 0 -5px 12px rgba(0, 0, 0, 0.45),
    0 5px 0 #4d0c08,
    0 10px 18px rgba(0, 0, 0, 0.64);
}
.roll-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  filter: grayscale(0.4);
}

.admin-btn {
  display: inline-block;
  padding: 0.55rem 1rem;
  margin: 0.25rem 0.3rem 0.25rem 0;
  background: #3a2418;
  border: 2px solid #8b6914;
  border-radius: 5px;
  color: #fff8dc;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: bold;
  cursor: pointer;
  letter-spacing: 0.05rem;
  transition: background 0.15s, transform 0.1s;
}
.admin-btn:hover { background: #5a3828; transform: translateY(-1px); }
.admin-btn.primary { background: linear-gradient(180deg, #d4302a, #8b1a15); border-color: #ffd700; }
.admin-btn.primary:hover { background: linear-gradient(180deg, #e04038, #a02218); }
.admin-btn.danger { background: #4a1a1a; border-color: #8b2a2a; }
.admin-btn.danger:hover { background: #6a2020; }
.admin-btn:disabled {
  cursor: not-allowed;
  opacity: .45;
  transform: none;
}

.admin-stats {
  font-size: 0.85rem;
  color: #d4b878;
  line-height: 1.6;
  font-family: monospace;
}
.admin-stats .stat-row {
  display: flex;
  justify-content: space-between;
  padding: 0.15rem 0;
}
.admin-stats .stat-swatch {
  display: inline-block;
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 2px;
  border: 1px solid rgba(0,0,0,0.4);
  vertical-align: middle;
  margin-right: 0.4rem;
}

.hidden,
[hidden] {
  display: none !important;
}

body.admin-route,
html:has(body.admin-route) {
  height: auto;
  min-height: 100%;
  overflow: auto;
}

body.admin-route {
  background:
    radial-gradient(circle at 22% 12%, rgba(255, 213, 91, .12), transparent 28rem),
    radial-gradient(circle at 80% 2%, rgba(218, 54, 45, .16), transparent 30rem),
    linear-gradient(180deg, #1a0c08 0%, #090504 100%);
  color: #fff8dc;
}

body.admin-route #gameContainer {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}

body.admin-route .roll-btn {
  display: none;
}

.admin-page {
  display: none;
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 3rem;
}

body.admin-route .admin-page {
  display: block;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 0 1.5rem;
  border-bottom: 1px solid rgba(230, 189, 69, .35);
  margin-bottom: 1.25rem;
}

.admin-kicker {
  color: #d4b878;
  font-size: .78rem;
  letter-spacing: .16rem;
  text-transform: uppercase;
  margin-bottom: .25rem;
}

.admin-topbar h1 {
  color: #ffe28a;
  font-size: clamp(1.55rem, 3vw, 2.45rem);
  line-height: 1;
  letter-spacing: .08rem;
  text-shadow: 0 2px 18px rgba(255, 196, 66, .22);
}

.admin-public-link {
  color: #fff8dc;
  text-decoration: none;
  border: 1px solid rgba(230, 189, 69, .6);
  border-radius: 6px;
  padding: .65rem .9rem;
  background: rgba(45, 24, 10, .72);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.09);
}

.admin-top-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .7rem;
}

.connection-pill {
  border: 1px solid rgba(230, 189, 69, .36);
  border-radius: 999px;
  color: #d4b878;
  font-weight: 900;
  padding: .55rem .8rem;
  background: rgba(0,0,0,.22);
}

.connection-pill::before {
  content: '';
  display: inline-block;
  width: .65rem;
  height: .65rem;
  border-radius: 50%;
  margin-right: .45rem;
  background: #d64a3d;
  box-shadow: 0 0 10px rgba(214, 74, 61, .55);
}

.connection-pill.connected::before {
  background: #45d66c;
  box-shadow: 0 0 10px rgba(69, 214, 108, .75);
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.admin-card {
  background:
    linear-gradient(180deg, rgba(255,255,255,.055), rgba(255,255,255,0) 28%),
    rgba(24, 13, 8, .88);
  border: 1px solid rgba(230, 189, 69, .38);
  border-radius: 8px;
  box-shadow: 0 16px 34px rgba(0,0,0,.35);
  padding: 1rem;
}

.admin-card-wide {
  grid-column: 1 / -1;
}

.admin-card h2,
.admin-card-header h2 {
  color: #ffe28a;
  font-size: 1rem;
  letter-spacing: .1rem;
  text-transform: uppercase;
  margin-bottom: .9rem;
}

.admin-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .9rem;
}

.admin-card-header h2 {
  margin-bottom: 0;
}

.admin-pill {
  color: #1d0b06;
  background: linear-gradient(180deg, #fff1a8, #d79b28);
  border-radius: 999px;
  padding: .35rem .7rem;
  font-weight: 900;
  font-size: .78rem;
}

.status-grid,
.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .8rem;
}

.status-grid div {
  background: rgba(0,0,0,.22);
  border: 1px solid rgba(230, 189, 69, .18);
  border-radius: 6px;
  padding: .85rem;
}

.countdown-status .countdown-track {
  height: .75rem;
  margin: .55rem 0 .35rem;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(0,0,0,.42);
  border: 1px solid rgba(230, 189, 69, .16);
}

.countdown-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #d4302a, #ffd86b);
  transition: width .18s linear;
}

.status-grid span,
.admin-range span,
.admin-switch span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  color: #d4b878;
  font-size: .82rem;
}

.status-grid strong {
  display: block;
  color: #fff8dc;
  font-size: 1.35rem;
  margin-top: .25rem;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
  margin-top: 1rem;
}

.admin-actions.compact {
  margin-top: 0;
}

.admin-range {
  display: block;
  margin-bottom: 1rem;
}

.admin-range output {
  color: #ffe28a;
  font-weight: 900;
}

.admin-range input[type="range"] {
  width: 100%;
  margin-top: .55rem;
  accent-color: #e4b63b;
}

.radio-stack {
  display: grid;
  gap: .65rem;
}

.radio-stack label,
.manual-result label,
.admin-switch {
  color: #fff8dc;
  background: rgba(0,0,0,.18);
  border: 1px solid rgba(230, 189, 69, .18);
  border-radius: 6px;
  padding: .72rem;
}

.radio-stack input,
.admin-switch input {
  accent-color: #e4b63b;
}

.manual-result {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .65rem;
  margin-top: .9rem;
}

.manual-result select {
  width: 100%;
  margin-top: .45rem;
  padding: .5rem;
  color: #fff8dc;
  background: #120906;
  border: 1px solid rgba(230, 189, 69, .45);
  border-radius: 5px;
  font-family: inherit;
}

.result-preview-block {
  margin-top: .9rem;
  padding-top: .85rem;
  border-top: 1px solid rgba(230, 189, 69, .16);
}

.result-preview-block > span {
  display: block;
  color: #d4b878;
  font-size: .82rem;
  margin-bottom: .5rem;
}

.dice-preview,
.last-result-dice {
  display: flex;
  align-items: center;
  gap: .55rem;
}

.last-result {
  min-height: 5.2rem;
  display: flex;
  align-items: center;
}

.settings-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-stats {
  font-family: 'Trebuchet MS', Arial, sans-serif;
}

.admin-stats .stat-row {
  align-items: center;
  border-bottom: 1px solid rgba(230, 189, 69, .12);
  gap: 1rem;
  padding: .45rem 0;
}

.admin-stats .stat-row:last-child {
  border-bottom: none;
}

.admin-stats .stat-row strong {
  color: #fff8dc;
  text-align: right;
}

.admin-history {
  display: grid;
  gap: .55rem;
}

.history-row {
  display: grid;
  grid-template-columns: 4rem minmax(8rem, 1fr) 9rem;
  align-items: center;
  gap: .8rem;
  padding: .65rem;
  background: rgba(0,0,0,.2);
  border: 1px solid rgba(230, 189, 69, .14);
  border-radius: 6px;
}

.history-index {
  color: #b89968;
  font-family: monospace;
}

.history-die {
  display: inline-block;
  width: 1.6rem;
  height: 1.6rem;
  margin-right: .35rem;
  border-radius: 5px;
  background:
    radial-gradient(circle at 28% 22%, rgba(255,255,255,.75), transparent 28%),
    linear-gradient(135deg, rgba(255,255,255,.25), rgba(0,0,0,.28)),
    var(--die-color);
  border: 2px solid rgba(255, 241, 168, .72);
  box-shadow: 0 4px 10px rgba(0,0,0,.3);
  vertical-align: middle;
}

.admin-empty {
  color: #b89968;
  font-style: italic;
}

@media (max-width: 820px) {
  .admin-grid,
  .status-grid,
  .settings-grid,
  .manual-result {
    grid-template-columns: 1fr;
  }

  .admin-topbar {
    align-items: flex-start;
    flex-direction: column;
  }

.history-row {
    grid-template-columns: 1fr;
  }
}
