/*
 * Meyer-party — online raflebæger. One stylesheet, mobile-first (it's a phone
 * game). The bodega-felt design system is ported from the single-device `meyer`
 * app's globals.css; the lobby/multiplayer pieces are added below. Palette and
 * fonts live in CSS variables on :root — restyle by editing variables.
 */

:root {
  --felt: #0f2418;
  --felt-glow: #1d4533;
  --ink: #f3efe2;
  --muted: #b6bdaa;
  --gold: #e6b34a;
  --gold-soft: #f6dca0;
  --red: #c0492f;
  --red-soft: #e3795f;
  --green: #6fae6a;
  --ivory: #f4efe1;
  --pip: #1a1a1a;
  --border: rgba(243, 239, 226, 0.16);
  --card: rgba(8, 22, 15, 0.5);
  --font-body: ui-serif, Georgia, 'Iowan Old Style', 'Times New Roman', serif;
  --font-detail: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
}

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

body {
  min-height: 100svh;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(ellipse 110% 70% at 50% -10%, var(--felt-glow), transparent 60%),
    radial-gradient(ellipse 90% 60% at 50% 120%, rgba(230, 179, 74, 0.08), transparent 65%),
    var(--felt);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* Felt grain: inline-SVG turbulence tile, no asset, no request. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.table {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 4vw, 2.5rem);
}

.card {
  width: 100%;
  max-width: 30rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  padding: clamp(1.4rem, 5vw, 2.2rem);
  border: 1px solid var(--border);
  border-radius: 1.5rem;
  background: var(--card);
  backdrop-filter: blur(8px);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 30px 80px -40px rgba(0, 0, 0, 0.8);
  text-align: center;
  animation: rise 0.4s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.99);
  }
}

.kicker {
  margin: 0;
  font-family: var(--font-detail);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
}

h1 {
  margin: 0;
  font-size: clamp(2.6rem, 12vw, 3.8rem);
  font-weight: 600;
  line-height: 0.95;
  letter-spacing: -0.02em;
}
h2 {
  margin: 0;
  font-size: clamp(1.7rem, 8vw, 2.3rem);
  font-weight: 600;
  line-height: 1;
}
.lede {
  margin: 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.5;
}

/* --- buttons --- */
button {
  font-family: var(--font-detail);
  cursor: pointer;
  border-radius: 0.9rem;
  border: 1px solid var(--border);
  background: rgba(243, 239, 226, 0.06);
  color: var(--ink);
  font-size: 0.95rem;
  padding: 0.7rem 1rem;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
  touch-action: manipulation;
}
button:active {
  transform: scale(0.97);
}
button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.big {
  padding: 1.05rem 1.2rem;
  font-size: 1.1rem;
  font-weight: 500;
  width: 100%;
}
.primary {
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  color: #2a1c00;
  border-color: transparent;
  font-weight: 600;
}
.danger {
  background: linear-gradient(180deg, var(--red-soft), var(--red));
  color: #fff;
  border-color: transparent;
}
.ghost {
  background: rgba(243, 239, 226, 0.06);
}
.actions {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.row {
  display: flex;
  gap: 0.6rem;
}
.row > button {
  flex: 1;
}

/* --- inputs --- */
.add-row {
  display: flex;
  gap: 0.5rem;
}
input,
select {
  font-family: var(--font-detail);
  font-size: 1rem;
  padding: 0.75rem 0.9rem;
  border-radius: 0.9rem;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--ink);
}
input {
  flex: 1;
  min-width: 0;
}
input:focus,
select:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  text-align: left;
}
.field label {
  font-family: var(--font-detail);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.lives-pick {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-detail);
  font-size: 0.9rem;
  color: var(--muted);
  gap: 0.6rem;
}
.lives-pick select {
  padding: 0.45rem 0.7rem;
}

/* --- lobby list --- */
.section-title {
  font-family: var(--font-detail);
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  text-align: left;
  margin: 0.2rem 0 -0.3rem;
}
.lobby-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.lobby-list li {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 0.85rem;
  border-radius: 0.8rem;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--border);
}
.lobby-meta {
  flex: 1;
  text-align: left;
  min-width: 0;
}
.lobby-name {
  font-weight: 600;
  font-size: 1.05rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lobby-sub {
  font-family: var(--font-detail);
  font-size: 0.78rem;
  color: var(--muted);
}
.lobby-join {
  flex: 0 0 auto;
  padding: 0.55rem 1rem;
}
.empty {
  color: var(--muted);
  font-family: var(--font-detail);
  font-size: 0.9rem;
  padding: 0.8rem 0;
}

/* --- player / scoreboard --- */
.player-list,
.scoreboard {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.player-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.9rem;
  border-radius: 0.7rem;
  background: rgba(0, 0, 0, 0.2);
  font-family: var(--font-detail);
}
.dot {
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  margin-right: 0.5rem;
  background: var(--green);
  box-shadow: 0 0 6px rgba(111, 174, 106, 0.7);
}
.dot.off {
  background: var(--muted);
  box-shadow: none;
  opacity: 0.5;
}
.tag {
  font-family: var(--font-detail);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: var(--gold);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.1rem 0.4rem;
}

.scoreboard li {
  display: grid;
  grid-template-columns: auto auto 1fr auto auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem 0.4rem 0.4rem;
  border-radius: 0.7rem;
  background: rgba(0, 0, 0, 0.2);
  font-family: var(--font-detail);
}
.scoreboard li.turn {
  background: rgba(230, 179, 74, 0.16);
  border: 1px solid rgba(230, 179, 74, 0.4);
}
.sb-name {
  font-size: 0.95rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}
.sb-hearts {
  color: var(--red-soft);
  letter-spacing: 0.12em;
  font-size: 0.85rem;
  justify-self: end;
}
.scoreboard li.out {
  opacity: 0.45;
}
.scoreboard li.out .sb-hearts {
  color: var(--muted);
  letter-spacing: 0.06em;
}
.life-btn {
  width: 2rem;
  height: 2rem;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 0.55rem;
  font-size: 1.2rem;
  line-height: 1;
}
.life-btn.minus {
  background: rgba(192, 73, 47, 0.22);
  border-color: rgba(227, 121, 95, 0.5);
  color: var(--red-soft);
}
.life-btn.plus {
  color: var(--muted);
  font-size: 1rem;
}

/* --- dice --- */
.dice-pair {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin: 0.4rem 0;
}
.die {
  width: clamp(4.2rem, 22vw, 5.4rem);
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 14%;
  background: linear-gradient(150deg, #fff, var(--ivory) 60%, #ddd6c2);
  border-radius: 22%;
  box-shadow:
    0 2px 0 rgba(0, 0, 0, 0.25),
    0 12px 24px -10px rgba(0, 0, 0, 0.6),
    inset 0 0 0 1px rgba(0, 0, 0, 0.06);
  animation: tumble 0.45s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}
@keyframes tumble {
  from {
    transform: rotate(-18deg) scale(0.7);
    opacity: 0;
  }
}
.pip {
  display: grid;
  place-items: center;
}
.pip.on::after {
  content: '';
  width: 64%;
  height: 64%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #555, var(--pip));
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.3);
}

/* --- the cup --- */
.cup {
  width: 100%;
  min-height: 11rem;
  display: grid;
  place-items: center;
  border-radius: 1.2rem;
  border: 2px solid var(--border);
  background: repeating-linear-gradient(
    45deg,
    rgba(0, 0, 0, 0.22),
    rgba(0, 0, 0, 0.22) 10px,
    rgba(0, 0, 0, 0.16) 10px,
    rgba(0, 0, 0, 0.16) 20px
  );
  user-select: none;
  padding: 1rem;
}
.cup.open {
  background: rgba(0, 0, 0, 0.3);
  border-color: var(--gold);
}
.cup.shaking {
  animation: shake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}
@keyframes shake {
  10%, 90% { transform: translateX(-2px) rotate(-1deg); }
  20%, 80% { transform: translateX(4px) rotate(1.5deg); }
  30%, 50%, 70% { transform: translateX(-7px) rotate(-2deg); }
  40%, 60% { transform: translateX(7px) rotate(2deg); }
}
.cup-hint {
  font-family: var(--font-detail);
  letter-spacing: 0.08em;
  color: var(--gold-soft);
  text-align: center;
}
.cup-reveal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.dice-label {
  font-family: var(--font-detail);
  letter-spacing: 0.08em;
  color: var(--gold-soft);
  font-size: 1.05rem;
}
.turn-banner {
  font-family: var(--font-detail);
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.turn-banner strong {
  color: var(--gold);
}

/* --- claim picker --- */
.claim-row {
  display: flex;
  gap: 0.6rem;
}
.claim-row select {
  flex: 1;
  font-size: 1.1rem;
}
.claim-row button {
  flex: 0 0 auto;
  padding-left: 1.4rem;
  padding-right: 1.4rem;
}

/* --- public events: fælles skål + snyd reveal --- */
.event {
  border-radius: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  animation: rise 0.35s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}
.event p {
  margin: 0;
  font-family: var(--font-detail);
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.5;
}
.event p strong {
  color: var(--ink);
}
.event-big {
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.event.skaal {
  background: linear-gradient(180deg, rgba(230, 179, 74, 0.22), rgba(230, 179, 74, 0.08));
  border-color: rgba(230, 179, 74, 0.5);
}
.event.skaal .event-big {
  color: var(--gold-soft);
}
.event.challenge {
  background: linear-gradient(180deg, rgba(192, 73, 47, 0.18), rgba(0, 0, 0, 0.25));
  border-color: rgba(227, 121, 95, 0.45);
}
.event .loser {
  color: var(--red-soft);
  font-weight: 600;
}

.cup-foot,
.share {
  margin: 0;
  font-family: var(--font-detail);
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  line-height: 1.5;
}
.share code {
  color: var(--gold-soft);
  font-size: 0.95rem;
  letter-spacing: 0.1em;
}
.link {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  color: var(--gold);
  text-decoration: underline;
  cursor: pointer;
}
.small {
  padding: 0.45rem 0.9rem;
  font-size: 0.82rem;
  align-self: center;
}
.reset {
  color: var(--muted);
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  z-index: 10;
  background: rgba(192, 73, 47, 0.95);
  color: #fff;
  font-family: var(--font-detail);
  font-size: 0.85rem;
  padding: 0.6rem 1rem;
  border-radius: 0.7rem;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.7);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.toast.show {
  opacity: 1;
}

/* --- rules --- */
.rules {
  text-align: left;
  border-top: 1px solid var(--border);
  padding-top: 0.6rem;
}
.rules summary {
  cursor: pointer;
  font-family: var(--font-detail);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  color: var(--gold);
  list-style: none;
}
.rules summary::-webkit-details-marker {
  display: none;
}
.rules summary::before {
  content: '＋ ';
}
.rules[open] summary::before {
  content: '－ ';
}
.rules-body {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.55;
}
.rules-body ol {
  padding-left: 1.2rem;
}
.rules-body li {
  margin-bottom: 0.4rem;
}
.rules-body strong {
  color: var(--ink);
}

.winner {
  font-size: clamp(2rem, 10vw, 3rem);
  color: var(--gold);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
  }
}
