/* ペタッとロワイヤル（ペタロワ） by AZRION GAME — warm living-room world.
   Motion law: quiet スッ glides only (long ease-out, small travel). */
:root {
  --ink: #2b2118;
  --ink-soft: #5c4c3a;
  --cream: #f8f1e2;
  --paper: #fffdf7;
  --accent: #d8442c;
  --accent-deep: #b03320;
  --gold: #e9b23e;
  --line: #e4d5ba;
  --ease: cubic-bezier(.22, .8, .26, 1);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  background: var(--cream); color: var(--ink);
  overflow: hidden; overscroll-behavior: none;
  position: fixed; inset: 0;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }

#az-progress { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 200; pointer-events: none; }
#az-progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s var(--ease); }

/* ---------- boot stages ---------- */
#boot { position: fixed; inset: 0; z-index: 50; }
.bstage {
  position: absolute; inset: 0; height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(var(--sat) + 16px) 20px calc(var(--sab) + 16px);
  opacity: 0; visibility: hidden; transform: translateY(10px);
  transition: opacity .45s var(--ease), transform .45s var(--ease), visibility 0s .45s;
}
.bstage.active { opacity: 1; visibility: visible; transform: none; transition: opacity .45s var(--ease), transform .45s var(--ease); }
#boot.gone { display: none; }

.amark { display: block; }
.amark-lg { width: 92px; height: auto; }

/* splash */
#stage-splash { background: #fff; justify-content: center; }
.splash-word { margin-top: 18px; font-weight: 800; letter-spacing: .34em; font-size: 15px; text-indent: .34em; }
.splash-sub { margin-top: 5px; font-size: 10px; letter-spacing: .42em; text-indent: .42em; color: #9a8b76; }

/* world backdrop (KV colors as soft wash) */
.worldbg { position: absolute; inset: 0; background: linear-gradient(180deg, #f0d6a2 0%, #e7c288 55%, #dfae72 100%); }
.worldbg.dim::after { content: ""; position: absolute; inset: 0; background: rgba(43, 30, 16, .38); }

/* notice */
#stage-notice { background: linear-gradient(180deg, #f0d6a2, #e2b57a); }
.notice-card, .result-card {
  position: relative; width: min(92vw, 380px);
  background: var(--paper); border: 1px solid var(--line); border-radius: 22px;
  padding: 22px 20px 18px; box-shadow: 0 18px 44px rgba(70, 45, 15, .22);
}
.kicker { font-size: 10px; font-weight: 800; letter-spacing: .3em; color: var(--accent); }
.notice-h { font-size: 20px; font-weight: 800; margin: 6px 0 12px; }
.notice-body { list-style: none; text-align: left; }
.notice-body li {
  font-size: 13.5px; line-height: 1.78; color: var(--ink-soft);
  padding-left: 14px; position: relative; margin-bottom: 9px;
}
.notice-body li::before { content: ""; position: absolute; left: 0; top: 9px; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }

/* buttons */
.btn-main {
  display: block; width: 100%; margin-top: 14px;
  background: var(--accent); color: #fff; font-weight: 800; font-size: 15.5px;
  padding: 14px 18px; border-radius: 999px; box-shadow: 0 8px 20px rgba(216, 68, 44, .32);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), background .18s var(--ease);
}
.btn-main:active { transform: scale(.975); background: var(--accent-deep); }
.btn-main.big { font-size: 17px; padding: 16px 18px; }
.btn-main.sm { width: auto; margin-top: 0; padding: 10px 18px; font-size: 13.5px; }
.btn-quiet {
  display: block; width: 100%; margin-top: 10px; padding: 11px;
  font-size: 13.5px; font-weight: 700; color: var(--ink-soft);
}
.btn-quiet.sm { width: auto; margin-top: 0; }
.btn-danger {
  display: block; width: 100%; margin-top: 12px; padding: 12px;
  border: 1.5px solid #c0452f; color: #c0452f; border-radius: 999px; font-weight: 700; font-size: 14px;
}

/* title */
#stage-title { justify-content: flex-start; padding: 0; background: #e9c48d; }
.kv { position: absolute; inset: 0; }
.kv svg { width: 100%; height: 100%; display: block; }
.title-brand {
  position: absolute; top: calc(var(--sat) + 12px); left: 16px;
  display: flex; align-items: center; gap: 7px;
  color: #fff; font-size: 11px; font-weight: 800; letter-spacing: .24em;
  text-shadow: 0 1px 8px rgba(60, 35, 5, .35);
}
.title-brand .amark { width: 20px; height: auto; }
.title-box {
  position: relative; margin-top: auto; width: 100%;
  padding: 0 22px calc(var(--sab) + 14px);
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.title-en { font-size: 11px; font-weight: 800; letter-spacing: .4em; text-indent: .4em; color: #fff; text-shadow: 0 1px 10px rgba(60, 35, 5, .4); }
.title-name {
  font-size: 57px; font-weight: 900; letter-spacing: .04em; color: #fff; line-height: 1.12; margin-top: 2px; white-space: nowrap;
  text-shadow: 0 3px 0 rgba(160, 70, 30, .55), 0 8px 26px rgba(60, 35, 5, .45);
}
.title-formal { margin-top: 7px; font-size: 12.5px; font-weight: 800; letter-spacing: .34em; text-indent: .34em; color: #ffedb8; text-shadow: 0 1px 8px rgba(60, 35, 5, .5); }
.title-catch { margin-top: 5px; font-size: 14px; font-weight: 700; color: #fff8ea; text-shadow: 0 1px 8px rgba(60, 35, 5, .45); }
.title-records { margin-top: 8px; font-size: 11.5px; font-weight: 700; color: #ffedb8; min-height: 15px; text-shadow: 0 1px 6px rgba(60, 35, 5, .5); }
.btn-start {
  margin-top: 14px; width: min(78vw, 300px);
  background: var(--accent); color: #fff; border-radius: 999px;
  padding: 13px 20px 11px; box-shadow: 0 12px 28px rgba(150, 50, 20, .42), inset 0 -3px 0 rgba(0,0,0,.14);
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  transition: transform .18s var(--ease);
}
.btn-start:active { transform: scale(.97); }
.btn-start .s1 { font-size: 21px; font-weight: 900; letter-spacing: .3em; text-indent: .3em; }
.btn-start .s2 { font-size: 10.5px; font-weight: 700; opacity: .85; }
.title-links { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; justify-content: center; }
.tlink {
  font-size: 12px; font-weight: 700; color: #fff;
  background: rgba(50, 32, 12, .38); border: 1px solid rgba(255, 248, 234, .35);
  padding: 8px 13px; border-radius: 999px; backdrop-filter: blur(4px);
}
.title-repair { margin-top: 12px; font-size: 11.5px; color: #ffedb8; text-decoration: underline; text-underline-offset: 3px; }
.title-foot { margin-top: 10px; display: flex; align-items: center; gap: 14px; font-size: 11px; color: rgba(255, 248, 234, .85); }
.tcenter { letter-spacing: .14em; font-weight: 700; text-decoration: none; }
.tver { opacity: .8; }
.title-note { margin-top: 7px; font-size: 10.5px; color: rgba(255, 248, 234, .75); }

/* loading */
#stage-loading { background: linear-gradient(180deg, #f0d6a2, #e2b57a); justify-content: center; }
.load-box { position: relative; width: min(84vw, 340px); text-align: center; }
.load-title { font-size: 14px; font-weight: 800; letter-spacing: .18em; color: var(--ink-soft); }
.load-pct { font-size: 64px; font-weight: 900; line-height: 1.1; margin-top: 8px; font-variant-numeric: tabular-nums; }
.load-pct small { font-size: 22px; font-weight: 800; margin-left: 2px; }
.load-gauge { height: 9px; border-radius: 99px; background: rgba(90, 62, 25, .18); overflow: hidden; margin-top: 10px; }
.load-gauge i { display: block; height: 100%; width: 0%; background: var(--accent); border-radius: 99px; transition: width .25s var(--ease); }
.load-status { margin-top: 12px; font-size: 13px; font-weight: 700; }
.load-tip { margin-top: 6px; font-size: 11.5px; color: var(--ink-soft); line-height: 1.6; }

/* result */
#stage-result { background: linear-gradient(180deg, #f0d6a2, #e2b57a); }
.result-card { text-align: center; }
.res-phrase { font-size: 17px; font-weight: 900; margin-top: 8px; }
.res-placement { font-size: 54px; font-weight: 900; line-height: 1.15; font-variant-numeric: tabular-nums; }
.res-of { font-size: 17px; font-weight: 800; color: var(--ink-soft); }
.res-stats { list-style: none; display: flex; gap: 8px; margin-top: 12px; }
.res-stats li { flex: 1; background: #faf3e3; border: 1px solid var(--line); border-radius: 14px; padding: 9px 4px; }
.res-stats span { display: block; font-size: 10.5px; font-weight: 700; color: var(--ink-soft); }
.res-stats b { font-size: 19px; font-weight: 900; font-variant-numeric: tabular-nums; }
.res-best { margin-top: 10px; font-size: 12px; font-weight: 700; color: var(--accent-deep); min-height: 16px; }
.install-card { margin-top: 14px; text-align: left; background: #faf3e3; border: 1px solid var(--line); border-radius: 16px; padding: 13px 14px; }
.ic-title { font-size: 13.5px; font-weight: 800; }
.ic-text { font-size: 12px; color: var(--ink-soft); line-height: 1.6; margin-top: 4px; }
.ic-actions { display: flex; gap: 8px; align-items: center; margin-top: 10px; }

/* loadout select */
#stage-select { background: linear-gradient(180deg, #f0d6a2, #e2b57a); }
.sel-card {
  position: relative; width: min(94vw, 400px);
  background: var(--paper); border: 1px solid var(--line); border-radius: 22px;
  padding: 18px 16px 12px; box-shadow: 0 18px 44px rgba(70, 45, 15, .22);
  text-align: center;
}
.sel-title { font-size: 19px; font-weight: 900; margin-top: 4px; }
.sel-h { font-size: 12px; font-weight: 900; letter-spacing: .14em; color: var(--ink-soft); text-align: left; margin: 12px 2px 7px; }
.chara-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.chara-card, .weapon-card {
  background: #faf3e3; border: 2px solid var(--line); border-radius: 14px;
  display: flex; flex-direction: column; align-items: center;
  transition: transform .16s var(--ease), border-color .16s var(--ease), background .16s var(--ease), box-shadow .16s var(--ease);
}
.chara-card { padding: 5px 1px 4px; }
.chara-card:active, .weapon-card:active { transform: scale(.95); }
.chara-card canvas { width: 46px; height: 46px; display: block; }
.chara-card .cname { font-size: 9.5px; font-weight: 800; line-height: 1.25; }
.weapon-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.weapon-card { padding: 6px 2px 5px; }
.weapon-card canvas { width: 60px; height: 44px; display: block; }
.weapon-card .wname { font-size: 10.5px; font-weight: 800; line-height: 1.3; }
.chara-card.sel, .weapon-card.sel { border-color: var(--accent); background: #fdeee7; box-shadow: 0 5px 14px rgba(216, 68, 44, .22); }
.weapon-note { margin-top: 8px; font-size: 11.5px; font-weight: 700; color: var(--ink-soft); min-height: 17px; }

/* sheets */
.sheet-wrap { position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(43, 30, 16, .42); }
.sheet {
  position: relative; width: min(100vw, 430px); max-height: 82dvh; overflow-y: auto;
  background: var(--paper); border-radius: 24px 24px 0 0; padding: 20px 20px calc(var(--sab) + 18px);
  animation: sheet-in .38s var(--ease);
}
@keyframes sheet-in { from { transform: translateY(26px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet-h { font-size: 17px; font-weight: 900; margin-bottom: 12px; }
.howto-list { list-style: none; text-align: left; }
.howto-list li { font-size: 13.5px; line-height: 1.75; color: var(--ink-soft); padding-left: 14px; position: relative; margin-bottom: 6px; }
.howto-list li::before { content: ""; position: absolute; left: 0; top: 10px; width: 5px; height: 5px; border-radius: 50%; background: var(--gold); }
.howto-list b { color: var(--ink); }
.sheet-note { font-size: 12.5px; line-height: 1.7; color: var(--ink-soft); margin-top: 10px; text-align: left; }

/* ---------- game ---------- */
#scr-game { position: fixed; inset: 0; height: 100dvh; z-index: 10; background: #3a2a18; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hud {
  position: absolute; top: calc(var(--sat) + 8px); left: 10px; right: 10px;
  display: flex; align-items: center; gap: 6px; pointer-events: none; z-index: 5;
}
.hud-pill {
  display: flex; align-items: baseline; gap: 4px;
  background: rgba(255, 253, 247, .92); border: 1px solid rgba(120, 90, 40, .16);
  border-radius: 999px; padding: 6px 11px; font-size: 12px; font-weight: 800;
  box-shadow: 0 3px 10px rgba(60, 35, 5, .14); font-variant-numeric: tabular-nums;
}
.hud-label { font-size: 10px; color: var(--ink-soft); font-weight: 700; }
.hud-unit { font-size: 10px; color: var(--ink-soft); }
.hud-zone { font-size: 11px; color: var(--accent-deep); max-width: 40vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-zone.warn { background: #fde9e2; }
.hud-sp { flex: 1; }
.hud-btn {
  pointer-events: auto; width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255, 253, 247, .92); border: 1px solid rgba(120, 90, 40, .16);
  font-size: 15px; font-weight: 800; color: var(--ink-soft);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 10px rgba(60, 35, 5, .14);
}
#feed { position: absolute; top: calc(var(--sat) + 52px); right: 10px; z-index: 5; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; pointer-events: none; }
.feed-line {
  font-size: 11px; font-weight: 700; color: #fff; background: rgba(43, 30, 16, .62);
  padding: 5px 10px; border-radius: 999px; animation: feed-in .3s var(--ease);
}
@keyframes feed-in { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: none; } }
#banner {
  position: absolute; top: 34%; left: 50%; transform: translate(-50%, -50%); z-index: 6;
  font-size: 44px; font-weight: 900; color: #fff; letter-spacing: .06em; white-space: nowrap;
  text-shadow: 0 3px 0 rgba(160, 60, 25, .65), 0 10px 30px rgba(40, 20, 0, .5); pointer-events: none; text-align: center;
}
#banner small { display: block; font-size: 15px; letter-spacing: .2em; margin-top: 4px; }
.ownbar {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--sab) + 128px); width: min(58vw, 250px); z-index: 5; pointer-events: none;
}
.hp-row { display: flex; align-items: center; gap: 7px; }
.hp-label { font-size: 10px; font-weight: 900; color: #fff; text-shadow: 0 1px 5px rgba(40, 20, 0, .6); }
.hp-track { flex: 1; height: 11px; border-radius: 99px; background: rgba(43, 30, 16, .45); border: 1px solid rgba(255, 255, 255, .5); overflow: hidden; }
#hp-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #57b368, #8fd06a); border-radius: 99px; transition: width .18s var(--ease); }
#hp-fill.low { background: linear-gradient(90deg, #d8442c, #e97a4e); }
.hp-num { font-size: 12px; font-weight: 900; color: #fff; text-shadow: 0 1px 5px rgba(40, 20, 0, .6); font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }
.ammo-row { display: flex; gap: 5px; justify-content: center; margin-top: 6px; }
.ammo-pip { width: 30px; height: 9px; border-radius: 99px; background: rgba(43, 30, 16, .4); border: 1px solid rgba(255, 255, 255, .45); overflow: hidden; position: relative; }
.ammo-pip i { position: absolute; inset: 0; background: var(--gold); transform-origin: left; }
.ammo-pip.full i { transform: scaleX(1); }
.stick { position: absolute; width: 116px; height: 116px; border-radius: 50%; z-index: 7; pointer-events: none;
  background: rgba(255, 253, 247, .14); border: 1.5px solid rgba(255, 253, 247, .55); transform: translate(-50%, -50%); }
.stick .stick-nub { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; border-radius: 50%;
  background: rgba(255, 253, 247, .9); box-shadow: 0 4px 14px rgba(40, 20, 0, .3); transform: translate(-50%, -50%); }
.stick.aim { background: rgba(216, 68, 44, .14); border-color: rgba(255, 190, 160, .7); }
.stick.aim .stick-nub { background: rgba(255, 214, 190, .95); }
#tutorial { position: absolute; inset: 0; z-index: 8; display: flex; align-items: center; justify-content: center; background: rgba(43, 30, 16, .45); padding: 20px; }
.tut-card { width: min(92vw, 360px); background: var(--paper); border-radius: 22px; padding: 20px; box-shadow: 0 18px 44px rgba(40, 20, 0, .35); }
.tut-h { font-size: 17px; font-weight: 900; margin-bottom: 10px; text-align: center; }
#toast {
  position: fixed; left: 50%; bottom: calc(var(--sab) + 26px); transform: translateX(-50%); z-index: 120;
  background: rgba(43, 33, 24, .94); color: #fff; font-size: 13px; font-weight: 700;
  padding: 10px 16px; border-radius: 999px; box-shadow: 0 8px 24px rgba(40, 20, 0, .3); white-space: nowrap;
}
@media (min-width: 700px) {
  .title-name { font-size: 72px; }
  .ownbar { bottom: calc(var(--sab) + 148px); }
}
