* { box-sizing: border-box; }
:root {
    color-scheme: light;
    --paper: #f3ead7;
    --paper-light: #fffaf0;
    --ink: #292b28;
    --ink-soft: #625e52;
    --rule: #d7ccb6;
    --pencil-red: #a94335;
    --pencil-blue: #315d67;
    --pencil-yellow: #c58b27;
}
body {
    font-family: 'Yu Gothic', 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
    background:
        repeating-linear-gradient(0deg, rgba(91, 69, 35, 0.025) 0, rgba(91, 69, 35, 0.025) 1px, transparent 1px, transparent 5px),
        var(--paper);
    text-align: center;
    color: var(--ink);
    margin: 0;
    padding: 12px 20px;
}

/* ================= キャラクター選択画面 ================= */
#select-screen { max-width: 1120px; margin: 0 auto; padding-bottom: 30px; }
#select-screen h1 {
    margin: 2px 0 10px;
    font-size: clamp(1.45rem, 3vw, 2rem);
    letter-spacing: 0.04em;
    color: var(--ink);
    font-family: Georgia, 'Yu Mincho', serif;
    letter-spacing: 0.08em;
    text-shadow: 1px 1px 0 rgba(255,255,255,0.65);
}

/* モード選択タブ（対人戦 vs CPU対戦） */
.mode-selector {
    display: flex; justify-content: center; gap: 15px; margin: 10px auto 12px auto;
}
.mode-btn {
    flex: 1; max-width: 280px; padding: 12px 18px; border-radius: 4px;
    border: 1px solid var(--rule); background: var(--paper-light); cursor: pointer;
    transition: border-color 0.2s, background 0.2s; text-align: center;
    box-shadow: 2px 3px 0 rgba(67, 55, 34, 0.12);
}
.mode-btn:hover { border-color: var(--pencil-blue); }
.mode-btn.active-pvp {
    border-color: var(--pencil-red); background: #f8eee2;
    box-shadow: inset 0 -3px 0 rgba(169, 67, 53, 0.2), 2px 3px 0 rgba(67, 55, 34, 0.12);
}
.mode-btn.active-cpu {
    border-color: var(--pencil-blue); background: #eaf0ec;
    box-shadow: inset 0 -3px 0 rgba(49, 93, 103, 0.18), 2px 3px 0 rgba(67, 55, 34, 0.12);
}
.mode-btn.active-ffa {
    border-color: var(--pencil-yellow); background: #f8f0dd;
    box-shadow: inset 0 -3px 0 rgba(197, 139, 39, 0.2), 2px 3px 0 rgba(67, 55, 34, 0.12);
}
.mode-btn-title { display: block; font-size: 1.1em; font-weight: bold; color: var(--ink); }
.mode-btn-sub { display: block; font-size: 0.8em; color: var(--ink-soft); margin-top: 3px; }
.username-field {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    margin: 8px auto 12px; color: var(--ink); font-weight: bold;
}
.username-field input {
    width: min(280px, 60vw); padding: 9px 11px; border: 1px solid var(--rule);
    border-radius: 3px; background: var(--paper-light); color: var(--ink); font: inherit;
}

/* 観戦案内バナー */
#spectate-banner {
    display: none; background: var(--ink); color: #fffaf0; padding: 10px 20px;
    border-radius: 3px; margin-bottom: 12px; align-items: center; justify-content: center; gap: 15px;
}
.spectate-btn {
    background: var(--pencil-blue); color: white; border: none; border-radius: 3px;
    padding: 7px 18px; font-weight: bold; cursor: pointer; font-size: 0.9em;
}
.spectate-btn:hover { background: #244750; }

/* キャラ技・性能プレビュー枠 */
#preview-panel {
    position: sticky;
    top: 8px;
    z-index: 70;
    background: rgba(255,250,240,0.98);
    border: 1px solid var(--rule);
    border-top: 3px solid var(--pencil-blue);
    border-radius: 3px;
    padding: 9px 14px;
    margin-bottom: 14px;
    text-align: left;
    box-shadow: 3px 4px 0 rgba(67, 55, 34, 0.12);
    min-height: 158px;
    display: grid;
    grid-template-columns: 230px repeat(2, minmax(0, 1fr));
    grid-template-rows: auto;
    align-items: start;
    gap: 8px 14px;
}
.preview-placeholder { grid-column: 1 / -1; width: 100%; min-height: 138px; display: flex; align-items: center; justify-content: center; color: var(--ink-soft); font-weight: bold; }
.preview-left { grid-column: 1; grid-row: 1; min-width: 0; text-align: center; border-right: 2px solid #edf1f4; padding-right: 12px; display: flex; flex-direction: column; justify-content: center; align-items: center; }
.preview-left img { height: 92px; max-width: 130px; object-fit: contain; filter: drop-shadow(0 5px 8px rgba(44,62,80,0.18)); }
.preview-left h3 { max-width: 100%; margin: 2px 0; font-size: 1.05em; overflow-wrap: anywhere; }
.preview-left p { margin: 0; font-weight: bold; color: #5d6d7e; font-size: 0.82em; line-height: 1.45; }

.preview-col { flex: 1; font-size: 0.8em; line-height: 1.28; min-width: 0; }
.normal-moves-preview { grid-column: 2; grid-row: 1; }
.aura-moves-preview { grid-column: 3; grid-row: 1; }
.preview-col-title { min-width: 0; font-weight: bold; padding: 5px 8px; border-radius: 7px; margin-bottom: 4px; font-size: 0.92em; overflow-wrap: anywhere; }
.preview-col-title.normal { background: #e8e0d1; color: var(--ink); }
.preview-col-title.aura { background: #f4e8ce; color: #805521; border: 1px solid #d9c393; }
.preview-col-title.skill { background: #e4edf0; color: var(--pencil-blue); }
.preview-col div.face-row { min-width: 0; padding: 2px 5px; border-bottom: 1px dashed var(--rule); overflow-wrap: anywhere; }
.preview-col.active-skill-preview {
    grid-column: 1 / -1; grid-row: 2; display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 4px 12px;
    width: 100%; padding: 6px 8px;
    border: 1px solid #c9d7d6; border-radius: 3px; background: #f4f8f6;
}
.active-skill-preview .preview-col-title { grid-column: 1 / -1; min-width: 0; margin: 0; padding: 3px 6px; white-space: normal; overflow-wrap: anywhere; }
.active-skill-preview .face-row { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 3px; border-bottom: 0; }
.active-skill-preview .face-row strong { color: var(--pencil-blue); }
.active-skill-preview.single-active-skill { grid-template-columns: minmax(0, 1fr); }

/* カテゴリごとのUIスタイル（4体×3段） */
.type-section { margin-bottom: 14px; background: rgba(255,250,240,0.9); border: 1px solid var(--rule); padding: 12px 15px 15px; border-radius: 3px; box-shadow: 3px 4px 0 rgba(67, 55, 34, 0.1); }
.type-title { margin: 0 0 10px 0; font-size: 1.05em; border-bottom: 1px solid var(--rule); padding-bottom: 7px; text-align: left; padding-left: 10px; color: var(--ink); }
.type-title.balance { border-left: 4px solid #667d54; }
.type-title.defense { border-left: 4px solid var(--pencil-blue); }
.type-title.attack { border-left: 4px solid var(--pencil-red); }
.type-title span { color: var(--ink-soft); font-size: 0.87em; font-weight: normal; }

.char-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.char-btn { background: #fffaf0; border: 1px solid #d3c7b2; border-radius: 3px; padding: 9px 8px 8px; cursor: pointer; transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s, background 0.18s; box-shadow: 1px 2px 0 rgba(67, 55, 34, 0.1); }
.char-btn:hover:not(:disabled),
.char-btn:focus-visible,
.char-btn.selected { transform: translateY(-2px); border-color: var(--pencil-red); background: #f8eee2; box-shadow: 2px 4px 0 rgba(169,67,53,0.2); outline: none; }
.char-btn:disabled { opacity: 0.6; cursor: not-allowed; border-color: #ddd; background: #eee; }
.char-btn img { max-width: 100%; height: 82px; object-fit: contain; filter: drop-shadow(0 4px 5px rgba(44,62,80,0.12)); }
.char-btn h3 { margin: 4px 0 2px 0; font-size: 0.98em; color: #2c3e50; overflow-wrap: anywhere; }
.char-btn p { margin: 0; font-size: 0.82em; color: #7f8c8d; font-weight: bold; }

/* ================= バトル画面（1画面完結レイアウト） ================= */
#battle-screen { 
    display: none; 
    height: calc(100vh - 20px); 
    flex-direction: column; 
    justify-content: space-between; 
    max-width: 1160px; 
    margin: 0 auto; 
}

.battle-top-bar {
    display: flex; align-items: center; gap: 8px;
    width: min(860px, 100%); margin: 0 auto;
}
.battle-top-bar #battle-log { flex: 1; width: auto; margin: 0; }
.lobby-back-btn {
    flex: 0 0 auto; padding: 8px 14px; border: 1px solid var(--rule);
    border-radius: 3px; background: var(--ink-soft); color: var(--paper-light);
    font: inherit; font-weight: bold; cursor: pointer;
}
.lobby-back-btn:hover { background: var(--ink); }

#battle-log { 
    background-color: var(--ink); color: #fffaf0; padding: 8px 15px; border-radius: 3px; 
    width: 100%; max-width: 860px; margin: 0 auto; font-weight: bold; font-size: 0.96em; 
    min-height: 42px; display: flex; align-items: center; justify-content: center;
    line-height: 1.4;
    overflow-wrap: anywhere;
    box-shadow: 0 3px 6px rgba(0,0,0,0.1);
}

.control-bar {
    display: flex; justify-content: center; align-items: center; gap: 25px; margin: 6px auto; min-height: 54px;
}

/* 本格バトエン（鉛筆）グラフィック */
.pencil-wrapper { display: flex; align-items: center; filter: drop-shadow(0 5px 6px rgba(0,0,0,0.25)); }
.pencil-lead { width: 0; height: 0; border-top: 7px solid transparent; border-bottom: 7px solid transparent; border-right: 16px solid #2c3e50; }
.pencil-wood { width: 0; height: 0; border-top: 21px solid transparent; border-bottom: 21px solid transparent; border-right: 30px solid #f5cba7; margin-left: -16px; z-index: -1; }
.pencil-body {
    width: 230px; height: 42px;
    background: linear-gradient(to bottom, #f4d03f 0%, #f1c40f 30%, #d4ac0d 70%, #b7950b 100%);
    border-top: 2px solid #f9e79f; border-bottom: 2px solid #9a7d0a;
    display: flex; align-items: center; justify-content: center;
    font-weight: bold; font-size: 1.1em; color: #fff; text-shadow: 1px 1px 2px rgba(0,0,0,0.6);
    position: relative;
}
.pencil-body::before, .pencil-body::after { content: ""; position: absolute; left: 0; right: 0; height: 1px; background: rgba(255,255,255,0.4); }
.pencil-body::before { top: 12px; }
.pencil-body::after { bottom: 12px; background: rgba(0,0,0,0.2); }
.pencil-ferrule { width: 14px; height: 42px; background: linear-gradient(to bottom, #bdc3c7, #ecf0f1, #7f8c8d); }
.pencil-eraser { width: 20px; height: 42px; background: linear-gradient(to bottom, #f1948a, #ec7063, #cb4335); border-radius: 0 6px 6px 0; }

.pencil-rolling { animation: pencilRollBounce 0.25s infinite alternate ease-in-out; }
@keyframes pencilRollBounce {
    0% { transform: translateY(-6px) rotate(-2deg) scaleY(0.95); }
    50% { transform: translateY(4px) rotate(1deg) scaleY(1.05); }
    100% { transform: translateY(-4px) rotate(2deg) scaleY(0.92); }
}

.action-btn { 
    font-size: 16px; font-weight: bold; padding: 12px 30px; border: none;             border-radius: 4px; 
    cursor: pointer; background: var(--pencil-red); color: white; 
    box-shadow: 2px 3px 0 rgba(67, 55, 34, 0.2); transition: transform 0.15s; white-space: nowrap;
}
.action-btn:hover:not(:disabled) { transform: translateY(-2px); }
.action-btn:disabled { background: #9c978c; box-shadow: none; cursor: not-allowed; }
.action-btn.active-skill-btn { background: var(--pencil-blue); padding: 10px 16px; font-size: 0.9em; }
.action-btn.active-skill-btn:disabled { background: #9c978c; }

.spectator-badge {
    background: var(--ink); color: #e5c276; padding: 10px 22px; border-radius: 3px; font-weight: bold; font-size: 0.95em;
}

/* メインバトルエリア */
.battle-container { 
    display: flex; justify-content: center; align-items: stretch; gap: 15px; 
    width: 100%; flex: 1; max-height: calc(100vh - 185px); 
}
.battle-container.ffa-mode { display: block; overflow: auto; }
#ffa-board {
    display: none; grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px; max-width: 1160px; margin: 0 auto; padding: 8px;
}
#ffa-board .card { width: auto; min-width: 0; }
#ffa-board .card h2 { overflow-wrap: anywhere; }
#ffa-lobby-panel {
    display: none; background: var(--paper-light); border: 1px solid var(--rule);
    border-left: 5px solid var(--pencil-yellow); border-radius: 3px; padding: 10px;
    width: min(860px, 100%); margin: 4px auto; box-shadow: 2px 3px 0 rgba(67, 55, 34, 0.1);
}
#ffa-lobby-roster { margin: 5px 0; color: var(--ink-soft); }
#ffa-start-btn { display: none; margin: 4px auto; padding: 8px 18px; }

.sidebar { 
    background: var(--paper-light); padding: 10px 12px; border: 1px solid var(--rule); border-radius: 3px; width: 265px; text-align: left; 
    box-shadow: 2px 3px 0 rgba(67, 55, 34, 0.1); display: flex; flex-direction: column; justify-content: space-between;
    transition: background 0.3s, border 0.3s;
}
.sidebar.aura-sidebar {
    background: #f4e8ce;
    border: 2px solid var(--pencil-yellow);
}
.sidebar h3 { margin: 0 0 6px 0; font-size: 0.95em; text-align: center; border-bottom: 2px solid #eee; padding-bottom: 5px; }
.sidebar.aura-sidebar h3 { color: #805521; border-bottom-color: #d9c393; }
.sidebar ul { list-style: none; padding: 0; margin: 0; font-size: 0.88em; flex: 1; display: flex; flex-direction: column; justify-content: space-around; gap: 2px; }
.sidebar li { display: grid; grid-template-columns: 3.6em minmax(0, 1fr); align-items: start; column-gap: 4px; padding: 5px 3px; border-bottom: 1px dashed #dfe5e8; line-height: 1.38; overflow-wrap: break-word; word-break: normal; }
.sidebar li strong { color: var(--pencil-blue); white-space: nowrap; }
.sidebar li .move-description { min-width: 0; }
.sidebar li:last-child { border-bottom: none; }
.ultimate-text { color: #805521; font-weight: bold; background: #f4e8ce; padding: 4px !important; border-radius: 2px; border: 1px solid #d9c393 !important; }

/* キャラカード */
.board { display: flex; gap: 20px; align-items: center; }
.card { 
    background: var(--paper-light); padding: 14px; border: 1px solid var(--rule); border-radius: 3px; width: 235px; 
    box-shadow: 3px 4px 0 rgba(67, 55, 34, 0.12); position: relative; transition: transform 0.2s, box-shadow 0.3s; 
}
.card.turn-active {
    outline: 3px solid var(--pencil-yellow); outline-offset: 1px;
    background: #fff5d8; box-shadow: 0 0 16px rgba(197,139,39,0.5);
}
.turn-indicator {
    display: none; align-self: center; margin: 0 0 2px; padding: 2px 7px;
    border: 1px solid #d9c393; border-radius: 999px;
    background: #f4e8ce; color: #805521; font-size: 0.72em;
    font-weight: bold; line-height: 1.2;
}
.card.turn-active .turn-indicator.current-user-turn {
    display: flex; width: fit-content; margin: 0 auto 2px;
}
.my-card { border-top: 5px solid var(--pencil-blue); }
.opp-card { border-top: 5px solid var(--pencil-red); }
.card h2 { margin: 0 0 6px 0; font-size: 1.1em; }
.card img { max-width: 100%; height: 115px; object-fit: contain; margin: 0 auto 6px auto; }
.card p { margin: 4px 0; font-weight: bold; font-size: 0.95em; }
.aura-text { display: flex; flex-wrap: wrap; justify-content: center; align-content: flex-start; gap: 4px; margin-top: 7px; min-height: 1.8em; font-size: 0.85em; line-height: 1.3; }
.status-chip { display: inline-flex; align-items: center; max-width: 100%; padding: 2px 6px; border: 1px solid; border-radius: 2px; font-size: 0.88em; font-weight: bold; line-height: 1.35; }
.status-aura { color: #805521; background: #f4e8ce; border-color: #d9c393; }
.status-charge { color: #754a18; background: #f6ecd7; border-color: #c58b27; }
.status-guard { color: #315d67; background: #e4edf0; border-color: #9bb2b6; }
.status-evasion { color: #536c47; background: #e5eee0; border-color: #a4b899; }
.status-skip { color: #973f34; background: #f5e1dc; border-color: #d8a69e; }
.status-active-skill { color: var(--ink-soft); background: #e8e0d1; border-color: var(--rule); }

/* カスタムHPバー */
.hp-bar-bg {
    width: 100%; height: 16px; background-color: #ddd4c4; border: 1px solid #c8bda9; border-radius: 2px; overflow: hidden;
}
.hp-bar-fill {
    height: 100%; width: 100%; background-color: #86ad63; transition: width 0.35s ease, background-color 0.35s ease;
}
.hp-mid { background-color: #f3cb4f !important; }
.hp-low { background-color: #ed715d !important; animation: hpBlink 0.7s infinite alternate; }
@keyframes hpBlink { 0% { opacity: 1; } 100% { opacity: 0.5; } }

.card-pinch { box-shadow: 0 0 18px rgba(231, 76, 60, 0.75) !important; border-color: #e74c3c; }
.card-ko {
    filter: grayscale(0.85);
    opacity: 0.72;
    box-shadow: 0 0 24px rgba(231, 76, 60, 0.9) !important;
    border: 3px solid #c0392b;
}
.card-ko::after {
    content: "KO";
    position: absolute;
    inset: 38% 0 auto;
    color: #fff;
    font-size: 3.8em;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-shadow: 3px 3px 0 #c0392b, -2px -2px 0 #c0392b, 0 0 14px #000;
    transform: rotate(-8deg);
    z-index: 28;
    pointer-events: none;
}

.has-aura {
    animation: auraPulse 1.8s infinite alternate ease-in-out;
    border: 2px solid var(--pencil-yellow);
    background: #f7edda;
}
@keyframes auraPulse {
    0% { box-shadow: 2px 3px 0 rgba(67, 55, 34, 0.12); transform: scale(1); }
    100% { box-shadow: 0 0 12px rgba(197, 139, 39, 0.42), 2px 3px 0 rgba(67, 55, 34, 0.12); transform: scale(1.01); }
}
.card.card-ko { animation: koFall 0.62s cubic-bezier(0.2, 0.75, 0.35, 1) both; }
.card.card-ko::after { animation: koStamp 0.48s cubic-bezier(0.2, 0.8, 0.3, 1.2) both; }
@keyframes koFall {
    0% { transform: translateY(-12px) scale(1.04); filter: grayscale(0); opacity: 1; }
    45% { transform: translateY(4px) scale(0.96); filter: grayscale(0.45); opacity: 0.8; }
    100% { transform: translateY(0) scale(1); filter: grayscale(0.85); opacity: 0.72; }
}
@keyframes koStamp {
    0% { opacity: 0; transform: rotate(-8deg) scale(2.2); }
    70% { opacity: 1; transform: rotate(-8deg) scale(0.92); }
    100% { opacity: 1; transform: rotate(-8deg) scale(1); }
}

/* ワンクリック定型スタンプバー */
#stamp-bar {
    display: flex; justify-content: center; gap: 8px; margin-top: 6px; flex-wrap: wrap;
}
.stamp-btn {
    background: var(--paper-light); border: 1px solid #b9ad99; border-radius: 3px;
    padding: 5px 14px; font-size: 0.88em; font-weight: bold; color: var(--ink);
    cursor: pointer; transition: transform 0.15s, border-color 0.15s, background 0.15s;
}
.stamp-btn:hover { transform: translateY(-1px); border-color: var(--pencil-blue); background: #eaf0ec; }

.stamp-bubble {
    position: absolute; top: -42px; left: 50%; transform: translateX(-50%);
    background: #fff; border: 3px solid #2c3e50; border-radius: 18px;
    padding: 6px 14px; font-weight: bold; font-size: 0.95em; color: #2c3e50;
    white-space: nowrap; box-shadow: 0 4px 10px rgba(0,0,0,0.2); z-index: 30;
    animation: bubblePop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.stamp-bubble::after {
    content: ""; position: absolute; bottom: -10px; left: 50%; transform: translateX(-50%);
    border-width: 10px 8px 0; border-style: solid; border-color: #2c3e50 transparent transparent;
}
@keyframes bubblePop { 0% { transform: translateX(-50%) scale(0.3); opacity: 0; } 100% { transform: translateX(-50%) scale(1); opacity: 1; } }

/* 揺れ・突進アニメーション */
.shake { animation: shake 0.35s ease-in-out; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

.screen-shake { animation: screenShake 0.6s ease-in-out; }
@keyframes screenShake {
    0%, 100% { transform: translate(0, 0); }
    10%, 30%, 50%, 70%, 90% { transform: translate(-10px, 6px); }
    20%, 40%, 60%, 80% { transform: translate(10px, -6px); }
}

.attack-motion { animation: attackMotion 0.45s ease; z-index: 5; }
@keyframes attackMotion { 0% { transform: translateX(0); } 50% { transform: translateX(40px) scale(1.08); box-shadow: 0 10px 25px rgba(0,0,0,0.25); } 100% { transform: translateX(0); } }

.attack-motion-opp { animation: attackMotionOpp 0.45s ease; z-index: 5; }
@keyframes attackMotionOpp { 0% { transform: translateX(0); } 50% { transform: translateX(-40px) scale(1.08); box-shadow: 0 10px 25px rgba(0,0,0,0.25); } 100% { transform: translateX(0); } }

.floating-damage { 
    position: absolute; left: -20px; right: -20px; top: 30%; text-align: center; 
    color: #e74c3c; font-size: 2.5em; font-weight: 900; 
    text-shadow: 2px 2px 0 #fff, -2px -2px 0 #fff, 0 4px 10px rgba(0,0,0,0.4); 
    pointer-events: none; animation: floatUp 1.3s forwards; z-index: 25; line-height: 1.1;
}
.floating-big { font-size: 3.3em; color: #ff2e00; }
.floating-heal { color: #2ecc71; }
.floating-mod { display: block; font-size: 0.42em; background: #2c3e50; color: #f1c40f; padding: 2px 8px; border-radius: 10px; width: fit-content; margin: 0 auto 2px auto; text-shadow: none; }
@keyframes floatUp { 0% { opacity: 1; margin-top: 0; transform: scale(0.7); } 20% { transform: scale(1.25); } 100% { opacity: 0; margin-top: -70px; transform: scale(1.05); } }

/* VFX エフェクト */
.vfx { position: absolute; left: 0; right: 0; top: 25%; text-align: center; font-size: 5.5em; pointer-events: none; z-index: 20; opacity: 0; }
.vfx-fire { animation: vfx-explode 0.7s ease-out; }
.vfx-slash { animation: vfx-cut 0.45s ease-out; }
.vfx-hit { animation: vfx-bump 0.35s ease-out; }
.vfx-aura { animation: vfx-glow 1s ease-out; font-size: 6em; }
.vfx-laser { animation: vfx-explode 0.7s ease-out; filter: hue-rotate(180deg); }
.vfx-heal { animation: vfx-glow 0.8s ease-out; }
.vfx-ice { animation: vfx-glow 0.75s ease-out; filter: drop-shadow(0 0 8px #74d4ff); }
.vfx-aura-ultimate {
    animation: auraUltimateBurst 1.25s cubic-bezier(0.16, 1, 0.3, 1);
    filter: drop-shadow(0 0 16px #fff3a6) drop-shadow(0 0 30px #ff8a24);
    text-shadow: 0 0 20px #fff3a6, 0 0 42px #ff8a24;
}
.vfx-aura-ultimate::before,
.vfx-aura-ultimate::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 1.25em;
    height: 1.25em;
    border: 5px solid rgba(255, 231, 143, 0.9);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: auraUltimateRing 1.15s ease-out both;
}
.vfx-aura-ultimate::after {
    width: 1.75em;
    height: 1.75em;
    border-color: rgba(255, 125, 44, 0.8);
    animation-delay: 0.12s;
}
.active-skill-vfx {
    position: absolute;
    inset: 12% 0 auto;
    z-index: 22;
    color: #fff;
    font-size: 4.5em;
    line-height: 1;
    pointer-events: none;
    text-shadow: 0 0 12px #fff, 0 0 28px #55c8e8;
    animation: activeSkillBurst 1.05s ease-out both;
}
.active-skill-vfx-heal { text-shadow: 0 0 12px #fff, 0 0 28px #5ee99a; }
.active-skill-vfx-guard { text-shadow: 0 0 12px #fff, 0 0 28px #62b9ff; }
.active-skill-vfx-charge { text-shadow: 0 0 12px #fff, 0 0 28px #ffd65a; }
.active-skill-activation {
    outline: 3px solid #6bd9f4;
    box-shadow: 0 0 28px rgba(74, 205, 241, 0.95), 0 0 58px rgba(255, 220, 112, 0.7) !important;
    animation: activeSkillCard 1.05s ease-out;
}
@keyframes activeSkillBurst {
    0% { opacity: 0; transform: scale(0.25) translateY(24px) rotate(-12deg); }
    35% { opacity: 1; transform: scale(1.25) translateY(0) rotate(5deg); }
    100% { opacity: 0; transform: scale(1.7) translateY(-30px) rotate(0); }
}
@keyframes activeSkillCard {
    0%, 100% { filter: brightness(1); transform: scale(1); }
    30% { filter: brightness(1.5); transform: scale(1.07); }
    60% { filter: brightness(1.15); transform: scale(1.02); }
}
@keyframes auraUltimateBurst {
    0% { opacity: 0; transform: scale(0.1) rotate(-20deg); }
    25% { opacity: 1; transform: scale(1.1) rotate(8deg); }
    65% { opacity: 1; transform: scale(1.35) rotate(-5deg); }
    100% { opacity: 0; transform: scale(2.2) rotate(0); }
}
@keyframes auraUltimateRing {
    0% { opacity: 0.95; transform: translate(-50%, -50%) scale(0.2); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(2.8); }
}
.multi-hit-count {
    position: absolute;
    right: 18%;
    bottom: 8%;
    font-size: 0.24em;
    line-height: 1;
    color: #fff;
    background: rgba(231, 76, 60, 0.95);
    border: 2px solid #fff;
    border-radius: 999px;
    padding: 3px 8px;
    text-shadow: 1px 1px 0 #000;
}
@keyframes vfx-explode { 0% { transform: scale(0.4); opacity: 1; } 50% { transform: scale(1.6); opacity: 1; } 100% { transform: scale(2.1); opacity: 0; } }
@keyframes vfx-cut { 0% { transform: scale(2) rotate(-45deg); opacity: 0; } 50% { transform: scale(1.1) rotate(0deg); opacity: 1; } 100% { opacity: 0; } }
@keyframes vfx-bump { 0% { transform: scale(0); opacity: 1; } 100% { transform: scale(1.6); opacity: 0; } }
@keyframes vfx-glow { 0% { transform: scale(0.7); opacity: 1; } 100% { transform: scale(1.3); opacity: 0; } }

/* カットイン演出オーバーレイ */
#cutin-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 80; justify-content: center; align-items: center; }
.cutin-bar {
    width: 100%; height: 140px;
    background: linear-gradient(90deg, rgba(41,43,40,0.96) 0%, rgba(49,93,103,0.98) 50%, rgba(41,43,40,0.96) 100%);
    border-top: 2px solid #d7ccb6; border-bottom: 2px solid #d7ccb6;
    display: flex; align-items: center; justify-content: center; gap: 30px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4); animation: cutinSlide 1.1s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.cutin-bar img { height: 120px; max-width: min(20vw, 150px); flex: 0 0 auto; object-fit: contain; object-position: center; }
.cutin-bar span { color: white; flex: 0 1 auto; min-width: 0; max-width: calc(100vw - min(24vw, 190px) - 72px); white-space: nowrap; font-size: clamp(1rem, 3.2vw, 2.8em); font-weight: 900; font-style: normal; text-shadow: 2px 2px 0 #000; letter-spacing: 0.02em; }
@keyframes cutinSlide { 0% { transform: translateX(-100%) skewX(-15deg); opacity: 0; } 20% { transform: translateX(0) skewX(-15deg); opacity: 1; } 80% { transform: translateX(0) skewX(-15deg); opacity: 1; } 100% { transform: translateX(100%) skewX(-15deg); opacity: 0; } }

#cutin-overlay.ultimate-mode { background: rgba(0, 0, 0, 0.78); animation: ultFlash 1.6s ease-out forwards; }
.active-skill-mode .cutin-bar {
    height: 170px;
    background: linear-gradient(100deg, #173b50 0%, #277f91 48%, #735b28 100%);
    border-top: 3px solid #8cecff;
    border-bottom: 3px solid #8cecff;
    box-shadow: 0 0 28px rgba(86, 220, 255, 0.8), 0 8px 32px rgba(0,0,0,0.65);
    animation: activeSkillCutin 1.1s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.active-skill-mode .cutin-bar span {
    color: #fff;
    text-shadow: 0 0 12px #5bdcff, 2px 2px 0 #173b50;
}
.active-skill-mode .cutin-bar img { height: 145px; }
.active-skill-mode { background: radial-gradient(ellipse, rgba(53, 162, 190, 0.34), rgba(0, 0, 0, 0.68)); }
#cutin-overlay.ultimate-mode.aura-ultimate-mode {
    overflow: hidden;
    background: radial-gradient(circle, rgba(255, 211, 94, 0.52), rgba(88, 31, 99, 0.82) 48%, rgba(12, 8, 24, 0.94));
    animation: auraUltimateFlash 2.3s ease-out forwards;
}
.aura-ultimate-mode::before,
.aura-ultimate-mode::after {
    content: "";
    position: absolute;
    inset: -35%;
    background: repeating-conic-gradient(from 0deg, rgba(255, 229, 145, 0.3) 0deg 4deg, transparent 4deg 18deg);
    animation: auraUltimateRays 2.3s linear infinite;
}
.aura-ultimate-mode::after {
    inset: 12%;
    border: 3px solid rgba(255, 232, 153, 0.8);
    border-radius: 50%;
    background: radial-gradient(circle, transparent 55%, rgba(255, 221, 130, 0.24));
    animation: auraUltimateHalo 2.3s ease-out both;
}
.ultimate-mode.aura-ultimate-mode .cutin-bar {
    position: relative;
    z-index: 1;
    height: 250px;
    background: linear-gradient(100deg, #38165b 0%, #923c72 28%, #ca652e 58%, #e0b544 78%, #51234e 100%);
    border-top: 4px solid #fff0a6;
    border-bottom: 4px solid #ffbd55;
    box-shadow: 0 0 30px #ffb84d, 0 0 75px rgba(255, 92, 63, 0.9), 0 8px 40px rgba(0,0,0,0.75);
    animation: auraUltimateCutin 2.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.ultimate-mode.aura-ultimate-mode .cutin-bar img { height: 210px; filter: drop-shadow(0 0 18px #fff2a1); }
.ultimate-mode.aura-ultimate-mode .cutin-bar span {
    color: #fff8cc;
    font-size: clamp(1.2rem, 4.6vw, 4.3em);
    text-shadow: 0 0 12px #ffef9a, 0 0 28px #ff8a32, 3px 4px 0 #421748;
}
.ultimate-mode.aura-ultimate-mode .cutin-bar.long-title { min-height: 225px; }
.ultimate-mode.aura-ultimate-mode .cutin-bar.long-title img { height: 68px; }
.ultimate-mode.aura-ultimate-mode .cutin-bar.long-title span { font-size: clamp(1rem, 3.5vw, 2.3em) !important; }
@keyframes activeSkillCutin {
    0% { transform: translateX(-100%) scale(0.9); opacity: 0; }
    18% { transform: translateX(0) scale(1); opacity: 1; }
    78% { transform: translateX(0) scale(1); opacity: 1; }
    100% { transform: translateX(100%) scale(1.04); opacity: 0; }
}
@keyframes auraUltimateRays { to { transform: rotate(360deg); } }
@keyframes auraUltimateFlash {
    0% { background-color: rgba(255, 255, 255, 0.95); }
    12% { background-color: rgba(246, 147, 63, 0.72); }
    25%, 82% { background-color: rgba(20, 9, 36, 0.9); }
    100% { background-color: rgba(20, 9, 36, 0); }
}
@keyframes auraUltimateHalo {
    0% { opacity: 0; transform: scale(0.25) rotate(-20deg); }
    30% { opacity: 1; transform: scale(1) rotate(10deg); }
    100% { opacity: 0.2; transform: scale(1.35) rotate(55deg); }
}
@keyframes auraUltimateCutin {
    0% { transform: scale(0.76) translateY(35px) rotate(-2deg); opacity: 0; }
    12% { transform: scale(1.04) translateY(0) rotate(0); opacity: 1; }
    22% { transform: scale(0.99); }
    82% { transform: scale(1); opacity: 1; }
    100% { transform: scale(1.07) translateY(-24px); opacity: 0; }
}
.aura-ultimate-impact { animation: auraUltimateScreenShake 1.05s ease-in-out; }
@keyframes auraUltimateScreenShake {
    0%, 100% { transform: translate(0, 0); filter: brightness(1); }
    10%, 30%, 50%, 70%, 90% { transform: translate(-12px, 8px); filter: brightness(1.3); }
    20%, 40%, 60%, 80% { transform: translate(12px, -8px); filter: brightness(1.1); }
}
.ultimate-mode .cutin-bar {
    height: 220px; background: linear-gradient(90deg, #51452f 0%, #977039 35%, #a94335 75%, #4f2924 100%);
    border-top: 3px solid #e5c276; border-bottom: 3px solid #e5c276; box-shadow: 0 8px 32px rgba(0,0,0,0.65);
    animation: ultCutinZoom 1.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.ultimate-mode .cutin-bar img { height: 190px; max-width: min(24vw, 190px); }
.ultimate-mode .cutin-bar span { max-width: calc(100vw - min(24vw, 190px) - 72px); font-size: clamp(1rem, 4vw, 3.8em); color: #fff; text-shadow: 2px 2px 0 #2b2114; }
.cutin-bar.long-title { height: auto; min-height: 150px; flex-direction: column; gap: 6px; padding: 8px 16px; }
.cutin-bar.long-title img { height: 54px; max-width: 100px; }
.cutin-bar.long-title span { max-width: calc(100vw - 32px); white-space: normal; text-align: center; text-wrap: balance; line-height: 1.2; font-size: clamp(1rem, 3.2vw, 2em) !important; }
.ultimate-mode .cutin-bar.long-title { min-height: 210px; }
.ultimate-mode .cutin-bar.long-title img { height: 64px; }
@keyframes ultFlash { 0% { background: rgba(255, 255, 255, 0.95); } 15% { background: rgba(0, 0, 0, 0.85); } 85% { background: rgba(0, 0, 0, 0.85); } 100% { background: rgba(0, 0, 0, 0); } }
@keyframes ultCutinZoom { 0% { transform: scale(0.94) translateY(12px); opacity: 0; } 15% { transform: scale(1) translateY(0); opacity: 1; } 85% { transform: scale(1) translateY(0); opacity: 1; } 100% { transform: scale(0.98) translateY(-12px); opacity: 0; } }

@media (max-width: 900px) {
    body { padding: 8px 10px; }
    #preview-panel {
        min-height: 150px;
        max-height: 42vh;
        overflow-y: auto;
        grid-template-columns: 170px repeat(2, minmax(0, 1fr));
    }
    .preview-left img { height: 76px; }
    .char-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    #battle-screen { height: auto; min-height: 100vh; }
    .battle-container {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        flex: none;
        max-height: none;
        overflow: visible;
    }
    .battle-container .board {
        grid-column: 1 / -1;
        grid-row: 1;
        justify-content: center;
        width: 100%;
        gap: 12px;
    }
    .battle-container .sidebar {
        width: 100%;
        min-height: 190px;
        height: auto;
        flex-shrink: 1;
    }
    #my-sidebar { grid-column: 1; grid-row: 2; }
    #opp-sidebar { grid-column: 2; grid-row: 2; }
    .sidebar ul { font-size: 0.82em; }
    .card { width: 220px; max-width: calc(50vw - 16px); }
    .control-bar { gap: 10px; flex-wrap: wrap; }
    #stamp-bar { margin: 8px 0; }
}

@media (max-width: 620px) {
    body { padding: 6px; }
    .mode-selector { gap: 7px; }
    .mode-btn { padding: 9px 7px; }
    .mode-btn-title { font-size: 0.92em; }
    .mode-btn-sub { font-size: 0.72em; }
    #preview-panel {
        position: sticky;
        top: 4px;
        display: grid;
        grid-template-columns: minmax(0, 92px) minmax(0, 1fr);
        gap: 8px;
        min-height: 138px;
        max-height: 48vh;
    }
    .preview-placeholder { grid-column: 1 / -1; min-height: 120px; }
    .preview-left { width: auto; border-right: 1px solid #edf1f4; padding-right: 6px; }
    .preview-left img { height: 58px; max-width: 82px; }
    .preview-left h3 { font-size: 0.82em; }
    .preview-left p { font-size: 0.72em; }
    #preview-panel > .normal-moves-preview { grid-column: 2; grid-row: 1; }
    #preview-panel > .aura-moves-preview,
    #preview-panel > .active-skill-preview { grid-column: 1 / -1; }
    .preview-col.active-skill-preview { grid-template-columns: minmax(0, 1fr); }
    .preview-col { font-size: 0.74em; }
    .char-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .type-section { padding: 10px 8px 12px; }
    .char-btn img { height: 70px; }
    .battle-container { gap: 6px; }
    .battle-container .board { gap: 6px; }
    .battle-container .sidebar {
        min-height: 230px;
        padding: 8px 6px;
    }
    .sidebar h3 { font-size: 0.82em; }
    .sidebar ul { font-size: 0.75em; }
    .sidebar li { grid-template-columns: 3.2em minmax(0, 1fr); column-gap: 2px; padding: 4px 2px; line-height: 1.32; }
    .card { width: calc(50vw - 10px); max-width: none; padding: 10px 8px; }
    .card h2 { font-size: 0.92em; }
    .card img { height: 82px; }
    .card p { font-size: 0.78em; }
    .aura-text { font-size: 0.72em; }
    .pencil-wrapper { transform: scale(0.82); transform-origin: center; }
    .action-btn { padding: 10px 18px; font-size: 0.92em; }
}

/* コイントス演出オーバーレイ */
#coin-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.75); z-index: 90; justify-content: center; align-items: center; flex-direction: column; color: white; }
.coin { width: 130px; height: 130px; border-radius: 50%; background: radial-gradient(circle at 30% 30%, #f9e79f, #f1c40f 60%, #b7950b); border: 6px solid #fff; box-shadow: 0 0 30px rgba(241, 196, 15, 0.8); display: flex; align-items: center; justify-content: center; font-size: 2.2em; font-weight: bold; color: #7e5109; margin-bottom: 20px; }
.coin-spinning { animation: coinSpin 0.25s linear infinite; }
@keyframes coinSpin { 0% { transform: rotateY(0deg) scale(1.1); } 50% { transform: rotateY(180deg) scale(1.2); } 100% { transform: rotateY(360deg) scale(1.1); } }
#coin-result-text { font-size: 2.5em; font-weight: bold; text-shadow: 0 0 15px #f1c40f; }

/* リザルト画面オーバーレイ */
#result-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.85); z-index: 100; justify-content: center; align-items: center; flex-direction: column; color: white; }
#result-title { font-size: 5em; margin: 0; text-shadow: 0 0 20px #f1c40f; }
#result-sub { font-size: 1.5em; margin-bottom: 40px; color: #ecf0f1; }
#target-roulette {
    display: none; position: fixed; inset: 0; z-index: 98; align-items: center; justify-content: center;
    background: rgba(26, 29, 27, 0.78); color: #fffaf0;
}
#target-roulette-card {
    min-width: min(360px, 82vw); padding: 22px 30px; border: 3px solid var(--pencil-yellow);
    border-radius: 8px; background: var(--paper-light); color: var(--ink);
    box-shadow: 0 0 30px rgba(197, 139, 39, 0.65); animation: roulettePulse 0.25s infinite alternate;
}
#target-roulette-title { margin: 0 0 8px; font-size: 1em; color: var(--ink-soft); }
#target-roulette-name { margin: 0; font-size: 1.8em; }
@keyframes roulettePulse { to { transform: scale(1.035); } }
@media (max-width: 560px) {
    .mode-selector { gap: 7px; flex-wrap: wrap; }
    .mode-btn { min-width: 145px; padding: 10px 8px; }
    .username-field { flex-wrap: wrap; }
    #ffa-board { gap: 7px; padding: 4px; }
    #ffa-board .card { padding: 9px 6px; }
    #ffa-board .card img { height: 74px; }
    #ffa-board .card h2 { font-size: 0.82em; }
    #ffa-board .card p { font-size: 0.72em; }
    #ffa-board .aura-text { font-size: 0.65em; }
}

.player-name-tag {
    display: flex; align-items: center; justify-content: center; gap: 4px;
    max-width: 100%; margin: 0 auto 2px; padding: 2px 6px;
    border: 1px solid #c9d7d6; border-radius: 999px;
    background: #e8f0ed; color: var(--pencil-blue);
    font-size: 0.7em; line-height: 1.2;
}
.player-name-caption { flex: 0 0 auto; color: var(--ink-soft); }
.player-name-value {
    min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-weight: 800;
}
body.ffa-battle-mode {
    height: 100vh; overflow: hidden; padding-top: 8px; padding-bottom: 8px;
}
#battle-screen.ffa-battle-screen {
    height: calc(100vh - 16px); min-height: 0; max-height: 100%;
    justify-content: flex-start; gap: 4px; overflow: hidden;
}
.ffa-battle-screen #battle-log {
    flex: 0 0 auto; min-height: 36px; max-height: 3em;
    padding: 5px 10px; overflow: hidden;
}
.ffa-battle-screen .battle-top-bar { flex: 0 0 auto; }
.ffa-battle-screen .lobby-back-btn { padding: 5px 10px; font-size: 0.78em; }
.ffa-battle-screen #ffa-lobby-panel {
    flex: 0 0 auto; overflow: visible;
    margin: 2px auto; padding: 5px 8px; font-size: 0.78em;
}
.ffa-battle-screen #ffa-lobby-roster {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ffa-battle-screen #ffa-start-btn { padding: 5px 12px; margin: 2px auto 0; font-size: 0.78em; }
.ffa-battle-screen .control-bar {
    flex: 0 0 auto; min-height: 42px; margin: 2px auto;
    gap: 10px;
}
.ffa-battle-screen .pencil-wrapper { transform: scale(0.74); transform-origin: left center; }
.ffa-battle-screen .battle-container.ffa-mode {
    display: flex; flex: 0 1 auto; min-height: 0; height: auto;
    max-height: none; overflow: visible; align-items: stretch;
}
.ffa-battle-screen #ffa-board {
    display: grid; width: 100%; height: auto; min-height: 0;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    grid-template-rows: auto;
    gap: 6px; padding: 2px; overflow: visible; align-content: start;
}
.ffa-battle-screen #ffa-board.ffa-count-1 {
    grid-template-columns: minmax(0, min(420px, 100%));
    grid-template-rows: auto;
    justify-content: center;
}
.ffa-battle-screen #ffa-board.ffa-count-2 { grid-template-rows: auto; }
.ffa-battle-screen #ffa-board .card {
    display: flex; flex-direction: column; justify-content: flex-start;
    width: auto; height: auto; max-height: clamp(210px, 40vh, 320px);
    align-self: stretch; min-width: 0; min-height: 0; gap: 2px;
    overflow: hidden; padding: clamp(6px, 1vh, 12px) 6px;
}
.ffa-battle-screen #ffa-board:not(.ffa-count-1) .card {
    width: min(100%, 46vw, 460px); justify-self: center;
}
.ffa-battle-screen #ffa-board .player-name-tag {
    flex: 0 0 auto; margin: 0 auto 1px; padding: 1px 5px;
    font-size: clamp(0.62em, 1.35vh, 0.76em);
}
.ffa-battle-screen #ffa-board .turn-indicator {
    flex: 0 0 auto; margin: 0 0 1px; padding: 1px 6px;
    font-size: clamp(0.62em, 1.3vh, 0.76em);
}
.ffa-battle-screen #ffa-board .card img {
    flex: 0 1 auto; height: clamp(54px, 15vh, 112px);
    max-height: 112px; margin: 0 auto 1px;
}
.ffa-battle-screen #ffa-board .card h2 {
    flex: 0 0 auto; max-height: 2.3em; margin: 0; font-size: clamp(0.72em, 1.7vh, 1.05em);
    line-height: 1.15; overflow: hidden; overflow-wrap: anywhere;
}
.ffa-battle-screen #ffa-board .card p {
    flex: 0 0 auto; margin: 1px 0; font-size: clamp(0.68em, 1.35vh, 0.84em);
    line-height: 1.15;
}
.ffa-battle-screen #ffa-board .hp-bar-bg {
    flex: 0 0 10px; width: min(75%, 190px); height: 10px; margin: 0 auto;
}
.ffa-battle-screen #ffa-board .aura-text {
    flex: 0 0 auto; max-height: 2.3em; min-height: 0; margin-top: 1px; gap: 2px; overflow: hidden;
    font-size: clamp(0.62em, 1.25vh, 0.78em);
}
.ffa-battle-screen .ffa-moves-btn {
    flex: 0 0 auto; align-self: center; margin-top: 2px; padding: 3px 9px;
    border: 1px solid #9bb2b6; border-radius: 3px; background: #e4edf0;
    color: var(--pencil-blue); font: inherit; font-size: clamp(0.64em, 1.25vh, 0.78em);
    font-weight: bold; line-height: 1.1; cursor: pointer;
}
.ffa-battle-screen .ffa-moves-btn:hover { background: #d7e5e8; }
#ffa-moves-dialog {
    width: min(560px, calc(100vw - 24px)); max-height: min(80dvh, 620px);
    margin: auto; padding: 14px; border: 1px solid var(--rule);
    border-top: 4px solid var(--pencil-blue); border-radius: 4px;
    background: var(--paper-light); color: var(--ink);
    box-shadow: 0 8px 28px rgba(0,0,0,0.3); text-align: left;
}
#ffa-moves-dialog::backdrop { background: rgba(41,43,40,0.58); }
.ffa-moves-dialog-header {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
    margin-bottom: 8px;
}
.ffa-moves-dialog-header h2 { margin: 0; font-size: 1.1em; overflow-wrap: anywhere; }
.ffa-moves-dialog-close {
    flex: 0 0 auto; padding: 4px 9px; border: 1px solid var(--rule);
    border-radius: 3px; background: #e8e0d1; color: var(--ink);
    font: inherit; font-weight: bold; cursor: pointer;
}
#ffa-moves-list {
    max-height: min(64dvh, 500px); overflow-y: auto; list-style: none;
    padding: 0; margin: 0; font-size: 0.9em;
}
#ffa-moves-list li {
    display: grid; grid-template-columns: 3.6em minmax(0, 1fr);
    align-items: start; column-gap: 6px; padding: 6px 3px;
    border-bottom: 1px dashed var(--rule); line-height: 1.38;
    overflow-wrap: anywhere;
}
#ffa-moves-list li strong { color: var(--pencil-blue); white-space: nowrap; }
#ffa-moves-list li.ultimate-text { color: #805521; background: #f4e8ce; }
#ffa-moves-list li.active-skill-move {
    grid-template-columns: minmax(0, 1fr);
    background: #e4edf0; border-left: 3px solid var(--pencil-blue); padding-left: 7px;
}
#ffa-moves-list li.active-skill-move .move-description { min-width: 0; }
#ffa-moves-list li.active-skill-move .active-skill-mode {
    display: inline-block; width: fit-content; max-width: 100%;
    padding: 2px 6px; border-radius: 2px;
    background: #d7e5e8; color: #244750;
    font-size: 0.82em; font-weight: 600; line-height: 1.3;
}
#ffa-moves-list li.active-skill-move .active-skill-name {
    display: block; white-space: normal; overflow-wrap: anywhere; color: var(--pencil-blue);
    font-size: 1.05em;
}
#ffa-moves-list li.active-skill-move .active-skill-effect {
    display: block; margin-top: 2px;
}
.ffa-battle-screen #stamp-bar {
    display: grid; flex: 0 0 auto; grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px; margin: 2px 0 0;
}
.ffa-battle-screen .stamp-btn {
    min-width: 0; padding: 4px 2px; font-size: 0.72em; line-height: 1.2;
    white-space: normal; overflow-wrap: anywhere;
}
.ffa-battle-screen #ffa-board .stamp-message-slot {
    display: flex; position: relative; flex: 0 0 36px;
    align-items: center; justify-content: center; width: 100%; min-width: 0;
    visibility: hidden;
}
.ffa-battle-screen #ffa-board .stamp-message-slot:not(:empty) { visibility: visible; }
.ffa-battle-screen #ffa-board .stamp-bubble {
    position: absolute; top: 0; left: 50%; transform: translateX(-50%);
    transform-origin: top center;
    padding: 2px 8px; border-width: 2px; line-height: 1.1;
    max-width: calc(100% - 8px); font-size: 0.95em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    animation: ffaBubblePop 0.3s ease-out;
}
@keyframes ffaBubblePop {
    0% { opacity: 0; transform: translateX(-50%) scale(0.3); }
    100% { opacity: 1; transform: translateX(-50%) scale(1); }
}
@media (max-width: 900px) {
    body.ffa-battle-mode { height: 100dvh; padding: 5px; }
    #battle-screen.ffa-battle-screen { height: calc(100dvh - 10px); }
    .ffa-battle-screen .battle-container.ffa-mode { display: flex; }
    .ffa-battle-screen .control-bar { gap: 5px; flex-wrap: nowrap; }
    .ffa-battle-screen .pencil-wrapper {
        transform: scale(0.42); transform-origin: left center; margin-right: -171px;
    }
    .ffa-battle-screen .action-btn { padding: 6px 8px; font-size: 0.76em; }
    .ffa-battle-screen .action-btn.active-skill-btn {
        max-width: 32vw; padding: 5px 6px; font-size: 0.68em; white-space: normal;
    }
    .ffa-battle-screen #roll-btn { padding: 6px 8px; font-size: 0.76em; }
    .ffa-battle-screen #ffa-board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ffa-battle-screen #ffa-board { gap: 3px; padding: 1px; }
    .ffa-battle-screen #ffa-board .card { padding: 2px; }
    .ffa-battle-screen #ffa-board .card img {
        height: clamp(60px, 16vh, 112px); max-height: 112px;
    }
    .ffa-battle-screen #ffa-board .card p { font-size: 0.7em; }
    .ffa-battle-screen #ffa-board .aura-text { font-size: 0.64em; }
}
@media (max-width: 380px) {
    .ffa-battle-screen .pencil-wrapper { display: none; }
    .ffa-battle-screen .control-bar { justify-content: center; }
}
