:root {
  color-scheme: light;
  --page: #f6f8fb;
  --paper: #ffffff;
  --paper-soft: #eef6f5;
  --ink: #172033;
  --muted: #667085;
  --line: #d9e1ea;
  --teal: #0f9f8f;
  --blue: #2f68d8;
  --rose: #e75a7c;
  --sun: #f4c542;
  --green: #30a46c;
  --shadow: 0 18px 45px rgba(23, 32, 51, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(15, 159, 143, 0.16), transparent 30rem),
    radial-gradient(circle at bottom right, rgba(47, 104, 216, 0.13), transparent 28rem),
    var(--page);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 0;
}

.screen {
  display: grid;
  gap: 18px;
}

.home-grid {
  min-height: calc(100vh - 56px);
  align-items: center;
  grid-template-columns: minmax(0, 1fr) 420px;
}

.brand-panel {
  display: grid;
  gap: 24px;
  align-content: center;
}

.badge {
  width: fit-content;
  padding: 8px 12px;
  border-radius: 999px;
  color: #0b625a;
  background: rgba(15, 159, 143, 0.14);
  font-size: 0.88rem;
  font-weight: 750;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  max-width: 760px;
  font-size: clamp(2.5rem, 8vw, 5.8rem);
  line-height: 0.94;
  letter-spacing: 0;
}

h2 {
  font-size: clamp(1.55rem, 4vw, 2.25rem);
  letter-spacing: 0;
}

h3 {
  font-size: 1rem;
}

.lead {
  max-width: 660px;
  color: var(--muted);
  font-size: clamp(1.02rem, 2vw, 1.2rem);
  line-height: 1.6;
}

.feature-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.feature-pill {
  padding: 10px 12px;
  border: 1px solid rgba(15, 159, 143, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  color: #214047;
  font-weight: 700;
}

.panel {
  padding: 22px;
  border: 1px solid rgba(217, 225, 234, 0.88);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.panel.flat {
  box-shadow: none;
}

.stack {
  display: grid;
  gap: 14px;
}

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

.form-row {
  display: grid;
  gap: 7px;
}

label {
  color: #344054;
  font-size: 0.9rem;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 13px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(15, 159, 143, 0.14);
}

.button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  padding: 0 16px;
  color: #fff;
  background: var(--teal);
  font-weight: 850;
  cursor: pointer;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    opacity 160ms ease;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(15, 159, 143, 0.22);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
  box-shadow: none;
}

.button.secondary {
  color: var(--ink);
  background: #e9eef5;
}

.button.blue {
  background: var(--blue);
}

.button.rose {
  background: var(--rose);
}

.button.discord {
  background: #5865f2;
}

.button.test-mode {
  color: #063f37;
  background: var(--sun);
}

.small-note {
  font-size: 0.88rem;
}

.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 8px;
  padding: 0 12px;
  color: var(--blue);
  background: transparent;
  font-weight: 800;
  cursor: pointer;
}

.muted {
  color: var(--muted);
}

.error {
  padding: 12px;
  border-radius: 8px;
  color: #8a1f3d;
  background: rgba(231, 90, 124, 0.12);
  font-weight: 750;
}

.lobby-header,
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.lobby-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.discord-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid rgba(88, 101, 242, 0.24);
  border-radius: 8px;
  padding: 11px 12px;
  color: #263066;
  background: rgba(88, 101, 242, 0.1);
  font-size: 0.9rem;
  font-weight: 800;
}

.discord-status a {
  color: #3944c7;
}

.discord-status.warning {
  border-color: rgba(231, 90, 124, 0.3);
  color: #8a1f3d;
  background: rgba(231, 90, 124, 0.12);
}

.room-code {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 8px;
  padding: 10px 12px;
  color: #0b625a;
  background: rgba(15, 159, 143, 0.13);
  font-weight: 900;
  letter-spacing: 0.05em;
}

.player-list {
  display: grid;
  gap: 10px;
}

.player-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.avatar {
  display: inline-flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: #fff;
  background: var(--blue);
  font-weight: 900;
}

.player-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.player-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 850;
}

.tag {
  width: fit-content;
  padding: 5px 8px;
  border-radius: 999px;
  color: #475467;
  background: #eef2f7;
  font-size: 0.78rem;
  font-weight: 850;
}

.tag.active {
  color: #0b625a;
  background: rgba(15, 159, 143, 0.15);
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.65fr);
  gap: 18px;
}

.dice-zone {
  display: grid;
  gap: 18px;
}

.score-panel {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: start;
}

.scoreboard-panel {
  grid-column: 1;
}

.turn-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-soft);
}

.dice-stage {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1.74 / 1;
  min-height: 0;
  border: 10px solid #254234;
  border-radius: 8px;
  background: #0b6b4b;
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.08),
    inset 0 20px 55px rgba(255, 255, 255, 0.06),
    inset 0 -24px 60px rgba(0, 0, 0, 0.24);
}

.dice-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.stage-empty,
.stage-error {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  color: rgba(255, 255, 255, 0.78);
  font-weight: 850;
  text-align: center;
  pointer-events: none;
}

.dice-stage:not(.is-empty) .stage-empty {
  display: none;
}

.dice-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(70px, 1fr));
  gap: 14px;
  min-height: 120px;
  align-items: center;
}

.die-button {
  display: grid;
  min-width: 0;
  gap: 9px;
  justify-items: center;
  padding: 8px 4px;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
}

.die-button:disabled {
  cursor: default;
}

.die-button.held .die-scene {
  filter: drop-shadow(0 0 0 rgba(0, 0, 0, 0));
}

.die-button.held .die {
  outline: 4px solid rgba(15, 159, 143, 0.2);
}

.hold-label {
  min-height: 20px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.die-button.held .hold-label {
  color: var(--teal);
}

.die-scene {
  --die-size: clamp(58px, 10vw, 82px);
  display: block;
  width: var(--die-size);
  height: var(--die-size);
  perspective: 620px;
}

.die {
  display: block;
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 380ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.die.show-1 {
  transform: rotateX(0deg) rotateY(0deg);
}

.die.show-2 {
  transform: rotateX(-90deg) rotateY(0deg);
}

.die.show-3 {
  transform: rotateX(0deg) rotateY(-90deg);
}

.die.show-4 {
  transform: rotateX(0deg) rotateY(90deg);
}

.die.show-5 {
  transform: rotateX(90deg) rotateY(0deg);
}

.die.show-6 {
  transform: rotateX(0deg) rotateY(180deg);
}

.die.show-1,
.die.show-2,
.die.show-3,
.die.show-4,
.die.show-5,
.die.show-6 {
  transform: rotateX(12deg) rotateY(-18deg) rotateZ(-10deg);
}

.die.rolling {
  animation: tumble 780ms ease-in-out;
}

@keyframes tumble {
  0% {
    transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg);
  }
  35% {
    transform: rotateX(210deg) rotateY(130deg) rotateZ(80deg);
  }
  70% {
    transform: rotateX(460deg) rotateY(300deg) rotateZ(190deg);
  }
  100% {
    transform: rotateX(720deg) rotateY(540deg) rotateZ(260deg);
  }
}

.face {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 5px;
  border: 1px solid rgba(23, 32, 51, 0.12);
  border-radius: 10px;
  padding: 10px;
  background: linear-gradient(145deg, #fff, #edf3f7);
  box-shadow: inset -8px -8px 16px rgba(23, 32, 51, 0.07);
  backface-visibility: hidden;
}

.front {
  transform: rotateY(0deg) translateZ(calc(var(--die-size) / 2));
  z-index: 2;
}

.back {
  transform: rotateY(180deg) translateZ(calc(var(--die-size) / 2));
}

.right {
  transform: rotateY(90deg) translateZ(calc(var(--die-size) / 2));
}

.left {
  transform: rotateY(-90deg) translateZ(calc(var(--die-size) / 2));
}

.top {
  transform: rotateX(90deg) translateZ(calc(var(--die-size) / 2));
}

.bottom {
  transform: rotateX(-90deg) translateZ(calc(var(--die-size) / 2));
}

.pip {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: var(--ink);
  opacity: 0;
}

.pip.on {
  opacity: 1;
}

.blank-face {
  background: linear-gradient(145deg, #ecf3f8, #dfe9f0);
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.score-list {
  display: grid;
  gap: 8px;
}

.score-choice {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--ink);
  background: #fff;
  text-align: left;
  cursor: pointer;
}

.score-choice strong {
  display: block;
}

.score-choice span {
  color: var(--muted);
  font-size: 0.82rem;
}

.score-choice b {
  min-width: 42px;
  border-radius: 8px;
  padding: 8px 10px;
  color: #0b625a;
  background: rgba(15, 159, 143, 0.13);
  text-align: center;
}

.score-choice:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

.scoreboard-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.scoreboard {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
}

.scoreboard th,
.scoreboard td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: middle;
}

.scoreboard th {
  color: #344054;
  background: #f1f5f9;
  font-size: 0.86rem;
}

.scoreboard td {
  color: var(--ink);
}

.scoreboard tr:last-child th,
.scoreboard tr:last-child td {
  border-bottom: 0;
}

.scoreboard .total-row th,
.scoreboard .total-row td {
  font-weight: 900;
  background: rgba(244, 197, 66, 0.18);
}

.empty-die {
  display: grid;
  width: clamp(58px, 10vw, 82px);
  height: clamp(58px, 10vw, 82px);
  place-items: center;
  border: 2px dashed var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  font-weight: 900;
}

.winner-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-radius: 8px;
  color: #063f37;
  background: rgba(15, 159, 143, 0.15);
  font-weight: 850;
}

@media (max-width: 880px) {
  .home-grid,
  .game-layout {
    grid-template-columns: 1fr;
  }

  .score-panel,
  .scoreboard-panel {
    grid-column: auto;
    grid-row: auto;
  }

  .home-grid {
    align-items: start;
  }

  h1 {
    font-size: clamp(2.35rem, 16vw, 4.7rem);
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding: 10px 0 18px;
  }

  .panel {
    padding: 16px;
  }

  .split,
  .lobby-header,
  .game-header {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .lobby-actions {
    justify-content: stretch;
  }

  .lobby-actions .button {
    width: 100%;
  }

  .dice-row {
    grid-template-columns: repeat(5, minmax(48px, 1fr));
    gap: 6px;
  }

  .dice-stage {
    aspect-ratio: 1.46 / 1;
    min-height: 0;
    border-width: 7px;
  }

  .die-button {
    padding: 4px 0;
  }

  .hold-label {
    font-size: 0.68rem;
  }
}
