/* DFHJ 共通スタイル — アーケード筐体のような暗い画面 (ダーク固定のデザイン) */
:root {
  --ink: #0d0f1c;
  --panel: #161a2e;
  --panel-2: #1d2240;
  --line: #2a2f4d;
  --text: #e8eaf6;
  --muted: #9097b8;
  --outer: #ff8a5c;   /* D / J レーン */
  --inner: #62c6ff;   /* F / H レーン */
  --gold: #ffd36b;    /* Perfect */
  --good: #8be0a4;    /* Good */
  --miss: #ff5d73;    /* Miss */
  --display: "Chakra Petch", "Zen Kaku Gothic New", system-ui, sans-serif;
  --body: "Zen Kaku Gothic New", system-ui, sans-serif;
  color-scheme: dark;
}
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--body);
  font-size: 14px;
  line-height: 1.6;
}
a { color: var(--inner); }
.app {
  min-height: 100%;
  box-sizing: border-box;
  padding-block: 14px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex;
  flex-direction: column;
  gap: 12px;
}
header.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
}
.brand { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.45rem;
  letter-spacing: 0.04em;
  line-height: 1.1;
  text-wrap: balance;
}
h1 .k { color: var(--outer); }
h1 .k.i { color: var(--inner); }
nav.links { display: flex; gap: 14px; font-size: 0.85rem; }
nav.links a { color: var(--muted); text-decoration: none; }
nav.links a:hover, nav.links a[aria-current] { color: var(--text); }

.btn {
  font: 700 0.85rem var(--body);
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--gold); color: var(--ink); border-color: var(--gold); }
.btn.big { font-family: var(--display); font-size: 1rem; letter-spacing: 0.1em; padding: 12px 28px; }
.btn.on { background: var(--miss); border-color: var(--miss); color: var(--ink); }
.btn:focus-visible, select:focus-visible, input:focus-visible, .seg button:focus-visible { outline: 3px solid var(--inner); outline-offset: 2px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button {
  font: 700 0.85rem var(--body);
  color: var(--muted);
  background: transparent;
  border: 0;
  padding: 6px 12px;
  cursor: pointer;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button .n { font-family: var(--display); font-size: 0.75rem; font-weight: 500; font-variant-numeric: tabular-nums; }
.seg button[aria-pressed="true"] { background: var(--panel-2); color: var(--text); box-shadow: inset 0 -3px 0 var(--gold); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.card h3 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.card p { margin: 0; }
.hint { font-size: 0.78rem; color: var(--muted); }
label.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
label.row + label.row { margin-top: 8px; }
select, input[type="number"] {
  font: inherit;
  background: var(--ink);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 6px;
}
input[type="number"] { width: 5.5em; font-variant-numeric: tabular-nums; }
input[type="range"] { accent-color: var(--inner); }
label.row input[type="range"] { width: 9em; max-width: 50%; }
table.plain { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.plain td { padding: 3px 0; border-bottom: 1px solid var(--line); }
table.plain td:last-child { text-align: right; color: var(--muted); }
table.plain tr:last-child td { border-bottom: 0; }
.p { color: var(--gold); font-weight: 700; }
.g { color: var(--good); font-weight: 700; }
.m { color: var(--miss); font-weight: 700; }
kbd {
  font: 700 0.75rem var(--display);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 5px;
  background: var(--ink);
}

/* プレイ画面 */
.field {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--ink);
}
.field canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.judge {
  position: absolute;
  left: 0; right: 0;
  bottom: 38%;
  text-align: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: 2rem;
  letter-spacing: 0.08em;
  pointer-events: none;
  opacity: 0;
}
.judge small { display: block; font-size: 0.75rem; letter-spacing: 0.1em; font-weight: 500; color: var(--muted); }
.judge.perfect { color: var(--gold); }
.judge.good { color: var(--good); }
.judge.miss { color: var(--miss); }
.judge.show { animation: pop 0.45s ease-out forwards; }
@keyframes pop {
  0% { opacity: 0; transform: scale(1.35); }
  20% { opacity: 1; transform: scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-8px); }
}
.combo {
  position: absolute;
  left: 0; right: 0; top: 24%;
  text-align: center;
  pointer-events: none;
  font-family: var(--display);
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
}
.combo b { display: block; font-size: 3rem; line-height: 1; }
.combo span { font-size: 0.75rem; letter-spacing: 0.3em; color: var(--muted); }
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  background: rgba(13, 15, 28, 0.86);
  backdrop-filter: blur(3px);
}
.overlay h2 { margin: 0; font-family: var(--display); font-size: 1.5rem; letter-spacing: 0.06em; }
.overlay p { margin: 0; color: var(--muted); max-width: 32ch; }
.rank { font-family: var(--display); font-weight: 700; font-size: 4rem; line-height: 1; color: var(--gold); }
.result-grid {
  display: grid;
  grid-template-columns: auto auto;
  gap: 3px 22px;
  margin: 0;
  font-variant-numeric: tabular-nums;
  text-align: left;
}
.result-grid dt { color: var(--muted); }
.result-grid dd { margin: 0; text-align: right; font-family: var(--display); font-weight: 700; }
.stats { display: flex; gap: 18px; }
.stat { display: flex; flex-direction: column; align-items: flex-end; }
.stat .lbl { font-family: var(--display); font-size: 0.66rem; letter-spacing: 0.14em; color: var(--muted); text-transform: uppercase; }
.stat .val { font-family: var(--display); font-weight: 700; font-size: 1.3rem; font-variant-numeric: tabular-nums; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 16px;
  max-width: calc(100% - 32px);
  box-sizing: border-box;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.toast.warn { border-color: var(--miss); }
@media (prefers-reduced-motion: reduce) {
  .judge.show { animation-duration: 0.01s; opacity: 1; }
}
