* {
  box-sizing: border-box;
}
#liveModeView { max-width: 1000px; margin: 0 auto; }
#liveModeView .camera-eyebrow { color: var(--ok); font-size: .7rem; font-weight: 800; letter-spacing: .12em; margin-bottom: 6px; }
#liveModeView h2 { margin-bottom: 0; }
#liveModeView .subtitle { display: block; font-size: .85rem; line-height: 1.5; }
#liveModeView .card.muted { background: #edf2ef; border: 1px solid #d6e2da; }
#liveModeView .camera-video-head, #liveModeView .camera-result-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
#liveModeView .camera-result-head { margin-top: 24px; }
#liveModeView .camera-result-head h3 { margin: 0; }
#liveModeView .camera-preview { position: relative; overflow: hidden; border-radius: 16px; background: #182820; margin-top: 12px; }
#liveModeView #liveMainVideo { display: block; min-height: 220px; object-fit: contain; }
#liveModeView #liveDetectionOverlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#liveModeView #liveCameraPlaceholder { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; color: #d9e7df; padding: 24px; line-height: 1.8; pointer-events: none; }
#liveModeView .camera-corrections { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
#liveModeView [hidden] { display: none !important; }
#liveModeView .camera-corrections label { font-size: .75rem; margin: 0; }
#liveModeView .camera-corrections select { width: 100%; padding: 10px 4px; margin-top: 6px; border: 1px solid var(--line); border-radius: 10px; background: white; color: var(--text); font-size: 16px; }
#liveModeView #liveDiceBoard { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; perspective: none; transform-style: flat; }
#liveModeView .camera-die { background: #f8faf9; color: var(--text); border: 2px solid transparent; min-width: 0; width: 100%; padding: 12px 4px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
#liveModeView .camera-die[aria-pressed="true"] { border-color: var(--ok); background: #e6f1eb; }
#liveModeView .camera-die svg { display: block; width: 100%; max-width: 70px; height: auto; }
#liveModeView .camera-die .small-label { font-size: .65rem; }
#liveModeView .camera-unknown { height: 55px; display: grid; place-items: center; font-size: 2rem; color: var(--muted); }
#liveModeView .camera-rolling { animation: camera-roll .15s ease-in-out 3; }
#liveModeView button:focus-visible, #liveModeView select:focus-visible { outline: 3px solid var(--ok); outline-offset: 3px; }
@keyframes camera-roll { 50% { transform: translateY(-5px) rotate(5deg); } }
@media (max-width: 520px) { #liveModeView .camera-corrections { grid-template-columns: repeat(3, minmax(0, 1fr)); } #liveModeView .camera-video-head { align-items: flex-start; flex-direction: column; } #liveModeView .button-row > button { flex: 1 1 140px; } }
@media (prefers-reduced-motion: reduce) { #liveModeView .camera-rolling { animation: none; } }
:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #d1d5db;
  --accent: #2563eb;
  --danger: #b91c1c;
  --ok: #047857;
  --shadow: 0 10px 30px rgba(17, 24, 39, 0.08);
  --radius: 18px;
}
html,
body {
  margin: 0;
  padding: 0;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
body {
  padding-bottom: calc(env(safe-area-inset-bottom) + 18px);
}
.topbar {
  padding: 4px 12px 2px;
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
}
h1 {
  margin: 0;
  font-size: 1.5rem;
}
h2,
h3 {
  margin-top: 0;
}
.subtitle {
  margin: 4px 0 0;
  color: var(--muted);
}
.app-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 8px 12px 24px;
}
.screen {
  display: none;
}
.screen.active {
  display: block;
}
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.card.muted {
  background: #eef2ff;
}
.rules {
  margin: 0;
  padding-left: 20px;
}
label {
  display: block;
  font-size: 0.95rem;
  margin-bottom: 12px;
}
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  margin-top: 6px;
  font-size: 16px;
  background: #fff;
}
button {
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
button.secondary {
  background: #e5e7eb;
  color: #111827;
}
button.danger {
  background: var(--danger);
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.button-row.compact button {
  padding: 10px 12px;
  font-size: 14px;
}
.divider {
  text-align: center;
  color: var(--muted);
  margin: 12px 0;
  position: relative;
}
.divider::before,
.divider::after {
  content: "";
  height: 1px;
  background: var(--line);
  position: absolute;
  top: 50%;
  width: 36%;
}
.divider::before {
  left: 0;
}
.divider::after {
  right: 0;
}
.small-label {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 4px;
}
.game-code {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}
.lobby-head,
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.player-list {
  display: grid;
  gap: 10px;
}
.player-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}
.player-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.badge {
  display: inline-flex;
  align-items: center;
  background: #dbeafe;
  color: #1d4ed8;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.badge.host {
  background: #dcfce7;
  color: #047857;
}
.badge.me {
  background: #fef3c7;
  color: #92400e;
}
.table-wrap {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 900px;
}
th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: center;
  background: #fff;
}
th:first-child,
td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #f9fafb;
  text-align: left;
  min-width: 190px;
}
thead th {
  position: sticky;
  top: 0;
  background: #f3f4f6;
  z-index: 3;
}
.score-input {
  width: 86px;
  min-width: 86px;
  text-align: center;
  padding: 10px 6px;
  font-weight: 600;
}
.readonly-cell {
  font-weight: 800;
  color: var(--ok);
}
.row-muted {
  color: var(--muted);
  background: #f9fafb;
}
.mobile-only {
  display: none;
}
.desktop-only {
  display: block;
}
.mobile-tabs {
  display: flex;
  gap: 8px;
  overflow: auto;
  padding-bottom: 6px;
}
.mobile-tab {
  white-space: nowrap;
}
.mobile-tab.active {
  background: #111827;
  color: #fff;
}
.mobile-scores {
  display: grid;
  gap: 10px;
}
.score-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.score-card h3 {
  margin: 0;
  padding: 12px 14px;
  background: #f9fafb;
  font-size: 1rem;
}
.score-row {
  display: grid;
  grid-template-columns: 1.3fr 0.7fr;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
}
.score-row.computed {
  background: #f9fafb;
}
.score-row label {
  margin: 0;
  font-size: 0.95rem;
}
.score-row input {
  margin-top: 0;
  text-align: center;
}
.dialog-form menu {
  display: flex;
  justify-content: end;
  gap: 10px;
  padding: 0;
  margin: 18px 0 0;
}
#playerDialog {
  border: none;
  border-radius: 18px;
  width: min(92vw, 460px);
  box-shadow: var(--shadow);
}
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 80px);
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 12px 16px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 10000;
}
.hidden {
  display: none !important;
}
.chip {
  display: inline-block;
  background: #dcfce7;
  color: #166534;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
}
@media (max-width: 860px) {
  .status-grid {
    grid-template-columns: 1fr;
  }
  h1 {
    font-size: 1.3rem;
  }
  .app-shell {
    padding: 8px 10px 24px;
  }
  .card {
    padding: 14px;
  }
  .mobile-only {
    display: block;
  }
  .desktop-only {
    display: none;
  }
}

.category-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #eef2ff;
  color: #1f2937;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 14px;
  font-weight: 700;
  width: 100%;
  text-align: left;
}
.category-btn.mobile-label {
  padding: 10px 12px;
}
.category-btn:hover {
  background: #e0e7ff;
}

.simple-list {
  display: grid;
  gap: 10px;
}
.simple-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: #fff;
}
.simple-item-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  border-radius: 999px;
  background: #111827;
  color: #fff;
  font-weight: 800;
}
.small-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
@media (max-width: 860px) {
  .small-grid {
    grid-template-columns: 1fr;
  }
}

.app-view {
  display: none;
}
.app-view.active {
  display: block;
}
.live-header {
  position: sticky;
  top: 0;
  z-index: 5;
}
.compact-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  padding: 10px 12px calc(env(safe-area-inset-bottom) + 10px);
  background: rgba(243, 244, 246, 0.98);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  z-index: 25;
}
.nav-btn {
  background: #e5e7eb;
  color: #111827;
  border-radius: 14px;
  padding: 12px 8px;
  font-size: 13px;
}
.nav-btn.active {
  background: #111827;
  color: white;
}
.menu-list {
  display: grid;
  gap: 10px;
}
@media (max-width: 860px) {
  .compact-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.scorebar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.leader-ticker {
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.35;
}
.turn-box {
  border: 1px solid var(--line);
  background: #f9fafb;
  border-radius: 14px;
  padding: 10px 12px;
  min-width: 180px;
}
.turn-info {
  font-size: 1rem;
  font-weight: 800;
}
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  margin-top: 6px;
  font-size: 16px;
  background: #fff;
}
@media (max-width: 860px) {
  .leader-ticker {
    font-size: 0.95rem;
  }
  .turn-box {
    width: 100%;
  }
}

.turn-quick-btn {
  margin-top: 10px;
  width: 100%;
}
.simple-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.simple-actions button {
  padding: 8px 10px;
  font-size: 13px;
}

.profile-pill {
  display: inline-flex;
  align-items: center;
  background: #eef2ff;
  color: #1d4ed8;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
}

.player-submeta {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.badge.active-turn {
  background: #fee2e2;
  color: #b91c1c;
}
.mobile-tab.active-turn {
  outline: 2px solid #b91c1c;
  outline-offset: 1px;
}
.score-card.active-turn {
  border: 2px solid #b91c1c;
}

.update-banner {
  position: fixed;
  left: 12px;
  right: 12px;
  top: calc(env(safe-area-inset-top) + 10px);
  z-index: 40;
  background: #111827;
  color: #fff;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(17, 24, 39, 0.25);
  padding: 12px 14px;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}
.update-banner button {
  white-space: nowrap;
}

.version-badge {
  display: inline-block;
  margin-top: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #eef2ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 800;
}
.menu-version {
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.topbar {
  padding-bottom: 2px;
}
.subtitle {
  display: none;
}
.live-header {
  position: sticky;
  top: 0;
  z-index: 8;
}
.scorebar {
  align-items: flex-start;
}
.live-header .scorebar > div:first-child {
  flex: 1 1 100%;
  min-width: 0;
}
.leaderboard-lines {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px;
  margin-top: 8px;
  width: 100%;
}
.leader-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f9fafb;
}
.leader-line-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.leader-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  border-radius: 999px;
  background: #111827;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}
.leader-rank.active-turn {
  background: #b91c1c;
}
.leader-main {
  min-width: 0;
}
.leader-name {
  font-weight: 800;
  font-size: 15px;
  line-height: 1.2;
}
.leader-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}
.leader-score {
  font-size: 18px;
  font-weight: 900;
  white-space: nowrap;
}
@media (max-width: 860px) {
  .topbar {
    padding-top: 2px;
  }
  h1 {
    font-size: 1.25rem;
  }
  .leader-line {
    padding: 10px;
  }
  .leader-name {
    font-size: 14px;
  }
  .leader-score {
    font-size: 16px;
  }
}

.recent-highlight {
  border: 2px solid #2563eb;
  background: #eff6ff;
}

.debug-version {
  background: #fee2e2;
  color: #b91c1c;
  border: 2px solid #b91c1c;
}

.list-group {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  background: #fff;
}
.list-group-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.list-group-title {
  font-size: 1.15rem;
  font-weight: 900;
}
.list-items {
  display: grid;
  gap: 8px;
}
.list-item-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f9fafb;
}
.list-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: #111827;
  color: #fff;
  font-weight: 800;
  font-size: 12px;
}
.list-score {
  font-weight: 900;
  font-size: 1.1rem;
}
.list-tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.mini-btn {
  padding: 8px 10px;
  font-size: 13px;
  border-radius: 10px;
}
.edit-row {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  background: #f9fafb;
}
.edit-row-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.mode-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0;
}
.mode-card {
  background: #f9fafb;
  color: #111827;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  text-align: left;
}
.mode-card.active {
  background: #111827;
  color: #fff;
}
.mode-title {
  font-weight: 900;
  font-size: 15px;
}
.mode-subtitle {
  font-size: 12px;
  opacity: 0.85;
  margin-top: 4px;
}
.dice-status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.dice-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.die-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.die-card.held {
  border: 2px solid #b91c1c;
  background: #fee2e2;
}
.die-number {
  font-size: 2.25rem;
}
@media (max-width: 860px) {
  .mode-picker {
    grid-template-columns: 1fr;
  }
  .dice-status-grid {
    grid-template-columns: 1fr;
  }
  .dice-board {
    grid-template-columns: repeat(3, 1fr);
  }
}

.mode-badge {
  display: inline-block;
  margin-top: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #ecfeff;
  color: #155e75;
  font-size: 12px;
  font-weight: 800;
}
.die-card.rolling {
  animation: dieShake 420ms ease-in-out;
}
@keyframes dieShake {
  0% {
    transform: rotate(0deg) scale(1);
  }
  20% {
    transform: rotate(-10deg) scale(1.05);
  }
  40% {
    transform: rotate(10deg) scale(0.98);
  }
  60% {
    transform: rotate(-8deg) scale(1.04);
  }
  80% {
    transform: rotate(8deg) scale(0.99);
  }
  100% {
    transform: rotate(0deg) scale(1);
  }
}
.die-card.disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.die-card {
  background: linear-gradient(180deg, #ffffff 0%, #f3f4f6 100%);
  border: 1px solid #d1d5db;
}
.die-face {
  font-size: 3.1rem;
  line-height: 1;
  display: inline-block;
  transform: translateY(1px);
}
.die-card.held .die-face {
  transform: translateY(1px) scale(1.02);
}

.dice-board {
  gap: 14px;
}
.die-card {
  min-height: 104px;
  border-radius: 22px;
  border: 1px solid #cbd5e1;
  background: linear-gradient(180deg, #ffffff 0%, #eef2f7 100%);
  box-shadow:
    0 12px 24px rgba(15, 23, 42, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
  transition:
    transform 0.14s ease,
    box-shadow 0.14s ease,
    border-color 0.14s ease,
    background 0.14s ease;
}
.die-card:hover {
  transform: translateY(-1px);
  box-shadow:
    0 14px 28px rgba(15, 23, 42, 0.13),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
}
.die-card:active {
  transform: scale(0.98);
}
.die-card.held {
  border: 2px solid #b91c1c;
  background: linear-gradient(180deg, #fff1f2 0%, #ffe4e6 100%);
  box-shadow:
    0 14px 30px rgba(185, 28, 28, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}
.die-card.disabled {
  opacity: 0.65;
  filter: grayscale(0.06);
}
.die-face {
  font-size: 3.6rem;
  line-height: 1;
  display: inline-block;
  color: #111827;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
}
.die-card.held .die-face {
  color: #991b1b;
}
@media (max-width: 860px) {
  .die-card {
    min-height: 92px;
    border-radius: 18px;
  }
  .die-face {
    font-size: 3.1rem;
  }
}

.dice-suggestions {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.suggestion-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: #fff;
}
.suggestion-card.best {
  border: 2px solid #2563eb;
  background: #eff6ff;
}
.suggestion-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 6px;
}
.suggestion-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.suggestion-actions button {
  padding: 8px 10px;
  font-size: 13px;
}

.dice-actions-sticky {
  position: sticky;
  top: 118px;
  z-index: 6;
  background: linear-gradient(
    180deg,
    rgba(243, 244, 246, 0.96) 0%,
    rgba(243, 244, 246, 0.88) 100%
  );
  backdrop-filter: blur(8px);
  padding: 10px 0 8px;
  margin-top: 10px;
}
.dice-actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.dice-actions-row button {
  width: 100%;
}
@media (max-width: 860px) {
  .dice-actions-sticky {
    top: 92px;
  }
  .dice-actions-row {
    grid-template-columns: 1fr;
  }
}

.dice-actions-sticky {
  position: sticky;
  top: 110px;
  z-index: 7;
  background: linear-gradient(
    180deg,
    rgba(243, 244, 246, 0.98) 0%,
    rgba(243, 244, 246, 0.92) 100%
  );
  backdrop-filter: blur(10px);
  padding: 8px 0 10px;
  margin: 10px 0 12px;
}
.remote-roll-hint {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #b91c1c;
  font-weight: 700;
}
.remote-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #ef4444;
  animation: remotePulse 0.9s ease-in-out infinite;
}
@keyframes remotePulse {
  0% {
    transform: scale(0.85);
    opacity: 0.7;
  }
  50% {
    transform: scale(1.15);
    opacity: 1;
  }
  100% {
    transform: scale(0.85);
    opacity: 0.7;
  }
}

.dice-actions-sticky {
  position: sticky;
  top: 110px;
  z-index: 7;
  background: linear-gradient(
    180deg,
    rgba(243, 244, 246, 0.98) 0%,
    rgba(243, 244, 246, 0.92) 100%
  );
  backdrop-filter: blur(10px);
  padding: 8px 0 10px;
  margin: 10px 0 12px;
}
.dice-actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.dice-actions-row button {
  width: 100%;
}
@media (max-width: 860px) {
  .dice-actions-sticky {
    top: 92px;
  }
  .dice-actions-row {
    grid-template-columns: 1fr;
  }
}

#diceSummaryText {
  font-size: 1rem;
  font-weight: 800;
}
.zero-suggestion {
  opacity: 0.9;
}

.suggestion-card.bonus-highlight {
  border: 2px solid #0ea5e9;
  background: linear-gradient(180deg, #ecfeff 0%, #f0f9ff 100%);
}
.suggestion-card.best.bonus-highlight {
  box-shadow: 0 10px 24px rgba(14, 165, 233, 0.16);
}
.dice-stat-row {
  display: grid;
  grid-template-columns: 1.2fr 0.9fr 0.9fr;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.dice-stat-row:last-child {
  border-bottom: none;
}
.dice-stat-name {
  font-weight: 800;
}
.dice-stat-number {
  font-weight: 800;
  text-align: right;
}
.die-card {
  transform-style: preserve-3d;
}
.die-card.rolling {
  animation: dieRollReal 560ms cubic-bezier(0.22, 0.61, 0.36, 1);
}
@keyframes dieRollReal {
  0% {
    transform: rotateX(0deg) rotateY(0deg) scale(1);
  }
  20% {
    transform: rotateX(180deg) rotateY(90deg) scale(1.02);
  }
  40% {
    transform: rotateX(360deg) rotateY(180deg) scale(0.98);
  }
  60% {
    transform: rotateX(540deg) rotateY(270deg) scale(1.03);
  }
  80% {
    transform: rotateX(720deg) rotateY(360deg) scale(0.99);
  }
  100% {
    transform: rotateX(900deg) rotateY(450deg) scale(1);
  }
}
@media (max-width: 860px) {
  .dice-stat-row {
    grid-template-columns: 1fr 0.8fr 0.8fr;
    font-size: 14px;
  }
}

/* Overview Table */
.overview-table-container {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  max-height: 50vh;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
}
.overview-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.overview-table th, .overview-table td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 8px 10px;
  text-align: center;
  background: var(--card);
  white-space: nowrap;
}
.overview-table th:last-child, .overview-table td:last-child {
  border-right: none;
}
.overview-table tbody tr:last-child th, .overview-table tbody tr:last-child td {
  border-bottom: none;
}
.overview-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f9fafb;
  font-weight: 700;
  box-shadow: inset 0 -1px 0 var(--line);
}
.overview-table thead th:not(:first-child) {
  max-width: 75px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.overview-table tbody th {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #f9fafb;
  text-align: left;
  font-weight: 600;
  box-shadow: inset -1px 0 0 var(--line);
}
.overview-table thead th:first-child {
  position: sticky;
  left: 0;
  z-index: 3;
  background: #f9fafb;
  box-shadow: inset -1px -1px 0 var(--line);
}
.overview-table tr.computed-row td, .overview-table tr.computed-row th {
  background: #f3f4f6 !important;
  font-weight: 700;
}
.overview-table thead th.active-turn {
  background: #fff7f7 !important;
  color: var(--danger);
  border-bottom: 2px solid var(--danger);
}
.overview-table tbody td.active-turn {
  background: #fff7f7 !important;
}

.bottom-sheet-dialog {
  padding: 0;
  border: none;
  background: transparent;
  width: min(720px, 100%);
  max-width: 100%;
  align-self: end;
}
.bottom-sheet-dialog::backdrop {
  background: rgba(17, 24, 39, 0.38);
}
.bottom-sheet {
  background: #fff;
  border-radius: 24px 24px 0 0;
  padding: 14px 16px calc(env(safe-area-inset-bottom) + 18px);
  max-height: 72vh;
  overflow: auto;
  box-shadow: 0 -10px 30px rgba(15, 23, 42, 0.18);
}
.bottom-sheet-handle {
  width: 56px;
  height: 6px;
  border-radius: 999px;
  background: #d1d5db;
  margin: 0 auto 12px;
}

.dice-board-sheet {
  margin-top: 0;
}
.dice-sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
#diceSheetSummaryText {
  font-size: 1rem;
  font-weight: 800;
}
.optional-suggestion {
  border-style: dashed;
}
@media (max-width: 860px) {
  .dice-sheet-actions {
    grid-template-columns: 1fr;
  }
}

.compact-start-card {
  padding-bottom: 16px;
}
.start-identity-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: end;
}
.start-profile-create {
  display: flex;
  align-items: end;
  height: 100%;
}
.start-profile-create button {
  width: 100%;
}
@media (max-width: 860px) {
  .start-identity-grid {
    grid-template-columns: 1fr;
  }
}

.die-card.held.rolling {
  animation: none !important;
}


.chat-list {
  display: grid;
  gap: 10px;
  max-height: 42vh;
  overflow: auto;
  margin-top: 6px;
}
.chat-message {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  background: #fff;
}
.chat-message.me {
  border-color: #bfdbfe;
  background: #eff6ff;
}
.chat-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 4px;
}
.chat-author {
  font-weight: 800;
}
.chat-text {
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-compose {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 12px;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 999px;
  background: #e5e7eb;
}
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
}

.start-hero {
  display: none;
  text-align: center;
  padding: 10px 20px 8px;
}
.start-hero h1 {
  font-size: 18px;
  margin-bottom: 2px;
}
.start-hero p {
  font-size: 13px;
  color: #6b7280;
  margin: 0;
}

.winner-name {
  font-size: 1.4rem;
  font-weight: 900;
  margin: 6px 0;
}
.winner-score {
  font-size: 1.1rem;
  font-weight: 800;
  color: #2563eb;
}

#scanResultText {
  font-size: 1.1rem;
  font-weight: 800;
}

#liveDiceStatus strong,
#liveDiceResult strong {
  font-size: 1.05rem;
}
.live-ok {
  color: #047857;
  font-weight: 800;
}
.live-warn {
  color: #b45309;
  font-weight: 800;
}
.live-bad {
  color: #b91c1c;
  font-weight: 800;
}

#liveMainStatus strong,
#liveMainResult strong {
  font-size: 1.05rem;
}

.lobby-person-row,
.invite-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #e5e7eb;
}
.lobby-person-row:last-child,
.invite-row:last-child {
  border-bottom: none;
}
.lobby-person-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.online-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #16a34a;
  margin-right: 8px;
}
.status-busy {
  color: #b45309;
  font-weight: 700;
}
.status-free {
  color: #166534;
  font-weight: 700;
}

.die-card {
  position: relative;
  border: 1px solid #cbd5e1;
  border-radius: 22px;
  background: radial-gradient(
    circle at 30% 25%,
    rgba(255, 255, 255, 0.95),
    rgba(255, 255, 255, 0.75) 35%,
    rgba(226, 232, 240, 0.95) 100%
  );
  min-height: 94px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  cursor: pointer;
  box-shadow:
    0 12px 24px rgba(15, 23, 42, 0.1),
    inset 0 2px 0 rgba(255, 255, 255, 0.95),
    inset 0 -8px 14px rgba(148, 163, 184, 0.22);
  transform: translateY(0);
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    border-color 120ms ease,
    background 120ms ease;
}
.die-card::before {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 16px;
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.55),
    rgba(255, 255, 255, 0.02)
  );
  pointer-events: none;
}
.die-card .die-face {
  position: relative;
  z-index: 1;
  font-size: 2.35rem;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.7));
}
.die-card:hover:not(.disabled) {
  transform: translateY(-2px);
  box-shadow:
    0 16px 28px rgba(15, 23, 42, 0.13),
    inset 0 2px 0 rgba(255, 255, 255, 0.98),
    inset 0 -8px 14px rgba(148, 163, 184, 0.2);
}
.die-card.held {
  border: 2px solid #2563eb;
  background: radial-gradient(
    circle at 30% 25%,
    rgba(239, 246, 255, 0.98),
    rgba(219, 235, 254, 0.9) 40%,
    rgba(191, 219, 254, 0.95) 100%
  );
  box-shadow:
    0 14px 26px rgba(37, 99, 235, 0.18),
    inset 0 2px 0 rgba(255, 255, 255, 0.98),
    inset 0 -10px 16px rgba(96, 165, 250, 0.26);
}
.die-card.held .die-face {
  transform: scale(1.03);
}

.dice-board-3d .die-card {
  position: relative;
  overflow: visible;
  border: none;
  border-radius: 22px;
  background: transparent;
  min-height: 96px;
  box-shadow: none;
  padding: 0;
}
.dice-board-3d .die-card::before,
.dice-board-3d .die-card::after {
  display: none;
}
.die-svg {
  width: 82px;
  height: 82px;
  filter: drop-shadow(0 10px 12px rgba(15, 23, 42, 0.14));
  transform: perspective(220px) rotateX(18deg) rotateY(-18deg) translateY(0);
  transition:
    transform 160ms ease,
    filter 160ms ease;
}
.die-svg .die-svg-face {
  stroke: rgba(148, 163, 184, 0.7);
  stroke-width: 1.5;
}
.die-svg circle {
  fill: #111827;
}
.dice-board-3d .die-card:hover:not(.disabled) .die-svg {
  transform: perspective(220px) rotateX(18deg) rotateY(-18deg) translateY(-3px)
    scale(1.02);
}
.die-card.held .die-svg {
  transform: perspective(220px) rotateX(18deg) rotateY(-18deg) translateY(-2px)
    scale(1.03);
  filter: drop-shadow(0 12px 16px rgba(37, 99, 235, 0.24));
}
.die-card.held .die-svg .die-svg-face {
  stroke: rgba(37, 99, 235, 0.9);
  stroke-width: 2.2;
}
.dice-board-3d .die-card.rolling .die-svg {
  animation: dieRoll3d 520ms ease-in-out;
}
@keyframes dieRoll3d {
  0% {
    transform: perspective(220px) rotateX(18deg) rotateY(-18deg) rotateZ(0deg)
      scale(1);
  }
  20% {
    transform: perspective(220px) rotateX(22deg) rotateY(-28deg) rotateZ(-10deg)
      translateY(-3px) scale(1.04);
  }
  40% {
    transform: perspective(220px) rotateX(14deg) rotateY(24deg) rotateZ(8deg)
      translateY(2px) scale(0.98);
  }
  60% {
    transform: perspective(220px) rotateX(26deg) rotateY(-12deg) rotateZ(-6deg)
      translateY(-2px) scale(1.03);
  }
  80% {
    transform: perspective(220px) rotateX(16deg) rotateY(10deg) rotateZ(6deg)
      translateY(1px) scale(1.01);
  }
  100% {
    transform: perspective(220px) rotateX(18deg) rotateY(-18deg) rotateZ(0deg)
      scale(1);
  }
}
.dice-cup-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px 0 12px;
}
.dice-cup-overlay.hidden {
  display: none;
}
.dice-cup {
  width: 70px;
  height: 70px;
  border-radius: 18px 18px 28px 28px;
  background: linear-gradient(180deg, #475569, #1e293b);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  box-shadow:
    0 12px 20px rgba(15, 23, 42, 0.18),
    inset 0 2px 0 rgba(255, 255, 255, 0.15);
  transform-origin: 50% 80%;
}
.dice-cup-overlay.cup-animate .dice-cup {
  animation: cupShake 520ms ease-in-out;
}
@keyframes cupShake {
  0% {
    transform: rotate(0deg) translateY(0);
  }
  20% {
    transform: rotate(-12deg) translateY(-2px);
  }
  40% {
    transform: rotate(10deg) translateY(1px);
  }
  60% {
    transform: rotate(-9deg) translateY(-2px);
  }
  80% {
    transform: rotate(8deg) translateY(1px);
  }
  100% {
    transform: rotate(0deg) translateY(0);
  }
}

/* deeper 3D feel */
.die-svg-face {
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.6));
}

.die-pip {
  fill: #0f172a;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.25));
}

/* subtle inset illusion */
.die-svg circle {
  transform: translateY(0.5px);
}

/* stronger material look */
.die-svg {
  background: radial-gradient(
    circle at 30% 20%,
    rgba(255, 255, 255, 0.9),
    rgba(226, 232, 240, 0.95)
  );
  border-radius: 18px;
}

/* cup improvement */
.dice-cup {
  background: linear-gradient(180deg, #334155, #0f172a);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  border-bottom-left-radius: 30px;
  border-bottom-right-radius: 30px;
  box-shadow:
    0 14px 24px rgba(0, 0, 0, 0.25),
    inset 0 2px 0 rgba(255, 255, 255, 0.1),
    inset 0 -6px 10px rgba(0, 0, 0, 0.4);
}

/* cup tilt animation more realistic */
@keyframes cupShake {
  0% {
    transform: rotate(0deg) translateY(0);
  }
  20% {
    transform: rotate(-18deg) translateY(-3px);
  }
  40% {
    transform: rotate(14deg) translateY(2px);
  }
  60% {
    transform: rotate(-12deg) translateY(-2px);
  }
  80% {
    transform: rotate(10deg) translateY(2px);
  }
  100% {
    transform: rotate(0deg) translateY(0);
  }
}

.dice-board-3d .die-card {
  transition: transform 0.2s ease;
}


.dice-throw-scene {
  position: relative;
  height: 132px;
  margin: 0 0 8px;
  overflow: hidden;
}
.dice-throw-scene.hidden {
  display: none;
}
.dice-cup-overlay {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
}
.dice-cup {
  width: 82px;
  height: 90px;
  border-radius: 18px 18px 30px 30px;
  background: linear-gradient(180deg, #475569 0%, #1e293b 55%, #0f172a 100%);
  box-shadow:
    0 14px 24px rgba(15, 23, 42, 0.22),
    inset 0 3px 0 rgba(255, 255, 255, 0.14),
    inset 0 -10px 12px rgba(0, 0, 0, 0.35);
  position: relative;
}
.dice-cup::before {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  top: 8px;
  height: 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.14);
}
.dice-cup::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  top: 14px;
  height: 26px;
  border-radius: 10px 10px 16px 16px;
  background: linear-gradient(
    180deg,
    rgba(15, 23, 42, 0.9),
    rgba(30, 41, 59, 0.5)
  );
}
.falling-dice-row {
  position: absolute;
  inset: 8px 0 0;
  z-index: 2;
}
.falling-die {
  position: absolute;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(145deg, #fff, #e2e8f0);
  box-shadow: 0 8px 12px rgba(15, 23, 42, 0.16);
  opacity: 0;
}
.falling-die::before {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 30%, #111827 0 2px, transparent 2.5px),
    radial-gradient(circle at 70% 70%, #111827 0 2px, transparent 2.5px),
    radial-gradient(circle at 30% 70%, #111827 0 2px, transparent 2.5px),
    radial-gradient(circle at 70% 30%, #111827 0 2px, transparent 2.5px);
}
.fd1 {
  left: calc(50% - 60px);
}
.fd2 {
  left: calc(50% - 35px);
}
.fd3 {
  left: calc(50% - 10px);
}
.fd4 {
  left: calc(50% + 15px);
}
.fd5 {
  left: calc(50% + 40px);
}
.fd6 {
  left: calc(50% + 65px);
}
.throw-animate .dice-cup {
  animation: cupPour 760ms ease-in-out;
}
.throw-animate .fd1 {
  animation: dieDrop1 760ms ease-in-out;
}
.throw-animate .fd2 {
  animation: dieDrop2 760ms ease-in-out;
}
.throw-animate .fd3 {
  animation: dieDrop3 760ms ease-in-out;
}
.throw-animate .fd4 {
  animation: dieDrop4 760ms ease-in-out;
}
.throw-animate .fd5 {
  animation: dieDrop5 760ms ease-in-out;
}
.throw-animate .fd6 {
  animation: dieDrop6 760ms ease-in-out;
}
@keyframes cupPour {
  0% {
    transform: translateX(0) rotate(0deg);
  }
  20% {
    transform: translateX(-6px) rotate(-10deg);
  }
  45% {
    transform: translateX(2px) rotate(22deg);
  }
  70% {
    transform: translateX(0) rotate(10deg);
  }
  100% {
    transform: translateX(0) rotate(0deg);
  }
}
@keyframes dieDrop1 {
  0% {
    top: 12px;
    transform: rotate(0deg);
    opacity: 0;
  }
  18% {
    opacity: 1;
  }
  58% {
    top: 72px;
    transform: rotate(110deg);
    opacity: 1;
  }
  76% {
    top: 58px;
    transform: rotate(150deg);
    opacity: 1;
  }
  100% {
    top: 70px;
    transform: rotate(180deg);
    opacity: 0;
  }
}
@keyframes dieDrop2 {
  0% {
    top: 10px;
    transform: rotate(0deg);
    opacity: 0;
  }
  18% {
    opacity: 1;
  }
  58% {
    top: 74px;
    transform: rotate(100deg);
    opacity: 1;
  }
  78% {
    top: 60px;
    transform: rotate(140deg);
    opacity: 1;
  }
  100% {
    top: 72px;
    transform: rotate(170deg);
    opacity: 0;
  }
}
@keyframes dieDrop3 {
  0% {
    top: 8px;
    transform: rotate(0deg);
    opacity: 0;
  }
  18% {
    opacity: 1;
  }
  58% {
    top: 76px;
    transform: rotate(120deg);
    opacity: 1;
  }
  74% {
    top: 62px;
    transform: rotate(170deg);
    opacity: 1;
  }
  100% {
    top: 74px;
    transform: rotate(200deg);
    opacity: 0;
  }
}
@keyframes dieDrop4 {
  0% {
    top: 11px;
    transform: rotate(0deg);
    opacity: 0;
  }
  18% {
    opacity: 1;
  }
  58% {
    top: 73px;
    transform: rotate(-120deg);
    opacity: 1;
  }
  77% {
    top: 61px;
    transform: rotate(-160deg);
    opacity: 1;
  }
  100% {
    top: 72px;
    transform: rotate(-190deg);
    opacity: 0;
  }
}
@keyframes dieDrop5 {
  0% {
    top: 10px;
    transform: rotate(0deg);
    opacity: 0;
  }
  18% {
    opacity: 1;
  }
  58% {
    top: 74px;
    transform: rotate(-100deg);
    opacity: 1;
  }
  77% {
    top: 60px;
    transform: rotate(-140deg);
    opacity: 1;
  }
  100% {
    top: 72px;
    transform: rotate(-170deg);
    opacity: 0;
  }
}
@keyframes dieDrop6 {
  0% {
    top: 12px;
    transform: rotate(0deg);
    opacity: 0;
  }
  18% {
    opacity: 1;
  }
  58% {
    top: 72px;
    transform: rotate(-110deg);
    opacity: 1;
  }
  76% {
    top: 58px;
    transform: rotate(-150deg);
    opacity: 1;
  }
  100% {
    top: 70px;
    transform: rotate(-180deg);
    opacity: 0;
  }
}
.dice-board-3d .die-svg {
  width: 88px;
  height: 88px;
  filter: drop-shadow(0 12px 14px rgba(15, 23, 42, 0.14));
  transform: perspective(260px) rotateX(20deg) rotateY(-20deg) translateY(0);
}
.die-top {
  fill: url(#dieTopGrad);
  stroke: rgba(100, 116, 139, 0.75);
  stroke-width: 1.4;
}
.die-right {
  fill: url(#dieSideGrad);
  stroke: rgba(71, 85, 105, 0.7);
  stroke-width: 1.2;
}
.die-bottom {
  fill: rgba(148, 163, 184, 0.55);
  stroke: rgba(100, 116, 139, 0.65);
  stroke-width: 1.2;
}
.die-pip {
  fill: #111827;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.22));
}
.dice-board-3d .die-card.rolling .die-svg {
  animation: dieRoll3d 620ms ease-in-out;
}
@keyframes dieRoll3d {
  0% {
    transform: perspective(260px) rotateX(20deg) rotateY(-20deg) rotateZ(0deg)
      scale(1);
  }
  22% {
    transform: perspective(260px) rotateX(28deg) rotateY(-36deg) rotateZ(-10deg)
      translateY(-4px) scale(1.05);
  }
  44% {
    transform: perspective(260px) rotateX(10deg) rotateY(26deg) rotateZ(8deg)
      translateY(4px) scale(0.98);
  }
  66% {
    transform: perspective(260px) rotateX(30deg) rotateY(-10deg) rotateZ(-8deg)
      translateY(-2px) scale(1.03);
  }
  100% {
    transform: perspective(260px) rotateX(20deg) rotateY(-20deg) rotateZ(0deg)
      scale(1);
  }
}

.die-svg-soft {
  width: 88px;
  height: 88px;
  filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.15));
  transform: perspective(300px) rotateX(18deg) rotateY(-18deg);
}

.die-body-soft {
  stroke: rgba(0, 0, 0, 0.05);
  stroke-width: 1.2;
}

.die-pip-soft {
  fill: #111;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.25));
}

.die-svg-soft,
.die-svg-soft * {
  pointer-events: none;
}

.dice-board-3d .die-card {
  padding: 6px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.die-card.held {
  background: radial-gradient(
    circle at 30% 25%,
    rgba(219, 235, 254, 0.9),
    rgba(191, 219, 254, 0.55)
  );
  box-shadow:
    0 0 0 2px rgba(37, 99, 235, 0.35),
    0 12px 22px rgba(37, 99, 235, 0.18),
    inset 0 0 0 1px rgba(255, 255, 255, 0.7);
}

.dice-board-3d .die-card.held::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 26px;
  box-shadow:
    0 0 0 3px rgba(59, 130, 246, 0.28),
    0 0 18px rgba(59, 130, 246, 0.22);
  pointer-events: none;
}

.die-card.held .die-svg-soft {
  filter: drop-shadow(0 12px 16px rgba(37, 99, 235, 0.25));
  transform: perspective(300px) rotateX(18deg) rotateY(-18deg) translateY(-1px)
    scale(1.03);
}

.dice-board-3d .die-card.tap-pop {
  transform: scale(0.97);
}

#diceThrowScene,
.dice-cup-overlay,
.dice-cup,
.falling-dice-row,
.falling-die {
  display: none !important;
}

.menu-version,
.menu-build {
  text-align: center;
  color: #6b7280;
  font-size: 0.95rem;
  margin-top: 8px;
}

.compact-block-card {
  border: 1px solid #e5e7eb;
  border-radius: 20px;
  padding: 14px;
  background: #fff;
}

.mobile-score-list {
  margin-top: 10px;
}

.mobile-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid #eef2f7;
}

.mobile-row:last-child {
  border-bottom: none;
}

.mobile-label {
  color: #111827;
  font-weight: 600;
  line-height: 1.2;
}

.mobile-value {
  color: #111827;
  font-weight: 800;
  min-width: 48px;
  text-align: right;
}

#diceBlockPopupDialog .bottom-sheet {
  max-height: 78vh;
  overflow: auto;
}

#diceBlockPopupDialog .section-head {
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 2;
  padding-bottom: 8px;
}

#menuDialog .menu-version,
#menuDialog .menu-build,
#menuModal .menu-version,
#menuModal .menu-build {
  display: block;
}

.action-tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}
.action-tile {
  border: 1px solid #e5e7eb;
  background: #fff;
  border-radius: 16px;
  min-height: 54px;
  padding: 8px 10px;
  font-weight: 700;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.06);
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease,
    background 0.12s ease,
    border-color 0.12s ease;
}
.action-tile:active {
  transform: scale(0.98);
}
.action-tile.primary {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}
.action-tile.active {
  background: #dbeafe;
  border-color: #60a5fa;
  color: #1d4ed8;
}
.compact-roll-summary {
  border-radius: 16px;
}
#diceBoard.tap-roll-enabled {
  cursor: pointer;
}
#diceBoard.tap-roll-enabled::after {
  content: "Tippen zum Würfeln";
  display: block;
  text-align: center;
  color: #6b7280;
  font-size: 0.9rem;
  margin-top: 8px;
}
.sheet-top-actions {
  justify-content: flex-start;
}
@media (max-width: 860px) {
  .action-tiles {
    grid-template-columns: repeat(3, 1fr);
  }
}

#diceThrowScene,
.dice-cup-overlay,
.falling-dice-row {
  display: none !important;
}

.action-tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 8px;
}
.action-tile {
  min-height: 56px;
  border-radius: 18px;
  border: 1px solid #e5e7eb;
  background: #fff;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
  font-weight: 700;
  font-size: 1rem;
  padding: 10px 8px;
}
.action-tile.primary {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}
.action-tile:disabled {
  opacity: 0.5;
}
.action-links-row {
  display: flex;
  gap: 14px;
  justify-content: center;
  margin: 4px 0 2px;
}
.action-link-btn {
  background: transparent;
  border: none;
  color: #475569;
  font-weight: 700;
  padding: 6px 8px;
  border-radius: 12px;
}
.action-link-btn.active {
  color: #2563eb;
  background: #dbeafe;
}
#diceBoard.tap-roll-enabled::after {
  display: none !important;
}
#diceRollSummary {
  margin-top: 6px !important;
}
@media (max-width: 860px) {
  .action-tiles {
    grid-template-columns: repeat(2, 1fr);
  }
  .action-link-btn {
    font-size: 0.95rem;
  }
}

#diceThrowScene,
.diceThrowScene,
.falling-dice-row,
.falling-die,
.dice-cup-overlay,
.dice-cup {
  display: none !important;
}
.action-tile,
.action-link-btn {
  color: #111827;
}
.action-tile:disabled,
.action-link-btn:disabled {
  opacity: 0.55;
  color: #94a3b8;
}
.dice-sheet-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.dice-sheet-actions button {
  min-height: 52px;
  border-radius: 16px;
}
@media (min-width: 700px) {
  .dice-sheet-actions {
    grid-template-columns: repeat(3, 1fr);
  }
}

#gameFinishedDialog .bottom-sheet {
  max-height: 78vh;
  overflow: auto;
}
#gameFinishedContent .mobile-row:first-child .mobile-label,
#gameFinishedContent .mobile-row:first-child .mobile-value {
  font-weight: 800;
}

.disabled-card,
.score-btn:disabled,
input[readonly] {
  opacity: 0.6;
}
input[readonly] {
  cursor: not-allowed;
}

#gameFinishedDialog .button-row,
#finishListChooserDialog .button-row {
  flex-wrap: wrap;
}
#finishListChooserDialog .dialog-form {
  max-height: 78vh;
  overflow: auto;
}

#playerOrderDialog .dialog-form {
  max-height: 78vh;
  overflow: auto;
}
#playerOrderDialog select {
  border-radius: 10px;
  padding: 6px 10px;
}

.badge.success {
  background: #dcfce7;
  color: #166534;
}

@media (max-width: 760px) {
  .leaderboard-lines,
  #leaderTicker {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
  }
  .leader-line {
    width: 100%;
    min-width: 0;
  }
  .leader-line-left {
    min-width: 0;
  }
  .leader-name,
  .leader-meta {
    white-space: normal;
  }
}
.waiting-room-card {
  border: 2px dashed #bfdbfe;
  background: linear-gradient(180deg, #f8fbff, #eef6ff);
}
.waiting-room-code {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.8);
}
.waiting-room-code span {
  font-weight: 800;
  letter-spacing: 0.06em;
}
button.small {
  padding: 6px 10px;
  min-height: auto;
  border-radius: 10px;
  font-size: 0.95rem;
}

.remote-move-toast {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  z-index: 9999;
  max-width: min(92vw, 520px);
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(24, 24, 27, 0.9);
  color: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
  text-align: center;
  font-weight: 700;
}
.remote-move-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.remote-move-toast.hidden {
  display: block;
  opacity: 0;
}

.lobby-person-row.selected-row {
  outline: 2px solid rgba(59, 130, 246, 0.25);
  background: rgba(59, 130, 246, 0.06);
}
.lobby-select-btn.is-selected {
  font-weight: 700;
}
.invite-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
}
.invite-status-pill {
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}
.invite-status-pill.status-accepted {
  background: #dcfce7;
  color: #166534;
}
.invite-status-pill.status-pending {
  background: #fef3c7;
  color: #92400e;
}
.invite-status-pill.status-declined {
  background: #fee2e2;
  color: #991b1b;
}
.invite-status-pill.status-expired {
  background: #e5e7eb;
  color: #374151;
}

#homeLobbySection.hidden {
  display: none;
}

.bot-debug-box {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.35;
  border: 1px solid #d8d8d8;
  background: #f5f5f7;
  color: #1f2937;
}

.bot-debug-box.error {
  background: #fff4f4;
  border-color: #f1b3b3;
  color: #991b1b;
}

.bot-debug-box.success {
  background: #f0fff4;
  border-color: #b7e4c7;
  color: #166534;
}

.finish-debug-box {
  position: fixed;
  top: 84px;
  left: 12px;
  right: 12px;
  z-index: 10001;
  background: rgba(127, 29, 29, 0.97);
  color: #fff;
  border-radius: 16px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.35;
  white-space: pre-wrap;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24);
}

.finish-debug-box.hidden {
  display: none !important;
}

#screenHome.home-login-only #homePostLogin {
  display: none !important;
}
#screenHome.home-logged-in #homePostLogin {
  display: block !important;
}
#screenHome.home-logged-in #homePreLogin {
  display: none !important;
}

.compact-start-card .mode-picker {
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

/* v229 UI polish */
.compact-start-card .mode-card,
#homePostLogin .mode-card,
#screenHome .mode-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: auto;
  padding: 10px 4px;
  gap: 4px;
}

.mode-icon {
  font-size: 28px;
  margin-bottom: 2px;
}

.compact-start-card .mode-picker {
  margin: 16px 0 18px;
  align-items: stretch;
}

.compact-start-card .mode-title {
  font-size: 14px;
  line-height: 1.15;
  text-align: center;
}

.compact-start-card .btn-primary {
  max-width: 320px;
}

.compact-start-card .btn-row,
.compact-start-card .join-actions,
.compact-start-card .join-buttons,
.compact-start-card .home-join-actions {
  display: flex;
  gap: 10px;
  flex-wrap: nowrap;
}

.compact-start-card .btn-row .btn,
.compact-start-card .join-actions .btn,
.compact-start-card .join-buttons .btn,
.compact-start-card .home-join-actions .btn {
  flex: 1 1 0;
}

.compact-start-card .divider,
.compact-start-card .home-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #999;
}

.compact-start-card .divider::before,
.compact-start-card .divider::after,
.compact-start-card .home-divider::before,
.compact-start-card .home-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #ddd;
}

.compact-start-card .mode-card.active,
.compact-start-card .mode-card.is-active {
  transform: scale(1.02);
}

@media (max-width: 860px) {
  .compact-start-card .mode-card,
  #screenHome .mode-card {
    min-height: auto;
  }

  .compact-start-card .mode-title {
    font-size: 14px;
  }
}

.dice-board-3d .die-card.rolling {
  animation: beautifulTumble 440ms cubic-bezier(0.25, 1, 0.5, 1) forwards;
  z-index: 10;
}

@keyframes beautifulTumble {
  0% {
    transform: perspective(400px) rotateX(0deg) rotateY(0deg) scale(1) translateY(0px);
  }
  25% {
    transform: perspective(400px) rotateX(90deg) rotateY(-45deg) scale(1.15) translateY(-15px);
  }
  50% {
    transform: perspective(400px) rotateX(180deg) rotateY(-90deg) scale(1.2) translateY(-25px);
  }
  75% {
    transform: perspective(400px) rotateX(270deg) rotateY(-45deg) scale(1.1) translateY(-10px);
  }
  100% {
    transform: perspective(400px) rotateX(360deg) rotateY(0deg) scale(1) translateY(0px);
  }
}

/* Add slight variations to each die's animation so they don't look perfectly synced, 
   but ensure they all finish at 440ms or very close */
.dice-board-3d .die-card:nth-child(1).rolling { animation-duration: 440ms; }
.dice-board-3d .die-card:nth-child(2).rolling { animation-duration: 430ms; }
.dice-board-3d .die-card:nth-child(3).rolling { animation-duration: 450ms; }
.dice-board-3d .die-card:nth-child(4).rolling { animation-duration: 440ms; }
.dice-board-3d .die-card:nth-child(5).rolling { animation-duration: 430ms; }
.dice-board-3d .die-card:nth-child(6).rolling { animation-duration: 450ms; }

/* Ensure the SVG rotates around its center naturally */
.dice-board-3d .die-card {
  transform-style: preserve-3d;
  transform-origin: center center;
}

/* Beautiful 2D CSS Dice */
.dice-board-3d .die-card {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-height: unset !important;
  padding: 0 !important;
  perspective: none !important;
  transform-style: flat !important;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
  width: 100% !important;
  aspect-ratio: 1/1 !important;
}

.css-die {
  width: 86%;
  height: 86%;
  max-width: 90px;
  max-height: 90px;
  aspect-ratio: 1/1;
  background: linear-gradient(145deg, #ffffff 0%, #f1f5f9 100%);
  border-radius: 20px;
  box-shadow: 
    0 10px 20px rgba(15,23,42,0.1),
    0 2px 6px rgba(15,23,42,0.05),
    inset 0 4px 6px rgba(255,255,255,1),
    inset 0 -4px 8px rgba(148,163,184,0.15);
  border: 1px solid rgba(226,232,240,0.8);
  display: grid;
  padding: 16%;
  grid-template-areas:
    "a . c"
    "d e f"
    "g . i";
  gap: 8%;
  align-items: center;
  justify-items: center;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}

.d-dot {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border-radius: 50%;
  box-shadow: 
    inset 0 2px 4px rgba(0,0,0,0.4), 
    0 2px 3px rgba(255,255,255,0.8);
  aspect-ratio: 1/1;
}

.d-a { grid-area: a; } .d-c { grid-area: c; } .d-d { grid-area: d; }
.d-e { grid-area: e; } .d-f { grid-area: f; } .d-g { grid-area: g; }
.d-i { grid-area: i; }

/* Held State */
.die-card.held .css-die {
  background: linear-gradient(145deg, #eff6ff 0%, #dbeafe 100%);
  box-shadow: 
    0 0 0 4px rgba(59,130,246,0.5),
    0 14px 28px rgba(37,99,235,0.25),
    inset 0 4px 6px rgba(255,255,255,1),
    inset 0 -4px 8px rgba(147,197,253,0.4);
  border-color: transparent;
  transform: translateY(-6px) scale(1.08);
}
.die-card.held .d-dot {
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
  box-shadow: 
    inset 0 2px 4px rgba(0,0,0,0.3), 
    0 2px 3px rgba(255,255,255,0.5);
}

/* Rolling Animation - 3D Cube */
.dice-board-3d .die-card {
  perspective: 1200px !important;
  transform-style: preserve-3d !important;
  overflow: visible !important;
}

.die-cube {
  position: relative;
  width: 86%;
  height: 86%;
  max-width: 90px;
  max-height: 90px;
  aspect-ratio: 1/1;
  transform-style: preserve-3d;
}

.die-card:not(.rolling) .die-cube {
  transform: translateZ(0) rotateX(0deg) rotateY(0deg) rotateZ(0deg) !important;
}

.die-cube .face {
  position: absolute;
  top: 0; left: 0;
  width: 100% !important;
  height: 100% !important;
  backface-visibility: hidden;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
}

.die-cube .front  { transform: rotateY(0deg) translateZ(clamp(15px, 9vw, 40px)); }
.die-cube .back   { transform: rotateY(180deg) translateZ(clamp(15px, 9vw, 40px)); }
.die-cube .right  { transform: rotateY(90deg) translateZ(clamp(15px, 9vw, 40px)); }
.die-cube .left   { transform: rotateY(-90deg) translateZ(clamp(15px, 9vw, 40px)); }
.die-cube .top    { transform: rotateX(90deg) translateZ(clamp(15px, 9vw, 40px)); }
.die-cube .bottom { transform: rotateX(-90deg) translateZ(clamp(15px, 9vw, 40px)); }

.dice-board-3d .die-card.rolling {
  animation: none !important;
  z-index: 10;
}

.dice-board-3d .die-card.rolling .die-cube {
  animation: rollCube3D 0.5s cubic-bezier(0.3, 0.1, 0.4, 0.9) infinite !important;
}

.dice-board-3d .die-card.rolling .die-cube .face {
  box-shadow: 
    inset 0 4px 6px rgba(255,255,255,0.8),
    inset 0 -4px 8px rgba(148,163,184,0.3);
  border-color: rgba(203,213,225,0.8);
}

@keyframes rollCube3D {
  0% { transform: scale(1) rotateX(0deg) rotateY(0deg) rotateZ(0deg) translateY(0); }
  25% { transform: scale(1.1) rotateX(135deg) rotateY(90deg) rotateZ(45deg) translateY(-12px); }
  50% { transform: scale(0.95) rotateX(270deg) rotateY(180deg) rotateZ(90deg) translateY(-4px); }
  75% { transform: scale(1.1) rotateX(405deg) rotateY(270deg) rotateZ(135deg) translateY(-12px); }
  100% { transform: scale(1) rotateX(540deg) rotateY(360deg) rotateZ(180deg) translateY(0); }
}

.dice-board-3d .die-card:nth-child(1).rolling .die-cube { animation-duration: 0.45s !important; animation-delay: 0s !important; }
.dice-board-3d .die-card:nth-child(2).rolling .die-cube { animation-duration: 0.50s !important; animation-delay: 0.02s !important; }
.dice-board-3d .die-card:nth-child(3).rolling .die-cube { animation-duration: 0.47s !important; animation-delay: 0.04s !important; }
.dice-board-3d .die-card:nth-child(4).rolling .die-cube { animation-duration: 0.52s !important; animation-delay: 0.01s !important; }
.dice-board-3d .die-card:nth-child(5).rolling .die-cube { animation-duration: 0.48s !important; animation-delay: 0.05s !important; }
.dice-board-3d .die-card:nth-child(6).rolling .die-cube { animation-duration: 0.51s !important; animation-delay: 0.03s !important; }

/* Remove old die-svg if any */
.die-svg, .die-svg-soft { display: none !important; }

/* Fix overlapping faces when not rolling */
.die-card:not(.rolling) .die-cube .face:not(.front) {
  display: none !important;
}
.die-card:not(.rolling) .die-cube .front {
  transform: none !important;
}
/* Ensure held state transforms the front face properly */
.die-card.held .die-cube .front {
  transform: translateY(-6px) scale(1.08) !important;
}

.compact-start-card h2 {
  font-size: 1.15rem;
  margin-bottom: 8px;
}
.compact-start-card .mode-picker {
  margin: 10px 0 12px;
  gap: 8px;
}
.compact-start-card .mode-card {
  padding: 8px 4px;
}
.compact-start-card .mode-icon {
  font-size: 20px;
}
.compact-start-card button,
.compact-start-card input {
  padding: 8px 12px;
  font-size: 14px;
}
.compact-start-card .button-row button {
  padding: 10px 12px;
}
#btnJoinGame {
  padding: 8px 12px;
  margin-top: 6px;
}

/* Compact adjustments for home page */
.compact-start-card h2 {
  font-size: 1.1rem;
  margin-bottom: 6px !important;
}

.compact-start-card .mode-picker {
  margin: 8px 0 10px !important;
  gap: 8px !important;
}

.compact-start-card .mode-card {
  padding: 8px 4px !important;
  gap: 2px !important;
}

.compact-start-card .mode-icon {
  font-size: 20px !important;
}

.compact-start-card .mode-title {
  font-size: 13px !important;
}

.compact-start-card .button-row button {
  padding: 10px 14px !important;
  font-size: 14px !important;
}

.compact-start-card {
  padding-bottom: 12px !important;
}

#btnJoinGame {
  padding: 8px 12px !important;
  font-size: 14px !important;
  margin-top: 6px !important;
}

#joinCode {
  padding: 8px 10px !important;
  font-size: 14px !important;
}

.start-identity-grid label {
  font-size: 0.85rem !important;
  margin-bottom: 8px !important;
}

.compact-start-card .section-head {
  margin-bottom: 6px !important;
}

.compact-start-card .section-head h2 {
  margin-bottom: 0 !important;
}

.compact-start-card h2 {
  font-size: 1.15rem !important;
  margin-bottom: 6px !important;
}

.compact-start-card .mode-picker {
  margin: 6px 0 10px !important;
  gap: 8px !important;
}

.compact-start-card .mode-card {
  padding: 8px 4px !important;
  gap: 2px !important;
  min-height: 60px !important;
}

.compact-start-card .mode-icon {
  font-size: 20px !important;
}

.compact-start-card .mode-title {
  font-size: 13px !important;
}

.compact-start-card .button-row button {
  padding: 8px 12px !important;
  font-size: 14px !important;
}

.compact-start-card {
  padding: 12px 14px 12px !important;
}

#btnJoinGame {
  padding: 8px 12px !important;
  font-size: 14px !important;
  margin-top: 6px !important;
}

#joinCode {
  padding: 8px 10px !important;
  font-size: 14px !important;
}

.start-identity-grid label {
  font-size: 0.85rem !important;
  margin-bottom: 6px !important;
}

.compact-start-card .section-head {
  margin-bottom: 6px !important;
}

.compact-start-card .section-head h2 {
  margin-bottom: 0 !important;
}

/* Ensure perfect alignment for join code row */
#joinCode, #btnJoinGame {
  height: 38px !important;
  margin-top: 4px !important;
  box-sizing: border-box !important;
}

#btnJoinGame {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

#btnJoinGame {
  padding: 0 12px !important;
}

#joinCode {
  padding: 0 10px !important;
}

.start-identity-grid {
  gap: 8px !important;
}


/* ==============================================================
   V2 DICE MODE & 3D DICE STYLES (Redesigned & Cleaned Up)
   ============================================================== */

/* Layout & Container */
.v2-dice-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #f8fafc;
  border-radius: 24px;
  padding: 16px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

.v2-dice-header {
  background: #ffffff;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.v2-dice-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.v2-dice-header-top h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  color: #0f172a;
}

.v2-dice-status-bar {
  display: flex;
  gap: 12px;
  background: #f1f5f9;
  padding: 10px 14px;
  border-radius: 12px;
}

.v2-status-item {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.v2-status-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  font-weight: 700;
  color: #64748b;
  margin-bottom: 2px;
}

.v2-status-val {
  font-size: 1.05rem;
  font-weight: 800;
  color: #0f172a;
}

/* Play Area */
.v2-dice-play-area {
  position: relative;
  background: linear-gradient(180deg, #ffffff 0%, #f4f4f5 100%);
  border-radius: 20px;
  padding: 24px 16px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.02), 0 4px 6px rgba(0,0,0,0.04);
  border: 1px solid #e2e8f0;
}

/* Würfel nebeneinander anordnen */
.v2-dice-board {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  perspective: 1200px;
  transform-style: preserve-3d;
  flex-wrap: nowrap;
  width: 100%;
  max-width: 100%;
}

.v2-dice-board > .v2-die-card {
  flex: 1 1 0;
  max-width: 16%;
}

@media (min-width: 600px) {
  .v2-dice-board {
    gap: 12px;
  }
}

.v2-roll-summary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.8);
  padding: 10px 16px;
  border-radius: 999px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  font-size: 0.95rem;
  margin-bottom: 12px;
}

.v2-live-indicators {
  display: flex;
  justify-content: center;
  gap: 16px;
}

.v2-live-info {
  font-size: 0.8rem;
  font-weight: 600;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 6px;
}

.v2-live-info::before {
  content: '';
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 4px #22c55e;
}

/* Actions Sticky */
.v2-dice-actions-sticky {
  position: sticky;
  top: 70px;
  z-index: 20;
  background: rgba(248, 250, 252, 0.9);
  backdrop-filter: blur(12px);
  border-radius: 20px;
  padding: 12px;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.08);
  border: 1px solid rgba(255,255,255,0.5);
}

.v2-action-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.v2-action-subgrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.v2-btn-huge {
  font-size: 1.1rem !important;
  padding: 16px !important;
  border-radius: 16px !important;
  font-weight: 800 !important;
  box-shadow: 0 8px 16px rgba(37, 99, 235, 0.2) !important;
}

.v2-btn-primary {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.v2-btn-primary:active {
  transform: scale(0.98);
}

.v2-btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.v2-btn-secondary {
  background: white;
  color: #334155;
  border: 1px solid #cbd5e1;
  padding: 12px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
  cursor: pointer;
  transition: all 0.2s ease;
}

.v2-btn-secondary:active {
  background: #f1f5f9;
  transform: scale(0.98);
}

.v2-action-links {
  display: flex;
  justify-content: space-around;
  padding-top: 10px;
  border-top: 1px solid #e2e8f0;
}

.v2-link-btn {
  background: none;
  border: none;
  color: #64748b;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 8px;
}

.v2-link-btn:hover {
  background: #f1f5f9;
  color: #334155;
}

.v2-link-btn.v2-danger {
  color: #ef4444;
}

.v2-link-btn.v2-danger:hover {
  background: #fef2f2;
}

/* Data Cards */
.v2-dice-data-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.v2-data-card {
  background: white;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.v2-data-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.v2-data-header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
}

.v2-data-content {
  font-size: 0.95rem;
}

.v2-dice-hint {
  text-align: center;
  font-size: 0.85rem;
  color: #94a3b8;
  margin: 10px 0 0;
}


/* ==============================================================
   BEAUTIFUL 3D CSS DICE
   ============================================================== */

.v2-die-card {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  width: 100% !important;
  aspect-ratio: 1/1 !important;
  perspective: 1200px;
  transform-style: preserve-3d;
  transform-style: preserve-3d;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Base Cube */
.v2-die-cube {
  position: relative;
  width: 80%;
  height: 80%;
  max-width: 85px;
  max-height: 85px;
  aspect-ratio: 1/1;
  transform-style: preserve-3d;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Normal State (Not Rolling) */
.v2-die-card:not(.rolling) .v2-die-cube {
  transform: translateZ(0) rotateX(0deg) rotateY(0deg) rotateZ(0deg);
}

/* We hide non-front faces when not rolling to prevent rendering artifacts/z-fighting
   in normal 2D mode, but keep them for 3D rolling */
.v2-die-card:not(.rolling) .v2-face:not(.v2-front) {
  display: none !important;
}
.v2-die-card:not(.rolling) .v2-front {
  transform: translateZ(0) !important; /* Flatten */
}

/* Faces */
.v2-face {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: linear-gradient(145deg, #ffffff 0%, #f1f5f9 100%);
  border-radius: 20px;
  box-shadow:
    inset 0 4px 6px rgba(255,255,255,1),
    inset 0 -4px 8px rgba(148,163,184,0.15),
    0 4px 10px rgba(0,0,0,0.1);
  border: 1px solid rgba(226,232,240,0.8);
  backface-visibility: hidden;
  
  /* Dots Grid */
  display: grid;
  padding: 18%;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  grid-template-areas:
    "tl tc tr"
    "ml cc mr"
    "bl bc br";
  gap: 5%;
}

/* 3D Translations for faces (used during rolling) */
.v2-die-card.rolling .v2-face {
  box-shadow: inset 0 0 10px rgba(0,0,0,0.05); /* Simpler shadow during roll */
}

.v2-die-card.rolling .v2-front  { transform: rotateY(0deg) translateZ(var(--dz, clamp(16px, 6vw, 42px))); }
.v2-die-card.rolling .v2-back   { transform: rotateY(180deg) translateZ(var(--dz, clamp(16px, 6vw, 42px))); }
.v2-die-card.rolling .v2-right  { transform: rotateY(90deg) translateZ(var(--dz, clamp(16px, 6vw, 42px))); }
.v2-die-card.rolling .v2-left   { transform: rotateY(-90deg) translateZ(var(--dz, clamp(16px, 6vw, 42px))); }
.v2-die-card.rolling .v2-top    { transform: rotateX(90deg) translateZ(var(--dz, clamp(16px, 6vw, 42px))); }
.v2-die-card.rolling .v2-bottom { transform: rotateX(-90deg) translateZ(var(--dz, clamp(16px, 6vw, 42px))); }

@media (min-width: 600px) {
  .v2-die-card.rolling {
    --dz: clamp(20px, 6vw, 42px);
  }
}

/* Dots */
.v2-dot {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border-radius: 50%;
  box-shadow:
    inset 0 2px 4px rgba(0,0,0,0.4),
    0 2px 3px rgba(255,255,255,0.8);
  aspect-ratio: 1/1;
  align-self: center;
  justify-self: center;
}

.v2-dot-tl { grid-area: tl; }
.v2-dot-tr { grid-area: tr; }
.v2-dot-ml { grid-area: ml; }
.v2-dot-center { grid-area: cc; }
.v2-dot-mr { grid-area: mr; }
.v2-dot-bl { grid-area: bl; }
.v2-dot-br { grid-area: br; }

/* Held State */
.v2-die-card.held .v2-face {
  background: linear-gradient(145deg, #eff6ff 0%, #dbeafe 100%);
  box-shadow:
    0 0 0 3px rgba(59,130,246,0.6),
    0 10px 20px rgba(37,99,235,0.2),
    inset 0 4px 6px rgba(255,255,255,1),
    inset 0 -4px 8px rgba(147,197,253,0.4);
  border-color: transparent;
}
.v2-die-card.held .v2-die-cube {
  transform: translateY(-8px) scale(1.05);
}
.v2-die-card.held .v2-dot {
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
}

/* Pop Animation on Click */
.v2-die-card.tap-pop .v2-die-cube {
  transform: scale(0.9);
}
.v2-die-card.held.tap-pop .v2-die-cube {
  transform: translateY(-8px) scale(0.95);
}

/* Disabled State */
.v2-die-card.disabled {
  opacity: 0.6;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

/* ==============================================================
   ROLLING ANIMATION
   ============================================================== */

.v2-die-card.rolling {
  z-index: 10;
}

.v2-die-card.rolling {
  animation: rollCubeV2 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) infinite;
}

@keyframes rollCubeV2 {
  0% { transform: scale(1) rotateX(0deg) rotateY(0deg) rotateZ(0deg) translateY(0); }
  25% { transform: scale(1.1) rotateX(135deg) rotateY(90deg) rotateZ(45deg) translateY(-20px); }
  50% { transform: scale(0.95) rotateX(270deg) rotateY(180deg) rotateZ(90deg) translateY(-5px); }
  75% { transform: scale(1.1) rotateX(405deg) rotateY(270deg) rotateZ(135deg) translateY(-15px); }
  100% { transform: scale(1) rotateX(540deg) rotateY(360deg) rotateZ(180deg) translateY(0); }
}

/* Stagger Animations */
.v2-die-card:nth-child(1).rolling { animation-duration: 0.55s; animation-delay: 0s; }
.v2-die-card:nth-child(2).rolling { animation-duration: 0.60s; animation-delay: 0.03s; }
.v2-die-card:nth-child(3).rolling { animation-duration: 0.58s; animation-delay: 0.06s; }
.v2-die-card:nth-child(4).rolling { animation-duration: 0.62s; animation-delay: 0.02s; }
.v2-die-card:nth-child(5).rolling { animation-duration: 0.57s; animation-delay: 0.08s; }
.v2-die-card:nth-child(6).rolling { animation-duration: 0.61s; animation-delay: 0.05s; }


#menuDialog .dialog-form {
  max-height: 85vh;
  overflow-y: auto;
}

/* ==============================================================
   SPARKLE BURST ANIMATION
   ============================================================== */
.die-burst-container {
  position: fixed;
  pointer-events: none;
  z-index: 1000;
  width: 0;
  height: 0;
}
.die-spark {
  position: absolute;
  top: -7px;
  left: -2px;
  width: 4px;
  height: 14px;
  background: white;
  border-radius: 4px;
  transform-origin: center bottom;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.8), 0 0 10px rgba(59, 130, 246, 0.5);
  animation: sparkFly 0.5s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}
@keyframes sparkFly {
  0% {
    transform: rotate(var(--rot)) translateY(-20px) scaleY(1);
    opacity: 1;
  }
  100% {
    transform: rotate(var(--rot)) translateY(-80px) scaleY(0.2);
    opacity: 0;
  }
}





/* cup-v2 Animation */
.cup-v2 {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(1);
  width: 140px;
  height: 180px;
  background: linear-gradient(180deg, #654321 0%, #3e2723 100%);
  border-radius: 10px 10px 30px 30px;
  box-shadow: 
    inset 0 -10px 20px rgba(0,0,0,0.5),
    0 15px 30px rgba(0,0,0,0.4);
  border-top: 10px solid #2d1810;
  z-index: 100;
  display: none;
  transform-origin: bottom center;
}

.cup-v2::after {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; height: 10px;
  background: #1a0f0a;
  border-radius: 5px;
}

.cup-v2.active {
  display: block;
  animation: cupShakeV2 0.6s ease-in-out infinite;
}

.cup-v2.reveal {
  display: block;
  animation: cupRevealV2 0.4s ease-out forwards;
}

@keyframes cupShakeV2 {
  0% { transform: translate(-50%, -50%) rotate(0deg); }
  25% { transform: translate(-45%, -55%) rotate(15deg); }
  50% { transform: translate(-50%, -50%) rotate(0deg); }
  75% { transform: translate(-55%, -45%) rotate(-15deg); }
  100% { transform: translate(-50%, -50%) rotate(0deg); }
}

@keyframes cupRevealV2 {
  0% { transform: translate(-50%, -50%) rotate(0deg); opacity: 1; }
  100% { transform: translate(-50%, -150%) rotate(20deg); opacity: 0; }
}

.v2-dice-play-area {
  position: relative;
  min-height: 120px;
}


/* App-wide iPhone/iPad fast-tap fix (including Kniffel modes, menus and dice).
   Safari must treat consecutive touches as app input instead of double-tap zoom.
   'manipulation' still permits vertical/horizontal scrolling and pinch-to-zoom.
   Do NOT disable viewport zoom / accessibility or intercept touch events. */
html,
body {
  touch-action: manipulation;
}
button,
a,
summary,
label,
select,
input,
textarea,
[role="button"],
[role="tab"],
[role="checkbox"],
[role="radio"],
.die-card,
.score-cell,
.card,
.tile,
.clickable {
  touch-action: manipulation;
}


/* Mode-first start screen: one consistent entry for Kniffel, Risiko and Zahlenjagd. */
.home-game-hub .home-game-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.home-game-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  min-height: 120px;
  padding: 12px 9px;
  border-radius: 14px;
  border: 1px solid #54688b;
  background: #233d66;
  color: #f5f8ff;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.home-game-option:hover, .home-game-option:focus-visible {
  outline: 2px solid #a7c7ff;
  outline-offset: 2px;
  text-decoration: none;
  filter: brightness(1.08);
}
.home-game-kniffel { background: linear-gradient(135deg, #233b70, #315ba1); }
.home-game-risiko { background: linear-gradient(135deg, #24446c, #206178); }
.home-game-zahlenjagd { background: linear-gradient(135deg, #1d614f, #2b588d); }
.home-game-emoji { font-size: 29px; line-height: 1.15; }
.home-game-label { font-weight: 800; font-size: 1.04rem; line-height: 1.2; }
.home-game-description { font-size: .76rem; line-height: 1.25; opacity: .92; }
.home-kniffel-header { gap: 10px; align-items: center; }
.home-back-games { flex-shrink: 0; }
#homeKniffelActions .card { margin-top: 8px; }
@media (max-width: 560px) {
  .home-game-hub .home-game-grid { grid-template-columns: 1fr; gap: 9px; margin-top: 11px; }
  .home-game-option {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    grid-template-rows: auto auto;
    justify-items: start;
    text-align: left;
    column-gap: 9px;
    row-gap: 2px;
    min-height: 74px;
    padding: 12px;
  }
  .home-game-emoji { grid-row: 1 / 3; grid-column: 1; align-self: center; }
  .home-game-label { grid-row: 1; grid-column: 2; }
  .home-game-description { grid-row: 2; grid-column: 2; }
  .home-kniffel-header h2 { font-size: 1rem; }
  .home-back-games { font-size: .85rem; padding: 8px 10px; }
}

/* Würfelkaskade: four-column game hub remains responsive on phones. */
.home-game-kaskade { background:linear-gradient(135deg,#5b3f8e,#116478); }
