:root {
    --bg-top: #253018;
    --bg-mid: #18220e;
    --bg-bottom: #0c1308;
    --panel: rgba(12, 21, 10, 0.82);
    --border: rgba(154, 207, 109, 0.4);
    --text: #eff4e3;
    --subtle: #b8cca0;
    --accent: #b7ea5b;
    --accent-2: #6edb7a;
    --danger: #ff7969;
    --warn: #ffcf63;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: "Noto Sans JP", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 18% 14%, rgba(138, 204, 106, 0.2), transparent 34%),
        radial-gradient(circle at 82% 80%, rgba(86, 145, 43, 0.22), transparent 36%),
        linear-gradient(180deg, var(--bg-top), var(--bg-mid) 42%, var(--bg-bottom));
    position: relative;
    padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}

.background-orb {
    position: fixed;
    border-radius: 999px;
    filter: blur(2px);
    z-index: 0;
    opacity: 0.45;
    pointer-events: none;
}

.orb-a {
    width: 180px;
    height: 180px;
    left: 4%;
    top: 6%;
    background: radial-gradient(circle at 30% 30%, rgba(183, 234, 91, 0.42), rgba(113, 162, 62, 0));
    animation: driftA 10s ease-in-out infinite;
}

.orb-b {
    width: 260px;
    height: 260px;
    right: 5%;
    bottom: 4%;
    background: radial-gradient(circle at 50% 50%, rgba(70, 189, 123, 0.3), rgba(41, 109, 65, 0));
    animation: driftB 13s ease-in-out infinite;
}

@keyframes driftA {
    0%,
    100% {
        transform: translate(0, 0);
    }

    50% {
        transform: translate(14px, -10px);
    }
}

@keyframes driftB {
    0%,
    100% {
        transform: translate(0, 0);
    }

    50% {
        transform: translate(-18px, 10px);
    }
}

.game-shell {
    position: relative;
    z-index: 1;
    width: min(1120px, 100%);
    margin: 0 auto;
    display: grid;
    gap: 14px;
}

.back-link {
    font-family: "Orbitron", sans-serif;
    text-decoration: none;
    color: var(--subtle);
    font-size: 0.8rem;
    width: fit-content;
}

.top-panel {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--panel);
    padding: 14px;
}

.top-panel .label {
    margin: 0;
    color: var(--subtle);
    letter-spacing: 0.06em;
    font-size: 0.76rem;
    text-transform: uppercase;
}

.top-panel h1 {
    margin: 6px 0 0;
    font-family: "Orbitron", sans-serif;
    font-size: clamp(1.2rem, 2.7vw, 1.8rem);
    letter-spacing: 0.03em;
}

.meta-box {
    display: grid;
    gap: 2px;
    text-align: right;
    color: var(--subtle);
    font-size: 0.66rem;
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
}

.status-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel);
    padding: 10px;
}

.status-card.param-duplicate {
    display: none;
}

.status-title {
    margin: 0;
    color: var(--subtle);
    font-size: 0.74rem;
}

.status-main {
    margin: 7px 0 0;
    font-size: 1.08rem;
    font-weight: 700;
}

.status-sub {
    margin: 4px 0 0;
    font-size: 0.8rem;
}

.status-sub.mono {
    font-family: "Orbitron", "Noto Sans JP", sans-serif;
    font-size: 0.72rem;
    letter-spacing: 0.02em;
}

.bar {
    margin-top: 7px;
    height: 9px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    overflow: hidden;
}

.bar span {
    display: block;
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #75d557, var(--accent));
    transition: width 0.2s ease;
}

.bar.stamina span {
    background: linear-gradient(90deg, #57b8ff, #8be3ff);
}

.bar.boss {
    margin-top: 10px;
    height: 11px;
}

.bar.boss span {
    background: linear-gradient(90deg, #f39a55, #ff6464);
}

.arena-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    gap: 12px;
}

.panel {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--panel);
    padding: 12px;
    min-height: 430px;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.panel-head h2 {
    margin: 0;
    font-size: 1rem;
}

.panel-head p {
    margin: 0;
    color: var(--subtle);
    font-size: 0.82rem;
}

.map-stage {
    position: relative;
    border-radius: 12px;
    border: 1px solid rgba(168, 214, 119, 0.34);
    overflow: hidden;
    background: rgba(8, 17, 8, 0.75);
    aspect-ratio: 16 / 9;
}

#field-canvas {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

.field-hud {
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    z-index: 7;
    display: grid;
    gap: 6px;
    pointer-events: none;
}

.field-hud-top {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid rgba(176, 214, 120, 0.45);
    background: rgba(10, 20, 9, 0.72);
    font-size: 0.67rem;
    line-height: 1;
    color: #def2bd;
    backdrop-filter: blur(2px);
}

.pill strong {
    font-family: "Orbitron", "Noto Sans JP", sans-serif;
    font-size: 0.7rem;
}

.field-hud-bars {
    width: min(340px, calc(100% - 4px));
    border: 1px solid rgba(176, 214, 120, 0.34);
    border-radius: 10px;
    background: rgba(7, 15, 7, 0.68);
    padding: 6px 8px;
    display: grid;
    gap: 6px;
    backdrop-filter: blur(2px);
}

.battle-scene-overlay {
    position: absolute;
    left: 10px;
    right: 10px;
    z-index: 9;
    border: 1px solid rgba(214, 235, 168, 0.5);
    border-radius: 12px;
    background: linear-gradient(160deg, rgba(8, 16, 8, 0.86), rgba(8, 18, 8, 0.64));
    padding: 8px 10px;
    pointer-events: none;
    backdrop-filter: blur(3px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.24);
}

.battle-scene-overlay.hidden {
    display: none;
}

.battle-scene-top {
    top: 8px;
}

.battle-scene-bottom {
    bottom: 8px;
}

.battle-scene-main {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
    align-items: center;
}

.battle-scene-avatar {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    border: 1px solid rgba(202, 236, 137, 0.5);
    background: rgba(7, 16, 8, 0.7);
    object-fit: contain;
    padding: 3px;
}

.battle-scene-avatar.enemy {
    border-color: rgba(255, 188, 130, 0.72);
}

.battle-scene-avatar.player {
    border-color: rgba(149, 223, 132, 0.72);
}

.battle-scene-info {
    display: grid;
    gap: 3px;
}

.battle-scene-head {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: baseline;
}

.battle-scene-head p {
    margin: 0;
    line-height: 1.1;
}

.battle-scene-head p:first-child {
    font-size: 0.84rem;
    color: #f4ffdf;
    font-weight: 700;
}

.battle-scene-head p:last-child {
    font-size: 0.68rem;
    color: #c4dea1;
}

.battle-scene-hand {
    margin: 0;
    font-size: 0.76rem;
    color: #d4f0b7;
}

.battle-scene-hand strong {
    font-family: "Orbitron", "Noto Sans JP", sans-serif;
    color: #f8ffe7;
}

.battle-scene-hp {
    margin: 0;
    font-family: "Orbitron", "Noto Sans JP", sans-serif;
    font-size: 0.74rem;
    color: #ecffd4;
}

.battle-scene-bar {
    height: 10px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(193, 225, 133, 0.42);
}

.battle-scene-bar span {
    display: block;
    height: 100%;
    width: 100%;
}

.battle-scene-bar.enemy span {
    background: linear-gradient(90deg, #ff8e66, #ff615f);
}

.battle-scene-bar.player span {
    background: linear-gradient(90deg, #74dd5a, #b9ea61);
}

.rps-overlay {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 7;
    min-width: 122px;
    border: 1px solid rgba(176, 214, 120, 0.45);
    border-radius: 10px;
    background: rgba(8, 15, 8, 0.74);
    padding: 6px 8px;
    display: grid;
    gap: 3px;
    pointer-events: none;
    backdrop-filter: blur(2px);
}

.rps-overlay.hidden {
    display: none;
}

body.battle-active .field-hud,
body.battle-active .rps-overlay,
body.battle-active .map-overlay {
    display: none;
}

.rps-title {
    margin: 0;
    font-size: 0.62rem;
    color: #c9e6a4;
}

.rps-line {
    margin: 0;
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.66rem;
    color: #e4f6c9;
}

.rps-line strong {
    font-family: "Orbitron", "Noto Sans JP", sans-serif;
    color: #f3ffdf;
}

.rps-round {
    margin: 2px 0 0;
    font-size: 0.58rem;
    color: #b9d89d;
}

.hud-bar-item {
    display: grid;
    gap: 3px;
}

.hud-bar-item > span {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.64rem;
    color: #d7edb6;
}

.hud-bar-item strong {
    font-family: "Orbitron", "Noto Sans JP", sans-serif;
    color: #e7ffc7;
}

.hud-mini-bar {
    height: 7px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.14);
}

.hud-mini-bar span {
    display: block;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #7ddf63, #b7ea5b);
}

.hud-mini-bar.stamina span {
    background: linear-gradient(90deg, #57b8ff, #8be3ff);
}

.map-overlay {
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 8px;
    border-radius: 10px;
    background: rgba(6, 13, 5, 0.68);
    border: 1px solid rgba(176, 215, 124, 0.34);
    padding: 8px;
    pointer-events: none;
}

.map-overlay p {
    margin: 0;
    font-size: 0.74rem;
    color: #d8ecbc;
}

.map-overlay p + p {
    margin-top: 4px;
    color: #e7ffbe;
}

.map-actions {
    margin-top: 10px;
}

.map-actions button {
    width: 100%;
    border: 1px solid rgba(194, 234, 132, 0.6);
    border-radius: 10px;
    background: linear-gradient(145deg, rgba(146, 200, 72, 0.4), rgba(76, 114, 35, 0.75));
    color: #f5ffe6;
    font-weight: 700;
    padding: 10px;
    cursor: pointer;
}

.map-actions button:disabled {
    opacity: 0.46;
    cursor: not-allowed;
}

.touch-pad {
    display: none;
    margin-top: 10px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.touch-pad button {
    border: 1px solid rgba(180, 224, 112, 0.42);
    border-radius: 10px;
    background: rgba(77, 120, 35, 0.35);
    color: #f2ffe0;
    font-size: 1rem;
    font-weight: 700;
    min-height: 42px;
    cursor: pointer;
}

body.input-touch .touch-pad {
    display: grid;
}

.battle-target {
    border: 1px solid rgba(182, 215, 130, 0.3);
    border-radius: 12px;
    background: rgba(20, 28, 14, 0.82);
    min-height: 146px;
    padding: 12px;
}

.battle-target.idle {
    opacity: 0.78;
}

.target-name {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
}

.target-sub {
    margin: 7px 0 0;
    color: var(--subtle);
    font-size: 0.82rem;
}

.action-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-top: 12px;
}

.action-row.janken-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.action-row.utility {
    grid-template-columns: 1fr;
}

.action-row button {
    border: 1px solid rgba(184, 219, 128, 0.52);
    border-radius: 10px;
    padding: 10px 8px;
    color: #f2ffe0;
    font-size: 0.82rem;
    font-weight: 700;
    background: linear-gradient(155deg, rgba(80, 145, 45, 0.7), rgba(52, 90, 31, 0.8));
    cursor: pointer;
}

.action-row button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.log-panel {
    margin-top: 12px;
    border: 1px solid rgba(153, 196, 101, 0.28);
    border-radius: 10px;
    padding: 8px;
    min-height: 154px;
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 6px;
    background: rgba(8, 15, 8, 0.62);
}

.log-panel p {
    margin: 0;
    color: var(--subtle);
    font-size: 0.78rem;
}

.log-panel ul {
    margin: 0;
    padding: 0;
    list-style: none;
    overflow: auto;
    display: grid;
    gap: 4px;
}

.log-panel li {
    font-size: 0.8rem;
    line-height: 1.4;
}

.log-panel li.warn {
    color: #ffd0a4;
}

.log-panel li.danger {
    color: #ffaea7;
}

.log-panel li.good {
    color: #b9ffd6;
}

.reward-modal {
    position: fixed;
    inset: 0;
    z-index: 20;
    background: rgba(0, 0, 0, 0.58);
    display: grid;
    place-items: center;
    padding: 20px;
}

.reward-modal.hidden {
    display: none;
}

.reward-card {
    width: min(420px, 100%);
    border-radius: 14px;
    border: 1px solid rgba(180, 223, 122, 0.5);
    background: linear-gradient(180deg, rgba(31, 50, 18, 0.95), rgba(17, 28, 10, 0.95));
    padding: 18px;
    text-align: center;
}

.reward-card h2 {
    margin: 0;
    font-family: "Orbitron", sans-serif;
    letter-spacing: 0.03em;
}

.reward-card p {
    margin: 12px 0;
    line-height: 1.6;
    color: #d9f2bd;
    white-space: pre-line;
}

.reward-card button {
    border: 1px solid rgba(194, 236, 130, 0.6);
    border-radius: 999px;
    padding: 10px 18px;
    background: rgba(138, 199, 62, 0.25);
    color: #f2ffe0;
    font-weight: 700;
    cursor: pointer;
}

@media (max-width: 920px) {
    .status-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .arena-grid {
        grid-template-columns: 1fr;
    }

    .panel {
        min-height: auto;
    }

    body {
        padding-left: max(10px, env(safe-area-inset-left));
        padding-right: max(10px, env(safe-area-inset-right));
    }

    .map-stage {
        aspect-ratio: 16 / 10;
    }
}

@media (max-width: 640px) {
    body {
        padding-top: max(6px, env(safe-area-inset-top));
        padding-left: max(6px, env(safe-area-inset-left));
        padding-right: max(6px, env(safe-area-inset-right));
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }

    .background-orb {
        display: none;
    }

    .game-shell {
        gap: 8px;
    }

    .back-link {
        font-size: 0.66rem;
    }

    .top-panel {
        padding: 8px 10px;
        gap: 6px;
    }

    .top-panel .label {
        display: none;
    }

    .top-panel h1 {
        margin: 0;
        font-size: clamp(1rem, 4.6vw, 1.2rem);
    }

    .meta-box {
        font-size: 0.52rem;
    }

    .status-grid {
        grid-template-columns: none;
        grid-auto-flow: column;
        grid-auto-columns: minmax(142px, 1fr);
        gap: 8px;
        overflow-x: auto;
        padding-bottom: 2px;
        scroll-snap-type: x mandatory;
        order: 4;
    }

    .status-grid::-webkit-scrollbar {
        height: 4px;
    }

    .status-grid::-webkit-scrollbar-thumb {
        background: rgba(164, 208, 111, 0.45);
        border-radius: 999px;
    }

    .status-card {
        padding: 8px;
        min-height: 88px;
        scroll-snap-align: start;
    }

    .status-main {
        font-size: 0.94rem;
    }

    .status-sub {
        font-size: 0.72rem;
    }

    .status-sub.mono {
        font-size: 0.65rem;
    }

    .arena-grid {
        gap: 8px;
        order: 3;
    }

    .top-panel {
        flex-direction: column;
        align-items: flex-start;
    }

    .meta-box {
        text-align: left;
    }

    .action-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .action-row.janken-row {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .field-panel {
        position: sticky;
        top: max(4px, env(safe-area-inset-top));
        z-index: 8;
        padding: 8px;
        backdrop-filter: blur(3px);
    }

    .panel-head {
        margin-bottom: 7px;
    }

    .panel-head h2 {
        font-size: 0.92rem;
    }

    .panel-head p {
        font-size: 0.74rem;
    }

    .map-stage {
        aspect-ratio: auto;
        height: min(58dvh, 500px);
        min-height: 340px;
    }

    .map-overlay {
        left: 6px;
        right: 6px;
        bottom: 6px;
        padding: 7px;
    }

    .map-overlay p {
        font-size: 0.68rem;
    }

    .field-hud {
        top: 6px;
        left: 6px;
        right: 6px;
        gap: 4px;
    }

    .field-hud-top {
        gap: 4px;
    }

    .pill {
        padding: 4px 7px;
        font-size: 0.6rem;
    }

    .pill strong {
        font-size: 0.63rem;
    }

    .field-hud-bars {
        width: min(300px, calc(100% - 2px));
        padding: 5px 7px;
        gap: 5px;
    }

    .hud-bar-item > span {
        font-size: 0.58rem;
    }

    .hud-mini-bar {
        height: 6px;
    }

    .rps-overlay {
        top: 6px;
        right: 6px;
        min-width: 108px;
        padding: 5px 6px;
    }

    .rps-title {
        font-size: 0.56rem;
    }

    .rps-line {
        font-size: 0.58rem;
    }

    .rps-round {
        font-size: 0.52rem;
    }

    .map-actions button,
    .action-row button {
        min-height: 52px;
        font-size: 0.92rem;
    }

    .map-actions {
        margin-top: 8px;
    }

    .touch-pad button {
        min-height: 58px;
        font-size: 1.22rem;
    }

    .touch-pad {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .battle-panel {
        padding: 8px;
    }

    .battle-target {
        min-height: 106px;
        padding: 9px;
    }

    .target-name {
        font-size: 1rem;
    }

    .target-sub {
        margin-top: 5px;
        font-size: 0.74rem;
    }

    .log-panel {
        min-height: 96px;
        max-height: 112px;
    }
}

@media (max-width: 900px) {
    html,
    body.input-touch {
        height: 100dvh;
    }

    body.input-touch {
        overflow: hidden;
    }

    body.input-touch .game-shell {
        height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
        gap: 6px;
        grid-template-rows: auto 1fr;
        overflow: hidden;
    }

    body.input-touch .back-link {
        position: fixed;
        top: max(4px, env(safe-area-inset-top));
        left: max(6px, env(safe-area-inset-left));
        z-index: 30;
        padding: 3px 6px;
        border: 1px solid rgba(168, 203, 120, 0.36);
        border-radius: 999px;
        background: rgba(11, 19, 10, 0.7);
        font-size: 0.56rem;
    }

    body.input-touch .top-panel {
        padding: 6px 10px;
        min-height: 44px;
    }

    body.input-touch .top-panel .label {
        display: none;
    }

    body.input-touch .top-panel h1 {
        margin: 0;
        font-size: clamp(0.92rem, 3.9vw, 1.08rem);
    }

    body.input-touch .meta-box {
        font-size: 0.5rem;
        text-align: right;
    }

    body.input-touch .status-grid {
        display: none;
    }

    body.input-touch .arena-grid {
        min-height: 0;
        height: 100%;
        grid-template-columns: 1fr;
        grid-template-rows: minmax(0, 1.15fr) minmax(0, 1fr);
        gap: 6px;
    }

    body.input-touch .panel {
        min-height: 0;
        overflow: hidden;
        padding: 6px;
    }

    body.input-touch .panel-head {
        margin-bottom: 6px;
    }

    body.input-touch .panel-head h2 {
        font-size: 0.86rem;
    }

    body.input-touch .panel-head p {
        font-size: 0.7rem;
    }

    body.input-touch .field-panel {
        position: relative;
        top: auto;
        display: grid;
        grid-template-rows: auto minmax(0, 1fr) auto auto;
        gap: 6px;
    }

    body.input-touch .map-stage {
        min-height: 0;
        height: 100%;
        aspect-ratio: auto;
    }

    body.input-touch .map-actions,
    body.input-touch .touch-pad,
    body.input-touch .action-row,
    body.input-touch .log-panel {
        margin-top: 0;
    }

    body.input-touch .map-actions button,
    body.input-touch .action-row button {
        min-height: 46px;
        font-size: 0.86rem;
    }

    body.input-touch .touch-pad {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 6px;
    }

    body.input-touch .touch-pad button {
        min-height: 52px;
        font-size: 1.06rem;
    }

    body.input-touch .battle-panel {
        display: grid;
        grid-template-rows: auto auto auto auto minmax(0, 1fr);
        gap: 6px;
    }

    body.input-touch .battle-target {
        min-height: 96px;
        padding: 8px;
    }

    body.input-touch .target-name {
        font-size: 0.9rem;
    }

    body.input-touch .target-sub {
        margin-top: 4px;
        font-size: 0.68rem;
    }

    body.input-touch .action-row {
        gap: 6px;
    }

    body.input-touch .log-panel {
        min-height: 0;
        max-height: 82px;
        padding: 6px;
    }

    body.input-touch .log-panel p {
        font-size: 0.66rem;
    }

    body.input-touch .log-panel li {
        font-size: 0.68rem;
    }
}

/* Mobile gameplay-first override: one-screen, no-scroll layout */
@media (max-width: 900px) {
    body.input-touch {
        padding: 0;
        overflow: hidden;
    }

    body.input-touch .background-orb {
        display: none;
    }

    body.input-touch .game-shell {
        width: 100vw;
        height: 100dvh;
        margin: 0;
        gap: 0;
        grid-template-rows: 1fr;
        overflow: hidden;
    }

    body.input-touch .top-panel,
    body.input-touch .status-grid {
        display: none;
    }

    body.input-touch .back-link {
        top: max(6px, env(safe-area-inset-top));
        left: max(8px, env(safe-area-inset-left));
        z-index: 40;
        font-size: 0.58rem;
        padding: 3px 8px;
    }

    body.input-touch .arena-grid {
        height: 100%;
        grid-template-columns: 1fr;
        grid-template-rows: minmax(0, 1fr) auto;
        gap: 0;
    }

    body.input-touch .field-panel {
        position: relative;
        padding: 0;
        border: 0;
        border-radius: 0;
        background: transparent;
        display: block;
        overflow: hidden;
    }

    body.input-touch .field-panel .panel-head {
        display: none;
    }

    body.input-touch .map-stage {
        width: 100%;
        height: 100%;
        min-height: 0;
        border: 0;
        border-radius: 0;
    }

    body.input-touch .battle-scene-overlay {
        left: 8px;
        right: 8px;
        padding: 6px 8px;
        border-radius: 10px;
    }

    body.input-touch .battle-scene-top {
        top: max(34px, calc(env(safe-area-inset-top) + 28px));
    }

    body.input-touch .battle-scene-bottom {
        bottom: calc(94px + env(safe-area-inset-bottom));
    }

    body.input-touch .battle-scene-main {
        gap: 8px;
    }

    body.input-touch .battle-scene-avatar {
        width: 46px;
        height: 46px;
    }

    body.input-touch .battle-scene-head p:first-child {
        font-size: 0.74rem;
    }

    body.input-touch .battle-scene-head p:last-child,
    body.input-touch .battle-scene-hand,
    body.input-touch .battle-scene-hp {
        font-size: 0.66rem;
    }

    body.input-touch .field-hud {
        top: max(36px, calc(env(safe-area-inset-top) + 30px));
        left: 8px;
        right: 8px;
        gap: 4px;
    }

    body.input-touch .field-hud-bars {
        width: min(220px, calc(100% - 10px));
    }

    body.input-touch .rps-overlay {
        top: max(36px, calc(env(safe-area-inset-top) + 30px));
        right: 8px;
        min-width: 94px;
        padding: 4px 6px;
    }

    body.input-touch .map-overlay {
        left: 8px;
        right: 8px;
        bottom: 78px;
        padding: 6px 8px;
    }

    body.input-touch .map-overlay p {
        font-size: 0.62rem;
    }

    body.input-touch.battle-active .field-hud-bars {
        display: none;
    }

    body.input-touch.battle-active .field-hud {
        top: max(36px, calc(env(safe-area-inset-top) + 22px));
    }

    body.input-touch.battle-active .map-overlay {
        display: none;
    }

    body.input-touch .map-actions {
        position: absolute;
        right: 8px;
        bottom: 8px;
        width: min(42vw, 180px);
        margin: 0;
        z-index: 15;
    }

    body.input-touch .map-actions button {
        min-height: 42px;
        padding: 8px 10px;
        font-size: 0.78rem;
    }

    body.input-touch .touch-pad {
        position: absolute;
        left: 8px;
        bottom: 8px;
        width: min(56vw, 240px);
        margin: 0;
        padding: 6px;
        border: 1px solid rgba(166, 206, 114, 0.46);
        border-radius: 12px;
        background: rgba(7, 14, 8, 0.72);
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 6px;
        z-index: 15;
    }

    body.input-touch .touch-pad button {
        min-height: 42px;
        font-size: 1rem;
    }

    /* Mobile: remove arrow pad and engage button from gameplay area */
    body.input-touch .map-actions,
    body.input-touch .touch-pad {
        display: none;
    }

    body.input-touch .map-overlay {
        bottom: 8px;
    }

    body.input-touch .battle-panel {
        border: 0;
        border-top: 1px solid rgba(154, 207, 109, 0.42);
        border-radius: 16px 16px 0 0;
        background: rgba(9, 17, 9, 0.94);
        padding: 8px 8px max(8px, env(safe-area-inset-bottom));
        display: grid;
        grid-template-rows: auto;
        gap: 6px;
        max-height: 84px;
    }

    body.input-touch .battle-panel .panel-head {
        display: none;
    }

    body.input-touch .battle-panel .panel-head h2 {
        font-size: 0.82rem;
    }

    body.input-touch .battle-panel .panel-head p {
        font-size: 0.68rem;
    }

    body.input-touch .battle-target {
        display: none;
    }

    body.input-touch .target-name {
        font-size: 0.84rem;
    }

    body.input-touch .target-sub {
        margin-top: 3px;
        font-size: 0.62rem;
    }

    body.input-touch .bar.boss {
        margin-top: 6px;
        height: 8px;
    }

    body.input-touch .action-row.janken-row {
        margin-top: 0;
        gap: 6px;
    }

    body.input-touch .action-row button {
        min-height: 42px;
        font-size: 0.9rem;
        padding: 8px 6px;
    }

    body.input-touch .action-row.utility,
    body.input-touch .log-panel {
        display: none;
    }
}

/* Fallback: ensure mobile viewport always hides arrow pad and engage button */
@media (max-width: 900px) {
    .map-actions,
    .touch-pad {
        display: none !important;
    }
}
