html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0b0d1a;
}

canvas {
  display: block;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

/* ===== メニュー(タイトル / ゲームオーバー画面) ===== */
.menu {
  position: fixed;
  left: 0;
  right: 0;
  bottom: max(10px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  pointer-events: none; /* ボタン以外の部分はキャンバスへのタップを通す */
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
}

.menu-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.menu-buttons .btn {
  pointer-events: auto;
}

.menu-status {
  margin: 0;
  min-height: 1em;
  font-size: 13px;
  color: #ffd84f;
  text-shadow: 0 1px 3px #0b0d1a;
  text-align: center;
}

.menu-status:empty {
  display: none;
}

/* ===== ボタン ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 18px;
  border: 2px solid #5ef2ff;
  border-radius: 8px;
  background: rgba(13, 15, 31, 0.85);
  color: #5ef2ff;
  font: bold 15px system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover,
.btn:focus-visible {
  background: #5ef2ff;
  color: #0b0d1a;
  outline: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn-sub {
  border-color: #a9b0e0;
  color: #a9b0e0;
}

.btn-sub:hover,
.btn-sub:focus-visible {
  background: #a9b0e0;
  color: #0b0d1a;
}

/* ===== モーダル ===== */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(13, 15, 31, 0.75);
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  color: #ffffff;
  touch-action: manipulation;
}

.panel {
  width: 100%;
  max-width: 360px;
  max-height: 100%;
  overflow-y: auto;
  box-sizing: border-box;
  padding: 18px 18px 16px;
  border: 2px solid #5ef2ff;
  border-radius: 12px;
  background: #1a1240;
  box-shadow: 0 0 24px rgba(94, 242, 255, 0.25);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel h2 {
  margin: 0;
  font-size: 20px;
  color: #5ef2ff;
  text-align: center;
}

.status {
  margin: 0;
  font-size: 13px;
  color: #a9b0e0;
  text-align: center;
}

.status:empty {
  display: none;
}

.status.error {
  color: #ff4f8b;
}

.ranking-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ranking-list li {
  display: grid;
  grid-template-columns: 2.2em 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 15px;
}

.ranking-list li.me {
  background: rgba(255, 216, 79, 0.2);
  outline: 1px solid #ffd84f;
}

.ranking-list .rank {
  font-weight: bold;
  color: #a9b0e0;
}

.ranking-list li:nth-child(1) .rank { color: #ffd84f; }
.ranking-list li:nth-child(2) .rank { color: #dfe6f0; }
.ranking-list li:nth-child(3) .rank { color: #e0a36b; }

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

.ranking-list .score {
  font-weight: bold;
  font-variant-numeric: tabular-nums;
}

.entry-info {
  margin: 0;
  text-align: center;
  font-size: 18px;
  font-weight: bold;
  color: #ffd84f;
}

.entry-label {
  font-size: 13px;
  color: #a9b0e0;
}

#entry-name {
  min-height: 40px;
  padding: 0 12px;
  border: 2px solid #a9b0e0;
  border-radius: 8px;
  background: #0b0d1a;
  color: #ffffff;
  font-size: 16px; /* 16px未満だとiOSで自動ズームされる */
}

#entry-name:focus {
  border-color: #5ef2ff;
  outline: none;
}

.row {
  display: flex;
  gap: 10px;
}

.row .btn {
  flex: 1;
}
