
:root {
  --bg: #17181c;
  --tray: #1f2127;
  --hand: #2a2c33;
  --ink: #eceae4;
  --muted: #a5a39c;
  --line: #3d404a;
  --accent: #9fd3e2;
  --gold: #e2c06a;
  --ui: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  --tray-h: 160px; --hand-h: 116px; --safe-b: 0px;
  color-scheme: dark;
}
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--ui); overflow: hidden;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#safeProbe { position: fixed; left: 0; bottom: 0; width: 0; height: env(safe-area-inset-bottom, 0px); pointer-events: none; }
button { font-family: var(--ui); color: var(--ink); cursor: pointer; touch-action: manipulation; }
button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

#top { position: fixed; top: calc(env(safe-area-inset-top, 0px) + 6px); left: calc(env(safe-area-inset-left, 0px) + 8px);
  right: calc(env(safe-area-inset-right, 0px) + 8px); display: flex; align-items: flex-start; gap: 6px; pointer-events: none; }
#sampleBtn { pointer-events: auto; width: 76px; height: 76px; padding: 0; border-radius: 10px; border: 1px solid var(--line);
  background: var(--tray); overflow: hidden; flex: none; }
#sampleBtn img { display: block; width: 100%; height: 100%; object-fit: contain; }
#topLeft { display: flex; flex-direction: column; gap: 5px; flex: none; }
#lookBtn { pointer-events: auto; width: 76px; height: 40px; padding: 0; border-radius: 10px; border: 1px solid var(--line); background: color-mix(in srgb, var(--tray) 86%, transparent); font-size: 12px; line-height: 1; white-space: nowrap; }
#lookBtn b { font-weight: 600; margin-left: 4px; color: var(--muted); }
#lookBtn.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 20%, var(--bg)); }
#lookBtn.on b { color: var(--accent); }
#topRight { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
#btnRow { display: flex; justify-content: flex-end; gap: 6px; }
#info { display: flex; align-items: baseline; gap: 10px; padding-left: 2px; white-space: nowrap; }
#lvName { font-size: 14px; color: var(--ink); text-shadow: 0 1px 4px #000; }
#fps { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
body:not(.dev) #fps, body:not(.dev) .dv { display: none; }
.topbtn { pointer-events: auto; height: 42px; min-width: 44px; padding: 0 10px; border-radius: 12px; border: 1px solid var(--line);
  background: color-mix(in srgb, var(--tray) 86%, transparent); font-size: 14px; line-height: 1; flex: none; white-space: nowrap; }
#hintBtn b { color: var(--gold); font-variant-numeric: tabular-nums; margin-left: 4px; }
#menuBtn { font-size: 20px; padding: 0; }

#handRow { position: fixed; left: 0; right: 0; bottom: calc(var(--tray-h) + var(--safe-b)); height: var(--hand-h); box-sizing: border-box;
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; pointer-events: none; border-top: 1px solid var(--line); }
#handBox { width: calc(var(--hand-h) - 12px); height: calc(var(--hand-h) - 12px); flex: none; border-radius: 12px; box-sizing: border-box;
  border: 1px dashed var(--line); display: grid; place-items: center; font-size: 12px; color: var(--muted); text-align: center; line-height: 1.5; }
#handBox.on { border: 2px solid var(--accent); }
#rotBtns { display: flex; gap: 6px; }
#rotBtns button, #removeBtn { pointer-events: auto; width: 54px; height: 54px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--bg); padding: 0; display: grid; place-items: center; }
#rotBtns button svg { width: 34px; height: 34px; stroke: var(--accent); fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
#rotBtns button:active { background: color-mix(in srgb, var(--accent) 22%, var(--bg)); }
#removeBtn { width: auto; padding: 0 16px; font-size: 15px; border-color: var(--accent); }
#remain { margin-left: auto; font-size: 13px; color: var(--muted); white-space: nowrap; text-align: right; }
#remain b { font-size: 22px; color: var(--ink); font-variant-numeric: tabular-nums; margin: 0 2px; }
#tip { position: fixed; left: 10px; bottom: calc(var(--tray-h) + var(--hand-h) + var(--safe-b) + 8px); font-size: 13px; color: var(--accent);
  pointer-events: none; text-shadow: 0 1px 6px #000; max-width: calc(100% - 150px); line-height: 1.35; }
#tip.warn { color: var(--gold); font-size: 14px; padding: 5px 9px; border-radius: 9px; border: 1px solid var(--gold); background: color-mix(in srgb, var(--bg) 88%, transparent); }
#frontLbl { position: fixed; left: 0; top: 0; font-size: 11px; color: var(--gold); pointer-events: none; white-space: nowrap; text-shadow: 0 1px 4px #000, 0 0 2px #000; letter-spacing: .04em; }

#pushBtn { position: fixed; right: 10px; bottom: calc(var(--tray-h) + var(--hand-h) + var(--safe-b) + 8px); height: 46px; padding: 0 18px; border-radius: 23px;
  border: 2px solid var(--gold); background: color-mix(in srgb, var(--gold) 16%, var(--bg)); font-size: 15px; z-index: 2; }
#slots { position: fixed; left: 0; right: 0; bottom: var(--safe-b); height: var(--tray-h); display: grid; pointer-events: none; border-top: 1px solid var(--line); }
.slot { border-right: 1px solid color-mix(in srgb, var(--line) 55%, transparent); border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
  box-sizing: border-box; transition: background-color .15s, box-shadow .15s; }
.slot.sel { background: color-mix(in srgb, var(--accent) 14%, transparent); box-shadow: inset 0 0 0 2px var(--accent); }
.slot.hint { box-shadow: inset 0 0 0 3px var(--gold); background: color-mix(in srgb, var(--gold) 14%, transparent); }
.slot.empty { background: color-mix(in srgb, var(--bg) 70%, transparent); }
.slot.parked { display: grid; place-items: center; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 55%, transparent); background: color-mix(in srgb, var(--accent) 7%, transparent); }
.slot.parked::after { content: "仮置き\A 戻す"; white-space: pre; text-align: center; font-size: 12px; line-height: 1.45; color: var(--accent); }

#sampleBig { position: fixed; inset: 0; z-index: 5; touch-action: none; }
body.sv #top, body.sv #handRow, body.sv #slots, body.sv #tip, body.sv #pushBtn, body.sv #frontLbl { visibility: hidden; }
#sampleClose { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 10px); right: 12px; height: 44px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--accent); background: var(--bg); font-size: 15px; }
#exBox { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-b) + 52px); width: min(320px, calc(100% - 48px));
  display: flex; align-items: center; gap: 12px; padding: 8px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--tray); font-size: 14px; box-sizing: border-box; }
#exBox input { flex: 1; height: 32px; accent-color: var(--accent); touch-action: pan-x; }
#sampleNote { position: absolute; left: 0; right: 0; bottom: calc(var(--safe-b) + 18px); text-align: center; font-size: 13px; color: var(--muted); pointer-events: none; }

.panel { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -52%); width: min(380px, calc(100% - 24px));
  max-height: calc(100% - 32px); overflow: auto; box-sizing: border-box; z-index: 4;
  background: color-mix(in srgb, var(--tray) 95%, black); border: 1px solid var(--line); border-radius: 14px; padding: 16px 16px 14px;
  box-shadow: 0 18px 50px rgba(0,0,0,.5); }
.panel.sheet { top: auto; bottom: calc(var(--safe-b) + 8px); transform: translateX(-50%); max-height: 46%; padding: 12px 14px 10px; }
.panel.sheet h1 { font-size: 17px; margin-bottom: 6px; }
.panel.sheet .stats { font-size: 13px; gap: 2px 12px; }
.panel.sheet .wide { margin-top: 8px; }
.panel.sheet .note { margin-top: 6px; font-size: 11px; line-height: 1.4; }
.panel h1 { margin: 0 0 10px; font-size: 20px; letter-spacing: .03em; color: var(--accent); }
.panel p { margin: 14px 0 8px; font-size: 15px; }
.panel button { min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); font-size: 16px; }
.panel button.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 22%, var(--bg)); }
.panel button:disabled:not(.on) { opacity: .45; }
.panel .wide { width: 100%; margin-top: 12px; border-color: var(--accent); }
.stats { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 14px; font-variant-numeric: tabular-nums; }
.stats .k { color: var(--muted); } .stats .v { text-align: right; }
.row5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.row2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.ends { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 4px; }
.note { margin: 10px 0 0; font-size: 12px; color: var(--muted); line-height: 1.6; }
.sumgrid { display: grid; grid-template-columns: 1fr auto auto auto; gap: 4px 12px; font-size: 13px; font-variant-numeric: tabular-nums; margin-top: 4px; }
.sumgrid .h { color: var(--muted); font-size: 12px; } .sumgrid .v { text-align: right; }
.mrow { display: grid; grid-template-columns: 2.2em repeat(3, 1fr); gap: 6px; align-items: center; margin-bottom: 8px; }
.mhead { font-size: 13px; color: var(--muted); text-align: center; margin-bottom: 4px; }
.mname { font-size: 17px; }
.mrow button { font-size: 14px; padding: 2px 2px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.2; white-space: nowrap; }
.mrow button .mk { font-size: 11px; color: var(--gold); }
body:not(.dev) .sumgrid { grid-template-columns: 1fr auto auto; }
@media (prefers-reduced-motion: reduce) { .slot { transition: none; } }
#latRange { width:100%;height:32px;accent-color:var(--accent) }

.lab-off { display: none !important; }
.lab-box { margin: 14px 0 0; padding: 12px 0 0; border-top: 1px solid var(--line); text-align: center; }
.lab-box p { margin: 0 0 10px; font-size: 14px; line-height: 1.6; }
.lab-link { display: flex; align-items: center; justify-content: center; min-height: 44px; border-radius: 10px; background: var(--accent); color: var(--bg);
  font-size: 16px; font-weight: 700; text-decoration: none; }
.lab-link--line { width: 100%; box-sizing: border-box; background: transparent; color: var(--accent); border: 1px solid var(--accent); margin-top: 8px; }
.lab-back { display: inline-block; margin-top: 10px; font-size: 13px; color: var(--muted); text-underline-offset: 3px; min-height: 32px; line-height: 32px; }
#done .lab-link { pointer-events: auto; }

body { background: #cfe8f3 !important; }
#labBg { position: fixed; left: 0; top: 0; width: 100%; z-index: -1; pointer-events: none; }
#labBg svg { display: block; width: 100%; height: 100%; }
#labCard { position: fixed; z-index: 3; pointer-events: none; font-family: "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif; }
.cardA { position: relative; background: #fffdf6; color: #2a2520; border: 1.5px solid #2a2520; border-radius: 4px; padding: 8px 12px 9px; box-shadow: 3px 4px 0 rgba(0,0,0,.25); transform: rotate(-1.5deg); }
.cardA .hd { display: flex; gap: 8px; align-items: center; font-size: 10.5px; letter-spacing: .12em; color: #6b5d4f; border-bottom: 1px dashed #b5a58e; padding-bottom: 3px; margin-bottom: 4px; }
.cardA .hd b { background: #2a2520; color: #ffd84a; padding: 0 6px; border-radius: 2px; letter-spacing: .08em; }
.cardA .tt { font-size: 22px; font-weight: 900; letter-spacing: .06em; line-height: 1.25; }
.cardA .sb { font-size: 11.5px; color: #5c5247; margin-top: 2px; }
.cardA .stamp { position: absolute; right: -10px; top: -12px; width: 46px; height: 46px; border: 2.5px solid #d2382f; border-radius: 50%; color: #d2382f; font-weight: 900; font-size: 14px; display: flex; align-items: center; justify-content: center; transform: rotate(12deg); background: rgba(255,255,255,.55); }
.cardA .clip { position: absolute; left: 14px; top: -9px; width: 30px; height: 14px; border: 3px solid #8b939c; border-bottom: none; border-radius: 8px 8px 0 0; }


.labfx { position: fixed; left: 0; top: 0; z-index: 40; pointer-events: none; }
.labfx-word, .labfx-done { position: fixed; z-index: 41; pointer-events: none; opacity: 0; white-space: nowrap;
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif; font-weight: 900; }

@font-face { font-family: "LabZMG"; font-weight: 900; font-display: swap; src: url("../../assets/fonts/zmg-900.woff2") format("woff2"); }
.labfx-word { font-family: "LabZMG", "Hiragino Maru Gothic ProN", "Yu Gothic UI", sans-serif; font-weight: 900; font-size: 40px; letter-spacing: .04em; color: #E2574F;
  text-shadow: 0 0 1px #fff, 2px 0 0 #fff, -2px 0 0 #fff, 0 2px 0 #fff, 0 -2px 0 #fff, 1.5px 1.5px 0 #fff, -1.5px 1.5px 0 #fff, 1.5px -1.5px 0 #fff, -1.5px -1.5px 0 #fff, 3px 4px 0 rgba(30, 27, 58, .28);
  transform: translate(-50%, -50%) rotate(-7deg); }
.labfx-word.on { animation: labfxWord .9s ease-out both; }
@keyframes labfxWord { 0% { opacity: 0; transform: translate(-50%, -50%) rotate(-7deg) scale(1.6); } 14% { opacity: 1; transform: translate(-50%, -50%) rotate(-7deg) scale(.95); }
  24% { transform: translate(-50%, -50%) rotate(-7deg) scale(1); } 70% { opacity: 1; transform: translate(-50%, -62%) rotate(-7deg) scale(1); } 100% { opacity: 0; transform: translate(-50%, -80%) rotate(-7deg) scale(1); } }
@media (max-width: 700px) { .labfx-word { font-size: 30px; } }

.labfx-done { color: #d9ecff; font: 700 22px/1 Consolas, Menlo, monospace; letter-spacing: .12em; padding: 10px 18px; border: 2px solid #7fd7ff; background: rgba(11, 35, 64, .85); transform: translate(-50%, 0); }
.labfx-done.on { animation: labfxDone 1.8s ease-out both; }
@keyframes labfxDone { 0% { opacity: 0; transform: translate(-50%, 8px); } 12% { opacity: 1; transform: translate(-50%, 0); } 80% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .labfx-word.on, .labfx-done.on { animation-duration: .6s; } }
