:root {
  color-scheme: dark;
  --ink: #fff8e8;
  --muted: #bcb3c7;
  --panel: rgba(24, 13, 34, 0.82);
  --panel-border: rgba(255, 255, 255, 0.13);
  --gold: #ffd36a;
  --hot: #ff3d8d;
  --violet: #9b5cff;
  --cyan: #29d9ff;
  --green: #61ee9c;
  --danger: #ff596c;
  font-family: ui-rounded, "SF Pro Rounded", "PingFang TC", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100svh;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% -10%, #3b153e 0, transparent 40%),
    linear-gradient(150deg, #06030c 0%, #110719 54%, #07040d 100%);
  overflow-x: hidden;
}

button, input { font: inherit; }
button { touch-action: manipulation; }

.ambient {
  position: fixed;
  width: 19rem;
  height: 19rem;
  border-radius: 999px;
  filter: blur(100px);
  opacity: 0.22;
  pointer-events: none;
}
.ambient-one { top: -7rem; left: -8rem; background: var(--hot); }
.ambient-two { right: -9rem; bottom: 8rem; background: var(--cyan); }

.shell {
  position: relative;
  width: min(100%, 34rem);
  margin: 0 auto;
  padding: max(1.2rem, env(safe-area-inset-top)) 1rem max(2rem, env(safe-area-inset-bottom));
}

.kicker { margin: 0; color: var(--gold); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.17em; text-transform: uppercase; }

.status-badge {
  padding: 0.38rem 0.65rem;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
}

.panel {
  border: 1px solid var(--panel-border);
  border-radius: 1.45rem;
  background: var(--panel);
  box-shadow: 0 24px 55px rgba(0, 0, 0, 0.34), inset 0 1px rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(18px);
}

.join-panel { padding: 1.5rem; }
.join-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.join-panel h2 { margin: 0.45rem 0 0.65rem; font-size: clamp(1.75rem, 7vw, 2.35rem); line-height: 1.1; }
.join-state-badge {
  flex: 0 0 auto;
  padding: 0.38rem 0.65rem;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
}
.join-state-badge.open { border-color: rgba(97, 238, 156, 0.48); background: rgba(97, 238, 156, 0.12); color: var(--green); }
.join-state-badge.closed { border-color: rgba(255, 89, 108, 0.5); background: rgba(255, 89, 108, 0.12); color: var(--danger); }
.join-state-badge.checking { color: var(--muted); }
.muted { margin: 0 0 1.4rem; color: var(--muted); line-height: 1.55; }

form { display: grid; gap: 0.7rem; }
label { color: var(--muted); font-size: 0.83rem; font-weight: 700; }
input {
  width: 100%;
  padding: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 0.9rem;
  outline: none;
  background: rgba(255, 255, 255, 0.07);
  color: var(--ink);
  font-size: 1.1rem;
}
input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(41, 217, 255, 0.16); }

.primary-button, .catch-button {
  border: 0;
  color: white;
  font-weight: 900;
  cursor: pointer;
}
.primary-button {
  min-height: 3.4rem;
  margin-top: 0.3rem;
  border-radius: 0.95rem;
  background: linear-gradient(100deg, var(--hot), var(--violet), #386cff);
  box-shadow: 0 10px 25px rgba(155, 92, 255, 0.25);
}
.primary-button:disabled, .catch-button:disabled { opacity: 0.48; cursor: not-allowed; }

.notice { display: grid; gap: 0.45rem; margin-top: 1rem; padding: 0.9rem; border-radius: 0.85rem; font-size: 0.88rem; }
.notice.error { border: 1px solid rgba(255, 89, 108, 0.5); background: rgba(255, 89, 108, 0.12); }
.notice.claim { border: 1px solid rgba(255, 211, 106, 0.4); background: rgba(255, 211, 106, 0.08); }

.game-view { display: grid; gap: 1rem; }
.ones-banner {
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  padding: 0.8rem;
  border: 1px solid rgba(255, 211, 106, 0.5);
  border-radius: 1rem;
  background: linear-gradient(90deg, rgba(255, 61, 141, 0.18), rgba(255, 211, 106, 0.2));
  color: var(--gold);
  font-weight: 950;
  letter-spacing: 0.14em;
  box-shadow: 0 0 24px rgba(255, 61, 141, 0.2);
}
.ones-banner:not([hidden]) { display: flex; }
.pulse-dot { width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 0 rgba(255, 211, 106, 0.6); animation: pulse 1.5s infinite; }

.player-card { padding: 1.2rem; overflow: hidden; }
.player-heading, .dice-meta { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.player-heading h2 { margin: 0.25rem 0 0; font-size: 1.55rem; }

.dice-tray {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.45rem;
  min-height: 4.7rem;
  margin: 1.3rem 0 1rem;
}
.die {
  display: grid;
  place-items: center;
  width: clamp(2.7rem, 12.5vw, 3.5rem);
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 0.9rem;
  background: #120912;
  color: var(--gold);
  object-fit: cover;
  font-family: ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  font-size: clamp(2.7rem, 13vw, 3.6rem);
  font-weight: 950;
  line-height: 1;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.42), 0 0 15px rgba(255, 211, 106, 0.08);
  animation: deal 320ms both;
}
.die:nth-child(2) { animation-delay: 60ms; }
.die:nth-child(3) { animation-delay: 120ms; }
.die:nth-child(4) { animation-delay: 180ms; }
.die:nth-child(5) { animation-delay: 240ms; }
.dice-meta { color: var(--muted); font-size: 0.82rem; }
.dice-waiting { align-self: center; margin: 0; color: var(--muted); font-weight: 700; }

.text-button, .quiet-button { border: 0; background: none; color: var(--cyan); font-weight: 750; cursor: pointer; }
.text-button { padding: 0.35rem 0; text-align: left; }

.action-zone { display: grid; justify-items: center; padding: 1.1rem 0 0.4rem; }
.catch-button {
  display: grid;
  place-items: center;
  width: min(72vw, 15rem);
  aspect-ratio: 1;
  border: 0.45rem solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  background: radial-gradient(circle at 36% 28%, #ff6c9f, #ef145e 45%, #8d083c 100%);
  font-size: clamp(5rem, 24vw, 6.5rem);
  line-height: 1;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.26);
  box-shadow: 0 0 0 0.45rem rgba(255, 61, 141, 0.12), 0 18px 30px rgba(239, 20, 94, 0.32), inset 0 5px rgba(255, 255, 255, 0.22);
}
.catch-button:not(:disabled):active { transform: scale(0.96); }

.quiet-button { justify-self: center; margin-top: 0.2rem; color: #8e8598; font-size: 0.76rem; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

@keyframes deal { from { opacity: 0; transform: translateY(-10px) rotate(-8deg) scale(0.8); } to { opacity: 1; transform: none; } }
@keyframes pulse { 70% { box-shadow: 0 0 0 9px rgba(255, 211, 106, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 211, 106, 0); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
