:root {
  --pink: #ff6f91;
  --green: #4caf74;
  --sky: #cdeeff;
  --text-main: #2d2a26;
  --text-muted: #7a746c;
  --panel-bg: rgba(255, 255, 255, 0.96);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  font-family: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", sans-serif;
  color: var(--text-main);
  background: var(--sky);
}

.hidden {
  display: none !important;
}

/* --- サウンドパネル ------------------------------------------------------- */

.sound-controls {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.mute-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.9);
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.mute-btn.settings-btn {
  width: 32px;
  height: 32px;
  font-size: 14px;
}

.sound-panel {
  background: var(--panel-bg);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 180px;
}

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

.sound-row-label {
  flex-shrink: 0;
  white-space: nowrap;
  font-size: 12px;
}

.sound-mute-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: #eee;
  cursor: pointer;
  font-size: 12px;
}

.sound-volume {
  flex: 1;
}

/* --- 常時フッター ---------------------------------------------------------- */

.site-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  text-align: center;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.85);
  font-size: 11px;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
}

.footer-meta {
  color: var(--text-muted);
  margin: 2px 0 0;
}

.version-link {
  font-size: 10px;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 1px dotted currentColor;
}

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

/* --- 参加画面 --------------------------------------------------------------- */

.screen {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 60px;
}

.panel {
  background: var(--panel-bg);
  border-radius: 20px;
  padding: 24px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  text-align: center;
}

.panel h1 {
  margin: 0 0 8px;
  font-size: 24px;
}

.hint {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 16px;
}

.link-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
}

.link-row a,
.share-button {
  font-size: 12px;
  color: var(--text-main);
  text-decoration: none;
  background: #f2f2f2;
  border: none;
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
}

.link-row .home-link {
  background: #fff3d6;
}

.character-select {
  margin-bottom: 16px;
}

.character-select-label {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 6px;
}

.character-choice-row {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.character-choice {
  flex: 1;
  padding: 10px;
  border-radius: 12px;
  border: 2px solid #ddd;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
}

.character-choice.selected {
  border-color: var(--pink);
  background: #ffeef2;
  font-weight: 700;
}

#nickname-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #ccc;
  font-size: 14px;
  margin: 6px 0 14px;
}

.primary {
  background: var(--pink);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 12px 28px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
}

.mode-select {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.primary.chaos {
  background: #4a7ac9;
  font-size: 14px;
}

.chaos-wait-players {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 12px 0;
  text-align: left;
}

.chaos-wait-players .chaos-wait-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 10px;
  border-radius: 8px;
  background: #f2f2f2;
  font-size: 13px;
}

.chaos-result-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 14px 0;
  text-align: left;
}

.chaos-result-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 8px;
  background: #f4faee;
  font-size: 14px;
}

.chaos-result-row.me {
  background: #ffeef2;
  font-weight: 700;
}

.join-error {
  color: #c0392b;
  font-size: 12px;
  margin-top: 8px;
}

.ranking-groups {
  margin-top: 18px;
  text-align: left;
}

.ranking-group-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}

.ranking-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  padding: 4px 0;
  border-bottom: 1px dashed #eee;
}

.ranking-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-empty {
  color: var(--text-muted);
  justify-content: center;
}

/* --- 法務モーダル ------------------------------------------------------------ */

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

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

.legal-modal-box {
  position: relative;
  width: min(92vw, 640px);
  height: min(85vh, 720px);
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
}

.legal-modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.08);
  cursor: pointer;
}

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

/* --- 切断バナー -------------------------------------------------------------- */

.disconnect-banner {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
}

.disconnect-box {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  max-width: 320px;
}

.disconnect-title {
  font-weight: 700;
  margin: 0 0 8px;
}

/* --- ゲーム画面 -------------------------------------------------------------- */

#game-screen {
  position: fixed;
  inset: 0;
}

#canvas-host {
  position: absolute;
  inset: 0;
}

#canvas-host canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.hud {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 20;
  pointer-events: none;
}

.hud-nickname {
  display: inline-block;
  background: rgba(255, 255, 255, 0.75);
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
  max-width: 60vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud-height-row {
  background: rgba(255, 255, 255, 0.85);
  border-radius: 14px;
  padding: 8px 16px;
  display: flex;
  align-items: baseline;
  gap: 18px;
}

.hud-label {
  font-size: 11px;
  color: var(--text-muted);
}

.hud-value {
  font-size: 20px;
  font-weight: 700;
}

.hud-tier {
  margin-top: 6px;
  display: inline-block;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.hud-chaos-timer {
  margin-top: 6px;
  display: inline-block;
  background: #4a7ac9;
  color: #fff;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 14px;
  font-weight: 700;
}

.hud-opponents {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.hud-opponent-row {
  background: rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 11px;
  color: var(--text-main);
}

.hud-opponent-row.fallen {
  opacity: 0.5;
  text-decoration: line-through;
}

.cam-rotate-controls {
  position: absolute;
  bottom: 70px;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  gap: 20px;
  pointer-events: none;
}

.cam-rotate-btn {
  pointer-events: auto;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.85);
  font-size: 20px;
  color: var(--text-main);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  touch-action: none;
}

.cam-rotate-btn:active {
  background: rgba(255, 255, 255, 1);
}

.result-panel {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
}

.result-row {
  font-size: 14px;
  margin: 6px 0;
}

.result-row strong {
  font-size: 20px;
  color: var(--pink);
}

@media (max-width: 480px) {
  .panel {
    padding: 18px;
  }
}
