* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: radial-gradient(ellipse at center, #1d5c3f 0%, #0e3323 70%, #081f15 100%);
  color: #f0ede4;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

header { text-align: center; padding: 12px 16px 4px; }
#exit {
  display: inline-block;
  margin-bottom: 8px;
  color: #f0ede4;
  opacity: 0.75;
  text-decoration: none;
  font-size: 14px;
}
#exit:hover { opacity: 1; text-decoration: underline; }
.center { display: flex; flex-direction: column; align-items: center; gap: 2px; }
#matchscore { font-size: 14px; font-weight: 600; white-space: nowrap; }

#scoreboard {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  padding: 8px 18px;
}
.player { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 8px; }
.player.active { background: rgba(255, 215, 0, 0.15); outline: 1px solid rgba(255, 215, 0, 0.5); }
.pscore { font-size: 20px; font-weight: 700; color: gold; }
#target { opacity: 0.6; font-size: 11px; white-space: nowrap; }

.dot { width: 9px; height: 9px; border-radius: 50%; background: #777; display: inline-block; }
.dot.online { background: #4caf50; box-shadow: 0 0 6px #4caf50; }

main {
  width: 100%;
  max-width: 560px;
  padding: 12px 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

section {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 16px;
  padding: 14px;
  text-align: center;
}
section h2 { font-size: 15px; font-weight: 600; opacity: 0.85; margin-bottom: 10px; }

.dice-row { display: flex; gap: 10px; justify-content: center; min-height: 64px; }

.die {
  width: 58px;
  height: 58px;
  background: linear-gradient(145deg, #ffffff, #e8e4d8);
  border-radius: 12px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 8px;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4), inset 0 -2px 3px rgba(0, 0, 0, 0.15);
  user-select: none;
}
.die .pip {
  width: 10px;
  height: 10px;
  background: #222;
  border-radius: 50%;
  align-self: center;
  justify-self: center;
}
.die-empty { background: rgba(255, 255, 255, 0.08); box-shadow: none; border: 2px dashed rgba(255, 255, 255, 0.2); }
.die.kept {
  outline: 3px solid #2eff6a;
  box-shadow: 0 0 12px rgba(46, 255, 106, 0.8), 0 3px 6px rgba(0, 0, 0, 0.4);
  transform: translateY(-6px);
}
.die.rolling { animation: roll 0.45s ease-out; }

@keyframes roll {
  0% { transform: rotate(-180deg) scale(0.4); opacity: 0.2; }
  60% { transform: rotate(15deg) scale(1.1); }
  100% { transform: rotate(0) scale(1); opacity: 1; }
}

#turnpoints { margin-top: 10px; font-size: 18px; font-weight: 700; color: gold; min-height: 24px; }
#event { margin-top: 4px; font-size: 14px; min-height: 20px; opacity: 0.9; }

#status { text-align: center; font-size: 16px; min-height: 24px; opacity: 0.9; }
#result { text-align: center; font-size: 22px; font-weight: 700; min-height: 28px; }
#result.win { color: #7dff9b; }
#result.lose { color: #ff9b7d; }

#actions { display: flex; gap: 10px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
button {
  font: inherit;
  font-weight: 600;
  padding: 10px 20px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(145deg, #ffc93c, #e6a817);
  color: #2b2000;
  cursor: pointer;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.35);
  transition: transform 0.1s;
}
button:hover:not(:disabled) { transform: translateY(-2px); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
#btn-bank { background: linear-gradient(145deg, #9fd8a8, #6fb87c); color: #0c2a12; }

#hint { margin-top: 10px; font-size: 13px; opacity: 0.8; min-height: 18px; color: #ffd97d; }

#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #b33;
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

@media (max-width: 420px) {
  .die { width: 48px; height: 48px; padding: 6px; }
  .die .pip { width: 8px; height: 8px; }
}