:root {
  color-scheme: dark;
  --bg: #1e1218;
  --panel: rgba(42, 23, 33, 0.92);
  --border: rgba(244, 114, 182, 0.45);
  --text: #fff1f2;
  --muted: #fbcfe8;
  --accent: #f472b6;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Hiragino Sans", sans-serif;
  touch-action: manipulation;
  user-select: none;
}

.abl-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100svh;
  max-width: 720px;
  margin: 0 auto;
  padding: max(8px, env(safe-area-inset-top)) 10px max(8px, env(safe-area-inset-bottom));
  gap: 8px;
}

.abl-topbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.abl-hud {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.abl-stat {
  background: rgba(49, 25, 38, 0.95);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px 8px;
  text-align: center;
}

.abl-label {
  display: block;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  color: #f9a8d4;
  font-weight: 800;
}

.abl-stat strong {
  font-size: 1.02rem;
  font-variant-numeric: tabular-nums;
}

.abl-audio-slot {
  flex-shrink: 0;
}

.abl-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 0 28px rgba(244, 114, 182, 0.16);
}

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

.abl-dialogue-box {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  background: rgba(24, 13, 20, 0.88);
  border: 1px solid rgba(244, 114, 182, 0.5);
  border-radius: 12px;
  padding: 9px 12px;
  backdrop-filter: blur(6px);
}

.abl-speaker-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.abl-speaker {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 800;
  background: linear-gradient(90deg, #ec4899, #f472b6);
  color: #fff;
  padding: 2px 10px;
  border-radius: 999px;
}

.abl-mini-link {
  border: 1px solid rgba(244, 114, 182, 0.45);
  background: rgba(49, 25, 38, 0.9);
  color: #fbcfe8;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
}

.abl-dialogue-text {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.5;
  color: #fff;
}

.abl-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  background: rgba(18, 9, 14, 0.62);
  backdrop-filter: blur(4px);
}

.abl-overlay[hidden] { display: none; }

.abl-card {
  width: min(100%, 420px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px 16px;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
  gap: 9px;
  text-align: center;
}

.abl-badge {
  align-self: center;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: #fff;
  background: linear-gradient(90deg, #ec4899, #fb7185);
  padding: 4px 12px;
  border-radius: 999px;
}

.abl-title { margin: 0; font-size: 1.4rem; font-weight: 900; }
.abl-subtitle { margin: -4px 0 0; font-size: 0.84rem; color: #f9a8d4; font-weight: 700; }
.abl-end-title { margin: 0; font-size: 1.18rem; color: #fde047; }
.abl-intro { margin: 0; font-size: 0.86rem; line-height: 1.55; color: #ffe4e6; }
.abl-rules {
  margin: 0;
  padding: 8px 10px;
  list-style: none;
  background: rgba(20, 10, 16, 0.72);
  border-radius: 10px;
  font-size: 0.8rem;
  color: #fbcfe8;
  line-height: 1.55;
  text-align: left;
}

.abl-final-score { font-size: 2.45rem; font-weight: 900; color: #f472b6; line-height: 1.1; }
.abl-final-score small { font-size: 1rem; color: var(--muted); }
.abl-summary, .abl-rank-status { margin: 0; font-size: 0.86rem; }
.abl-rank-status { color: #fde047; font-weight: 700; }

.abl-actions { display: flex; flex-direction: column; gap: 7px; margin-top: 2px; }
.abl-btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 0.94rem;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}
.abl-btn-primary { background: linear-gradient(90deg, #ec4899, #f43f5e); color: #fff; box-shadow: 0 4px 16px rgba(236, 72, 153, 0.4); }
.abl-btn-secondary { background: rgba(63, 30, 48, 0.92); color: var(--text); border: 1px solid var(--border); }
.abl-btn-x { background: #000; color: #fff; border: 1px solid #475569; }

.abl-choices {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  flex-shrink: 0;
}

.abl-choice-btn {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  background: rgba(49, 25, 38, 0.94);
  color: #fff1f2;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  transition: transform 0.08s ease, background 0.12s ease;
}
.abl-choice-btn:active { transform: scale(0.98); background: rgba(236, 72, 153, 0.35); }

.abl-dialog {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #27141e;
  color: var(--text);
  width: min(92vw, 440px);
  padding: 0;
}
.abl-dialog::backdrop { background: rgba(0, 0, 0, 0.8); }
.abl-dialog-body { padding: 18px 16px; display: flex; flex-direction: column; gap: 10px; }
.abl-dialog-body h2 { margin: 0; font-size: 1.12rem; }
.abl-gallery-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  max-height: 55svh;
  overflow-y: auto;
}
.abl-still-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(15, 8, 12, 0.7);
}
.abl-still-card img { display: block; width: 100%; height: auto; }
.abl-still-card p { margin: 6px 10px; font-size: 0.82rem; color: #fbcfe8; }
.abl-field { display: flex; flex-direction: column; gap: 6px; font-size: 0.88rem; }
.abl-field input {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #140a0f;
  color: #fff;
  font-size: 1rem;
}
.abl-help { margin: 0; font-size: 0.82rem; color: var(--muted); }
.abl-error { margin: 0; font-size: 0.85rem; color: #fca5a5; }
.abl-dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.abl-ranking-list {
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 45svh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.abl-ranking-row {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  background: rgba(20, 10, 16, 0.75);
  font-size: 0.9rem;
}
.abl-ranking-row.is-self { border: 1px solid var(--accent); background: rgba(244, 114, 182, 0.25); }
