/* ========================================
   冒険（js/adventure.js）：レベル・経験値・STAGE CLEAR・案内役のキャラ・押したときの手ざわり
   クラシック（遊べるポートフォリオ）だけで使う
======================================== */

/* ---------- ヘッダーの Lv 表示（ヘッダーの左下に、タグのようにぶら下げる） ---------- */

.lv-hud {
    position: absolute;
    left: clamp(24px, 5vw, 76px);
    top: calc(100% + 8px);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 4px 12px 4px 4px;
    border: 2px solid var(--ui-line, #111713);
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 3px 0 var(--ui-line, #111713);
    color: var(--ui-ink, #111713);
    cursor: pointer;
    font: inherit;
    transition: transform .15s ease, box-shadow .15s ease;
}
.lv-hud:hover { transform: translateY(-2px); box-shadow: 0 5px 0 var(--ui-line, #111713); }
.lv-hud:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ui-line, #111713); }
.lv-hud-level { display: grid; place-items: center; min-width: 46px; height: 28px; padding: 0 6px; border-radius: 999px; background: #006ea8; color: #fff; font-size: 13px; font-weight: 900; letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.lv-hud-bar { position: relative; width: 80px; height: 10px; overflow: hidden; border: 2px solid var(--ui-line, #111713); border-radius: 999px; background: #eef1ec; }
.lv-hud-bar span { position: absolute; inset: 0; background: linear-gradient(90deg, #ffb300, #ffd54a); transform-origin: left; transition: transform .6s cubic-bezier(.3, 1.4, .5, 1); }
.lv-hud-text { font-size: 11px; font-weight: 900; letter-spacing: .04em; color: #4d5652; font-variant-numeric: tabular-nums; }
.lv-hud.is-up .lv-hud-level { animation: lv-hud-up .8s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes lv-hud-up { 30% { transform: scale(1.35) rotate(-6deg); background: #ffb300; color: #111713; } }

@media (max-width: 768px) {
    .lv-hud { left: 12px; top: calc(100% + 6px); gap: 6px; min-height: 36px; padding: 3px 10px 3px 3px; }
    .lv-hud-level { min-width: 40px; height: 26px; font-size: 12px; }
    .lv-hud-bar { width: 52px; height: 8px; }
}

/* ---------- 冒険の記録（トロフィー一覧）の上のレベル ---------- */

.trophy-level { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin: 0 0 10px; }
.trophy-level[hidden] { display: none; }
.trophy-level b { padding: 2px 10px; border-radius: 999px; background: #006ea8; color: #fff; font-weight: 900; }
.trophy-level span { font-weight: 900; }
.trophy-level small { color: #4d5652; font-weight: 700; }

/* ---------- +EXP の文字 ---------- */

.exp-pop {
    position: fixed;
    z-index: 2000;
    font-family: "Inter", "Noto Sans JP", sans-serif;
    font-size: 15px;
    font-weight: 900;
    color: #006ea8;
    text-shadow: 0 2px 0 #fff, 0 0 6px #fff;
    pointer-events: none;
    white-space: nowrap;
    transform: translate(-50%, 0);
    animation: exp-pop 1.1s cubic-bezier(.2, .8, .2, 1) forwards;
}
@keyframes exp-pop { 0% { opacity: 0; transform: translate(-50%, 6px) scale(.6); } 20% { opacity: 1; transform: translate(-50%, -6px) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -40px) scale(1); } }

/* ---------- LEVEL UP!（画面の真ん中） ---------- */

.lv-up {
    position: fixed;
    left: 50%;
    top: 42%;
    z-index: 2100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 18px 40px 20px;
    border: 3px solid #111713;
    border-radius: 24px;
    background: #fff;
    box-shadow: 0 8px 0 #111713, 0 24px 60px rgba(30, 45, 70, .25);
    font-family: "Inter", "Noto Sans JP", sans-serif;
    max-width: calc(100vw - 24px);
    text-align: center;
    pointer-events: none;
    transform: translate(-50%, -50%);
    animation: lv-up 2.2s cubic-bezier(.3, 1.4, .5, 1) forwards;
}
.lv-up small { font-size: 15px; font-weight: 900; letter-spacing: .2em; color: #ff5a5f; }
.lv-up b { font-size: 56px; font-weight: 900; line-height: 1; color: #006ea8; text-shadow: 0 4px 0 #ffd54a; }
.lv-up span { font-size: 14px; font-weight: 900; }
@keyframes lv-up {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(.4) rotate(-6deg); }
    18% { opacity: 1; transform: translate(-50%, -50%) scale(1.08) rotate(2deg); }
    28% { transform: translate(-50%, -50%) scale(1) rotate(0); }
    82% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -60%) scale(.96); }
}

/* ---------- STAGE CLEAR!（右上から） ---------- */

.stage-clear {
    position: fixed;
    right: 20px;
    top: 100px;
    z-index: 1150;
    display: grid;
    grid-template-columns: auto auto;
    align-items: baseline;
    gap: 0 8px;
    padding: 10px 18px 12px;
    border: 3px solid #111713;
    border-radius: 16px;
    background: #ffd54a;
    box-shadow: 0 5px 0 #111713;
    font-family: "Inter", "Noto Sans JP", sans-serif;
    pointer-events: none;
    max-width: calc(100vw - 24px);
    transform-origin: top right;
    animation: stage-clear 2s cubic-bezier(.3, 1.4, .5, 1) forwards;
}
.stage-clear small { font-size: 11px; font-weight: 900; letter-spacing: .14em; }
.stage-clear b { font-size: 22px; font-weight: 900; color: #111713; }
.stage-clear span { grid-column: 1 / -1; font-size: 12px; font-weight: 700; }
@keyframes stage-clear {
    0% { opacity: 0; transform: translateY(-24px) scale(.7) rotate(-4deg); }
    18% { opacity: 1; transform: translateY(4px) scale(1.06) rotate(1deg); }
    26% { transform: none; }
    85% { opacity: 1; transform: none; }
    100% { opacity: 0; transform: translateY(-12px) scale(.96); }
}


/* ---------- 案内役のキャラ（RPG の会話ウィンドウ・画面の下の真ん中に大きく） ---------- */

.rpg-talk {
    position: fixed;
    left: 50%;
    bottom: 24px;
    z-index: 1100;
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr) auto;
    align-items: start;
    gap: 6px 16px;
    width: min(720px, calc(100vw - 32px));
    min-height: 120px;
    padding: 18px 18px 12px 18px;
    border: 4px solid #111713;
    border-radius: 22px;
    background: #fff;
    box-shadow: 0 0 0 6px #ffd54a, 0 0 0 10px #111713, 0 22px 50px rgba(30, 45, 70, .28);
    font-family: "Inter", "Noto Sans JP", sans-serif;
    opacity: 0;
    transform: translate(-50%, 40px) scale(.9);
    transition: opacity .25s ease, transform .45s cubic-bezier(.3, 1.5, .5, 1);
}
.rpg-talk.is-show { opacity: 1; transform: translate(-50%, 0); }
.rpg-talk[hidden] { display: none; }
/* キャラは窓から上にはみ出して、跳ねて登場する */
.rpg-face {
    grid-row: 1 / span 2;
    align-self: end;
    width: 112px;
    height: 112px;
    margin-top: -64px;
    padding: 8px;
    border: 4px solid #111713;
    border-radius: 20px;
    background: radial-gradient(circle at 50% 35%, #fff 0 30%, #bfe8ff 70%);
    box-shadow: 0 5px 0 #111713;
    object-fit: contain;
    image-rendering: pixelated;
}
.rpg-talk.is-show .rpg-face { animation: rpg-jump .7s cubic-bezier(.3, 1.6, .5, 1) both, rpg-bob 1.4s ease-in-out .7s infinite; }
@keyframes rpg-jump { 0% { transform: translateY(40px) scale(.6) rotate(-10deg); } 60% { transform: translateY(-14px) scale(1.06) rotate(3deg); } 100% { transform: none; } }
@keyframes rpg-bob { 50% { transform: translateY(-4px); } }
.rpg-body { position: relative; min-width: 0; padding-top: 2px; cursor: pointer; }
.rpg-name { display: inline-block; margin-bottom: 6px; padding: 2px 12px; border-radius: 8px; background: #006ea8; color: #fff; font-size: 13px; font-weight: 900; letter-spacing: .14em; }
.rpg-source { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); margin: 0; }
.rpg-line { min-height: 3.4em; margin: 0; padding-right: 18px; font-size: 18px; font-weight: 800; line-height: 1.7; color: #111713; }
.rpg-more { position: absolute; right: 0; bottom: 0; font-size: 14px; color: #ff5a5f; animation: rpg-more .8s steps(2) infinite; }
@keyframes rpg-more { 50% { transform: translateY(3px); opacity: .3; } }
.rpg-close { width: 36px; height: 36px; border: 2px solid #111713; border-radius: 50%; background: #fff; cursor: pointer; font-size: 18px; font-weight: 900; line-height: 1; color: #111713; }
.rpg-close:hover { background: #ffb300; }
.rpg-off { grid-column: 2 / -1; justify-self: end; min-height: 28px; padding: 0 4px; border: 0; background: none; cursor: pointer; font-size: 11px; font-weight: 700; color: #4d5652; text-decoration: underline; text-underline-offset: 3px; }
.rpg-off:hover { color: #111713; }
.using-gamepad .rpg-talk { bottom: 76px; }
.motion-off .rpg-talk { transition: none; }

@media (max-width: 600px) {
    /* スマホは画面が小さいので、会話ウィンドウは低めに（下のボタンや映像を隠しすぎないように） */
    .rpg-talk { bottom: 10px; width: calc(100vw - 20px); grid-template-columns: 52px minmax(0, 1fr) auto; gap: 2px 10px; min-height: 0; padding: 10px 10px 6px; border-width: 3px; border-radius: 14px; box-shadow: 0 0 0 3px #ffd54a, 0 0 0 6px #111713, 0 12px 28px rgba(30, 45, 70, .22); }
    .rpg-face { width: 52px; height: 52px; margin-top: -26px; padding: 3px; border-width: 3px; border-radius: 12px; }
    .rpg-name { font-size: 10px; padding: 1px 8px; margin-bottom: 2px; }
    .rpg-line { min-height: 0; font-size: 13px; line-height: 1.6; padding-right: 8px; }
    .rpg-close { width: 32px; height: 32px; font-size: 15px; }
    .stage-clear { right: 12px; top: 84px; padding: 8px 14px 10px; }
    .stage-clear b { font-size: 18px; }
    .lv-up { padding: 14px 28px 16px; }
    .lv-up b { font-size: 44px; }
}

/* ---------- 押したときの手ざわり（沈む）・ITEM GET ---------- */

.is-pressed { translate: 0 3px; filter: brightness(.96); transition: translate .06s ease, filter .06s ease; }
.item-get {
    position: absolute;
    left: 50%;
    top: 16px;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 20px 10px;
    border: 3px solid #111713;
    border-radius: 16px;
    background: #ffd54a;
    box-shadow: 0 5px 0 #111713;
    font-family: "Inter", "Noto Sans JP", sans-serif;
    pointer-events: none;
    transform: translateX(-50%);
    animation: item-get 1.7s cubic-bezier(.3, 1.4, .5, 1) forwards;
}
.item-get b { font-size: 20px; font-weight: 900; letter-spacing: .06em; }
.item-get small { max-width: 60vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 700; }
@keyframes item-get {
    0% { opacity: 0; transform: translateX(-50%) translateY(20px) scale(.5); }
    20% { opacity: 1; transform: translateX(-50%) translateY(-6px) scale(1.1); }
    30% { transform: translateX(-50%) scale(1); }
    80% { opacity: 1; }
    100% { opacity: 0; transform: translateX(-50%) translateY(-16px); }
}
.motion-off .exp-pop, .motion-off .item-get { display: none; }
.motion-off .is-pressed { translate: none; }

/* ---------- クエスト（冒険の記録の中・QUEST CLEAR） ---------- */

.trophy-quests { margin: 0 0 14px; padding: 12px 14px; border: 2px solid #111713; border-radius: 14px; background: #fffbea; }
.trophy-quests[hidden] { display: none; }
.trophy-quests-head { display: flex; align-items: baseline; justify-content: space-between; margin: 0 0 6px; }
.trophy-quests-head b { font-weight: 900; letter-spacing: .14em; color: #c2410c; }
.trophy-quests-head small { font-weight: 700; color: #4d5652; }
.trophy-quest-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.trophy-quest-list li { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; }
.trophy-quest-list li small { font-weight: 900; font-variant-numeric: tabular-nums; color: #4d5652; }
.trophy-quest-box { display: grid; place-items: center; width: 20px; height: 20px; border: 2px solid #111713; border-radius: 6px; background: #fff; font-size: 12px; color: #fff; }
.trophy-quest-list li.is-done .trophy-quest-box { background: #22a34a; }
.trophy-quest-list li.is-done .trophy-quest-text { text-decoration: line-through; color: #4d5652; }
.stage-clear.is-quest { top: auto; bottom: 170px; background: #ffe2c2; }
.stage-clear.is-quest b { color: #c2410c; }

/* ---------- ▶ の選択カーソル ---------- */

.menu-cursor {
    position: fixed;
    z-index: 1050;
    font-size: 16px;
    line-height: 1;
    color: #ff5a5f;
    text-shadow: 0 2px 0 #111713;
    pointer-events: none;
    opacity: 0;
    transform: translate(-6px, -50%);
    transition: opacity .12s ease, left .12s cubic-bezier(.3, 1.4, .5, 1), top .12s cubic-bezier(.3, 1.4, .5, 1);
}
.menu-cursor.is-show { opacity: 1; animation: menu-cursor .6s ease-in-out infinite; }
@keyframes menu-cursor { 0%, 100% { transform: translate(-6px, -50%); } 50% { transform: translate(0, -50%); } }
.motion-off .menu-cursor { transition: none; }
.motion-off .menu-cursor.is-show { transform: translate(0, -50%); }

/* ---------- 「仲間にしますか？」 ---------- */

.party-dialog {
    position: fixed;
    inset: 0;
    margin: auto;
    height: fit-content;
    max-height: calc(100vh - 32px);
    width: min(460px, calc(100vw - 32px));
    padding: 22px 22px 18px;
    border: 4px solid #111713;
    border-radius: 22px;
    background: #fff;
    box-shadow: 0 0 0 6px #ffd54a, 0 0 0 10px #111713, 0 24px 60px rgba(30, 45, 70, .3);
    font-family: "Inter", "Noto Sans JP", sans-serif;
    color: #111713;
}
.party-dialog::backdrop { background: rgba(17, 23, 19, .45); }
.party-dialog[open] { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 8px 16px; animation: party-in .4s cubic-bezier(.3, 1.5, .5, 1); }
@keyframes party-in { from { opacity: 0; transform: translateY(20px) scale(.92); } }
.party-face { width: 64px; height: 64px; padding: 4px; border: 3px solid #111713; border-radius: 14px; background: #bfe8ff; image-rendering: pixelated; object-fit: contain; }
.party-title { margin: 4px 0 0; font-size: 20px; font-weight: 900; line-height: 1.4; }
.party-purpose { margin: 4px 0 0; font-size: 13px; font-weight: 700; color: #4d5652; }
.party-choices { grid-column: 1 / -1; display: grid; gap: 6px; margin-top: 10px; }
.party-choices button { position: relative; display: flex; align-items: center; min-height: 48px; padding: 0 16px 0 40px; border: 3px solid #111713; border-radius: 12px; background: #fff; cursor: pointer; font: inherit; font-size: 16px; font-weight: 900; text-align: left; }
.party-choices button::before { content: "▶"; position: absolute; left: 14px; color: #ff5a5f; opacity: 0; }
.party-choices button:hover::before, .party-choices button:focus-visible::before { opacity: 1; animation: menu-cursor-inline .6s ease-in-out infinite; }
@keyframes menu-cursor-inline { 50% { transform: translateX(4px); } }
.party-choices .party-yes { background: #ffd54a; box-shadow: 0 4px 0 #111713; }
.party-choices button:hover { filter: brightness(1.04); }

/* ================================================================
   通知が重ならないように
   ・短いお知らせ（STAGE CLEAR・QUEST・キャラを見つけた など）は、ヘッダーの下の1か所に順番に出す
   ・トロフィーの通知（右下）は、案内役の会話ウィンドウが出ている間は、その上に逃がす
   ・ヘッダーの右下の「STAGE ○○ ▶」（入ったステージの表示）は、STAGE CLEAR と重なるので出さない
================================================================ */
.play-notice[data-tone="stage"] { background: #ffd54a; }
.play-notice[data-tone="quest"] { background: #ffe2c2; }
.play-notice[data-tone="quest"] b { color: #c2410c; }
.stage-bar-chip { display: none !important; }
body:has(.rpg-talk.is-show) .achievement-toast { bottom: calc(var(--talk-h, 160px) + 56px); }
@media (max-width: 768px) {
    /* スマホは Lv の札の下に出す */
    .play-notice { top: 130px; }
}
@media (max-width: 600px) {
    body:has(.rpg-talk.is-show) .achievement-toast { bottom: calc(var(--talk-h, 120px) + 36px); }
}

/* ---------- エンディング：冒険の結果 ---------- */

.ending-adventure { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; width: 100%; margin-top: 10px; padding-top: 10px; border-top: 2px dashed currentColor; }
.ending-adventure b { padding: 2px 10px; border-radius: 999px; background: #006ea8; color: #fff; font-weight: 900; }
.ending-adventure-title { font-weight: 900; }
.ending-adventure small { flex-basis: 100%; font-weight: 700; opacity: .85; }
.credits-you b { margin-right: 4px; color: #ffb300; }
.lv-up.is-clear small { color: #22a34a; font-size: 18px; }
.ending-rank { flex-wrap: wrap; }

/* ---------- 採用担当の方へ：新しいデザインへの案内（SELECT MODE の下） ---------- */

.mode-select-calm { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin: 12px 0 0; padding: 10px 14px; border: 2px dashed #9aa3a0; border-radius: 14px; background: rgba(255, 255, 255, .7); font-size: 13px; font-weight: 700; color: #3c4541; }
.mode-select-calm a { display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: 999px; background: #111713; color: #fff; text-decoration: none; font-weight: 900; }
.mode-select-calm a:hover { background: #c8102e; }

/* ---------- 作品のアイテム図鑑 ---------- */

.dex-count { display: inline-flex; align-items: baseline; gap: 8px; margin-top: 8px; padding: 4px 14px; border: 2px solid #111713; border-radius: 999px; background: #fff; box-shadow: 0 3px 0 #111713; }
.dex-count small { font-size: 10px; font-weight: 900; letter-spacing: .14em; color: #006ea8; }
.dex-count b { font-size: 15px; font-weight: 900; font-variant-numeric: tabular-nums; }
.work-card { position: relative; }
.dex-mark { position: absolute; right: 10px; top: 10px; z-index: 3; padding: 2px 10px; border: 2px solid #111713; border-radius: 999px; background: #ffd54a; font-size: 11px; font-weight: 900; letter-spacing: .1em; color: #111713; transform: rotate(6deg); pointer-events: none; }

/* ---------- リザルト画像（js/result-card.js） ---------- */

.ending-share-row { flex-wrap: wrap; gap: 10px; }

.ending-result-card {
    border-color: #111713;
    background: #fff;
    box-shadow: 0 5px 0 #111713;
    color: #111713;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}
.ending-result-card:active { box-shadow: 0 2px 0 #111713; transform: translateY(3px); }
.ending-result-card:disabled { opacity: .6; cursor: progress; }

.result-card-dialog {
    width: min(760px, calc(100% - 24px));
    max-height: calc(100dvh - 24px);
    margin: auto;
    padding: 20px;
    overflow: auto;
    border: 3px solid #111713;
    border-radius: 20px;
    background: #fff;
    box-shadow: 0 8px 0 #111713;
    color: #111713;
    text-align: center;
}
.result-card-dialog::backdrop { background: rgba(17, 23, 19, .55); }
.result-card-dialog h2 { margin: 0 0 12px; font-size: 18px; font-weight: 900; letter-spacing: .06em; }
.result-card-image { display: block; width: 100%; height: auto; border: 2px solid #e1e7ef; border-radius: 12px; }
.result-card-note { margin: 10px 0 0; color: #5b6560; font-size: 12px; }
.result-card-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 14px; }
.result-card-actions .ending-button { font: inherit; font-weight: 800; cursor: pointer; }

/* ---------- 2周目（NEW GAME+） ---------- */

.lv-hud-plus {
    padding: 2px 8px;
    border-radius: 999px;
    background: #ffd54a;
    color: #111713;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: .08em;
    white-space: nowrap;
}
html.is-plus .lv-hud { border-color: #b8860b; box-shadow: 0 3px 0 #b8860b; }
.lv-up.is-plus small { color: #b8860b; }
.lv-up.is-plus b { font-size: clamp(40px, 7vw, 64px); letter-spacing: .02em; }
.trophy-quest-tag {
    display: inline-block;
    padding: 0 6px;
    border-radius: 6px;
    background: #111713;
    color: #ffd54a;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: .1em;
    vertical-align: 2px;
}
@media (max-width: 760px) {
    .lv-hud-plus { font-size: 9px; padding: 2px 6px; }
}
