* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #111; color: #fff; font-family: 'M PLUS Rounded 1c', sans-serif; user-select: none; -webkit-user-select: none; }
#game { position: fixed; inset: 0; }
#game canvas { display: block; width: 100%; height: 100%; touch-action: none; }
[hidden] { display: none !important; }

/* ---- スコープ ---- */
#scope { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
#scope .lens {
  position: absolute; left: 50%; top: 50%; width: 92vmin; height: 92vmin; transform: translate(-50%, -50%);
  border-radius: 50%; box-shadow: 0 0 0 200vmax #000, inset 0 0 6vmin 2vmin rgba(0, 0, 0, 0.85);
}
#scope .reticle { position: absolute; left: 50%; top: 50%; width: 92vmin; height: 92vmin; transform: translate(-50%, -50%); }
#scope line { stroke: #000; stroke-width: 0.35; }
#scope line.thick { stroke-width: 1.6; }
#scope .dots circle { fill: #000; }
#scope .center { fill: #e8322a; }

#crosshair { position: fixed; left: 50%; top: 50%; width: 22px; height: 22px; transform: translate(-50%, -50%); pointer-events: none; }
#crosshair::before, #crosshair::after { content: ''; position: absolute; background: rgba(255, 255, 255, 0.85); box-shadow: 0 0 2px #000; }
#crosshair::before { left: 10px; top: 0; width: 2px; height: 22px; }
#crosshair::after { top: 10px; left: 0; height: 2px; width: 22px; }
#flash { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(circle, rgba(255, 230, 170, 0.5), rgba(255, 200, 120, 0) 60%); opacity: 0; transition: opacity 0.15s; }
#flash.on { opacity: 1; transition: none; }

/* ---- HUD ---- */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hintArea {
  position: absolute; left: 50%; top: 50%; width: clamp(260px, 23vw, 460px); aspect-ratio: 1; transform: translate(-50%, -50%);
  border: 3px solid rgba(255, 216, 74, 0.9); border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 216, 74, 0.14) 0 58%, rgba(255, 216, 74, 0) 74%);
  box-shadow: 0 0 18px rgba(255, 216, 74, 0.8), inset 0 0 18px rgba(255, 216, 74, 0.25);
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.hud-left { position: absolute; left: 18px; top: 14px; text-shadow: 0 2px 4px #000; }
#timer { font-family: 'Dela Gothic One', sans-serif; font-size: 38px; letter-spacing: 1px; }
#timer.low { color: #ff5a4a; }
#ammo { margin-top: 4px; display: flex; gap: 5px; }
#ammo i { display: block; width: 8px; height: 26px; border-radius: 4px 4px 1px 1px; background: linear-gradient(#e9c46a 0 35%, #b08930 35%); box-shadow: 0 1px 3px #000; }
#ammo i.used { opacity: 0.2; }
#miss { margin-top: 8px; font-size: 18px; font-weight: 800; color: #ff5a4a; letter-spacing: 3px; }
#miss span { opacity: 0.25; color: #fff; }
.hud-zoom { position: absolute; left: 50%; bottom: 58px; transform: translateX(-50%); font-family: 'Dela Gothic One', sans-serif; font-size: 22px; text-shadow: 0 2px 4px #000; color: #b8f5a0; }
#breath { position: absolute; left: 50%; bottom: 44px; width: 160px; height: 5px; transform: translateX(-50%); background: rgba(255, 255, 255, 0.2); border-radius: 3px; overflow: hidden; }
#breathBar { height: 100%; width: 100%; background: #8fd3ff; }
#breath.tired #breathBar { background: #ff6a5a; }
#help { position: absolute; left: 0; right: 0; bottom: 12px; text-align: center; font-size: 12px; opacity: 0.75; text-shadow: 0 1px 3px #000; }
#hintButton {
  position: absolute; right: 18px; top: 350px; min-width: 126px; min-height: 46px; padding: 9px 18px;
  border: 2px solid rgba(255, 216, 74, 0.95); border-radius: 999px;
  background: rgba(65, 46, 0, 0.86); color: #fff4b0; font-family: inherit; font-size: 16px; font-weight: 800;
  letter-spacing: 0.05em; text-shadow: 0 2px 4px #000; box-shadow: 0 3px 12px rgba(0, 0, 0, 0.45), 0 0 12px rgba(255, 216, 74, 0.28);
  cursor: pointer; pointer-events: auto; touch-action: manipulation;
}
#hintButton:hover:not(:disabled) { background: rgba(131, 91, 0, 0.92); transform: translateY(-1px); }
#hintButton:active:not(:disabled) { transform: translateY(1px); }
#hintButton:disabled { border-color: rgba(255, 255, 255, 0.35); background: rgba(0, 0, 0, 0.45); color: rgba(255, 255, 255, 0.55); cursor: not-allowed; opacity: 0.7; box-shadow: none; }
#hint { position: absolute; right: 18px; top: 405px; max-width: 250px; text-align: right; font-size: 15px; font-weight: 800; text-shadow: 0 2px 4px #000; line-height: 1.5; }
#hint .ready { color: #ffd84a; }

/* 手配書 */
.poster { background: #efe2c4; color: #3a2a17; border-radius: 4px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5); text-align: center; font-family: 'Dela Gothic One', sans-serif; }
.poster.small { position: absolute; right: 18px; top: 14px; width: 150px; padding: 6px 8px 8px; transform: rotate(1.5deg); }
.poster.big { width: 220px; padding: 10px 12px 12px; transform: rotate(-2deg); flex: none; }
.poster-title { font-size: 20px; letter-spacing: 3px; }
.poster.big .poster-title { font-size: 30px; }
.poster-view { width: 100%; aspect-ratio: 3 / 4; background: #d8c8a4; border: 2px solid #6b5334; margin: 3px 0; }
.poster-name { font-size: 16px; letter-spacing: 4px; }
.poster.big .poster-name { font-size: 22px; }

#popups { position: absolute; left: 0; right: 0; top: 30%; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.pop { font-family: 'Dela Gothic One', sans-serif; font-size: 34px; text-shadow: 0 3px 8px #000; animation: pop 2.6s forwards; text-align: center; }
.pop small { display: block; font-family: 'M PLUS Rounded 1c', sans-serif; font-weight: 800; font-size: 17px; }
.pop.bad { color: #ff5a4a; }
.pop.good { color: #ffd84a; font-size: 56px; }
.pop.info { color: #fff; font-size: 22px; }
@keyframes pop { 0% { transform: scale(0.6); opacity: 0; } 8% { transform: scale(1.08); opacity: 1; } 14% { transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-20px); } }

/* ---- 画面 ---- */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }
#title { background: radial-gradient(ellipse at 50% 30%, rgba(40, 50, 70, 0.55), rgba(8, 10, 14, 0.92)); overflow-y: auto; padding: 24px 16px; align-items: flex-start; }
.title-inner { max-width: 760px; width: 100%; margin: auto; text-align: center; }
h1 { font-family: 'Dela Gothic One', sans-serif; font-size: clamp(48px, 10vw, 92px); line-height: 0.95; letter-spacing: 3px; color: #fff; text-shadow: 0 6px 0 #c0392b, 0 10px 24px rgba(0, 0, 0, 0.6); }
.lead { margin: 18px 0; font-size: 17px; line-height: 1.7; }
.brief { display: flex; gap: 28px; justify-content: center; align-items: center; margin: 10px 0 20px; flex-wrap: wrap; }
.features { list-style: none; text-align: left; font-size: 18px; line-height: 2; }
.features li::before { content: '✔ '; color: #ffd84a; }
.features .warn { color: #ff8a7a; font-size: 15px; line-height: 1.5; margin-top: 6px; }
.features .warn::before { content: '⚠ '; color: #ff8a7a; }
#levels { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.lv { width: 190px; padding: 14px 10px; border-radius: 10px; border: 2px solid #fff; background: #c0392b; color: #fff; cursor: pointer; font-family: inherit; }
.lv b { display: block; font-family: 'Dela Gothic One', sans-serif; font-size: 24px; }
.lv span { font-size: 13px; }
.lv:hover { transform: translateY(-2px); background: #d8473a; }
.lv.locked, .lv:disabled { background: #333; border-color: #555; color: #888; cursor: not-allowed; opacity: 0.75; transform: none; }
.lv.locked:hover, .lv:disabled:hover { background: #333; }
.controls { margin-top: 12px; font-size: 12px; opacity: 0.7; }
.title-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 20px; margin-bottom: 20px; }
.title-links a { color: #fff; font-size: 14px; font-weight: 800; text-underline-offset: 4px; }
.title-links a:hover, .title-links a:focus-visible { color: #ffd84a; }

/* ---- 最速タイムランキング ---- */
#leaderboard {
  margin: 22px auto 0; width: min(100%, 680px); padding: 18px 20px 14px;
  border: 1px solid rgba(255, 216, 74, 0.35); border-radius: 14px;
  background: linear-gradient(145deg, rgba(28, 31, 39, 0.96), rgba(12, 14, 19, 0.94));
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28); text-align: left;
}
.leaderboard-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; }
.leaderboard-heading h2 { font-family: 'M PLUS Rounded 1c', sans-serif; font-size: clamp(19px, 4vw, 25px); font-weight: 800; letter-spacing: 0.02em; line-height: 1.25; }
.eyebrow { margin-bottom: 4px; color: #ffd84a; font-family: 'Dela Gothic One', sans-serif; font-size: 10px; letter-spacing: 0.16em; }
.leaderboard-note { padding-bottom: 3px; color: rgba(255, 255, 255, 0.65); font-size: 12px; white-space: nowrap; }
.leaderboard-tabs { display: flex; gap: 8px; margin: 14px 0 10px; }
.leaderboard-tab {
  flex: 1; min-height: 38px; padding: 7px 10px; border: 1px solid rgba(255, 255, 255, 0.22); border-radius: 8px;
  background: rgba(255, 255, 255, 0.05); color: rgba(255, 255, 255, 0.74); font: inherit; font-size: 13px; font-weight: 800; cursor: pointer;
  touch-action: manipulation;
}
.leaderboard-tab:hover, .leaderboard-tab:focus-visible { border-color: #ffd84a; color: #fff; }
.leaderboard-tab[aria-selected="true"] { border-color: #ffd84a; background: rgba(192, 57, 43, 0.42); color: #fff; box-shadow: inset 0 -2px #ffd84a; }
.leaderboard-state { min-height: 1.4em; margin: 8px 0; color: rgba(255, 255, 255, 0.72); font-size: 12px; line-height: 1.5; }
.leaderboard-state.error { color: #ff988a; }
.leaderboard-table-wrap { overflow-x: auto; border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 8px; }
.leaderboard-table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
.leaderboard-table th, .leaderboard-table td { padding: 8px 7px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); text-align: left; }
.leaderboard-table th { color: rgba(255, 255, 255, 0.55); font-size: 10px; font-weight: 800; letter-spacing: 0.06em; }
.leaderboard-table th:first-child, .leaderboard-table td:first-child { width: 48px; text-align: center; }
.leaderboard-table th:nth-child(3), .leaderboard-table td:nth-child(3) { width: 104px; text-align: right; font-variant-numeric: tabular-nums; }
.leaderboard-table th:nth-child(4), .leaderboard-table td:nth-child(4) { width: 95px; text-align: center; }
.leaderboard-table tbody tr:last-child td { border-bottom: 0; }
.leaderboard-table td:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leaderboard-table .rank-cell { color: #ffd84a; font-family: 'Dela Gothic One', sans-serif; }
.leaderboard-table tr:nth-child(1) .rank-cell { color: #ffe27c; }
.leaderboard-table tr:nth-child(2) .rank-cell { color: #d9e5f0; }
.leaderboard-table tr:nth-child(3) .rank-cell { color: #e4aa77; }
.leaderboard-hints { color: #cbd5e1; font-size: 11px; white-space: nowrap; }
.leaderboard-hints.used { color: #ffd887; }
.leaderboard-footnote { margin-top: 8px; color: rgba(255, 255, 255, 0.48); font-size: 10px; line-height: 1.5; }
.leaderboard-submit { margin: 14px 0 16px; padding: 13px; border: 1px solid rgba(255, 216, 74, 0.35); border-radius: 10px; background: rgba(255, 216, 74, 0.07); text-align: left; }
.leaderboard-submit h3 { font-size: 16px; }
.leaderboard-submit-summary { margin: 4px 0 10px; color: rgba(255, 255, 255, 0.7); font-size: 12px; }
.leaderboard-submit label { display: block; margin-bottom: 5px; font-size: 12px; font-weight: 800; }
.leaderboard-submit-row { display: flex; gap: 8px; }
.leaderboard-submit input {
  min-width: 0; min-height: 44px; flex: 1; padding: 9px 12px; border: 1px solid rgba(255, 255, 255, 0.34); border-radius: 8px;
  background: rgba(0, 0, 0, 0.36); color: #fff; font: inherit; font-size: 16px; user-select: text; -webkit-user-select: text;
}
.leaderboard-submit input:focus-visible { outline: 2px solid #ffd84a; outline-offset: 1px; }
.leaderboard-submit-row .btn { min-height: 44px; margin: 0; padding: 8px 16px; font-size: 14px; white-space: nowrap; }
.leaderboard-submit .leaderboard-state { margin-bottom: 0; }
.leaderboard-submit button:disabled { cursor: wait; opacity: 0.62; }

.loading-text { font-family: 'Dela Gothic One', sans-serif; font-size: 26px; }
#loading { background: #0c0e12; }
.dim { background: rgba(0, 0, 0, 0.45); }
#result { align-items: flex-end; padding-bottom: 3vh; background: linear-gradient(transparent 40%, rgba(0, 0, 0, 0.75)); }
.panel { background: rgba(15, 18, 24, 0.9); border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 14px; padding: 16px 26px; text-align: center; min-width: 320px; max-width: 92vw; max-height: 92vh; overflow-y: auto; }
.panel h2 { font-family: 'Dela Gothic One', sans-serif; font-size: 40px; }
#resTitle.win { color: #ffd84a; }
#resTitle.lose { color: #ff5a4a; }
#resSub { margin: 8px 0 12px; line-height: 1.6; }
#resStats { display: grid; grid-template-columns: auto auto; gap: 4px 18px; justify-content: center; margin-bottom: 16px; font-size: 16px; }
#resStats .k { text-align: right; opacity: 0.7; }
#resStats .v { text-align: left; font-weight: 800; }
#resStats .rank { font-family: 'Dela Gothic One', sans-serif; font-size: 30px; color: #ffd84a; }
.row { display: flex; gap: 10px; justify-content: center; }
.btn { display: block; margin: 8px auto 0; padding: 12px 26px; border-radius: 999px; border: none; background: #c0392b; color: #fff; font-family: inherit; font-weight: 800; font-size: 17px; cursor: pointer; }
.row .btn { margin: 0; }
.btn.ghost { background: transparent; border: 2px solid rgba(255, 255, 255, 0.5); }

/* スマホ */
#touch { position: fixed; right: 16px; bottom: 70px; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
#touch button { width: 64px; height: 64px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.6); background: rgba(0, 0, 0, 0.4); color: #fff; font-size: 26px; font-weight: 800; }
#touch #tFire { width: 90px; height: 90px; font-size: 18px; background: rgba(192, 57, 43, 0.75); }

@media (max-width: 700px) {
  #leaderboard { padding: 14px 12px 11px; }
  .leaderboard-heading { align-items: start; flex-direction: column; gap: 4px; }
  .leaderboard-heading h2 { font-size: 20px; }
  .leaderboard-note { font-size: 11px; }
  .leaderboard-tabs { gap: 5px; }
  .leaderboard-tab { min-height: 40px; padding: 6px 4px; font-size: 12px; }
  .leaderboard-table { font-size: 12px; }
  .leaderboard-table th, .leaderboard-table td { padding: 7px 4px; }
  .leaderboard-table th:first-child, .leaderboard-table td:first-child { width: 36px; }
  .leaderboard-table th:nth-child(3), .leaderboard-table td:nth-child(3) { width: 82px; }
  .leaderboard-table th:nth-child(4), .leaderboard-table td:nth-child(4) { width: 75px; }
  .leaderboard-hints { font-size: 10px; }
  #result { padding: 4vh 0; align-items: center; }
  #result .panel { min-width: 0; width: 94vw; padding: 15px 14px; }
  .leaderboard-submit { padding: 11px; }
  .leaderboard-submit-row { flex-direction: column; }
  .leaderboard-submit-row .btn { width: 100%; }
  .poster.small { width: 96px; }
  .poster.small .poster-title { font-size: 13px; }
  #help { display: none; }
  #hint { top: 280px; font-size: 13px; }
  #hintButton { right: 16px; top: 225px; min-width: 112px; min-height: 48px; font-size: 15px; }
  #timer { font-size: 28px; }
}
#result #resStats { grid-template-columns: repeat(3, auto auto); gap: 2px 14px; }
#result .panel h2 { font-size: 34px; }
