/* ===== みんきめ！ ゲームセンター風スタイル ===== */
:root {
  --pink: #ff2d95;
  --cyan: #00e5ff;
  --yellow: #ffe600;
  --purple: #b43cff;
  --bg: #07000f;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }

body {
  background:
    radial-gradient(ellipse at 50% -10%, #3a0a6b 0%, transparent 60%),
    radial-gradient(ellipse at 50% 110%, #00355c 0%, transparent 55%),
    var(--bg);
  color: #fff;
  font-family: "Hiragino Sans", "Noto Sans JP", sans-serif;
  min-height: 100dvh;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* 走査線 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,.03) 0 1px, transparent 1px 3px);
}

/* 暴走モード時の赤い点滅 */
body.rampage::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 30;
  animation: redpulse .22s infinite alternate;
}
@keyframes redpulse {
  from { box-shadow: inset 0 0 60px rgba(255,0,0,.35); }
  to   { box-shadow: inset 0 0 160px rgba(255,0,0,.8); }
}

#app {
  position: relative;
  z-index: 2;
  max-width: 520px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 20px);
  display: flex;
  flex-direction: column;
}

/* ===== ロゴ ===== */
.title { text-align: center; margin-bottom: 6px; }
.logo {
  margin: 0;
  font-family: "Dela Gothic One", sans-serif;
  font-size: clamp(40px, 12vw, 60px);
  font-weight: 400;
  line-height: 1.1;
  text-shadow: 0 0 6px #fff, 0 0 14px var(--pink), 0 0 28px var(--pink), 0 0 50px var(--pink);
  animation: flicker 4s infinite;
}
.logo span {
  display: inline-block;
  color: var(--yellow);
  text-shadow: 0 0 6px #fff, 0 0 14px var(--yellow), 0 0 30px #ff9d00;
  animation: bounce 1s infinite;
}
.sub {
  margin: 2px 0 0;
  font-family: "Orbitron", sans-serif;
  font-size: 12px;
  letter-spacing: .4em;
  color: var(--cyan);
  text-shadow: 0 0 8px var(--cyan);
}
@keyframes flicker { 0%,19%,21%,62%,64%,100% { opacity: 1; } 20%,63% { opacity: .55; } }
@keyframes bounce { 0%,100% { transform: translateY(0) rotate(8deg); } 50% { transform: translateY(-6px) rotate(8deg); } }

/* ===== 画面切替 ===== */
.screen { display: none; flex: 1; flex-direction: column; align-items: center; gap: 14px; }
.screen.active { display: flex; }

/* ===== メンバー登録 ===== */
.guide { margin: 6px 0 0; font-weight: 700; color: #ffd6f0; text-align: center; }
.count {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 10px;
  border-radius: 99px;
  font-family: "Orbitron", sans-serif;
  font-size: 12px;
  color: var(--cyan);
  border: 1px solid var(--cyan);
}
.member-list {
  width: 100%;
  min-height: 120px;
  margin: 0;
  padding: 16px 10px;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px 6px;
  border: 2px solid rgba(0,229,255,.5);
  border-radius: 18px;
  background: rgba(0,10,30,.5);
  box-shadow: inset 0 0 20px rgba(0,229,255,.15), 0 0 16px rgba(0,229,255,.25);
}
.member-list:empty::before {
  content: "まだ誰もいません";
  grid-column: 1 / -1;
  align-self: center;
  text-align: center;
  color: rgba(255,255,255,.4);
}
.member {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  animation: pop .35s cubic-bezier(.2,1.6,.4,1);
}
.member img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid var(--yellow);
  background: #000;
  box-shadow: 0 0 10px var(--yellow);
}
.member .name {
  max-width: 72px;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.member .del {
  position: absolute;
  top: -6px;
  right: 0;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--pink);
  color: #fff;
  font-weight: 900;
  line-height: 24px;
  box-shadow: 0 0 8px var(--pink);
}
@keyframes pop { from { transform: scale(0); } to { transform: scale(1); } }

.add-row { width: 100%; display: flex; gap: 8px; }
.add-row input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border: 2px solid var(--purple);
  border-radius: 12px;
  outline: none;
  background: rgba(20,0,40,.8);
  color: #fff;
  font-size: 16px;
  box-shadow: 0 0 10px rgba(180,60,255,.4);
}

/* ===== ボタン ===== */
.btn {
  padding: 12px 18px;
  border: none;
  border-radius: 14px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  cursor: pointer;
  transition: transform .1s;
}
.btn:active { transform: scale(.95); }
.btn:disabled { opacity: .35; filter: grayscale(.7); }
.btn-neon {
  white-space: nowrap;
  background: linear-gradient(135deg, var(--pink), var(--purple));
  box-shadow: 0 0 14px var(--pink);
}
.btn-sub {
  padding: 8px 16px;
  font-size: 14px;
  background: transparent;
  border: 2px solid rgba(255,255,255,.35);
  color: rgba(255,255,255,.85);
}
.btn-big {
  width: 100%;
  margin-top: auto;
  padding: 16px;
  font-family: "Dela Gothic One", sans-serif;
  font-size: 24px;
  font-weight: 400;
  letter-spacing: .05em;
  color: #3a1400;
  background: linear-gradient(180deg, #ffe600, #ff9d00);
  text-shadow: 0 1px 0 rgba(255,255,255,.6);
  box-shadow: 0 6px 0 #b35c00, 0 0 24px rgba(255,200,0,.6);
}
.btn-big:active { transform: translateY(4px); box-shadow: 0 2px 0 #b35c00, 0 0 24px rgba(255,200,0,.6); }
.btn-spin {
  font-family: "Orbitron", "Dela Gothic One", sans-serif;
  font-size: 30px;
  font-weight: 900;
  animation: glow 1.2s infinite;
}
.btn-spin:disabled { animation: none; }
@keyframes glow { 50% { box-shadow: 0 6px 0 #b35c00, 0 0 44px rgba(255,220,0,.95); } }

/* ===== ルーレット ===== */
.status-row { height: 34px; display: flex; align-items: center; justify-content: center; }
.extra-badge {
  padding: 4px 16px;
  border: 2px solid var(--pink);
  border-radius: 99px;
  font-family: "Dela Gothic One", sans-serif;
  font-size: 18px;
  color: #fff;
  background: rgba(255,45,149,.2);
  text-shadow: 0 0 8px var(--pink);
  box-shadow: 0 0 16px var(--pink);
}
.wheel-wrap { position: relative; width: min(92vw, 50dvh, 460px); aspect-ratio: 1; }
.wheel-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 18px rgba(255,45,149,.55));
}
.fx-shake { animation: shake .5s; }
.fx-glitch { animation: glitch .45s steps(2); }
@keyframes shake {
  10%,90% { transform: translate(-2px,1px); }
  20%,80% { transform: translate(4px,-2px); }
  30%,50%,70% { transform: translate(-8px,3px); }
  40%,60% { transform: translate(8px,-3px); }
}
@keyframes glitch {
  0%   { filter: none; transform: none; }
  25%  { filter: hue-rotate(90deg) saturate(3); transform: translate(-6px,2px) skewX(6deg); }
  50%  { filter: invert(1); transform: translate(6px,-2px); }
  75%  { filter: hue-rotate(-90deg); transform: translate(-3px,0) skewX(-6deg); }
  100% { filter: none; transform: none; }
}

.peek-row { height: 70px; display: flex; align-items: center; justify-content: center; }
.peek { display: flex; align-items: center; gap: 8px; animation: peekIn .3s cubic-bezier(.2,1.6,.4,1); }
.peek img {
  width: 58px;
  height: 58px;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 16px var(--yellow);
}
.peek-name, .peek-text { font-family: "Dela Gothic One", sans-serif; font-size: 22px; }
.peek-name { color: var(--yellow); text-shadow: 0 0 10px #ff9d00; }
.peek-text { text-shadow: 0 0 10px var(--pink); }
@keyframes peekIn { from { transform: scale(2.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ===== 演出レイヤー ===== */
.fx-flash { position: fixed; inset: 0; z-index: 60; pointer-events: none; opacity: 0; }

.fx-cutin {
  --c: var(--yellow);
  position: fixed;
  left: 0;
  right: 0;
  top: 40%;
  z-index: 50;
  padding: 14px 0;
  pointer-events: none;
  text-align: center;
  background: linear-gradient(90deg, transparent, rgba(0,0,0,.88) 12%, rgba(0,0,0,.88) 88%, transparent);
  border-top: 3px solid var(--c);
  border-bottom: 3px solid var(--c);
  box-shadow: 0 0 30px var(--c);
  animation: cutin var(--d, 900ms) ease both;
}
.fx-cutin span {
  display: inline-block;
  font-family: "Dela Gothic One", sans-serif;
  font-size: clamp(28px, 10vw, 52px);
  white-space: nowrap;
  color: #fff;
  text-shadow: 0 0 8px var(--c), 0 0 22px var(--c), 3px 3px 0 #000;
}
.fx-cutin.rampage { --c: #ff2020; }
.fx-cutin.nudge   { --c: var(--pink); }
.fx-cutin.final   { --c: var(--yellow); }
.fx-cutin.glitch  { --c: var(--purple); }
.fx-cutin.glitch span { animation: glitchText .1s infinite; }
@keyframes cutin {
  0%   { transform: skewY(-6deg) translateX(100%); opacity: 0; }
  15%  { transform: skewY(-6deg) translateX(0); opacity: 1; }
  82%  { transform: skewY(-6deg) translateX(0); opacity: 1; }
  100% { transform: skewY(-6deg) translateX(-100%); opacity: 0; }
}
@keyframes glitchText {
  0%   { transform: translate(0); }
  33%  { transform: translate(-4px,2px); }
  66%  { transform: translate(4px,-2px); }
}

.fx-confetti { position: fixed; inset: 0; z-index: 45; width: 100%; height: 100%; pointer-events: none; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 30px);
  z-index: 70;
  transform: translateX(-50%);
  padding: 10px 20px;
  border-radius: 99px;
  background: rgba(0,0,0,.85);
  border: 1px solid var(--cyan);
  font-size: 14px;
}

/* ===== モーダル共通 ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 20px;
  overflow: hidden;
  background: rgba(5,0,15,.94);
}

/* ===== カメラ ===== */
.camera-box {
  position: relative;
  width: min(84vw, 380px);
  aspect-ratio: 1;
  overflow: hidden;
  border: 3px solid var(--cyan);
  border-radius: 24px;
  background: #000;
  box-shadow: 0 0 24px var(--cyan);
}
.camera-box video { display: block; width: 100%; height: 100%; object-fit: cover; }
.camera-box video.mirror { transform: scaleX(-1); }
.camera-guide {
  position: absolute;
  left: 12.5%;
  top: 12.5%;
  width: 75%;
  height: 75%;
  border: 3px dashed var(--yellow);
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 0 0 999px rgba(0,0,0,.45);
}
.camera-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  text-align: center;
  background: #000;
}
.camera-hint { margin: 0; color: var(--yellow); font-weight: 700; }
.camera-actions { width: min(84vw, 380px); display: flex; align-items: center; justify-content: space-between; }
.shutter {
  width: 76px;
  height: 76px;
  border: 6px solid rgba(255,255,255,.4);
  border-radius: 50%;
  background: #fff;
  background-clip: padding-box;
  box-shadow: 0 0 20px #fff;
}
.shutter:active { transform: scale(.9); }

/* ===== 結果 ===== */
.result { overflow-y: auto; justify-content: safe center; }
.result::before {
  content: "";
  position: fixed;
  left: 50%;
  top: 42%;
  z-index: -1;
  width: 180vmax;
  height: 180vmax;
  transform: translate(-50%,-50%);
  background: repeating-conic-gradient(rgba(255,230,0,.16) 0 10deg, transparent 10deg 20deg);
  animation: rays 12s linear infinite;
}
@keyframes rays { to { transform: translate(-50%,-50%) rotate(360deg); } }
.result-sub { font-weight: 800; color: var(--cyan); text-shadow: 0 0 8px var(--cyan); }
.jackpot {
  max-width: 100%;
  white-space: nowrap;
  font-family: "Dela Gothic One", "Orbitron", sans-serif;
  font-size: clamp(38px, 12vw, 64px);
  font-weight: 400;
  line-height: 1.2;
  background: linear-gradient(180deg, #fff6a0, #ffe600 45%, #ff9d00);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 12px rgba(255,200,0,.9));
  animation: jackpot .6s infinite alternate;
}
@keyframes jackpot { from { transform: scale(1); } to { transform: scale(1.08); } }
.result-face-wrap { position: relative; margin-top: 30px; }
.result-face {
  display: block;
  width: min(52vw, 220px);
  aspect-ratio: 1;
  border: 6px solid var(--yellow);
  border-radius: 50%;
  box-shadow: 0 0 30px var(--yellow), 0 0 80px #ff9d00;
  animation: zoomIn .6s cubic-bezier(.2,1.6,.4,1);
}
.crown {
  position: absolute;
  top: -58px;
  left: 50%;
  font-size: 64px;
  animation: crownDrop .8s .3s both cubic-bezier(.2,1.6,.4,1);
}
@keyframes zoomIn { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes crownDrop {
  from { transform: translate(-50%, -200px) rotate(-40deg); opacity: 0; }
  to   { transform: translate(-50%, 0) rotate(-10deg); opacity: 1; }
}
.result-name {
  max-width: 90vw;
  font-family: "Dela Gothic One", sans-serif;
  font-size: 36px;
  text-align: center;
  overflow-wrap: anywhere;
  text-shadow: 0 0 10px var(--pink), 0 0 24px var(--pink);
}
.result-label { margin-top: -10px; font-family: "Dela Gothic One", sans-serif; font-size: 24px; color: var(--yellow); }
.result-actions { width: 100%; max-width: 360px; margin-top: 8px; display: flex; flex-direction: column; gap: 10px; }
.result-list {
  max-width: 360px;
  margin: 0;
  padding: 10px 14px;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 14px;
  border: 1px solid rgba(255,230,0,.4);
  border-radius: 14px;
  background: rgba(0,0,0,.45);
}
.result-list li { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 800; }
.result-list img { width: 32px; height: 32px; border: 2px solid var(--yellow); border-radius: 50%; }
.result-list .goal { color: var(--yellow); }

/* ===== 画面ごとのロゴの大きさ ===== */
#app:not([data-screen="home"]) .logo { font-size: 26px; }
#app:not([data-screen="home"]) .sub { display: none; }

/* ===== 上部バー ===== */
.topbar {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
}
.topbar-title {
  font-family: "Dela Gothic One", sans-serif;
  font-size: 18px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 0 8px var(--pink);
}
.btn-small { padding: 8px 12px; font-size: 14px; }

/* ===== ホーム ===== */
.member-bar {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 2px solid rgba(0,229,255,.5);
  border-radius: 16px;
  background: rgba(0,10,30,.55);
  box-shadow: 0 0 14px rgba(0,229,255,.25);
}
.member-faces { flex: 1; min-width: 0; min-height: 40px; display: flex; align-items: center; overflow: hidden; }
.member-faces img {
  width: 40px;
  height: 40px;
  margin-left: -10px;
  border: 2px solid var(--yellow);
  border-radius: 50%;
  background: #000;
}
.member-faces img:first-child { margin-left: 0; }
.member-faces .more { margin-left: 8px; font-family: "Orbitron", sans-serif; font-size: 13px; color: var(--cyan); }
.member-faces .empty { font-size: 13px; color: rgba(255,255,255,.65); }

.machines { width: 100%; display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.machine {
  --c: var(--pink);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 8px 12px;
  border: 3px solid var(--c);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(0,0,0,.4)), #12002a;
  color: #fff;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 0 14px var(--c), inset 0 0 18px rgba(255,255,255,.06);
  transition: transform .1s;
}
.machine:nth-child(6n+1) { --c: var(--pink); }
.machine:nth-child(6n+2) { --c: var(--cyan); }
.machine:nth-child(6n+3) { --c: var(--yellow); }
.machine:nth-child(6n+4) { --c: #7dff3a; }
.machine:nth-child(6n+5) { --c: var(--purple); }
.machine:nth-child(6n+6) { --c: #ff7a1a; }
.machine.on:active { transform: scale(.95); }
.machine .m-icon { font-size: 44px; line-height: 1.1; filter: drop-shadow(0 0 8px var(--c)); }
.machine.on .m-icon { animation: wobble 2.4s ease-in-out infinite; }
.machine.on:nth-child(2) .m-icon { animation-delay: -1.2s; }
.machine .m-name { font-family: "Dela Gothic One", sans-serif; font-size: 16px; }
.machine .m-copy { font-size: 11px; color: rgba(255,255,255,.7); }
.machine .m-play {
  margin-top: 4px;
  font-family: "Orbitron", sans-serif;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .2em;
  color: var(--c);
  text-shadow: 0 0 8px var(--c);
  animation: blink 1s steps(2) infinite;
}
.machine.soon { filter: grayscale(.85) brightness(.65); box-shadow: none; }
.machine.soon::after {
  content: "COMING SOON";
  position: absolute;
  top: 14px;
  right: -36px;
  padding: 3px 38px;
  transform: rotate(35deg);
  background: var(--yellow);
  color: #000;
  font-family: "Orbitron", sans-serif;
  font-size: 9px;
  font-weight: 900;
}
.home-call {
  margin: 4px 0 0;
  font-family: "Dela Gothic One", sans-serif;
  font-size: 20px;
  letter-spacing: .05em;
  color: var(--yellow);
  text-shadow: 0 0 8px var(--yellow), 0 0 20px #ff9d00;
  animation: callGlow 1.6s ease-in-out infinite;
}
@keyframes callGlow {
  0%,100% { opacity: 1; transform: scale(1); }
  50% { opacity: .55; transform: scale(.97); }
}
@keyframes blink { 50% { opacity: 0; } }
@keyframes wobble {
  0%,100% { transform: rotate(0) scale(1); }
  20% { transform: rotate(-10deg) scale(1.1); }
  40% { transform: rotate(8deg) scale(1.05); }
  60% { transform: rotate(0) scale(1); }
}

/* ===== あみだくじ ===== */
.amida-wrap {
  position: relative;
  width: 100%;
  max-width: 460px;
  height: min(54dvh, 520px);
  border: 2px solid rgba(180,60,255,.6);
  border-radius: 18px;
  background: radial-gradient(ellipse at 50% 30%, rgba(80,0,140,.35), rgba(0,0,0,.5));
  box-shadow: 0 0 20px rgba(180,60,255,.35), inset 0 0 30px rgba(0,0,0,.6);
}
.amida-wrap canvas { display: block; width: 100%; height: 100%; }
.preset-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.chip {
  padding: 6px 14px;
  border: 2px solid var(--cyan);
  border-radius: 99px;
  background: transparent;
  color: var(--cyan);
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
}
.chip.active { background: var(--cyan); color: #001a22; box-shadow: 0 0 12px var(--cyan); }
.hint { margin: 0; font-size: 12px; color: rgba(255,255,255,.6); }

/* ===== メシガチャ ===== */
.gacha-wrap {
  position: relative;
  width: 100%;
  max-width: 460px;
  height: min(52dvh, 500px);
  border: 2px solid rgba(255,45,149,.6);
  border-radius: 18px;
  background: radial-gradient(ellipse at 50% 35%, rgba(120,0,80,.35), rgba(0,0,0,.5));
  box-shadow: 0 0 20px rgba(255,45,149,.35), inset 0 0 30px rgba(0,0,0,.6);
}
.gacha-wrap canvas { display: block; width: 100%; height: 100%; cursor: pointer; }
.genre-box { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.genre-list {
  width: 100%;
  max-height: 104px;
  overflow-y: auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}
.genre {
  padding: 5px 10px;
  border: 2px solid rgba(255,255,255,.25);
  border-radius: 99px;
  background: transparent;
  color: rgba(255,255,255,.45);
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  text-decoration: line-through;
}
.genre.on {
  border-color: var(--yellow);
  color: #fff;
  text-decoration: none;
  box-shadow: 0 0 8px rgba(255,230,0,.5);
}
.genre.add { border-style: dashed; border-color: var(--cyan); color: var(--cyan); text-decoration: none; }

/* ===== 結果：絵文字・ボーナスミッション ===== */
.result-emoji {
  width: min(52vw, 220px);
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: min(28vw, 120px);
  line-height: 1;
  border: 6px solid var(--yellow);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.25), rgba(255,157,0,.15) 60%, rgba(0,0,0,.3));
  box-shadow: 0 0 30px var(--yellow), 0 0 80px #ff9d00;
  animation: zoomIn .6s cubic-bezier(.2,1.6,.4,1);
}
.result-note {
  max-width: 340px;
  padding: 8px 14px;
  border: 2px dashed var(--pink);
  border-radius: 12px;
  background: rgba(255,45,149,.12);
  font-weight: 800;
  text-align: center;
}


/* ===== 順番決めレース ===== */
.race-wrap {
  position: relative;
  width: 100%;
  max-width: 460px;
  height: min(56dvh, 540px);
  border: 2px solid rgba(125,255,58,.55);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(0,40,20,.45), rgba(0,0,0,.55));
  box-shadow: 0 0 20px rgba(125,255,58,.3), inset 0 0 30px rgba(0,0,0,.6);
  overflow: hidden;
}
.race-wrap canvas { display: block; width: 100%; height: 100%; }

/* ===== チーム分け ===== */
.team-wrap {
  position: relative;
  width: 100%;
  max-width: 460px;
  height: min(56dvh, 540px);
  border: 2px solid rgba(45,140,255,.6);
  border-radius: 18px;
  background: radial-gradient(ellipse at 50% 85%, rgba(255,230,0,.12), rgba(0,0,0,.55) 60%);
  box-shadow: 0 0 20px rgba(45,140,255,.35), inset 0 0 30px rgba(0,0,0,.6);
  overflow: hidden;
}
.team-wrap canvas { display: block; width: 100%; height: 100%; }

/* ===== コイン＆サイコロ・お告げ・当番くじ（共通の枠） ===== */
.play-wrap {
  position: relative;
  width: 100%;
  max-width: 460px;
  height: min(52dvh, 500px);
  border: 2px solid rgba(255,230,0,.55);
  border-radius: 18px;
  background: radial-gradient(ellipse at 50% 45%, rgba(255,230,0,.1), rgba(0,0,0,.55) 65%);
  box-shadow: 0 0 20px rgba(255,230,0,.3), inset 0 0 30px rgba(0,0,0,.6);
  overflow: hidden;
}
.play-wrap canvas { display: block; width: 100%; height: 100%; }
.coin-wrap canvas { cursor: pointer; }
.oracle-wrap {
  border-color: rgba(232,50,45,.6);
  background: linear-gradient(180deg, #0a0630, #1a0a2a 60%, #2a0a1a);
  box-shadow: 0 0 20px rgba(232,50,45,.35), inset 0 0 30px rgba(0,0,0,.6);
}
.duty-wrap { border-color: rgba(255,45,149,.55); box-shadow: 0 0 20px rgba(255,45,149,.3), inset 0 0 30px rgba(0,0,0,.6); }

.coin-labels { width: 100%; display: flex; gap: 8px; }
.coin-labels label { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 800; color: #ffd6f0; white-space: nowrap; }
.coin-labels input { width: 100%; }
.coin-labels input, .oracle-form input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 2px solid var(--purple);
  border-radius: 12px;
  outline: none;
  background: rgba(20,0,40,.8);
  color: #fff;
  font-size: 16px;
}
.oracle-form { width: 100%; display: flex; flex-direction: column; gap: 8px; }

/* 台が奇数のとき、最後の台を横いっぱいに */
.machine:last-child:nth-child(odd) { grid-column: 1 / -1; }

/* 長いタイトル（DRAFT END!! など）は小さくして1行に収める */
.jackpot.long { font-size: clamp(28px, 9vw, 50px); }
/* 結果一覧があるときは顔を小さくして、ボタンが画面内に収まるようにする */
.result.has-list .result-face,
.result.has-list .result-emoji { width: min(34vw, 150px); }
.result.has-list .result-emoji { font-size: min(18vw, 80px); }
.result.has-list .result-face-wrap { margin-top: 22px; }
.result.has-list .crown { top: -44px; font-size: 48px; }

/* 公開先のサービスが画面右下にバッジを表示する場合、ボタンが隠れないよう下に余白を空ける */
body.has-host-badge #app { padding-bottom: calc(env(safe-area-inset-bottom) + 72px); }
body.has-host-badge .result { padding-bottom: 76px; }

/* ===== 結果：順位ランキング表 ===== */
.result.ranking-mode .result-face-wrap,
.result.ranking-mode .result-name,
.result.ranking-mode .result-label { display: none; }
.result-rank {
  width: 100%;
  max-width: 380px;
  border-collapse: separate;
  border-spacing: 0 6px;
  font-weight: 800;
}
.result-rank td {
  padding: 6px 10px;
  background: rgba(0,0,0,.55);
  border-top: 1px solid rgba(255,255,255,.12);
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.result-rank td:first-child { border-left: 1px solid rgba(255,255,255,.12); border-radius: 12px 0 0 12px; }
.result-rank td:last-child { border-right: 1px solid rgba(255,255,255,.12); border-radius: 0 12px 12px 0; }
.result-rank .rank {
  width: 5.2em;
  font-family: "Dela Gothic One", sans-serif;
  font-weight: 400;
  font-size: 16px;
  white-space: nowrap;
}
.result-rank .who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.result-rank .who img { flex: none; width: 34px; height: 34px; border: 2px solid #fff; border-radius: 50%; }
.result-rank .who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 1〜3位は金・銀・銅 */
.result-rank tr.top1 td { background: rgba(255,214,0,.22); border-color: rgba(255,214,0,.8); }
.result-rank tr.top1 .rank, .result-rank tr.top1 .who span { color: var(--yellow); text-shadow: 0 0 8px rgba(255,200,0,.8); }
.result-rank tr.top1 .who img { width: 42px; height: 42px; border-color: var(--yellow); box-shadow: 0 0 12px var(--yellow); }
.result-rank tr.top2 td { background: rgba(217,226,236,.14); border-color: rgba(217,226,236,.6); }
.result-rank tr.top2 .rank { color: #e6edf5; }
.result-rank tr.top3 td { background: rgba(224,138,74,.16); border-color: rgba(224,138,74,.6); }
.result-rank tr.top3 .rank { color: #f0a36b; }

/* ===== 名前入力キーボード ===== */
#name-input { cursor: pointer; caret-color: transparent; }
.kb-modal {
  position: fixed;
  inset: 0;
  z-index: 56;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(5,0,15,.6);
}
.kb-sheet {
  width: 100%;
  max-width: 520px;
  padding: 12px 10px calc(env(safe-area-inset-bottom) + 12px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-top: 3px solid var(--cyan);
  border-radius: 20px 20px 0 0;
  background: linear-gradient(180deg, #1a0638, #0a0018);
  box-shadow: 0 -8px 30px rgba(0,229,255,.35);
  animation: kbUp .22s ease-out;
}
body.has-host-badge .kb-sheet { padding-bottom: calc(env(safe-area-inset-bottom) + 64px); }
@keyframes kbUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.kb-head { display: flex; align-items: center; gap: 8px; }
.kb-display {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  border: 2px solid var(--purple);
  border-radius: 12px;
  background: rgba(20,0,40,.9);
  font-family: "Dela Gothic One", sans-serif;
  font-size: 24px;
  white-space: nowrap;
  overflow: hidden;
  box-shadow: 0 0 12px rgba(180,60,255,.45);
}
.kb-caret { width: 3px; height: 26px; margin-left: 2px; background: var(--yellow); animation: blink 1s steps(2) infinite; }
.kb-count { font-family: "Orbitron", sans-serif; font-size: 12px; color: var(--cyan); }
.kb-close {
  width: 40px;
  height: 40px;
  border: 2px solid rgba(255,255,255,.35);
  border-radius: 50%;
  background: transparent;
  color: #fff;
  font-size: 18px;
}
.kb-switches { display: flex; justify-content: space-between; gap: 8px; }
.kb-seg { display: flex; border: 2px solid var(--cyan); border-radius: 99px; overflow: hidden; }
.kb-seg button {
  padding: 6px 12px;
  border: none;
  background: transparent;
  color: var(--cyan);
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}
.kb-seg button.active { background: var(--cyan); color: #001a22; }
.kb-keys { display: flex; flex-direction: column; gap: 5px; }
.kb-row { display: flex; justify-content: center; gap: 4px; }
.kb-key {
  flex: 0 0 calc((100% - 36px) / 10);
  height: 42px;
  padding: 0;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px;
  background: linear-gradient(180deg, #3a1a66, #24104a);
  color: #fff;
  font-family: "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: 18px;
  font-weight: 800;
  box-shadow: 0 3px 0 #120526;
  touch-action: manipulation;
}
.kb-key:active { transform: translateY(2px); box-shadow: 0 1px 0 #120526; background: var(--pink); }
.kb-key.blank { visibility: hidden; }
.kb-actions { display: flex; gap: 6px; }
.kb-actions .kb-key { flex: 1; height: 46px; }
.kb-key.fn { background: linear-gradient(180deg, #0e4a5a, #08303c); color: var(--cyan); }
.kb-key.del { flex: 1.3; }
.kb-key.ok {
  flex: 2;
  background: linear-gradient(180deg, #ffe600, #ff9d00);
  color: #3a1400;
  font-family: "Dela Gothic One", sans-serif;
  font-weight: 400;
  box-shadow: 0 3px 0 #b35c00;
}

/* ===== 結果：出たコイン・サイコロの画像／大きな数字 ===== */
.result-visual {
  display: block;
  width: auto;
  max-width: min(78vw, 320px);
  max-height: min(34vh, 240px);
  filter: drop-shadow(0 0 18px rgba(255,230,0,.7));
  animation: zoomIn .6s cubic-bezier(.2,1.6,.4,1);
}
.result-big {
  font-family: "Orbitron", "Dela Gothic One", sans-serif;
  font-size: min(42vw, 190px);
  font-weight: 900;
  line-height: 1;
  background: linear-gradient(180deg, #fff6a0, #ffe600 45%, #ff9d00);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 18px rgba(255,200,0,.9));
  animation: zoomIn .6s cubic-bezier(.2,1.6,.4,1);
}

/* ===== 結果：当番表（左の列に当番名） ===== */
.result-rank.labeled .rank { width: 1%; padding-right: 18px; font-size: 15px; color: var(--yellow); }

/* ===== 結果：チームごとの表 ===== */
.result.teams-mode .result-face-wrap,
.result.teams-mode .result-label { display: none; }
.result.teams-mode .result-name { font-size: 26px; }
.result-teams {
  width: 100%;
  max-width: 400px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  align-items: start;
  gap: 10px;
}
.team-table {
  --c: #fff;
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border: 2px solid var(--c);
  border-radius: 14px;
  background: rgba(0,0,0,.6);
  box-shadow: 0 0 14px var(--c);
}
.team-table th {
  padding: 7px 8px;
  background: var(--c);
  color: #10001f;
  font-family: "Dela Gothic One", sans-serif;
  font-weight: 400;
  font-size: 15px;
  text-align: left;
  white-space: nowrap;
}
.team-table td { padding: 5px 8px; border-top: 1px solid rgba(255,255,255,.1); font-weight: 800; }
.team-table .who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.team-table .who img { flex: none; width: 30px; height: 30px; border: 2px solid var(--c); border-radius: 50%; }
.team-table .who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== 著作権表示（全ページ） ===== */
.copyright {
  margin-top: 14px;
  text-align: center;
  font-size: 11px;
  letter-spacing: .05em;
  color: rgba(255,255,255,.45);
}
.result .copyright { margin-top: 4px; }

/* ===== ホーム画面を1画面に収める ===== */
#app[data-screen="home"] { height: 100dvh; min-height: 0; }
#app[data-screen="home"] .title { margin-bottom: 4px; }
#app[data-screen="home"] .logo { font-size: clamp(32px, 9vw, 48px); }
#app[data-screen="home"] .sub { font-size: 10px; }
#app[data-screen="home"] .copyright { margin-top: 8px; }
#screen-home { min-height: 0; gap: 10px; }
#screen-home .member-bar { padding: 6px 10px; }
#screen-home .member-faces { min-height: 34px; }
#screen-home .member-faces img { width: 34px; height: 34px; }
#screen-home .home-call { margin: 0; font-size: clamp(16px, 4.6vw, 20px); }
/* 台は残りの高さを4段で均等に分け合う */
#screen-home .machines { flex: 1; min-height: 0; grid-auto-rows: minmax(0, 1fr); gap: 10px; }
#screen-home .machine { min-height: 0; justify-content: center; gap: 2px; padding: 6px 6px; }
#screen-home .machine .m-icon { font-size: clamp(26px, 5.2dvh, 44px); line-height: 1.05; }
#screen-home .machine .m-name { font-size: clamp(13px, 3.8vw, 16px); }
#screen-home .machine .m-copy { font-size: 11px; }
#screen-home .machine .m-play { margin-top: 2px; font-size: 12px; }
/* 画面が低い端末では説明文・PLAYを省いて収める */
@media (max-height: 740px) { #screen-home .machine .m-copy { display: none; } }
@media (max-height: 620px) { #screen-home .machine .m-play { display: none; } }

/* 絵文字の代わりに画像を使う台のアイコン（めしガチャ） */
.machine .m-icon-img { display: block; width: auto; height: 1.15em; }

/* ===== 当番くじ：スクロールできる当番一覧（文字サイズ固定） ===== */
.duty-rows {
  position: absolute;
  left: 10px;
  right: 10px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 2px;
}
.duty-row {
  flex: none;
  min-height: 36px;
  padding: 4px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-radius: 8px;
  background: rgba(255,255,255,.06);
  font-size: 15px;
  font-weight: 800;
}
.duty-row .duty-name { white-space: nowrap; }
.duty-row .duty-who { display: flex; align-items: center; gap: 8px; min-width: 0; color: rgba(255,255,255,.4); white-space: nowrap; }
.duty-row .duty-who span { overflow: hidden; text-overflow: ellipsis; }
.duty-row.done { background: rgba(255,230,0,.14); }
.duty-row.done .duty-who { color: var(--yellow); }
.duty-row .duty-who img { flex: none; width: 28px; height: 28px; border: 2px solid #fff; border-radius: 50%; }
.duty-row.flash { animation: dutyFlash .7s ease-out; }
@keyframes dutyFlash { from { background: rgba(255,230,0,.7); transform: scale(1.03); } to { background: rgba(255,230,0,.14); transform: none; } }
.duty-rows::-webkit-scrollbar { width: 4px; }
.duty-rows::-webkit-scrollbar-thumb { background: rgba(0,229,255,.6); border-radius: 4px; }

/* ===== 結果画面：長い表は枠の中だけスクロール（ボタンは常に見える） ===== */
.result-scroll {
  width: 100%;
  max-width: 400px;
  max-height: min(46dvh, 420px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}
.result-scroll:empty, .result-scroll:not(:has(> :not([hidden]))) { display: none; }
.result-scroll::-webkit-scrollbar { width: 4px; }
.result-scroll::-webkit-scrollbar-thumb { background: rgba(255,230,0,.6); border-radius: 4px; }

/* ===== ホーム：並べ替え・項目の選択 ===== */
.home-call-row, .home-edit-bar { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; }
.home-edit-btn { flex: none; padding: 4px 10px; font-size: 12px; }
.home-edit-bar { justify-content: space-between; }
.home-edit-hint { flex: 1; font-size: 12px; font-weight: 800; line-height: 1.3; color: var(--yellow); }
.home-edit-bar .chip { flex: none; padding: 5px 12px; font-size: 13px; }

/* 台の番号（編集モードで表示） */
.machine .m-slot {
  position: absolute;
  top: 6px;
  left: 8px;
  display: none;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 99px;
  background: var(--c);
  color: #10001f;
  font-family: "Orbitron", sans-serif;
  font-size: 11px;
  font-weight: 900;
  line-height: 20px;
}
#screen-home.editing .machine .m-slot { display: block; }
#screen-home.editing .machine { touch-action: none; cursor: grab; animation: wiggle .28s ease-in-out infinite alternate; }
#screen-home.editing .machine:nth-child(even) { animation-delay: -.14s; }
#screen-home.editing .machine .m-play { visibility: hidden; }
@keyframes wiggle { from { transform: rotate(-1.2deg); } to { transform: rotate(1.2deg); } }
.machine.drag-src { opacity: .25; }
.machine.drop-target { outline: 3px dashed #fff; outline-offset: 2px; }
.machine.empty { border-style: dashed; box-shadow: none; opacity: .75; --c: rgba(255,255,255,.5); }
/* ドラッグ中に指についてくる台 */
.machine-ghost {
  position: fixed;
  z-index: 80;
  margin: 0;
  pointer-events: none;
  opacity: .92;
  transform: scale(1.06) rotate(3deg);
  box-shadow: 0 0 30px var(--c), 0 12px 30px rgba(0,0,0,.6);
}

/* 項目の一覧（下から出る画面） */
.picker-sheet { max-height: 80dvh; }
.picker-head { display: flex; align-items: center; gap: 8px; }
.picker-title { flex: 1; font-family: "Dela Gothic One", sans-serif; font-size: 17px; color: var(--yellow); }
.picker-list { overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 2px; }
.picker-item {
  --c: #fff;
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 2px solid var(--c);
  border-radius: 14px;
  background: rgba(0,0,0,.4);
  color: #fff;
  font-family: inherit;
  text-align: left;
  box-shadow: 0 0 8px var(--c);
}
.picker-item.current { background: rgba(255,255,255,.12); }
.picker-item .p-icon { flex: none; width: 40px; font-size: 30px; line-height: 1; text-align: center; }
.picker-item .p-icon .m-icon-img { display: inline-block; height: 1.1em; width: auto; }
.picker-item .p-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.picker-item .p-name { font-family: "Dela Gothic One", sans-serif; font-size: 16px; }
.picker-item .p-copy { font-size: 11px; color: rgba(255,255,255,.65); }
.picker-item .p-tag { flex: none; font-size: 11px; font-weight: 800; color: var(--c); white-space: nowrap; }

/* 当番くじ：設定欄を詰めて1画面に収める */
.duty-wrap { height: min(48dvh, 480px); }
.duty-setup-head { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.duty-setup-head .chip { flex: none; padding: 5px 12px; font-size: 13px; }

/* ロゴ下の「みんなの決めアプ」（日本語の副題） */
.sub { font-family: "Dela Gothic One", sans-serif; letter-spacing: .3em; }
#app[data-screen="home"] .sub { font-size: 12px; }

/* ===== メンバーのグループ保存 ===== */
.group-bar { width: 100%; display: flex; align-items: center; gap: 6px; }
.group-label {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 800;
  color: var(--cyan);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.group-label.dirty { color: var(--yellow); }
.group-bar .chip { flex: none; padding: 5px 10px; font-size: 13px; }
.group-item {
  flex: none;
  display: flex;
  align-items: stretch;
  gap: 6px;
  border: 2px solid rgba(0,229,255,.6);
  border-radius: 14px;
  background: rgba(0,0,0,.4);
  overflow: hidden;
}
.group-item.current { border-color: var(--yellow); box-shadow: 0 0 10px rgba(255,230,0,.5); }
.group-item.new {
  justify-content: center;
  padding: 10px;
  border-style: dashed;
  color: var(--cyan);
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
}
.group-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 8px 10px;
  border: none;
  background: transparent;
  color: #fff;
  font-family: inherit;
  text-align: left;
}
.group-main .g-name { font-family: "Dela Gothic One", sans-serif; font-size: 16px; }
.group-main .g-faces { display: flex; }
.group-main .g-faces img { width: 28px; height: 28px; margin-left: -6px; border: 2px solid var(--yellow); border-radius: 50%; background: #000; }
.group-main .g-faces img:first-child { margin-left: 0; }
.group-main .g-date { font-size: 11px; color: rgba(255,255,255,.5); }
.g-del {
  flex: none;
  width: 64px;
  border: none;
  border-left: 1px solid rgba(255,255,255,.15);
  background: transparent;
  color: #fff;
  font-family: inherit;
  font-size: 18px;
}
.g-del.armed { background: #e8322d; font-size: 12px; font-weight: 800; }
.group-empty { margin: 6px 4px; font-size: 13px; color: rgba(255,255,255,.6); }

/* キーボードの見出し（グループ名の入力など） */
.kb-title { font-family: "Dela Gothic One", sans-serif; font-size: 15px; color: var(--yellow); }

/* 画面下のお知らせ：文字数に合わせて広がり、画面幅を超えるときだけ折り返す */
.toast { width: max-content; max-width: calc(100vw - 32px); text-align: center; line-height: 1.5; }

/* ===== STEP 1：ホームの入口（メンバー → みんなで決める） ===== */

.home-cta { width: 100%; display: flex; gap: 10px; align-items: stretch; }
.member-card {
  flex: 0 0 38%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  padding: 6px 10px;
  border: 2px solid rgba(0,229,255,.6);
  border-radius: 16px;
  background: rgba(0,10,30,.6);
  box-shadow: 0 0 12px rgba(0,229,255,.3);
  color: #fff;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform .1s;
}
.member-card:active { transform: scale(.96); }
.member-card .mc-title { max-width: 100%; font-size: 13px; font-weight: 800; color: var(--cyan); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#screen-home .member-card .member-faces { width: 100%; flex: none; min-height: 30px; }
#screen-home .member-card .member-faces img { width: 30px; height: 30px; margin-left: -8px; }
#screen-home .member-card .member-faces img:first-child { margin-left: 0; }
.member-card .member-faces .more { flex: none; margin-left: 6px; font-size: 13px; white-space: nowrap; }
.member-card .member-faces .empty { font-size: 12px; color: var(--yellow); }

.cta-main {
  flex: 1;
  min-width: 0;
  padding: 10px 8px;
  font-family: "Dela Gothic One", sans-serif;
  font-size: clamp(17px, 5vw, 22px);
  font-weight: 400;
  white-space: nowrap;
  color: #3a1400;
  background: linear-gradient(180deg, #ffe600, #ff9d00);
  text-shadow: 0 1px 0 rgba(255,255,255,.6);
  box-shadow: 0 5px 0 #b35c00, 0 0 22px rgba(255,200,0,.6);
  animation: glow 1.4s infinite;
}
.cta-main:active { transform: translateY(3px); box-shadow: 0 2px 0 #b35c00, 0 0 22px rgba(255,200,0,.6); }
#screen-home.editing .home-cta { display: none; }

/* 何を決める？（お題の一覧） */
.topic-list {
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 2px;
}
.topic-item {
  --c: #fff;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 6px 8px;
  border: 2px solid var(--c);
  border-radius: 14px;
  background: rgba(0,0,0,.4);
  box-shadow: 0 0 8px var(--c);
  color: #fff;
  font-family: inherit;
  cursor: pointer;
  transition: transform .1s;
}
.topic-item:active { transform: scale(.95); }
.topic-item .t-icon { font-size: 28px; line-height: 1.1; }
.topic-item .t-label { font-family: "Dela Gothic One", sans-serif; font-size: 15px; white-space: nowrap; }
.topic-item .t-tool { font-size: 11px; font-weight: 800; color: var(--c); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.topic-free { width: 100%; flex: none; margin-top: 4px; }
.topic-free.btn { background: transparent; border: 2px solid rgba(255,255,255,.35); color: rgba(255,255,255,.85); font-size: 14px; padding: 10px; }

/* ===== STEP 2：メンバー機能 ===== */
.member .face {
  position: relative;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: transform .1s;
}
.member .face:active { transform: scale(.92); }
.member .face img { display: block; }
.member.absent .face img { filter: grayscale(1) brightness(.55); border-color: rgba(255,255,255,.35); box-shadow: none; }
.member.absent .name { color: rgba(255,255,255,.45); text-decoration: line-through; }
.absent-tag {
  position: absolute;
  left: 50%;
  bottom: -2px;
  transform: translateX(-50%);
  padding: 1px 7px;
  border-radius: 99px;
  background: #3a3f5c;
  border: 1px solid rgba(255,255,255,.5);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}
.member-tip { margin: -4px 0 0; font-size: 12px; color: rgba(255,255,255,.55); text-align: center; }

.member-saved { width: 100%; }
.member-saved-title { margin: 0 0 6px; font-size: 13px; font-weight: 800; color: var(--cyan); }
.member-saved-list { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: none; }
.member-saved-list::-webkit-scrollbar { display: none; }
.saved-chip {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px 4px 4px;
  border: 2px solid rgba(0,229,255,.55);
  border-radius: 99px;
  background: rgba(0,10,30,.6);
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}
.saved-chip::after { content: "＋"; color: var(--yellow); }
.saved-chip:active { transform: scale(.94); }
.saved-chip:disabled { opacity: .35; }
.saved-chip img { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--yellow); background: #000; }

.member-sheet .ms-face { width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--yellow); background: #000; }
.ms-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ms-btn {
  padding: 14px 8px;
  font-size: 15px;
  background: rgba(255,255,255,.08);
  border: 2px solid rgba(255,255,255,.3);
}
.ms-main { grid-column: 1 / -1; font-size: 17px; border-color: var(--cyan); box-shadow: 0 0 10px rgba(0,229,255,.4); }
.ms-danger { border-color: rgba(255,80,80,.6); color: #ff9a9a; }

/* ===== STEP 3：グループ機能 ===== */
/* 誰で？ → 何を？ */
.topic-step {
  flex: none;
  padding: 2px 10px;
  border-radius: 99px;
  background: var(--yellow);
  color: #3a1400;
  font-family: "Dela Gothic One", sans-serif;
  font-size: 12px;
}
.topic-step-row { margin: 0; display: flex; }
.topic-who { flex: none; display: flex; flex-direction: column; gap: 6px; }
.topic-who-head { display: flex; align-items: center; gap: 8px; }
.topic-who-now { flex: 1; min-width: 0; font-size: 13px; font-weight: 800; color: var(--cyan); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topic-who-head .chip { flex: none; padding: 5px 10px; font-size: 12px; }
.topic-groups { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 4px; scrollbar-width: none; }
.topic-groups::-webkit-scrollbar { display: none; }
.who-chip {
  --c: #fff;
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 2px solid var(--c);
  border-radius: 99px;
  background: rgba(0,0,0,.4);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
  opacity: .75;
}
.who-chip .who-n { font-size: 11px; color: var(--c); }
.who-chip.current { opacity: 1; background: color-mix(in srgb, var(--c) 28%, transparent); box-shadow: 0 0 10px var(--c); }
.who-chip.current::before { content: "✓"; color: var(--c); }
.who-chip:active { transform: scale(.95); }

/* グループの種類に合うおすすめ */
.topic-item { position: relative; }
.topic-item.rec { background: color-mix(in srgb, var(--c) 16%, rgba(0,0,0,.4)); }
.t-rec {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  padding: 1px 8px;
  border-radius: 99px;
  background: var(--yellow);
  color: #3a1400;
  font-size: 10px;
  font-weight: 900;
  white-space: nowrap;
}
.topic-list { padding-top: 10px; }

/* グループの種類を選ぶ */
.cat-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.cat-item {
  --c: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 4px 10px;
  border: 2px solid var(--c);
  border-radius: 14px;
  background: rgba(0,0,0,.4);
  box-shadow: 0 0 8px var(--c);
  color: #fff;
  font-family: inherit;
  cursor: pointer;
}
.cat-item:active { transform: scale(.94); }
.cat-item.current { background: color-mix(in srgb, var(--c) 30%, transparent); }
.cat-item .c-icon { font-size: 30px; line-height: 1.1; }
.cat-item .c-label { font-family: "Dela Gothic One", sans-serif; font-size: 14px; }

/* グループ一覧の種類表示 */
.group-item:not(.new) { border-left: 6px solid var(--c, rgba(0,229,255,.6)); }
.group-main .g-head { display: flex; align-items: center; gap: 8px; max-width: 100%; }
.group-main .g-head .g-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-cat {
  flex: none;
  padding: 1px 8px;
  border-radius: 99px;
  border: 1px solid var(--c);
  color: var(--c);
  font-size: 11px;
  font-weight: 800;
}

/* ===== STEP 4：決定結果画面のボタン ===== */
.result-actions-row { display: flex; gap: 10px; }
.result-actions-row > .btn { flex: 1; min-width: 0; padding: 12px 6px; font-size: 14px; white-space: nowrap; }
.btn-alt {
  background: rgba(0,10,30,.7);
  border: 2px solid var(--cyan);
  box-shadow: 0 0 12px rgba(0,229,255,.45);
}
.btn-line {
  background: linear-gradient(180deg, #19d86a, #06c755);
  box-shadow: 0 4px 0 #04843a, 0 0 16px rgba(6,199,85,.55);
}
.btn-line:active { transform: translateY(3px); box-shadow: 0 1px 0 #04843a, 0 0 16px rgba(6,199,85,.55); }
.result-actions-sub > .btn { padding: 8px 6px; font-size: 13px; }
#alt-list .p-tag { color: #3a1400; background: var(--yellow); padding: 1px 8px; border-radius: 99px; }
#alt-list .p-tag:empty { display: none; }
.result-topic {
  padding: 3px 14px;
  border-radius: 99px;
  background: var(--yellow);
  color: #3a1400;
  font-family: "Dela Gothic One", sans-serif;
  font-size: 15px;
  max-width: 90vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 0 14px rgba(255,200,0,.6);
}

/* ===== STEP 5：LINE共有・招待 ===== */
.btn-invite { width: 100%; font-size: 15px; }
.welcome-sheet { gap: 10px; }
.welcome-brand {
  margin: 0;
  font-family: "Dela Gothic One", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  text-align: center;
  color: #fff;
}
.welcome-brand b { font-weight: 400; color: var(--yellow); font-size: 20px; text-shadow: 0 0 10px rgba(255,200,0,.7); }
.welcome-text { margin: 0; font-size: 14px; line-height: 1.6; color: #ffd6f0; text-align: center; }
.welcome-steps {
  margin: 0;
  padding: 10px 12px 10px 32px;
  border: 1px solid rgba(0,229,255,.4);
  border-radius: 12px;
  background: rgba(0,10,30,.5);
  font-size: 13px;
  line-height: 1.9;
  color: #e8e0f5;
}
.welcome-sheet .btn-big { margin-top: 4px; font-size: 18px; }

/* ===== STEP 6：履歴 ===== */
.title { position: relative; width: 100%; }
.history-btn {
  position: absolute;
  top: 2px;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 4px 8px;
  border: 2px solid rgba(0,229,255,.55);
  border-radius: 12px;
  background: rgba(0,10,30,.6);
  color: #fff;
  font-family: inherit;
  font-size: 18px;
  line-height: 1.1;
  cursor: pointer;
}
.history-btn span { font-size: 10px; font-weight: 800; color: var(--cyan); }
.history-btn:active { transform: scale(.94); }
#app:not([data-screen="home"]) .history-btn { display: none; }

.history-sheet { gap: 8px; }
.history-filters { flex: none; display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.history-filters::-webkit-scrollbar { display: none; }
.history-filters .chip { flex: none; padding: 5px 10px; font-size: 12px; white-space: nowrap; }
.history-stats {
  flex: none;
  padding: 8px 10px;
  border: 1px solid rgba(255,230,0,.5);
  border-radius: 12px;
  background: rgba(255,230,0,.08);
}
.hs-title { margin: 0 0 4px; font-size: 12px; font-weight: 800; color: var(--yellow); }
.hs-row { display: flex; flex-wrap: wrap; gap: 6px; }
.hs-item { padding: 2px 10px; border-radius: 99px; background: rgba(255,255,255,.1); font-size: 13px; font-weight: 800; }
.hs-item:first-child { background: var(--yellow); color: #3a1400; }
.history-list { flex: 1; min-height: 120px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.history-day { flex: none; margin: 6px 0 0; font-size: 12px; font-weight: 800; color: var(--cyan); }
.history-item {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px 8px 10px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 12px;
  background: rgba(0,0,0,.35);
}
.h-time { flex: none; width: 38px; font-family: "Orbitron", sans-serif; font-size: 12px; color: rgba(255,255,255,.6); }
.h-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.h-what { font-size: 12px; color: rgba(255,255,255,.7); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.h-result { font-family: "Dela Gothic One", sans-serif; font-size: 15px; color: #fff; overflow-wrap: anywhere; }
.h-del {
  flex: none;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.6);
  font-size: 16px;
}
.history-empty { margin: 16px 4px; font-size: 13px; color: rgba(255,255,255,.6); text-align: center; }
.history-foot { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.history-toggle { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 800; }
.history-toggle input { width: 18px; height: 18px; accent-color: var(--pink); }
.history-clear { padding: 5px 10px; font-size: 12px; }
.history-clear.armed { background: #e8322d; border-color: #e8322d; color: #fff; }
.history-note { flex: none; margin: 0; font-size: 11px; color: rgba(255,255,255,.5); }
.h-result.long { font-family: inherit; font-size: 12px; font-weight: 800; line-height: 1.5; }
/* 「さあ　どれで決める？？？」は狭い画面でも1行に収める */
#screen-home .home-call { white-space: nowrap; font-size: clamp(14px, 4.4vw, 20px); }

/* ===== STEP 7：広告（お知らせ）の枠 ===== */
.ad-slot { width: 100%; max-width: 360px; margin-top: 12px; animation: adIn .4s ease-out; }
@keyframes adIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.ad-card {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 10px 10px;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 14px;
  background: rgba(10,0,30,.8);
  color: #fff;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}
.ad-card:active { transform: scale(.98); }
.ad-tag {
  position: absolute;
  top: -8px;
  left: 10px;
  padding: 0 6px;
  border-radius: 4px;
  background: #3a3f5c;
  font-size: 10px;
  font-weight: 800;
  color: rgba(255,255,255,.85);
}
.ad-icon { flex: none; font-size: 26px; }
.ad-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ad-text b { font-size: 14px; }
.ad-text small { font-size: 11px; color: rgba(255,255,255,.65); }
.ad-go { flex: none; font-size: 12px; font-weight: 800; color: var(--yellow); white-space: nowrap; }
.ad-slot { min-height: 64px; }
.ad-slot.pending { visibility: hidden; animation: none; }
/* 枠の高さを固定（中身が出たときにボタンの位置が動かないように） */
.ad-slot { height: 72px; min-height: 0; }
.ad-card { height: 100%; }
.ad-text small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ad-tag { left: auto; right: 10px; }

/* ===== STEP 8：プレミアム ===== */
.premium-btn { right: auto; left: 0; border-color: rgba(255,230,0,.6); }
.premium-btn span { color: var(--yellow); }
.premium-sheet { gap: 10px; }
.premium-status {
  flex: none;
  margin: 0;
  padding: 6px 12px;
  border-radius: 99px;
  background: rgba(255,255,255,.1);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}
.premium-status.on { background: var(--yellow); color: #3a1400; }
.premium-features { flex: 1; min-height: 0; overflow-y: auto; margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.pf-item {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid rgba(255,230,0,.45);
  border-radius: 12px;
  background: rgba(255,230,0,.06);
}
.pf-item.soon { border-color: rgba(255,255,255,.18); background: rgba(0,0,0,.3); opacity: .75; }
.pf-icon { flex: none; font-size: 24px; }
.pf-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pf-text b { font-size: 14px; }
.pf-text small { font-size: 11px; color: rgba(255,255,255,.65); }
.pf-tag { flex: none; font-size: 11px; font-weight: 800; color: var(--yellow); white-space: nowrap; }
.pf-item.soon .pf-tag { color: rgba(255,255,255,.6); }
.premium-free { flex: none; margin: 0; font-size: 12px; color: #9dffb0; text-align: center; }
.premium-sheet .btn-big { margin-top: 0; font-size: 18px; }

/* 「みんなで決める」を外したので、メンバーのカードを横幅いっぱいにする */
.home-cta.solo .member-card {
  flex: 1 1 auto;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
}
.home-cta.solo .member-card .mc-title { flex: none; max-width: 45%; font-size: 15px; }
#screen-home .home-cta.solo .member-card .member-faces { flex: 1; width: auto; min-width: 0; justify-content: flex-end; }
#screen-home .home-cta.solo .member-card .member-faces img { width: 34px; height: 34px; }

/* 上部バーの見出しに付ける絵（顔ルーレットのルーレットの絵など） */
.topbar-icon { display: inline-block; height: 1.25em; width: auto; vertical-align: -0.3em; }

/* 小さな画面では、上部バーの見出しを少し小さくして切れないようにする */
@media (max-width: 389px) {
  .topbar-title { font-size: 15px; }
}
@media (max-width: 340px) {
  .topbar-title { font-size: 13px; }
  .topbar .btn-sub { padding: 8px 10px; font-size: 13px; }
}
/* パスタの絵は余白が多いので、見出しでは少し大きめに表示する */
.topbar-icon[src$="pasta.svg"] { height: 1.7em; vertical-align: -0.5em; }

/* ===== プライバシーポリシー・利用規約へのリンク（ホームだけ） ===== */
.doc-links { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 8px; font-size: 11px; color: rgba(255,255,255,.35); }
.doc-links a { color: rgba(255,255,255,.65); text-decoration: underline; text-underline-offset: 2px; padding: 4px 2px; }
#app:not([data-screen="home"]) .doc-links { display: none; }
#app[data-screen="home"] .doc-links + .copyright { margin-top: 2px; }

/* =====================================================================
 * 横向き（ランドスケープ）表示：LINEミニアプリのガイドラインに合わせる
 * ・左右44px・下21pxのセーフエリアに収める
 * ・ホームは台を4列×2段に、ツール画面と結果画面は「左に絵・右に操作」の2列にする
 * 縦向きの表示には影響しない（高さ540px以下の横向きのときだけ効く）
 * ===================================================================== */
@media (orientation: landscape) and (max-height: 540px) {
  #app {
    max-width: none;
    padding: calc(env(safe-area-inset-top) + 6px) max(44px, env(safe-area-inset-right)) max(21px, env(safe-area-inset-bottom)) max(44px, env(safe-area-inset-left));
  }
  /* ツール画面ではロゴを省いて高さを確保する */
  #app:not([data-screen="home"]) .title { display: none; }

  /* --- ホーム --- */
  #app[data-screen="home"] .title { margin-bottom: 2px; }
  #app[data-screen="home"] .logo { font-size: 26px; }
  #app[data-screen="home"] .sub { display: none; }
  .history-btn { top: 0; flex-direction: row; gap: 4px; padding: 3px 10px; font-size: 14px; }
  .history-btn span { font-size: 11px; }
  #screen-home { gap: 6px; }
  #screen-home .home-cta.solo .member-card { padding: 3px 14px; }
  #screen-home .home-cta.solo .member-card .member-faces { min-height: 28px; }
  #screen-home .home-cta.solo .member-card .member-faces img { width: 28px; height: 28px; }
  #screen-home .home-call { font-size: 15px; }
  #screen-home .home-edit-btn, #screen-home .home-edit-bar .chip { padding: 3px 10px; font-size: 12px; }
  #screen-home .machines { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  #screen-home .machine { padding: 4px; }
  #screen-home .machine .m-icon { font-size: clamp(20px, 7dvh, 34px); }
  #screen-home .machine .m-copy, #screen-home .machine .m-play { display: none; }
  .doc-links { margin-top: 4px; }
  #app[data-screen="home"] .doc-links + .copyright { margin-top: 0; }

  /* --- ツール画面：上部バーは横いっぱい、左に描画枠、右に操作 --- */
  .screen.active:not(#screen-home):not(#screen-members) {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    grid-auto-rows: min-content;
    column-gap: 20px;
    row-gap: 0;
    align-content: start;
    align-items: center;
  }
  .screen.active:not(#screen-home):not(#screen-members) > * { grid-column: 2; width: 100%; margin: 0 0 8px; }
  .screen.active:not(#screen-home):not(#screen-members) > .topbar { grid-column: 1 / -1; }
  /* 優先度をそろえるため、上と同じ :not(#…) を付ける */
  .screen.active:not(#screen-home):not(#screen-members) > .wheel-wrap,
  .screen.active:not(#screen-home):not(#screen-members) > .amida-wrap,
  .screen.active:not(#screen-home):not(#screen-members) > .gacha-wrap,
  .screen.active:not(#screen-home):not(#screen-members) > .race-wrap,
  .screen.active:not(#screen-home):not(#screen-members) > .team-wrap,
  .screen.active:not(#screen-home):not(#screen-members) > .play-wrap {
    grid-column: 1;
    grid-row: 2 / span 8;
    align-self: start;
    justify-self: center;
    width: 100%;
    max-width: none;
    height: calc(100dvh - 108px);
    margin: 0;
  }
  .screen.active:not(#screen-home):not(#screen-members) > .wheel-wrap { width: auto; max-width: 100%; aspect-ratio: 1; }
  .screen.active:not(#screen-home):not(#screen-members) > .btn-big { font-size: 20px; padding: 12px; }
  .screen.active:not(#screen-home):not(#screen-members) > .btn-spin { font-size: 24px; }
  .screen.active .genre-box { max-height: 40dvh; overflow-y: auto; }

  /* --- 結果画面：左に顔・画像・表、右に見出し・名前・ボタン --- */
  .result {
    display: grid;
    grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr);
    column-gap: 28px;
    row-gap: 0;
    align-content: safe center; /* 入りきらないときは上から並べて、見出しが切れないようにする */
    justify-items: center;
    padding: calc(env(safe-area-inset-top) + 10px) max(44px, env(safe-area-inset-right)) max(21px, env(safe-area-inset-bottom)) max(44px, env(safe-area-inset-left));
  }
  .result > * { grid-column: 2; margin-top: 0; margin-bottom: 6px; }
  .result > .result-face-wrap,
  .result > .result-visual,
  .result > .result-big,
  .result > .result-scroll {
    grid-column: 1;
    grid-row: 1 / span 12;
    align-self: center;
  }
  .result > .result-face-wrap { margin-top: 40px; }
  .result-face, .result.has-list .result-face { width: min(52dvh, 200px); }
  .result-emoji, .result.has-list .result-emoji { width: min(52dvh, 200px); font-size: min(30dvh, 110px); }
  .result-visual { width: min(62dvh, 240px); }
  .result > .result-scroll { width: 100%; max-height: calc(100dvh - 40px); }
  .jackpot, .jackpot.long { font-size: clamp(26px, 9dvh, 44px); }
  .result-name { font-size: 28px; max-width: 100%; }
  .result-label { margin-top: 0; font-size: 18px; }
  .result-actions { max-width: 380px; gap: 8px; }
  .result-actions > .btn-big { padding: 10px; font-size: 18px; }
  .result-actions-row > .btn { padding: 9px 4px; font-size: 13px; }
  .result .copyright { font-size: 10px; }
  .ad-slot { max-width: 380px; }
}
