* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: system-ui, Arial, sans-serif;
  background: #ffffff;
  color: #0b1324;
}

.game-wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px;
}

.hero {
  text-align: center;
  margin-bottom: 24px;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(2rem, 5vw, 3.5rem);
  color: #2f6efb;
}

.hero p {
  margin: 0;
  color: #56607a;
}

.score-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.mode-panel {
  margin-bottom: 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
}

.mode-field {
  display: grid;
  gap: 6px;
}

.mode-field span {
  font-size: 0.84rem;
  color: #56607a;
}

.mode-field select {
  border: 1px solid #d6def0;
  border-radius: 10px;
  padding: 8px 10px;
  background: #ffffff;
  color: #0b1324;
}

.run-stats {
  margin-left: auto;
  border: 1px solid #e6e8ee;
  background: #f8fafc;
  border-radius: 999px;
  padding: 9px 14px;
  color: #56607a;
  font-weight: 600;
}

.run-stats strong {
  color: #0b1324;
}

.run-stats__sep {
  margin: 0 8px;
  color: #a1acc2;
}

.daily-seed-badge {
  border: 1px solid #f5c542;
  background: #fff4bf;
  color: #6f5600;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.daily-note {
  margin: -2px 0 18px;
  border: 1px solid #d6def0;
  background: linear-gradient(135deg, #fff8dc 0%, #f8fafc 100%);
  border-radius: 16px;
  padding: 14px 16px;
}

.daily-note__badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid #f5c542;
  background: #fff4bf;
  color: #6f5600;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.daily-note__text {
  margin: 10px 0 0;
  color: #3b4864;
  line-height: 1.45;
}

.online-panel {
  margin: -2px 0 18px;
  border: 1px solid #d6def0;
  background: #f8fafc;
  border-radius: 16px;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.online-panel__row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.online-panel input {
  border: 1px solid #d6def0;
  border-radius: 10px;
  padding: 9px 10px;
  min-width: 130px;
  background: #ffffff;
}

.online-status {
  margin: 0;
  color: #3b4864;
  font-size: 0.92rem;
}

.match-panel {
  margin-bottom: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.opponent-card {
  margin-bottom: 18px;
  border: 1px solid #d6def0;
  background: linear-gradient(135deg, #f8fafc 0%, #edf3ff 100%);
  border-radius: 18px;
  padding: 16px 18px;
}

.opponent-card__header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.opponent-card__eyebrow {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #56607a;
}

.opponent-card__header strong {
  font-size: 1.35rem;
  color: #0b1324;
}

.opponent-card__blurb {
  margin: 0;
  color: #3b4864;
}

.player-stats {
  margin-bottom: 18px;
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
}

.player-stats,
.profile-card {
  display: none !important;
}

.player-stats div {
  border: 1px solid #e6e8ee;
  background: #ffffff;
  border-radius: 16px;
  padding: 14px;
  text-align: center;
}

.player-stats span {
  display: block;
  font-size: 0.82rem;
  color: #56607a;
}

.player-stats strong {
  font-size: 1.45rem;
}

.profile-card {
  margin-bottom: 18px;
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 12px;
}

.profile-card div {
  border: 1px solid #d6def0;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border-radius: 16px;
  padding: 14px;
  text-align: center;
}

.profile-card span {
  display: block;
  font-size: 0.82rem;
  color: #56607a;
}

.profile-card strong {
  font-size: 1.35rem;
}

.match-scoreboard {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
  border: 1px solid #e6e8ee;
  background: #ffffff;
  border-radius: 16px;
  padding: 12px 16px;
  min-width: 280px;
}

.match-scoreboard div {
  text-align: center;
}

.match-scoreboard span {
  display: block;
  color: #56607a;
  font-size: 0.82rem;
}

.match-scoreboard strong {
  font-size: 1.7rem;
}

.match-scoreboard__label {
  color: #2f6efb;
  font-weight: 700;
  white-space: nowrap;
}

.turn-indicator {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #d6def0;
  background: #f8fafc;
  border-radius: 999px;
  padding: 10px 14px;
  color: #56607a;
  font-weight: 700;
}

.turn-indicator.is-bot-turn {
  background: #edf3ff;
  border-color: #2f6efb;
  color: #1e4fbe;
}

.turn-indicator__dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #91a0be;
}

.turn-indicator.is-bot-turn .turn-indicator__dot {
  background: #2f6efb;
  animation: botPulse 0.9s ease-in-out infinite;
}

.score-panel div {
  background: #ffffff;
  border: 1px solid #e6e8ee;
  border-radius: 16px;
  padding: 16px;
  text-align: center;
}

.score-panel span {
  display: block;
  font-size: 0.85rem;
  color: #56607a;
}

.score-panel strong {
  font-size: 1.8rem;
}

.table {
  background: #ffffff;
  border: 1px solid #e6e8ee;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 6px 30px rgba(7, 14, 30, 0.06);
}

.message {
  background: #f8fafc;
  border: 1px solid #e6e8ee;
  border-radius: 14px;
  padding: 14px;
  text-align: center;
  margin-bottom: 20px;
  font-weight: 700;
}

.message.hot-dice-salute {
  border-color: #f5c542;
  background: linear-gradient(120deg, #fff8dc, #f8fafc 60%);
  box-shadow: 0 0 0 4px rgba(245, 197, 66, 0.2);
  animation: hotDicePop 0.95s ease-out;
}

@keyframes hotDicePop {
  0% {
    transform: scale(0.985);
  }
  25% {
    transform: scale(1.01);
  }
  100% {
    transform: scale(1);
  }
}

.dice-area {
  display: grid;
  grid-template-columns: repeat(6, minmax(48px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.die {
  aspect-ratio: 1;
  border-radius: 0;
  border: none;
  background: transparent;
  font-size: 2rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.15s;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.die-svg {
  width: 100%;
  height: 100%;
  max-width: 56px;
  max-height: 56px;
}

.die-shape {
  fill: #ffffff;
  stroke: #c7ceda;
  stroke-width: 2;
}

.die .pip {
  fill: #1f2937;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes diceRoll {
  0% {
    transform: rotateX(0deg) rotateY(0deg);
  }
  100% {
    transform: rotateX(720deg) rotateY(720deg);
  }
}

.die-svg.rolling {
  animation: diceRoll 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.die-svg.slideIn {
  animation: slideIn 0.3s ease-out;
}

.die:hover {
  transform: none;
}

.die.selected .die-shape {
  fill: #edf3ff;
  stroke: #2f6efb;
  stroke-width: 2.5;
}

.die.selected .die-svg {
  filter: drop-shadow(0 2px 8px rgba(47, 110, 251, 0.28));
}

.die.locked {
  opacity: 0.4;
  pointer-events: none;
}

.controls {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

button {
  border: 1px solid #e6e8ee;
  border-radius: 999px;
  padding: 13px 22px;
  font-weight: 800;
  cursor: pointer;
  background: #ffffff;
  color: #0b1324;
}

#rollBtn,
#bankBtn {
  background: #2f6efb;
  border-color: #2f6efb;
  color: #ffffff;
}

#rollBtn:hover,
#bankBtn:hover {
  filter: brightness(0.98);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.secondary {
  background: #ffffff;
}

.rules-box {
  margin-top: 24px;
  background: #ffffff;
  border-radius: 18px;
  padding: 20px;
  border: 1px solid #e6e8ee;
}

.rules-box h2 {
  margin-top: 0;
}

.leaderboard-status {
  margin-top: 0;
  color: #56607a;
}

.leaderboard-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.leaderboard-mode-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.lb-tab {
  border: 1px solid #d6def0;
  background: #ffffff;
  color: #0b1324;
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
  cursor: pointer;
}

.lb-tab.active {
  background: #edf3ff;
  border-color: #2f6efb;
  color: #1e4fbe;
}

.daily-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.daily-controls label {
  font-size: 0.9rem;
  color: #56607a;
}

.daily-controls input {
  border: 1px solid #d6def0;
  border-radius: 10px;
  padding: 8px 10px;
  color: #0b1324;
}

.leaderboard-wrap {
  overflow-x: auto;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
  border: 1px solid #e6e8ee;
  border-radius: 12px;
  overflow: hidden;
}

.leaderboard-table th,
.leaderboard-table td {
  padding: 10px 10px;
  text-align: left;
  border-bottom: 1px solid #eef1f6;
  white-space: nowrap;
}

.leaderboard-table th {
  color: #56607a;
  font-weight: 700;
  font-size: 0.9rem;
  background: #f8fafc;
}

.leaderboard-table tbody tr:last-child td {
  border-bottom: none;
}

.leaderboard-actions {
  margin-top: 12px;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.leaderboard-actions .secondary {
  padding: 8px 14px;
}

.leaderboard-pager {
  display: flex;
  gap: 8px;
  align-items: center;
  color: #56607a;
  font-size: 0.9rem;
}

.leaderboard-pager button {
  padding: 6px 10px;
  border-radius: 10px;
}

.effect-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  overflow: hidden;
}

.effect-layer::before,
.effect-layer::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0;
}

.effect-layer.effect-win::before {
  background: radial-gradient(circle at center, rgba(47, 110, 251, 0.24), transparent 52%);
  animation: flashBurst 0.7s ease-out;
}

.effect-layer.effect-bust::before {
  background: radial-gradient(circle at center, rgba(185, 28, 28, 0.22), transparent 52%);
  animation: flashBurst 0.55s ease-out;
}

.effect-layer.effect-match::before {
  background: radial-gradient(circle at center, rgba(255, 196, 0, 0.24), transparent 54%);
  animation: flashBurst 0.9s ease-out;
}

.effect-layer.effect-match::after {
  background-image:
    radial-gradient(circle, rgba(47, 110, 251, 0.55) 0 4px, transparent 5px),
    radial-gradient(circle, rgba(255, 196, 0, 0.65) 0 4px, transparent 5px),
    radial-gradient(circle, rgba(34, 197, 94, 0.55) 0 4px, transparent 5px);
  background-size:
    140px 140px,
    180px 180px,
    220px 220px;
  background-position:
    10% -10%,
    50% -20%,
    90% -10%;
  animation: confettiFall 0.95s ease-out;
}

@keyframes flashBurst {
  0% {
    opacity: 0;
    transform: scale(0.7);
  }
  18% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: scale(1.08);
  }
}

@keyframes confettiFall {
  0% {
    opacity: 0;
    transform: translateY(-8%);
  }
  15% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(20%);
  }
}

.table.is-bot-turn {
  box-shadow: 0 10px 32px rgba(47, 110, 251, 0.14);
}

@keyframes botPulse {
  0% {
    transform: scale(0.8);
    opacity: 0.65;
  }
  50% {
    transform: scale(1.2);
    opacity: 1;
  }
  100% {
    transform: scale(0.8);
    opacity: 0.65;
  }
}

.name-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
}

.name-modal[hidden] {
  display: none;
}

.name-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11, 19, 36, 0.45);
}

.name-modal__card {
  position: relative;
  width: min(92vw, 420px);
  background: #ffffff;
  border: 1px solid #d6def0;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 12px 34px rgba(7, 14, 30, 0.2);
}

.name-modal__card h3 {
  margin: 0 0 8px;
}

.name-modal__card p {
  margin: 0 0 12px;
  color: #56607a;
}

#playerNameInput {
  width: 100%;
  border: 1px solid #d6def0;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 1rem;
}

.name-modal__actions {
  margin-top: 14px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

@media (max-width: 640px) {
  .game-wrap {
    padding: 16px;
  }

  .hero h1 {
    font-size: 1.8rem;
  }

  .hero p {
    font-size: 0.9rem;
  }

  .score-panel {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    gap: 10px;
  }

  .daily-seed-badge {
    width: 100%;
    text-align: center;
  }

  .online-panel__row {
    flex-direction: column;
  }

  .online-panel input,
  .online-panel button {
    width: 100%;
  }

  .player-stats {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .profile-card {
    grid-template-columns: 1fr;
  }

  .score-panel div {
    padding: 12px;
  }

  .score-panel strong {
    font-size: 1.4rem;
  }

  .table {
    padding: 16px;
  }

  .dice-area {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }

  .die {
    font-size: 1.4rem;
    border-width: 2px;
  }

  .controls {
    gap: 8px;
  }

  button {
    padding: 10px 16px;
    font-size: 0.9rem;
  }

  .rules-box {
    margin-top: 16px;
    padding: 16px;
  }

  .rules-box h2 {
    font-size: 1.2rem;
  }

  .rules-box ul {
    font-size: 0.9rem;
    padding-left: 20px;
  }

  .leaderboard-table th,
  .leaderboard-table td {
    padding: 8px 10px;
    font-size: 0.88rem;
  }

  .mode-panel {
    gap: 10px;
  }

  .match-panel {
    gap: 10px;
  }

  .match-scoreboard {
    width: 100%;
    min-width: 0;
  }

  .run-stats {
    margin-left: 0;
    width: 100%;
    text-align: center;
  }

  .turn-indicator {
    width: 100%;
    justify-content: center;
  }

  .leaderboard-tabs {
    flex-wrap: wrap;
  }

  .leaderboard-actions {
    gap: 8px;
  }
}
