* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0b0d12;
  color: #e8ecf2;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* Restore text selection inside form fields only. */
input, textarea {
  user-select: text;
  -webkit-user-select: text;
}

/* Casino backdrop — slow drifting colored hot-spots */
body::before {
  content: "";
  position: fixed;
  inset: -10%;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 35%, rgba(255, 224, 122, 0.10) 0%, transparent 55%),
              radial-gradient(ellipse at 18% 80%, rgba(255, 90, 140, 0.08) 0%, transparent 50%),
              radial-gradient(ellipse at 82% 22%, rgba(90, 124, 255, 0.08) 0%, transparent 50%),
              radial-gradient(ellipse at 30% 30%, rgba(120, 220, 200, 0.06) 0%, transparent 45%);
  animation: bg-pulse 12s ease-in-out infinite alternate, bg-drift 30s ease-in-out infinite alternate;
  background-size: 200% 200%;
}
@keyframes bg-pulse {
  0%   { filter: brightness(0.85) saturate(0.95); }
  100% { filter: brightness(1.15) saturate(1.1); }
}
@keyframes bg-drift {
  0%   { background-position: 0% 0%, 0% 0%, 0% 0%, 0% 0%; }
  100% { background-position: 30% 20%, -20% 30%, 25% -25%, -15% -10%; }
}

/* Vignette darkens the corners behind the UI without obscuring the table */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse 70% 70% at center, transparent 0%, transparent 45%, rgba(0,0,0,0.55) 100%);
}

#canvas-root {
  position: fixed;
  inset: 0;
  z-index: 0;
}

#canvas-root canvas { display: block; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: radial-gradient(ellipse at center, rgba(10,14,22,0.85), rgba(0,0,0,0.95));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.overlay.hidden, #game-ui.hidden { display: none !important; }

.panel {
  background: #161a23;
  border: 1px solid #262c3a;
  border-radius: 14px;
  padding: 28px 32px;
  width: min(440px, 100%);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.panel h1 {
  margin: 0 0 4px;
  font-size: 44px;
  letter-spacing: -0.02em;
  background: linear-gradient(180deg, #fff7c2 0%, #ffd400 40%, #ff9b3d 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 2px 30px rgba(255, 200, 60, 0.3);
  font-weight: 800;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 24px;
}

.panel h3 {
  margin: 18px 0 8px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8a93a6;
}

.tag {
  color: #8a93a6;
  margin: 0 0 20px;
  font-size: 14px;
}

label {
  display: block;
  font-size: 13px;
  color: #b8c1d4;
  margin: 12px 0 6px;
}

input[type="text"] {
  width: 100%;
  background: #0e1219;
  color: #e8ecf2;
  border: 1px solid #2a3142;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 15px;
  outline: none;
  margin-top: 4px;
}

input[type="text"]:focus { border-color: #5a7cff; }

button {
  background: #232a3a;
  color: #e8ecf2;
  border: 1px solid #2f3852;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}

button:hover:not(:disabled) { background: #2c3548; }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.4; cursor: not-allowed; }

button.primary {
  background: linear-gradient(180deg, #ffd966 0%, #ff9b3d 100%);
  border-color: #ffe07a;
  color: #20140a;
  font-weight: 700;
  box-shadow: 0 0 14px rgba(255, 200, 60, 0.4);
}
button.primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #fff0a0 0%, #ffaa55 100%);
  box-shadow: 0 0 22px rgba(255, 220, 100, 0.6);
}

.row {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.row button { flex: 1; }

.divider {
  display: flex;
  align-items: center;
  margin: 18px 0 8px;
  color: #4a5366;
  font-size: 12px;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #262c3a;
}
.divider span { padding: 0 12px; }

.status {
  margin-top: 14px;
  font-size: 13px;
  color: #ffb86b;
  min-height: 18px;
}

.code-box {
  display: flex;
  gap: 8px;
  align-items: center;
  background: #0e1219;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #2a3142;
  margin-bottom: 10px;
}
.code-box code {
  flex: 1;
  font-family: "SF Mono", Menlo, monospace;
  font-size: 14px;
  color: #8aa9ff;
  word-break: break-all;
}

/* Share row — Discord / Messenger / Copy Link buttons */
.share-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.share-btn {
  flex: 1;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 700;
  cursor: pointer;
  font-size: 13px;
  color: #fff;
  transition: transform 0.05s, filter 0.15s, box-shadow 0.2s;
}
.share-btn:hover { transform: translateY(-1px); filter: brightness(1.1); }
.share-btn:active { transform: translateY(0); }
.share-btn.discord {
  background: linear-gradient(180deg, #6f7dfa, #5865F2);
  border-color: #7884ff;
  box-shadow: 0 0 12px rgba(88, 101, 242, 0.45);
}
.share-btn.messenger {
  background: linear-gradient(180deg, #44bec7 0%, #0084ff 100%);
  border-color: #44bec7;
  box-shadow: 0 0 12px rgba(0, 132, 255, 0.45);
}
.share-btn.copy {
  background: linear-gradient(180deg, #ffd966, #ff9b3d);
  border-color: #ffe07a;
  color: #20140a;
  box-shadow: 0 0 12px rgba(255, 200, 60, 0.45);
}

#player-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
#player-list li {
  padding: 8px 12px;
  background: #0e1219;
  border-radius: 6px;
  margin-bottom: 4px;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
}
#player-list li .badge {
  font-size: 11px;
  background: #4a6cf7;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#game-ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

#scoreboard {
  position: absolute;
  top: 16px;
  left: 16px;
  padding: 4px 8px;
  pointer-events: auto;
  min-width: 220px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.85), 0 0 2px rgba(0, 0, 0, 0.9);
}
#scoreboard h3 {
  margin: 0 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #8a93a6;
}
.score-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 14px;
}
.score-row.active {
  color: #ffe07a;
  font-weight: 700;
  background: linear-gradient(90deg, rgba(255,224,122,0.15), transparent 70%);
  margin: 0 -14px;
  padding: 4px 14px;
  border-radius: 6px;
  animation: active-glow 1.6s ease-in-out infinite alternate;
}
.score-row.active::before {
  content: "▶ ";
  color: #ffe07a;
}
@keyframes active-glow {
  0% { box-shadow: inset 0 0 8px rgba(255, 224, 122, 0.18); }
  100% { box-shadow: inset 0 0 22px rgba(255, 224, 122, 0.45); }
}
.score-row .pts { font-variant-numeric: tabular-nums; color: #b8c1d4; }
.score-row.active .pts { color: #ffe07a; }

#turn-banner {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 10px rgba(0,0,0,0.95), 0 0 6px rgba(0,0,0,0.85);
  white-space: nowrap;
}
#turn-banner .banner-name {
  font-weight: 800;
}
#turn-banner .turn-pts {
  color: #ffe07a;
  font-weight: 700;
  margin-left: 10px;
  text-shadow: 0 0 12px rgba(255, 224, 122, 0.6), 0 2px 8px rgba(0,0,0,0.95);
}
#turn-banner .banner-bust {
  color: #ff5c72;
  font-weight: 900;
  letter-spacing: 0.15em;
  text-shadow: 0 0 14px rgba(255, 80, 110, 0.8), 0 2px 8px rgba(0,0,0,0.95);
}
#turn-banner .banner-pass-pending {
  color: #b8c1d4;
  font-weight: 600;
  margin-left: 10px;
  letter-spacing: 0.03em;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.85);
}
#turn-banner .banner-bust-pending {
  color: #ffaa3c;
  font-weight: 800;
  margin-left: 10px;
  letter-spacing: 0.04em;
  text-shadow: 0 0 12px rgba(255, 140, 40, 0.8), 0 2px 8px rgba(0,0,0,0.95);
  animation: pending-pulse 0.9s ease-in-out infinite alternate;
}
@keyframes pending-pulse {
  0%   { opacity: 0.7; }
  100% { opacity: 1;   text-shadow: 0 0 20px rgba(255, 180, 60, 1), 0 2px 8px rgba(0,0,0,0.95); }
}
/* Banner shake while a bust is incoming — grabs attention so opponents notice. */
#turn-banner.shaking {
  animation: bust-shake 0.45s linear infinite;
}
@keyframes bust-shake {
  0%, 100% { transform: translateX(-50%) rotate(0deg); }
  20%      { transform: translateX(calc(-50% - 4px)) rotate(-1deg); }
  40%      { transform: translateX(calc(-50% + 4px)) rotate(1deg); }
  60%      { transform: translateX(calc(-50% - 3px)) rotate(-0.5deg); }
  80%      { transform: translateX(calc(-50% + 3px)) rotate(0.5deg); }
}
#turn-banner.bust {
  border-color: #ff4d68;
  background: linear-gradient(180deg, rgba(120, 20, 40, 0.9), rgba(50, 10, 20, 0.9));
  color: #ffd0d8;
  font-weight: 800;
  font-size: 24px;
  letter-spacing: 0.1em;
  animation: bust-shake 0.5s ease-out, bust-flash 0.5s ease-out;
  box-shadow: 0 0 40px rgba(255, 70, 100, 0.6);
}
@keyframes bust-shake {
  0%, 100% { transform: translateX(-50%) rotate(0); }
  25% { transform: translateX(calc(-50% - 6px)) rotate(-1deg); }
  75% { transform: translateX(calc(-50% + 6px)) rotate(1deg); }
}
@keyframes bust-flash {
  0% { filter: brightness(2); }
  100% { filter: brightness(1); }
}
#turn-banner.hot {
  border-color: #ff7c8a;
  background: linear-gradient(90deg, rgba(255, 100, 100, 0.85), rgba(255, 200, 60, 0.85));
  color: #20140a;
  font-weight: 800;
  animation: hot-pulse 0.8s ease-in-out 3;
}
@keyframes hot-pulse {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.1); }
}

#action-bar {
  position: absolute;
  bottom: 140px;
  left: 50%;
  transform: translateX(-50%);
  padding: 14px 18px;
  pointer-events: auto;
  min-width: 360px;
  text-align: center;
  /* Smooth movement when the bar gets bumped out of a die's way. */
  transition: left 0.35s ease, bottom 0.35s ease;
}
#selection-info { text-shadow: 0 2px 6px rgba(0, 0, 0, 0.85); }
#bank-btn {
  background: linear-gradient(180deg, #66e090 0%, #2bbd5e 100%);
  border-color: #7cf3a0;
  color: #062a13;
  font-weight: 700;
  box-shadow: 0 0 14px rgba(80, 240, 130, 0.4);
}
#bank-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, #88f3a8 0%, #44d178 100%);
  box-shadow: 0 0 22px rgba(120, 250, 160, 0.55);
}
#keep-btn {
  background: linear-gradient(180deg, #ffd966 0%, #ff9b3d 100%);
  border-color: #ffe07a;
  color: #20140a;
  font-weight: 700;
  box-shadow: 0 0 14px rgba(255, 200, 60, 0.4);
}
#keep-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, #fff0a0 0%, #ffaa55 100%);
  box-shadow: 0 0 22px rgba(255, 220, 100, 0.55);
}
#keep-btn.hot {
  background: linear-gradient(180deg, #ff7c3a 0%, #ff3b3b 100%);
  border-color: #ffa066;
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.05em;
  box-shadow: 0 0 18px rgba(255, 100, 60, 0.55);
  animation: hotbtn-pulse 1.4s ease-in-out infinite alternate;
}
#keep-btn.hot:hover:not(:disabled) {
  background: linear-gradient(180deg, #ffa05c 0%, #ff5050 100%);
  box-shadow: 0 0 26px rgba(255, 130, 80, 0.75);
}
@keyframes hotbtn-pulse {
  0%   { box-shadow: 0 0 12px rgba(255, 100, 60, 0.4); }
  100% { box-shadow: 0 0 26px rgba(255, 150, 80, 0.85); }
}
#roll-btn {
  background: linear-gradient(180deg, #5a8cff 0%, #3a55c8 100%);
  border-color: #6e9bff;
  color: white;
  font-weight: 700;
  box-shadow: 0 0 14px rgba(90, 140, 255, 0.4);
}
#roll-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, #7da7ff 0%, #4866e0 100%);
  box-shadow: 0 0 22px rgba(120, 170, 255, 0.55);
}
/* Rapid wiggle while the Roll/Keep button is being held — visual tension. */
#roll-btn.held,
#keep-btn.held {
  background: linear-gradient(180deg, #ffa05c 0%, #ff5050 100%);
  border-color: #ffa066;
  box-shadow: 0 0 28px rgba(255, 130, 80, 0.85);
  animation: rollbtn-wiggle 0.06s linear infinite alternate;
}
@keyframes rollbtn-wiggle {
  0%   { transform: translate(-1.5px, 1px) rotate(-1deg); }
  100% { transform: translate(1.5px, -1px) rotate(1deg); }
}
#selection-info {
  font-size: 13px;
  color: #b8c1d4;
  margin-bottom: 10px;
  min-height: 18px;
}
#selection-info .accept { color: #7cf3a0; }
#selection-info .reject { color: #ff7c8a; }
.actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

/* Networked cursor for each remote player. Position is set in JS as fixed
   px from a normalized 0..1 coord; .remote-cursor-arrow inherits its fill
   from --cursor-color, which we set per player. */
.remote-cursor {
  position: fixed;
  pointer-events: none;
  z-index: 9000;
  transform: translate(-2px, -2px);
  transition: left 0.06s linear, top 0.06s linear;
  --cursor-color: #ffffff;
}
.remote-cursor svg {
  display: block;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.55));
}
/* Target the path directly — some browsers / inheritance edge cases let the
   SVG path keep its implicit black fill if we only style the <svg>. */
.remote-cursor svg path {
  fill: var(--cursor-color);
  stroke: rgba(0, 0, 0, 0.85);
  stroke-width: 1.2;
}
.remote-cursor .remote-cursor-name {
  position: absolute;
  left: 18px;
  top: 14px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  padding: 1px 5px;
  border-radius: 4px;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
  border-left: 2px solid var(--cursor-color);
}

#log-panel {
  position: absolute;
  bottom: 24px;
  left: 16px;
  width: 280px;
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.32);
  border-radius: 12px;
  padding: 26px 4px 6px 10px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  transform-origin: bottom left;
  animation: log-pop-in 0.42s cubic-bezier(0.22, 1.2, 0.36, 1);
  transition:
    max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    padding 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  max-height: 240px;
}
@keyframes log-pop-in {
  0%   { transform: translateY(24px) scale(0.92); opacity: 0; }
  60%  { opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}
#log-panel.minimized {
  max-height: 30px;
  padding-top: 6px;
  padding-bottom: 6px;
}
#log-toggle {
  position: absolute;
  top: 4px;
  right: 6px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  color: #d4dbe7;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
  padding: 0;
  transition: background 0.15s ease, transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}
#log-toggle:hover { background: rgba(255, 255, 255, 0.12); }
#log-panel.minimized #log-toggle { transform: rotate(180deg); }

/* Latest-entry preview — only visible when the panel is minimized, so the
   player still sees the most recent log line at a glance. */
#log-preview {
  position: absolute;
  top: 7px;
  left: 10px;
  right: 36px;
  font-size: 11px;
  font-weight: 600;
  line-height: 16px;
  color: #d4dbe7;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
  transition: opacity 0.25s ease;
}
#log-preview.you { color: #ffe07a; }
#log-preview.bust { color: #ff7c8a; }
#log-preview.bank { color: #7cf3a0; }
#log-panel.minimized #log-preview { opacity: 1; }
#log {
  max-height: 200px;
  overflow-y: auto;
  font-size: 12px;
  color: #d4dbe7;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.9), 0 0 2px rgba(0, 0, 0, 0.8);
  transition: opacity 0.25s ease;
}
#log-panel.minimized #log {
  opacity: 0;
  pointer-events: none;
}
#log .entry {
  padding: 3px 0;
}
#log .entry.you { color: #ffe07a; }
#log .entry.bust { color: #ff7c8a; }
#log .entry.bank { color: #7cf3a0; }

/* End screen — flex row puts the final scoreboard on the left and the
   purchase receipts on the right. */
.end-panel { max-width: 760px; }
.end-body {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 12px;
}
.end-body > #final-scores { flex: 1 1 0; min-width: 0; margin: 0; }
.end-body > #receipts {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 60vh;
  overflow-y: auto;
}

/* Actual receipt paper — pale off-white, soft drop shadow, narrow column,
   monospaced text, zig-zag tear edges top and bottom via clip-path. */
.receipt {
  position: relative;
  background: linear-gradient(180deg, #fbf5e3 0%, #f4ecd2 100%);
  color: #2a1b08;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 11px;
  line-height: 1.45;
  padding: 22px 14px 24px;
  /* Triangular tear edges: 14 zigzag points top and bottom, flat sides. */
  clip-path: polygon(
    0% 6px, 4% 0%, 8% 6px, 12% 0%, 16% 6px, 20% 0%, 24% 6px, 28% 0%, 32% 6px, 36% 0%, 40% 6px, 44% 0%, 48% 6px, 52% 0%, 56% 6px, 60% 0%, 64% 6px, 68% 0%, 72% 6px, 76% 0%, 80% 6px, 84% 0%, 88% 6px, 92% 0%, 96% 6px, 100% 0%,
    100% 100%,
    96% calc(100% - 6px), 92% 100%, 88% calc(100% - 6px), 84% 100%, 80% calc(100% - 6px), 76% 100%, 72% calc(100% - 6px), 68% 100%, 64% calc(100% - 6px), 60% 100%, 56% calc(100% - 6px), 52% 100%, 48% calc(100% - 6px), 44% 100%, 40% calc(100% - 6px), 36% 100%, 32% calc(100% - 6px), 28% 100%, 24% calc(100% - 6px), 20% 100%, 16% calc(100% - 6px), 12% 100%, 8% calc(100% - 6px), 4% 100%, 0% calc(100% - 6px)
  );
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.5));
}
.receipt .header {
  text-align: center;
  border-bottom: 1px dashed #8a6a2a;
  padding-bottom: 6px;
  margin-bottom: 8px;
}
.receipt .header .name { font-weight: 800; letter-spacing: 0.5px; font-size: 13px; }
.receipt .header .sub { font-size: 10px; opacity: 0.75; }
.receipt .row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.receipt .row .desc { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.receipt .row .amt { flex: 0 0 auto; }
.receipt .total {
  border-top: 1px dashed #8a6a2a;
  margin-top: 8px;
  padding-top: 6px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.receipt .empty { text-align: center; font-style: italic; opacity: 0.6; padding: 4px 0; }

#final-scores {
  list-style: none;
  padding: 0;
  margin: 0 0 10px;
}
#final-scores li {
  padding: 10px 14px;
  background: #0e1219;
  border-radius: 8px;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  font-size: 15px;
}
#final-scores li.winner {
  background: linear-gradient(90deg, #ffd400 0%, #ff7c3a 100%);
  color: #20140a;
  font-weight: 800;
  box-shadow: 0 0 24px rgba(255, 200, 60, 0.6);
  animation: winner-shimmer 1.6s ease-in-out infinite alternate;
}
@keyframes winner-shimmer {
  0% { filter: brightness(1); }
  100% { filter: brightness(1.25) saturate(1.2); }
}

/* ---- Confetti / coins / popups / flashes ---- */

.confetti {
  position: fixed;
  pointer-events: none;
  z-index: 200;
  border-radius: 2px;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.4);
  will-change: transform, opacity;
}

.blood-spot {
  position: fixed;
  pointer-events: none;
  z-index: 200;
  border-radius: 50%;
  box-shadow: 0 0 4px rgba(255, 0, 30, 0.6), inset -2px -3px 4px rgba(0,0,0,0.4);
  will-change: transform, opacity;
}

/* Comic-book starburst (POW!, KABLAM!, etc.) */
.comic-burst {
  position: fixed;
  pointer-events: none;
  z-index: 260;
  font-family: "Impact", "Arial Black", "Helvetica Neue", sans-serif;
  font-weight: 900;
  font-size: 54px;
  letter-spacing: 0.04em;
  color: var(--burst-fg, #fff);
  background: var(--burst-bg, #ff4757);
  padding: 30px 46px;
  text-shadow:
    -3px -3px 0 #000, 3px -3px 0 #000, -3px 3px 0 #000, 3px 3px 0 #000,
     0 -3px 0 #000,  0  3px 0 #000, -3px 0 0 #000,  3px 0 0 #000,
     0 0 14px rgba(0,0,0,0.55);
  /* 10-point star clip path for the cartoony jagged shape */
  clip-path: polygon(
    50% 0%, 61% 26%, 100% 27%, 70% 49%, 84% 88%,
    50% 68%, 16% 88%, 30% 49%, 0% 27%, 39% 26%
  );
  animation: comic-burst-pop 0.85s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  transform: translate(-50%, -50%) scale(0.2) rotate(var(--burst-rot, 0deg));
  will-change: transform, opacity;
}
@keyframes comic-burst-pop {
  0%   { transform: translate(-50%, -50%) scale(0.2) rotate(calc(var(--burst-rot, 0deg) - 35deg)); opacity: 0; }
  22%  { transform: translate(-50%, -50%) scale(1.45) rotate(var(--burst-rot, 0deg)); opacity: 1; }
  40%  { transform: translate(-50%, -50%) scale(1) rotate(var(--burst-rot, 0deg)); }
  75%  { transform: translate(-50%, -50%) scale(1) rotate(var(--burst-rot, 0deg)); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.4) rotate(var(--burst-rot, 0deg)); opacity: 0; }
}

/* Q-style light flare: bright cross-shaped burst that pops + expands + fades.
   Three layered spans (.q-flash-core, .q-flash-ray, .q-flash-ray2) give the
   radial glow plus a horizontal and vertical light streak. */
.q-flash {
  position: fixed;
  pointer-events: none;
  z-index: 220;
  width: 0;
  height: 0;
  transform: translate(-50%, -50%);
  animation: q-flash-fade 0.7s ease-out forwards;
}
.q-flash .q-flash-core,
.q-flash .q-flash-ray,
.q-flash .q-flash-ray2 {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.q-flash .q-flash-core {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffffff 0%, #e0f0ff 35%, rgba(170, 210, 255, 0.6) 60%, transparent 75%);
  box-shadow:
    0 0 30px 10px rgba(255, 255, 255, 0.9),
    0 0 60px 20px rgba(180, 220, 255, 0.7),
    0 0 100px 30px rgba(120, 170, 255, 0.4);
  animation: q-flash-core 0.7s ease-out forwards;
}
.q-flash .q-flash-ray {
  width: 180px;
  height: 4px;
  background: linear-gradient(90deg, transparent 0%, #ffffff 50%, transparent 100%);
  filter: blur(1px);
  animation: q-flash-ray 0.7s ease-out forwards;
}
.q-flash .q-flash-ray2 {
  width: 180px;
  height: 4px;
  background: linear-gradient(90deg, transparent 0%, #ffffff 50%, transparent 100%);
  filter: blur(1px);
  transform: translate(-50%, -50%) rotate(90deg);
  animation: q-flash-ray2 0.7s ease-out forwards;
}
@keyframes q-flash-fade {
  0%   { opacity: 0; }
  10%  { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes q-flash-core {
  0%   { transform: translate(-50%, -50%) scale(0.1); }
  20%  { transform: translate(-50%, -50%) scale(1.4); }
  100% { transform: translate(-50%, -50%) scale(3.5); }
}
@keyframes q-flash-ray {
  0%   { transform: translate(-50%, -50%) scaleX(0); opacity: 0; }
  15%  { transform: translate(-50%, -50%) scaleX(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scaleX(0.3); opacity: 0; }
}
@keyframes q-flash-ray2 {
  0%   { transform: translate(-50%, -50%) rotate(90deg) scaleX(0); opacity: 0; }
  15%  { transform: translate(-50%, -50%) rotate(90deg) scaleX(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) rotate(90deg) scaleX(0.3); opacity: 0; }
}

.coin {
  position: fixed;
  pointer-events: none;
  z-index: 200;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff5b0 0%, #ffd400 35%, #b88200 80%);
  color: #6b3a00;
  font-weight: 900;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 12px rgba(255, 200, 60, 0.8);
  border: 1px solid #b88200;
  will-change: transform, opacity;
}

.score-popup {
  position: fixed;
  pointer-events: none;
  z-index: 250;
  font-weight: 800;
  font-size: 28px;
  color: #fff;
  text-shadow: 0 0 12px rgba(255, 224, 122, 0.9), 0 2px 6px rgba(0, 0, 0, 0.7);
  transform: translate(-50%, -50%);
  animation: pop-rise 1.7s ease-out forwards;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.score-popup.big {
  font-size: 56px;
  background: linear-gradient(180deg, #fff7c2, #ffd400 50%, #ff7c3a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 30px rgba(255, 200, 60, 0.9);
  animation: pop-big 2s ease-out forwards;
}
.score-popup.bust {
  color: #ff5c72;
  font-size: 44px;
  text-shadow: 0 0 16px rgba(255, 80, 110, 0.8);
  animation: pop-shake 1.2s ease-out forwards;
}
.score-popup.bank {
  color: #7cf3a0;
  text-shadow: 0 0 18px rgba(80, 240, 130, 0.85);
}
.score-popup.bonus {
  font-size: 56px;
  background: linear-gradient(180deg, #ff8a9d, #ff3050 50%, #b8001f);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 30px rgba(255, 60, 100, 0.85);
  animation: pop-big 2s ease-out forwards;
}

@keyframes pop-rise {
  0% { transform: translate(-50%, -50%) scale(0.6); opacity: 0; }
  20% { transform: translate(-50%, -80%) scale(1.1); opacity: 1; }
  80% { transform: translate(-50%, -180%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -240%) scale(0.95); opacity: 0; }
}
@keyframes pop-big {
  0% { transform: translate(-50%, -50%) scale(0.4) rotate(-6deg); opacity: 0; }
  18% { transform: translate(-50%, -60%) scale(1.3) rotate(2deg); opacity: 1; }
  35% { transform: translate(-50%, -70%) scale(1) rotate(-1deg); }
  85% { transform: translate(-50%, -180%) scale(1) rotate(0); opacity: 1; }
  100% { transform: translate(-50%, -260%) scale(0.95); opacity: 0; }
}
@keyframes pop-shake {
  0% { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
  10% { transform: translate(-50%, -55%) scale(1.4); opacity: 1; }
  20% { transform: translate(-46%, -55%) scale(1.2); }
  30% { transform: translate(-54%, -55%) scale(1.2); }
  40% { transform: translate(-46%, -55%) scale(1.2); }
  50% { transform: translate(-50%, -60%) scale(1.1); }
  90% { transform: translate(-50%, -120%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -150%) scale(0.95); opacity: 0; }
}

.screen-flash {
  position: fixed;
  inset: 0;
  z-index: 150;
  pointer-events: none;
  animation: flash-fade 0.5s ease-out forwards;
}
@keyframes flash-fade {
  0% { opacity: var(--start, 0.4); }
  100% { opacity: 0; }
}

/* Mute toggle */
#mute-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 20;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  background: rgba(15, 19, 28, 0.85);
  border: 1px solid #262c3a;
  font-size: 18px;
  cursor: pointer;
  pointer-events: auto;
}

/* Shop button — top right (left of mute) */
#shop-btn {
  position: fixed;
  top: 16px;
  right: 64px;
  z-index: 20;
  height: 38px;
  padding: 0 14px;
  border-radius: 19px;
  background: linear-gradient(180deg, #ffd966 0%, #ff9b3d 100%);
  border: 1px solid #ffe07a;
  color: #20140a;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 0 16px rgba(255, 200, 60, 0.4);
}
#shop-btn:hover {
  background: linear-gradient(180deg, #fff0a0 0%, #ffaa55 100%);
  box-shadow: 0 0 22px rgba(255, 220, 100, 0.6);
}
#shop-btn.hidden { display: none; }

/* Shop modal */
.shop-panel {
  width: min(720px, 100%);
  max-height: 85vh;
  overflow-y: auto;
}
.shop-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 4px;
}
.shop-header h2 {
  margin: 0;
  flex: 0 0 auto;
}
.shop-balance {
  flex: 1;
  text-align: right;
  font-size: 14px;
  color: #b8c1d4;
}
.shop-balance span {
  color: #ffe07a;
  font-weight: 700;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}
#shop-close {
  background: transparent;
  border: 1px solid #2a3142;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 14px;
  cursor: pointer;
}
#shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 14px;
}
/* Shop card — entire card is the buy button. Flashy casino styling. */
.shop-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, #2a1340 0%, #0a0512 100%);
  border: 2px solid #ffd400;
  border-radius: 16px;
  padding: 22px 12px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s, border-color 0.2s;
  box-shadow: 0 0 14px rgba(255, 200, 60, 0.3), inset 0 0 14px rgba(255, 200, 60, 0.1);
  font-family: inherit;
  color: #fff;
}
.shop-card:hover:not(:disabled) {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 0 30px rgba(255, 220, 120, 0.75), inset 0 0 18px rgba(255, 200, 60, 0.25);
  border-color: #fff7c2;
}
.shop-card:active:not(:disabled) { transform: translateY(0) scale(1.0); }
.shop-card.broke {
  border-color: #3a3340;
  background: linear-gradient(180deg, #181222 0%, #0a0510 100%);
  box-shadow: none;
  opacity: 0.55;
  cursor: not-allowed;
}
.shop-card .icon {
  font-size: 56px;
  line-height: 1;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.7));
}
.shop-card .name {
  font-weight: 800;
  font-size: 13px;
  color: #ffe07a;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-shadow: 0 0 6px rgba(255, 200, 60, 0.5);
}
.shop-card .cost {
  font-size: 26px;
  font-weight: 900;
  background: linear-gradient(180deg, #fff7c2 0%, #ffd400 60%, #ff9b3d 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 12px rgba(255, 200, 60, 0.5);
  font-variant-numeric: tabular-nums;
}
.shop-card .own {
  position: absolute;
  top: 8px; right: 8px;
  background: linear-gradient(180deg, #66e090, #2bbd5e);
  color: #062a13;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 0 8px rgba(80, 240, 130, 0.6);
}
/* Diagonal shimmer streak that sweeps across affordable cards */
.shop-card.available::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(45deg,
    transparent 35%,
    rgba(255, 230, 150, 0.10) 50%,
    transparent 65%);
  pointer-events: none;
  animation: card-shimmer 4s linear infinite;
}
@keyframes card-shimmer {
  0%   { transform: translate(-25%, -25%); }
  100% { transform: translate(25%, 25%); }
}

/* Inventory tray — bottom of screen, horizontal row, BIG icons */
#inventory {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: row;
  gap: 12px;
  z-index: 6;
  pointer-events: auto;
}
#inventory.hidden { display: none; }
.inv-item {
  background: linear-gradient(180deg, rgba(40, 24, 56, 0.92), rgba(15, 6, 22, 0.92));
  border: 2px solid #ffd400;
  border-radius: 16px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s, opacity 0.15s, box-shadow 0.2s;
  text-shadow: 0 2px 6px rgba(0,0,0,0.85);
  box-shadow: 0 0 14px rgba(255, 200, 60, 0.3);
}
.inv-item .ic { font-size: 44px; line-height: 1; }
.inv-item .ct { font-weight: 800; color: #ffe07a; font-size: 20px; font-variant-numeric: tabular-nums; }
.inv-item:hover:not(.disabled) {
  border-color: #fff7c2;
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 0 26px rgba(255, 220, 120, 0.7);
}
.inv-item.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: #444;
  box-shadow: none;
}
.inv-item.usable {
  border-color: #ffe07a;
  animation: inv-pulse 1.4s ease-in-out infinite alternate;
}
@keyframes inv-pulse {
  0%   { box-shadow: 0 0 14px rgba(255, 200, 60, 0.35); }
  100% { box-shadow: 0 0 28px rgba(255, 220, 120, 0.85); }
}

/* Visual selection ring colors per player are coordinated with three.js;
   "remote selection" rings use a different tint so spectators see who's clicking. */

/* Aiming reticle for items that target a point or a die */
#reticle {
  position: fixed;
  pointer-events: none;
  z-index: 120;
  width: 64px;
  height: 64px;
  margin-left: -32px;
  margin-top: -32px;
}
#reticle.hidden { display: none; }
#reticle .ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px dashed #ffe07a;
  box-shadow: 0 0 18px rgba(255, 200, 60, 0.7), inset 0 0 14px rgba(255, 200, 60, 0.3);
  animation: ret-spin 4s linear infinite;
}
#reticle .dot {
  position: absolute;
  left: 50%; top: 50%;
  width: 6px; height: 6px;
  margin-left: -3px; margin-top: -3px;
  background: #ffe07a;
  border-radius: 50%;
  box-shadow: 0 0 8px #ffe07a;
}
#reticle .hint {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 12px;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.95), 0 0 4px rgba(0, 0, 0, 0.8);
}
@keyframes ret-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
body.aiming { cursor: none; }
body.aiming.aiming-die #canvas-root { cursor: none; }
