* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #1a1025;
  color: #e0d0f0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
}
#app {
  width: 100%;
  max-width: 500px;
  background: #2a1a3a;
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  border: 1px solid #4a2a6a;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 20px;
}
.header h1 {
  font-size: 24px;
  background: linear-gradient(135deg, #f0c040, #d09030);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 2px;
}
.header .subtitle {
  font-size: 12px;
  color: #8a709a;
  margin-top: 2px;
}

/* Status bar */
.status-bar {
  display: flex;
  justify-content: space-between;
  background: #1a1025;
  padding: 10px 14px;
  border-radius: 12px;
  margin-bottom: 16px;
  font-size: 13px;
}
.status-bar .stat { text-align: center; position: relative; }
.status-bar .stat .label {
  color: #8a709a;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.status-bar .stat .value {
  font-size: 18px;
  font-weight: 700;
  color: #f0d0a0;
}

/* Dice tray */
.dice-tray {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.die {
  width: 60px;
  height: 60px;
  background: #f0e8d8;
  border-radius: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 28px;
  font-weight: 700;
  color: #1a1025;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  border: 3px solid transparent;
  user-select: none;
}
.die.held {
  border-color: #f0c040;
  box-shadow: 0 0 12px rgba(240,192,64,0.4);
  transform: translateY(-4px);
}
.die:hover { transform: translateY(-2px); }
.die.held:hover { transform: translateY(-6px); }

/* Roll button */
.roll-area {
  text-align: center;
  margin-bottom: 16px;
}
.btn {
  background: #4a2a6a;
  color: #e0d0f0;
  border: 1px solid #6a4a8a;
  padding: 10px 28px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 1px;
}
.btn:hover { background: #5a3a7a; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}
.btn-primary {
  background: #f0c040;
  color: #1a1025;
  border-color: #d0a030;
}
.btn-primary:hover { background: #f0d060; }
.btn-danger {
  background: #8a3040;
  border-color: #aa4050;
  color: #f0d0d0;
}
.btn-danger:hover { background: #aa4050; }

/* Category grid */
.category-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 16px;
}
.cat-card {
  background: #1a1025;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.12s;
  border: 2px solid transparent;
  text-align: center;
  font-size: 12px;
}
.cat-card .cat-name { font-weight: 600; color: #c0b0d0; }
.cat-card .cat-score { font-size: 16px; font-weight: 700; color: #f0d0a0; }
.cat-card .cat-level { font-size: 10px; color: #8a709a; }
.cat-card.available:hover {
  border-color: #6a4a8a;
  background: #2a1a40;
}
.cat-card.selected {
  border-color: #f0c040;
  background: #2a2035;
}
.cat-card.used {
  opacity: 0.3;
  cursor: not-allowed;
}
.cat-card.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Score popup */
.score-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #2a1a3a;
  border: 2px solid #f0c040;
  border-radius: 16px;
  padding: 24px 32px;
  text-align: center;
  z-index: 100;
  box-shadow: 0 0 40px rgba(240,192,64,0.3);
  display: none;
}
.score-popup.show { display: block; }
.score-popup .score-value {
  font-size: 48px;
  font-weight: 700;
  color: #f0c040;
}
.score-popup .score-category {
  font-size: 20px;
  color: #c0b0d0;
  margin-bottom: 4px;
}
.score-popup .score-note {
  font-size: 12px;
  color: #8a709a;
  margin-bottom: 16px;
}

/* Game over */
.game-over {
  display: none;
  text-align: center;
  padding: 32px 16px;
}
.game-over.show { display: block; }
.game-over h2 {
  font-size: 28px;
  color: #f0c040;
  margin-bottom: 8px;
}
.game-over p {
  color: #8a709a;
  margin-bottom: 6px;
  font-size: 14px;
}
.game-over .final-score {
  font-size: 36px;
  font-weight: 700;
  color: #f0d0a0;
  margin: 12px 0;
}

/* Roll log */
.roll-log {
  font-size: 11px;
  color: #6a5a7a;
  text-align: center;
  margin-bottom: 12px;
  min-height: 16px;
}
.roll-log .roll-num {
  color: #a090b0;
  font-weight: 600;
}

/* Screen transitions */
.screen { display: none; }
.screen.active { display: block; }

/* Target bar */
.target-bar {
  background: #1a1025;
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}
.target-bar .current-score { color: #f0d0a0; font-weight: 700; }
.target-bar .target-score { color: #8a709a; }
.target-bar .remaining { color: #f0c040; font-weight: 600; }

/* Ante header */
.ante-header {
  text-align: center;
  font-size: 14px;
  color: #8a709a;
  margin-bottom: 6px;
}
.ante-header .ante-num {
  color: #f0c040;
  font-weight: 700;
}

/* Shop */
.shop-screen {
  text-align: center;
  padding: 16px 0;
}
.shop-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding: 0 4px;
}
.shop-header h2 {
  color: #f0c040;
  font-size: 20px;
}
.shop-coins {
  color: #f0c040;
  font-weight: 600;
  font-size: 15px;
  background: #1a1025;
  padding: 4px 12px;
  border-radius: 8px;
}
.shop-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}
.shop-item {
  background: #1a1025;
  border: 2px solid #4a2a6a;
  border-radius: 12px;
  padding: 14px 10px;
  text-align: center;
  transition: all 0.12s;
}
.shop-item:hover { border-color: #6a4a8a; }
.shop-item.sold {
  opacity: 0.35;
  cursor: default;
}
.shop-item .si-emoji { font-size: 28px; margin-bottom: 4px; }
.shop-item .si-name  { font-size: 14px; font-weight: 600; color: #c0b0d0; }
.shop-item .si-desc  { font-size: 11px; color: #8a709a; margin: 2px 0 8px; }
.shop-item .si-cost  {
  font-size: 14px;
  font-weight: 700;
  color: #f0c040;
  margin-bottom: 8px;
}
.shop-item .btn {
  font-size: 13px;
  padding: 6px 16px;
}
.shop-item .btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.shop-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.shop-actions .btn { font-size: 14px; padding: 8px 18px; }
.shop-proceed .btn-primary { font-size: 15px; padding: 8px 24px; }

/* Hold hints */
.hint {
  font-size: 11px;
  color: #6a5a7a;
  text-align: center;
  margin-top: 4px;
  margin-bottom: 8px;
}

/* Die hold-cost badge */
.die {
  position: relative;
}
.die-cost {
  position: absolute;
  bottom: -6px;
  right: -6px;
  background: #8a3040;
  color: #f0d0d0;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 8px;
  border: 1px solid #aa4050;
  line-height: 1.4;
  pointer-events: none;
  z-index: 10;
}

/* Coin deduction flash */
.coin-flash {
  position: absolute;
  right: -4px;
  top: -2px;
  font-size: 13px;
  font-weight: 700;
  color: #f04040;
  opacity: 0;
  transition: none;
  pointer-events: none;
}
.coin-flash-show {
  animation: coinFlashAnim 1s ease-out forwards;
}
@keyframes coinFlashAnim {
  0%   { opacity: 1; transform: translateY(0); }
  60%  { opacity: 1; transform: translateY(-14px); }
  100% { opacity: 0; transform: translateY(-24px); }
}

/* Overlay (round complete) */
.overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  justify-content: center;
  align-items: center;
}
.overlay.show {
  display: flex;
}
.overlay-box {
  background: #2a1a3a;
  border: 2px solid #f0c040;
  border-radius: 16px;
  padding: 28px 32px;
  max-width: 360px;
  width: 90%;
  text-align: center;
}
.overlay-title {
  color: #f0c040;
  font-size: 22px;
  margin-bottom: 12px;
}
.rc-score {
  font-size: 16px;
  color: #c0b0d0;
  margin-bottom: 4px;
}
.rc-hands {
  font-size: 13px;
  color: #8a709a;
  margin-bottom: 16px;
}
.rc-rewards {
  background: #1a1025;
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 18px;
}
.reward-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: #c0b0d0;
  padding: 3px 0;
}
.reward-row .rc-coin {
  color: #f0c040;
  font-weight: 600;
}
.reward-row.total {
  border-top: 1px solid #4a2a6a;
  margin-top: 4px;
  padding-top: 6px;
  font-weight: 700;
  font-size: 16px;
  color: #f0d0a0;
}
.reward-row.total .rc-coin {
  font-size: 18px;
}

/* Loadout overlay */
.lo-box { max-width: 420px; }
.lo-ante { color: #8a709a; font-size: 14px; margin-bottom: 12px; }
.lo-pool-label, .lo-loadout-label {
  color: #c0b0d0;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  margin-bottom: 6px;
}
.lo-pool, .lo-loadout {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-bottom: 12px;
  min-height: 52px;
  background: #1a1025;
  border-radius: 10px;
  padding: 8px;
}
.lo-die {
  width: 46px;
  height: 46px;
  background: #3a2a4a;
  border: 2px solid #4a2a6a;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.1s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  position: relative;
}
.lo-die:hover { border-color: #6a4a8a; background: #4a2a5a; }
.lo-die .lo-die-emoji { font-size: 18px; line-height: 1; }
.lo-die .lo-die-count {
  font-size: 9px;
  color: #8a709a;
  position: absolute;
  top: -4px;
  right: -4px;
  background: #1a1025;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lo-die.selected {
  border-color: #f0c040;
  background: #2a2035;
}
.lo-hint {
  font-size: 11px;
  color: #6a5a7a;
  margin-bottom: 14px;
}
#loConfirm:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}