:root {
  --ink: #090909;
  --paper: #ffffff;
  --soft: #f5f5f5;
  --line: #d7d7d7;
  --muted: #696969;
  --shadow: rgba(0, 0, 0, 0.18);
  --sidebar: 25vw;
  --ads-height: 42px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background: #000000;
  font-family: "Libre Baskerville", Georgia, serif;
}

body::after {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 30;
  opacity: 0.16;
  content: "";
  background-image:
    radial-gradient(circle at 20% 30%, rgba(0, 0, 0, 0.08) 0 1px, transparent 1px),
    radial-gradient(circle at 70% 60%, rgba(0, 0, 0, 0.06) 0 1px, transparent 1px),
    linear-gradient(135deg, rgba(0, 0, 0, 0.025), transparent 38%);
  background-size: 7px 7px, 11px 11px, 100% 100%;
  mix-blend-mode: normal;
}

button {
  color: inherit;
  font: inherit;
}

.app-shell {
  display: grid;
  width: 100vw;
  height: 100vh;
  grid-template-columns: minmax(0, 3fr) minmax(280px, 1fr);
  grid-template-rows: minmax(0, 1fr) var(--ads-height);
  background: #000000;
}

.tabletop-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #000000;
  border-right: 1px solid var(--ink);
}

#dice-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

#dice-canvas.dragging {
  cursor: grabbing;
}

.table-hud {
  position: absolute;
  left: clamp(14px, 2vw, 28px);
  bottom: clamp(14px, 2vw, 28px);
  padding: 8px 11px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 14px 35px rgba(0, 0, 0, 0.08);
  font-family: "Cinzel", Georgia, serif;
  font-size: 11px;
  letter-spacing: 0;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
}

.sidebar {
  display: flex;
  min-width: 280px;
  min-height: 0;
  flex-direction: column;
  gap: 22px;
  padding: clamp(18px, 2vw, 28px);
  background: #fbfbfb;
  box-shadow: -22px 0 50px rgba(0, 0, 0, 0.08);
}

.sidebar-header {
  border-bottom: 1px solid var(--ink);
  padding-bottom: 18px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--muted);
  font-family: "Cinzel", Georgia, serif;
  font-size: 11px;
  letter-spacing: 0;
  text-transform: none;
}

h1,
h2 {
  margin: 0;
  font-family: "Cinzel", Georgia, serif;
  font-weight: 700;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 3.5vw, 46px);
  line-height: 0.95;
}

h2 {
  font-size: 18px;
}

.dice-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.dice-controls button,
.secondary-actions button,
#clear-results {
  min-height: 38px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--paper);
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
  font-family: "Cinzel", Georgia, serif;
  font-size: 13px;
  transition:
    transform 150ms ease,
    box-shadow 150ms ease,
    background 150ms ease;
}

.dice-controls button:hover,
.secondary-actions button:hover,
#clear-results:hover {
  background: #eeeeee;
  transform: translate(1px, 1px);
  box-shadow: 2px 2px 0 var(--ink);
}

.dice-controls button:active,
.secondary-actions button:active,
#clear-results:active {
  transform: translate(3px, 3px);
  box-shadow: 0 0 0 var(--ink);
}

.palette-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.palette-panel h2 {
  font-size: 14px;
}

.color-swatches {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.color-swatch {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
  border: 1px solid var(--ink);
  border-radius: 0;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.42), rgba(0, 0, 0, 0.06)),
    var(--swatch);
  box-shadow: 2px 2px 0 var(--ink);
  cursor: pointer;
  transition:
    transform 150ms ease,
    box-shadow 150ms ease;
}

.color-swatch::after {
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(0, 0, 0, 0.22);
  content: "";
}

.color-swatch:hover,
.color-swatch.is-active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--ink);
}

.color-swatch.is-active::before {
  position: absolute;
  inset: -5px;
  border: 1px solid var(--ink);
  content: "";
}

.secondary-actions {
  display: grid;
}

.results-panel {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.results-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

#clear-results {
  min-height: 30px;
  padding: 0 12px;
  box-shadow: 2px 2px 0 var(--ink);
  font-size: 11px;
}

.results-list {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.results-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  font-size: 16px;
}

.results-list .roll-label {
  font-family: "Cinzel", Georgia, serif;
  font-weight: 700;
}

.results-list .roll-time {
  color: var(--muted);
  font-size: 11px;
}

.empty-state {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
}

#ads-bar {
  grid-column: 1 / -1;
  min-height: var(--ads-height);
  border-top: 1px solid var(--ink);
  background:
    repeating-linear-gradient(
      90deg,
      #ffffff 0,
      #ffffff 18px,
      #f1f1f1 18px,
      #f1f1f1 36px
    );
}

@media (max-width: 860px) {
  html,
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 58svh auto var(--ads-height);
    height: auto;
    min-height: 100svh;
  }

  .tabletop-wrap {
    border-right: 0;
    border-bottom: 1px solid var(--ink);
  }

  .sidebar {
    width: 100vw;
    min-width: 0;
    max-width: 100vw;
    gap: 14px;
    padding: 16px;
    overflow: hidden;
  }

  .sidebar-header {
    padding-bottom: 12px;
  }

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

  .dice-controls button {
    min-width: 0;
  }

  .color-swatches {
    grid-template-columns: repeat(6, minmax(36px, 1fr));
  }

  h1 {
    font-size: 28px;
    line-height: 1;
  }
}
