* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; background: #0e1620; overflow: hidden;
  font-family: "Hiragino Sans", "Yu Gothic UI", "Meiryo", "Noto Sans JP", sans-serif;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none; overscroll-behavior: none;
}
button { font-family: inherit; touch-action: manipulation; }

#app {
  position: relative; height: 100vh; height: 100dvh; max-width: 1100px; margin: 0 auto;
  display: flex; flex-direction: column; background: #1c2430; overflow: hidden;
}

/* ---------- HUD ---------- */
#hud {
  flex: 0 0 auto; display: flex; align-items: center; gap: 10px;
  padding: 6px 12px; background: #1d3557; color: #fff; border-bottom: 3px solid #0f2038;
}
.stat { flex: 1; line-height: 1.1; min-width: 0; }
.stat .lab { display: block; font-size: 11px; opacity: .85; }
.stat .val { font-size: 14px; }
.stat b { font-size: 24px; font-variant-numeric: tabular-nums; }
#muteBtn {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; border: 2px solid #8aa4c8;
  background: #274a78; color: #fff; font-size: 18px; cursor: pointer; padding: 0;
}

/* ---------- 3Dステージ ---------- */
#stage { position: relative; flex: 1; min-height: 0; overflow: hidden; touch-action: manipulation; cursor: pointer; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#bubbles { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
#noGl { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; color: #fff; padding: 20px; }

/* 客の吹き出し(3D座標→画面座標に変換して頭上に表示) */
.bub {
  position: absolute; left: 0; top: 0; display: none; width: max-content; max-width: 150px; z-index: 5;
  margin-top: -6px; padding: 4px 9px; background: #fff; border: 2px solid #222; border-radius: 11px; color: #222;
  font-size: clamp(11px, 3.2vw, 16px); font-weight: 700; line-height: 1.25; text-align: center;
  will-change: transform; pointer-events: none;
}
.bub::after {
  content: ""; position: absolute; left: 50%; top: 100%; margin-left: -6px; border: 6px solid transparent; border-top-color: #222;
}
.bub .mark { position: absolute; right: -14px; top: -16px; font-size: 22px; animation: pop .25s ease-out; }
.bub.serve { border-color: #c40000; color: #c40000; background: #fffbe0; font-size: clamp(14px, 4.2vw, 22px); }

/* ---------- オーバーレイ ---------- */
.overlay {
  position: absolute; inset: 0; z-index: 20; background: rgba(10, 18, 28, .72);
  display: flex; padding: 14px; overflow: auto;
}
.hidden { display: none !important; }
.card {
  margin: auto; width: 100%; max-width: 440px; padding: 18px 20px; text-align: center; color: #222;
  background: #faf7ee; border: 4px solid #1d3557; border-radius: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
}
.card h1 { margin: 0 0 6px; font-size: clamp(26px, 7vw, 36px); color: #c40000; line-height: 1.15; }
.card h1 small { display: block; font-size: .5em; color: #1d3557; margin-top: 4px; }
.card h2 { margin: 0 0 10px; font-size: 22px; color: #1d3557; border-bottom: 3px double #1d3557; padding-bottom: 6px; }
.lead { margin: 6px 0 10px; font-weight: 700; }
.how { text-align: left; margin: 0 0 12px; padding-left: 1.3em; font-size: 14px; line-height: 1.55; }
.how li { margin-bottom: 4px; }
.how b { color: #c40000; }
.sub { font-size: 12px; color: #666; }
.best { margin: 8px 0; font-size: 13px; color: #1d3557; font-weight: 700; min-height: 1.3em; }
.btn {
  display: block; width: 100%; margin: 10px 0 6px; padding: 14px 10px; font-size: 20px; font-weight: 900; letter-spacing: .05em;
  color: #fff; background: linear-gradient(#e63b2e, #b3120a); border: 0; border-radius: 12px; cursor: pointer;
  box-shadow: 0 5px 0 #7a0a05; touch-action: manipulation;
}
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #7a0a05; }
.btn:disabled { filter: grayscale(.8) brightness(.9); }
.report { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 0 0 10px; text-align: left; font-size: 16px; }
.report dt { font-weight: 700; }
.report dd { margin: 0; text-align: right; font-weight: 900; }
.report b { font-size: 24px; color: #c40000; font-variant-numeric: tabular-nums; }
.rank { margin: 8px 0; padding: 8px; background: #fff3c4; border: 2px solid #d9a800; border-radius: 10px; display: flex; flex-direction: column; gap: 2px; }
.rank-lab { font-size: 12px; color: #7a5b00; }
.rank strong { font-size: 26px; color: #8a1c00; }

/* ---------- オンラインランキング ---------- */
.lb { margin-top: 10px; background: #fff; border: 2px solid #d8d2c0; border-radius: 12px; padding: 8px 12px; }
.lb-title { font-size: 14px; font-weight: 900; color: #1d3557; }
.lb-title small { margin-left: 6px; font-size: 11px; color: #999; font-weight: 400; }
.lb-list { margin: 4px 0 0; padding: 0; list-style: none; font-size: 14px; max-height: 172px; overflow-y: auto; }
.lb-list li { display: flex; justify-content: space-between; gap: 10px; padding: 2px 4px; }
.lb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-pt { font-weight: 900; color: #c40000; font-variant-numeric: tabular-nums; }
.lb-none { color: #999; }
.entry { margin-top: 8px; border-top: 2px dotted #ccc; padding-top: 8px; }
.entryrow { display: flex; gap: 8px; margin-top: 6px; }
.entryrow input {
  flex: 1; min-width: 0; font: inherit; font-size: 16px; padding: 6px 10px;
  border: 2px solid #1d3557; border-radius: 10px; user-select: text; -webkit-user-select: text;
}
.go2 {
  font: inherit; font-size: 15px; font-weight: 700; padding: 6px 14px; cursor: pointer;
  color: #fff; background: #1d3557; border: 0; border-radius: 10px; box-shadow: 0 3px 0 #0f2038;
}
.go2:active { transform: translateY(2px); box-shadow: 0 1px 0 #0f2038; }
.go2.sub { color: #1d3557; background: #fff; border: 2px solid #1d3557; }
.go2:disabled { opacity: .55; }
.rbtns { display: flex; gap: 8px; justify-content: center; margin-top: 10px; flex-wrap: wrap; }
.r-rank { margin-top: 4px; font-size: 14px; min-height: 18px; color: #1d3557; font-weight: 700; }
.foot { margin-top: 12px; display: flex; gap: 16px; justify-content: center; }
.foot .flink { color: #1d3557; font-size: 13px; text-decoration: underline; }

@media (max-height: 420px) { .card { padding: 10px 14px; } .how { font-size: 12px; margin-bottom: 6px; } .btn { padding: 8px; font-size: 16px; } .lead { display: none; } .card h1 { font-size: 22px; } }

@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
