* {
  box-sizing: border-box;
}

/* iPhoneは連打(ダブルタップ)をズーム操作と解釈することがある。
   manipulationにすると、ピンチズームは残したままダブルタップズームだけ止められる。 */
html {
  touch-action: manipulation;
}

:root {
  --font-body: "Zen Maru Gothic", -apple-system, "Hiragino Sans", "Yu Gothic", sans-serif;

  --felt: #1f5c45;
  --felt-dark: #143d2e;
  --felt-darker: #0b271d;
  --black: #16201c;
  --gold: #e0b23a;
  --gold-pale: #f4dfa1;
  --gold-dark: #a5822a;
  --cream: #fff8e7;
  --win: #2e7d5b;
  --win-pale: #d9f2e6;
  --lose: #b23a3a;
  --lose-pale: #fbe0e0;
  --text: #2c2416;
  --text-muted: #9a8f78;
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--cream);
  font-size: 16px;
  background:
    radial-gradient(circle at 50% -10%, rgba(224, 178, 58, 0.15), transparent 55%),
    linear-gradient(160deg, var(--felt-darker) 0%, var(--felt-dark) 45%, var(--felt) 100%);
  min-height: 100vh;
  min-height: 100dvh;
}

.screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 16px 90px;
}

.hidden {
  display: none !important;
}

.panel {
  background: linear-gradient(160deg, #1a2620 0%, var(--black) 100%);
  border-radius: 20px;
  padding: 32px;
  max-width: 440px;
  width: 100%;
  border: 2px solid var(--gold-dark);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(224, 178, 58, 0.15);
}

.panel h1 {
  margin: 0 0 10px;
  font-size: 26px;
  font-weight: 900;
  color: var(--gold-pale);
  text-align: center;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.hint {
  color: var(--cream);
  opacity: 0.85;
  font-size: 13px;
  text-align: center;
  line-height: 1.6;
}

.disclaimer {
  margin-top: 18px;
  color: var(--text-muted);
  font-size: 11px;
  text-align: center;
  line-height: 1.6;
}

.link-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 14px 0 0;
}

.rules-link,
.link-row .home-link,
.share-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(224, 178, 58, 0.12);
  border: 2px solid var(--gold-dark);
  color: var(--gold-pale);
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  text-decoration: none;
}

.rules-link:hover,
.link-row .home-link:hover,
.share-button:hover {
  background: var(--gold-dark);
  color: var(--black);
}

/* どの画面でも下に固定して出す、フッター一式(その他リンク・規約類・バージョン・著作権)。
   z-indexは音量パネル・規約モーダルより下にする。縦に積むと小さい画面でボタンに重なるため、
   2行に折りたたんでいる(footer-links / footer-meta)。 */
.site-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 55;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 12px;
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
  background: rgba(11, 39, 29, 0.92);
  border-top: 1px solid var(--gold-dark);
  backdrop-filter: blur(2px);
}

.site-footer a {
  color: var(--text-muted);
  text-decoration: underline;
  font-weight: 500;
}

.site-footer a:hover {
  color: var(--gold-pale);
}

.site-footer span {
  color: var(--text-muted);
}

.footer-links,
.footer-meta {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 2px 6px;
}

.copyright {
  color: var(--text-muted);
}

.sound-credit {
  color: var(--text-muted);
}

/* 【縦積みをやめて横並びにした理由】以前は🔊と⚙️を縦に積んでいたため、
   画面上端から約90pxぶんを固定で覆っていた。ゲーム画面は上から
   「名前バー → 局とドラの行 → 席」と詰まっているので、⚙️がドラの行に
   かぶって「場のチップ」が読めなくなっていた。
   横並びにすれば覆う高さが1段(約36px)で済み、名前バーの右端に収まる。 */
.sound-controls {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 50;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
}

.mute-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--black);
  border: 2px solid var(--gold-dark);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.settings-btn { width: 28px; height: 28px; font-size: 13px; }

.sound-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 10;
  width: 180px;
  background: var(--black);
  border: 2px solid var(--gold-dark);
  border-radius: 16px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sound-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sound-row-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--cream);
  width: 34px;
  flex: 0 0 auto;
}

.sound-mute-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--felt-dark);
  border: 2px solid var(--gold-dark);
  flex: 0 0 auto;
}

.sound-volume {
  flex: 1 1 auto;
  min-width: 0;
  accent-color: var(--gold);
}

.legal-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.legal-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.legal-modal-box {
  position: relative;
  width: 100%;
  max-width: 600px;
  height: min(80vh, 720px);
  height: min(80dvh, 720px);
  background: var(--cream);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  border: 3px solid var(--gold-dark);
}

.legal-modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid var(--gold-dark);
  color: var(--text);
  font-size: 15px;
  line-height: 1;
}

.legal-modal-frame {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--gold-pale);
  margin: 20px 0 8px;
}

input[type="text"] {
  width: 100%;
  height: 46px;
  border-radius: 10px;
  border: 2px solid var(--gold-dark);
  background: var(--cream);
  padding: 0 16px;
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="text"]:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(224, 178, 58, 0.25);
}

button {
  cursor: pointer;
  border-radius: 12px;
  border: 2px solid var(--gold-dark);
  background: #24352c;
  color: var(--cream);
  padding: 10px 18px;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 700;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.15s ease, opacity 0.15s ease;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
}

button:active {
  transform: translateY(0) scale(0.97);
  box-shadow: none;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

button.primary {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
  border-color: var(--gold-dark);
  color: #241505;
}

#join-button {
  width: 100%;
  margin-top: 22px;
  height: 50px;
  font-size: 17px;
}

.join-error {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--lose-pale);
  border: 2px solid var(--lose);
  color: var(--lose);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  animation: wobble 0.4s ease;
}

@keyframes wobble {
  0% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
  100% { transform: translateX(0); }
}

.disconnect-banner {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.65);
}

.disconnect-box {
  width: 100%;
  max-width: 380px;
  background: var(--black);
  border-radius: 20px;
  border: 2px solid var(--gold-dark);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  padding: 28px 24px;
  text-align: center;
}

.disconnect-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--gold-pale);
  margin: 0 0 8px;
}

.disconnect-box #reload-button {
  width: 100%;
  height: 46px;
  margin-top: 10px;
}

/* ---- 参加画面: ランキング ---- */

/* 各番付は横に並べず縦に積む(2026-08-16「最高所持チップと一撃は横にならべないでいい」)。
   横並びだと1列の幅が狭くなり、名前の省略が多発して読みづらかった。 */
.ranking-groups {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 22px;
}

.ranking-group {
  min-width: 0;
}

.ranking-group-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--gold-pale);
  text-align: center;
  margin-bottom: 8px;
}

.ranking {
  font-size: 13px;
}

/* 1行ピル(2026-08-16「ランキングのデザインが崩れすぎ」で作り直し):
   名前は伸び縮みして長ければ「…」で切り詰め(全文はtitle=ホバーで見える)、
   数値と「和了役」ボタンは絶対に折り返さない固定幅要素として右に並べる。
   以前はspace-between+絶対配置ボタンだったため、長い名前で数値が縦に割れたり
   ボタンが文字に覆いかぶさったりしていた。 */
.ranking-entry {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  margin-bottom: 6px;
  border-radius: 999px;
  background: rgba(224, 178, 58, 0.1);
  border: 1px solid var(--gold-dark);
  font-size: 12px;
  color: var(--cream);
}
.ranking-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}
.ranking-value {
  flex: 0 0 auto;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

/* 一撃最高和了点の「和了役」開閉(2026-08-16)。<details>を使い、summary行は
   通常のランキング行 + 行内の小さなボタン風ラベルという見た目にする。 */
.ranking-details > summary {
  list-style: none;
  cursor: pointer;
}
.ranking-details > summary::-webkit-details-marker {
  display: none;
}
.ranking-details-btn {
  flex: 0 0 auto;
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--gold-dark);
  color: #2a1f0e;
  font-weight: 700;
  white-space: nowrap;
}
.ranking-details[open] .ranking-details-btn {
  background: var(--cream);
}
.ranking-details-body {
  margin: -2px 0 8px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--gold-dark);
  font-size: 12px;
}
.ranking-details-kind {
  margin: 0 0 4px;
  font-size: 11px;
  opacity: 0.8;
}
/* 内訳の部品は結果画面(game.css)の見た目を参加画面向けに少し縮めて使う。 */
.ranking-details-body .result-hand {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-bottom: 6px;
}

@media (max-width: 480px) {
  /* 【下の余白を残す理由】フッター(利用規約・バージョン)は position:fixed で
     画面下に貼り付いている。ここで padding を 12px に上書きすると、
     スマホ幅のときだけパネルの下端がフッターの下に潜り込んで読めなくなる。
     左右だけ詰めて、下はフッターの高さぶんを必ず空けておく。 */
  .screen {
    padding: 12px 12px 84px;
  }

  .panel {
    padding: 24px 18px;
  }

  .panel h1 {
    font-size: 22px;
  }
}

/* --- バージョン表記 ------------------------------------------------------- */

/* フッターに出す。クリックするとリリースノートがポップアップで開く。
   主導線ではないので、著作権表示と同じくらい控えめにする。 */
.version-link {
  font-size: 10px;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 1px dotted currentColor;
}

.version-link:hover {
  color: var(--gold-pale);
}
