:root {
  --bg0: #0a0a1f;
  --bg1: #141233;
  --pink: #ff2e88;
  --cyan: #22e0ff;
  --violet: #7b5cff;
  --gold: #ffd23f;
  --green: #38e08a;
  --text: #f4f5ff;
  --muted: #a3a7d4;
  --glass: rgba(255, 255, 255, 0.06);
  --glass-brd: rgba(255, 255, 255, 0.14);
  --display: "Fredoka", "Baloo 2", "Hiragino Sans", "Noto Sans JP", sans-serif;
  --body: "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  color: var(--text);
  font-family: var(--body);
  min-height: 100%;
  background: var(--bg0);
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

/* 動く背景グロー */
body::before, body::after {
  content: ""; position: fixed; z-index: -2;
  width: 70vmax; height: 70vmax; border-radius: 50%;
  filter: blur(80px); opacity: .5; pointer-events: none;
}
body::before {
  background: radial-gradient(circle, var(--violet), transparent 60%);
  top: -25vmax; left: -20vmax; animation: drift1 18s ease-in-out infinite;
}
body::after {
  background: radial-gradient(circle, var(--pink), transparent 60%);
  bottom: -25vmax; right: -20vmax; animation: drift2 22s ease-in-out infinite;
}
@keyframes drift1 { 50% { transform: translate(15vmax, 10vmax) scale(1.2); } }
@keyframes drift2 { 50% { transform: translate(-12vmax, -8vmax) scale(1.15); } }

.wrap {
  position: relative; z-index: 1;
  max-width: 600px; margin: 0 auto;
  padding: 22px 16px 80px;
}

h1 {
  font-family: var(--display);
  font-weight: 700; font-size: 1.7rem;
  margin: 0 0 4px; letter-spacing: .01em;
}
.sub { color: var(--muted); font-size: .9rem; margin: 0 0 18px; }

/* ───────── Buttons ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 16px;
  padding: 16px 22px;
  font-family: var(--display); font-size: 1.15rem; font-weight: 600;
  color: #fff; cursor: pointer; width: 100%;
  background: linear-gradient(135deg, var(--pink), #ff6b3d);
  box-shadow: 0 10px 30px rgba(255, 46, 136, .35), inset 0 1px 0 rgba(255,255,255,.3);
  transition: transform .1s ease, filter .2s ease, box-shadow .2s ease;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(2px) scale(.99); box-shadow: 0 4px 14px rgba(255, 46, 136, .3); }
.btn.big { padding: 20px; font-size: 1.35rem; }
.btn.spin-btn {
  background: linear-gradient(135deg, var(--violet), var(--cyan));
  box-shadow: 0 10px 30px rgba(34, 224, 255, .3), inset 0 1px 0 rgba(255,255,255,.3);
}
.btn.spin-btn.stopping {
  background: linear-gradient(135deg, #ff3b3b, var(--gold));
  animation: btnpulse .7s ease-in-out infinite;
}
@keyframes btnpulse { 50% { transform: scale(1.03); } }
.btn.secondary { background: linear-gradient(135deg, #34335e, #232245); box-shadow: none; }
.btn.ghost { background: rgba(255,255,255,.05); border: 1px solid var(--glass-brd); box-shadow: none; color: var(--muted); font-size: .95rem; padding: 12px; }
.btn:disabled { filter: grayscale(.6) brightness(.6); cursor: not-allowed; transform: none; }

/* ───────── Inputs ───────── */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 7px; font-weight: 700; }
.input {
  width: 100%; padding: 16px; font-size: 1.15rem;
  border-radius: 14px; border: 1px solid var(--glass-brd);
  background: rgba(0,0,0,.25); color: var(--text);
  text-align: center; letter-spacing: .06em; font-family: var(--display);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(34,224,255,.25); }

/* ───────── Glass panels ───────── */
.panel {
  background: var(--glass);
  border: 1px solid var(--glass-brd);
  border-radius: 22px;
  padding: 18px;
  margin-bottom: 16px;
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 12px 36px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.08);
}
.panel-title {
  font-family: var(--display); font-weight: 600; font-size: 1.05rem;
  margin: 0 0 12px; display: flex; align-items: center; gap: 8px;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: .85rem; }
.center { text-align: center; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

/* ───────── Roulette ───────── */
.roulette-stage { display: flex; flex-direction: column; align-items: center; padding: 4px 0 8px; }
.roulette-label { color: var(--muted); font-size: .8rem; letter-spacing: .2em; margin-bottom: 12px; text-transform: uppercase; }
.roulette-ring {
  --size: clamp(180px, 56vw, 240px);
  width: var(--size); height: var(--size);
  border-radius: 50%; padding: 12px; position: relative;
  background: conic-gradient(from 0deg, var(--pink), var(--gold), var(--cyan), var(--violet), var(--pink));
  box-shadow: 0 0 50px rgba(123,92,255,.45), inset 0 0 18px rgba(0,0,0,.5);
}
.roulette-ring::after {
  content: ""; position: absolute; top: -6px; left: 50%; transform: translateX(-50%);
  border-left: 9px solid transparent; border-right: 9px solid transparent;
  border-top: 16px solid var(--gold);
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.5)); z-index: 3;
}
.roulette-ring.spinning { animation: ringspin .7s linear infinite; }
@keyframes ringspin { to { transform: rotate(360deg); } }
.roulette-disc {
  width: 100%; height: 100%; border-radius: 50%;
  background: radial-gradient(circle at 50% 32%, #2c285a, #110f28 72%);
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 8px 24px rgba(0,0,0,.7), inset 0 -2px 8px rgba(255,255,255,.05);
}
.roulette-ring.spinning .roulette-disc { animation: ringspin .7s linear infinite reverse; }
.number {
  font-family: var(--display); font-weight: 700; line-height: 1;
  font-size: clamp(3.4rem, 20vw, 6rem);
  color: var(--gold);
  text-shadow: 0 0 24px rgba(255, 210, 63, .6), 0 4px 10px rgba(0,0,0,.5);
  transition: transform .18s cubic-bezier(.2,1.6,.4,1);
}
.number.spin { color: var(--cyan); text-shadow: 0 0 26px rgba(34,224,255,.7); filter: blur(.6px); }
.number.pop { animation: numpop .4s cubic-bezier(.2,1.6,.4,1); }
@keyframes numpop { 0% { transform: scale(.4); } 60% { transform: scale(1.3); } 100% { transform: scale(1); } }
.remaining-pill {
  margin-top: 14px; font-family: var(--display); font-weight: 600;
  background: rgba(0,0,0,.3); border: 1px solid var(--glass-brd);
  padding: 6px 16px; border-radius: 999px; color: var(--muted); font-size: .9rem;
}

/* ゲスト最新数字（チケット風） */
.latest-ticket { text-align: center; }
.latest-ticket .roulette-ring { --size: clamp(150px, 44vw, 190px); margin: 0 auto; }

/* ───────── Bingo card ───────── */
.card-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 9px; }
.cell {
  position: relative; aspect-ratio: 1 / 1;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-weight: 600;
  font-size: clamp(1.1rem, 6vw, 1.9rem);
  background: linear-gradient(160deg, rgba(255,255,255,.1), rgba(255,255,255,.02));
  border-radius: 14px; border: 1px solid var(--glass-brd);
  color: var(--text); user-select: none; cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 4px 10px rgba(0,0,0,.25);
  transition: transform .1s ease, background .25s ease, box-shadow .25s ease;
}
.cell .num { position: relative; z-index: 2; }
.cell:active { transform: scale(.93); }
.cell.free { color: var(--gold); font-size: clamp(.7rem, 3.4vw, .95rem); letter-spacing: .04em; }

.cell.punched {
  background: radial-gradient(circle at 50% 38%, #5affb0, #15a35f 75%);
  border-color: transparent; color: #05311c;
  box-shadow: inset 0 3px 10px rgba(0,0,0,.35), 0 0 16px rgba(56,224,138,.45);
}
.cell.punched::before {
  content: ""; position: absolute; inset: 14%;
  border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, rgba(255,255,255,.9), rgba(255,255,255,0) 55%),
              radial-gradient(circle at 50% 60%, #ff3d6e, #b5174a);
  box-shadow: inset 0 3px 8px rgba(0,0,0,.5), 0 1px 2px rgba(0,0,0,.4);
  z-index: 1;
}
.cell.punched .num { color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.6); z-index: 2; }
.cell.pop { animation: stamp .45s cubic-bezier(.2,1.6,.4,1); }
@keyframes stamp { 0% { transform: scale(1.35) rotate(-6deg); } 60% { transform: scale(.92); } 100% { transform: scale(1); } }

.cell.remind {
  animation: remind .85s ease-in-out infinite;
}
@keyframes remind {
  0%, 100% { box-shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 0 0 rgba(255,46,136,0); border-color: var(--glass-brd); }
  50% {
    box-shadow: 0 0 0 2px var(--pink) inset, 0 0 18px rgba(255,46,136,.65);
    border-color: var(--pink); color: #ff7eae;
    background: linear-gradient(160deg, rgba(255,46,136,.25), rgba(255,46,136,.05));
  }
}
.cell.shake { animation: shake .35s; }
@keyframes shake {
  0%,100% { transform: translateX(0); } 20% { transform: translateX(-7px); }
  40% { transform: translateX(7px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(5px); }
}

/* ───────── Reach banner ───────── */
.reach-banner {
  text-align: center; font-family: var(--display); font-weight: 700;
  font-size: 1.8rem; letter-spacing: .1em; padding: 10px 0;
  background: linear-gradient(90deg, var(--gold), #ff8a3d, var(--gold));
  background-size: 200% auto;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 2s linear infinite, reachpulse 1s ease-in-out infinite;
  filter: drop-shadow(0 2px 8px rgba(255,138,61,.5));
}
@keyframes shimmer { to { background-position: 200% center; } }
@keyframes reachpulse { 50% { transform: scale(1.07); } }

/* ───────── BINGO overlay ───────── */
.bingo-overlay {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 40%, rgba(30,20,60,.7), rgba(6,6,18,.92));
  backdrop-filter: blur(6px);
}
.bingo-overlay .big {
  font-family: var(--display); font-weight: 700;
  font-size: clamp(3rem, 18vw, 6rem); letter-spacing: .04em;
  background: linear-gradient(90deg, var(--gold), var(--pink), var(--cyan), var(--gold));
  background-size: 300% auto;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: pop .55s cubic-bezier(.2,1.6,.3,1), shimmer 2.5s linear infinite;
  text-shadow: 0 0 40px rgba(255,210,63,.3);
}
@keyframes pop { from { transform: scale(.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.bingo-overlay .rankline { margin-top: 16px; font-family: var(--display); font-size: 1.4rem; color: var(--gold); }
.bingo-overlay .tap-hint { margin-top: 30px; color: var(--muted); font-size: .85rem; }

#confetti { position: fixed; inset: 0; z-index: 55; pointer-events: none; }

/* ───────── Drawn numbers ───────── */
.drawn-list { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.chip {
  min-width: 36px; padding: 6px 9px; text-align: center;
  font-family: var(--display); font-weight: 600; font-size: .92rem;
  background: rgba(255,255,255,.08); border: 1px solid var(--glass-brd);
  border-radius: 10px; color: var(--text);
}
.chip.new {
  background: linear-gradient(135deg, var(--gold), #ff8a3d);
  color: #3a2400; border-color: transparent;
  box-shadow: 0 0 14px rgba(255,210,63,.5); animation: chipin .4s ease;
}
@keyframes chipin { from { transform: scale(.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ───────── Host: QR / code ───────── */
.qr-box { text-align: center; }
.qr-box img { width: 220px; height: 220px; border-radius: 16px; background: #fff; padding: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.code {
  font-family: var(--display); font-weight: 700; font-size: 2.4rem;
  letter-spacing: .35em; text-indent: .35em; margin-top: 14px;
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.url { word-break: break-all; color: var(--muted); font-size: .78rem; margin-top: 2px; }

/* ───────── Host: players & history ───────── */
.players { display: flex; flex-direction: column; gap: 9px; }
.player-row {
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,.05); border: 1px solid var(--glass-brd);
  border-radius: 13px; padding: 11px 14px;
}
.player-row .pname { font-weight: 700; }
.player-row .pmeta { font-size: .74rem; color: var(--muted); }
.badge {
  font-family: var(--display); font-size: .76rem; font-weight: 600;
  padding: 5px 12px; border-radius: 999px; white-space: nowrap;
}
.badge.playing { background: rgba(255,255,255,.08); color: var(--muted); }
.badge.reach { background: linear-gradient(135deg, var(--gold), #ff8a3d); color: #3a2400; }
.badge.bingo { background: linear-gradient(135deg, var(--pink), var(--violet)); color: #fff; box-shadow: 0 0 14px rgba(255,46,136,.5); }
.badge.offline { opacity: .4; }

.history-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; background: rgba(255,255,255,.05);
  border: 1px solid var(--glass-brd); border-radius: 13px; margin-bottom: 8px;
}
.history-item .rank {
  width: 32px; height: 32px; border-radius: 50%; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-weight: 700;
  background: rgba(255,255,255,.12); color: var(--text);
}
.history-item .rank.r1 { background: linear-gradient(135deg, var(--gold), #ff8a3d); color: #3a2400; box-shadow: 0 0 14px rgba(255,210,63,.5); }
.history-item .rank.r2 { background: linear-gradient(135deg, #dfe4f3, #9aa0c0); color: #1a1c33; }
.history-item .rank.r3 { background: linear-gradient(135deg, #e0985a, #b06a2e); color: #2a1300; }
.history-item .pname { font-weight: 700; }

/* ───────── Toast ───────── */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(10px);
  background: rgba(20,18,45,.95); border: 1px solid var(--glass-brd);
  color: var(--text); padding: 12px 20px; border-radius: 999px;
  font-weight: 700; font-size: .9rem; box-shadow: 0 10px 30px rgba(0,0,0,.5);
  z-index: 70; opacity: 0; pointer-events: none; transition: opacity .25s ease, transform .25s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

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