/* ═══════════════════════════════════════════════
   MINIGAME PAGE — LAPIN RACE
   Board game where a memory-match minigame decides
   each move. Uses the global palette from style.css
   (--pink-*, --white, --text-pink, --shadow, --radius-*)
   ═══════════════════════════════════════════════ */

.minigame-section .section-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 22px;
}

/* ── Setup panel ─────────────────────────────── */
/* LAPIN RACE - Sound Control */
.mg-sound-control {
    display: flex;
    justify-content: flex-end;
    margin: 10px 0 14px;
}

.mg-sound-control .mg-btn {
    min-width: 150px;
}

@media (max-width: 600px) {
    .mg-sound-control {
        justify-content: stretch;
    }

    .mg-sound-control .mg-btn {
        width: 100%;
        min-width: 0;
    }
}
.mg-setup {
    width: 100%;
    max-width: 460px;
    background: var(--pink-light);
    border-radius: var(--radius-md);
    padding: 24px 22px;
    text-align: center;
    margin-top: 10px;
}

.mg-setup p.mg-lead {
    font-size: 14px;
    color: var(--text-pink);
    font-weight: 600;
    margin-bottom: 16px;
    line-height: 1.6;
}

.mg-count-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-bottom: 14px;
}

.mg-count-row input[type="number"] {
    width: 76px;
    text-align: center;
    font-family: 'Kanit', sans-serif;
    font-size: 22px;
    font-weight: 800;
    color: var(--text-pink);
    border: 2px solid var(--pink-mid);
    border-radius: var(--radius-sm);
    padding: 8px 4px;
    background: var(--white);
}

.mg-count-row input[type="range"] {
    flex: 1;
    accent-color: var(--pink-deep);
}

.mg-presets {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-bottom: 18px;
}

.mg-preset-btn {
    background: var(--white);
    border: 2px solid var(--pink-mid);
    color: var(--text-pink);
    font-family: 'Kanit', sans-serif;
    font-weight: 700;
    font-size: 13px;
    border-radius: 999px;
    padding: 6px 16px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, transform 0.15s;
}

.mg-preset-btn:hover {
    background: var(--pink-deep);
    color: var(--white);
    transform: translateY(-2px);
}

.mg-start-btn {
    font-family: 'Bebas Neue', sans-serif;
    letter-spacing: 2px;
    font-size: 20px;
    background: var(--pink-deep);
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    padding: 12px 40px;
    cursor: pointer;
    box-shadow: 0 4px 14px var(--shadow);
    transition: transform 0.15s, box-shadow 0.15s;
}

.mg-start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px var(--shadow);
}

/* ── Turn banner ──────────────────────────────── */
.mg-game {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.mg-turn-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--white);
    border: 3px solid var(--pink-mid);
    border-radius: 999px;
    padding: 8px 22px 8px 8px;
    box-shadow: 0 4px 14px var(--shadow);
}

.mg-turn-banner .mg-turn-label {
    font-family: 'Kanit', sans-serif;
    font-size: 12px;
    font-weight: 700;
    color: var(--pink-mid);
    letter-spacing: 1px;
    display: block;
}

.mg-turn-banner .mg-turn-name {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 22px;
    letter-spacing: 1px;
    color: var(--text-pink);
    line-height: 1.1;
}

/* ── Player strip (scrollable, supports up to 30) ── */
.mg-player-strip {
    width: 100%;
    max-width: 720px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 6px 4px 10px;
    scrollbar-width: thin;
}

.mg-player-chip {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--white);
    border: 2px solid var(--pink-light);
    border-radius: 999px;
    padding: 5px 12px 5px 5px;
    font-family: 'Kanit', sans-serif;
    font-size: 12px;
    font-weight: 700;
    color: #7a4a55;
    white-space: nowrap;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.mg-player-chip.active {
    border-color: var(--pink-deep);
    box-shadow: 0 0 0 3px var(--shadow);
    color: var(--text-pink);
}

/* ── Rabbit token badge (used everywhere: strip, board, start area) ── */
.mg-token {
    --tcolor: #f4869a;
    position: relative;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--tcolor);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 800;
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.25);
    flex-shrink: 0;
}

.mg-token::before,
.mg-token::after {
    content: "";
    position: absolute;
    width: 7px;
    height: 12px;
    background: var(--tcolor);
    border-radius: 50% 50% 50% 50% / 65% 65% 35% 35%;
    top: -7px;
}

.mg-token::before {
    left: 2px;
    transform: rotate(-18deg);
}

.mg-token::after {
    right: 2px;
    transform: rotate(18deg);
}

.mg-token.mg-token-lg {
    width: 30px;
    height: 30px;
    font-size: 13px;
}

.mg-token.mg-token-lg::before,
.mg-token.mg-token-lg::after {
    width: 9px;
    height: 16px;
    top: -9px;
}

.mg-token-more {
    background: #7a4a55;
    color: #fff;
    font-family: 'Kanit', sans-serif;
    font-weight: 800;
    font-size: 9px;
    border-radius: 999px;
    padding: 2px 6px;
    flex-shrink: 0;
}

/* ── Board ────────────────────────────────────── */
.mg-board {
    width: 100%;
    max-width: 640px;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(5, 1fr);
    gap: 6px;
    background: var(--pink-light);
    border: 3px solid var(--pink-deep);
    border-radius: var(--radius-md);
    padding: 8px;
    aspect-ratio: 6 / 5;
}

.mg-square {
    position: relative;
    background: var(--white);
    border-radius: 10px;
    border: 1.5px solid #ffe3ea;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 3px 2px;
}

.mg-square .mg-num {
    font-family: 'Kanit', sans-serif;
    font-size: 10px;
    color: #d99aa8;
    font-weight: 700;
}

.mg-square .mg-effect-icon {
    font-size: 14px;
    margin-top: 1px;
}

.mg-square.start { background: #fff0f4; border-color: var(--pink-mid); }
.mg-square.finish { background: #fff4d8; border-color: #f0b840; }
.mg-square.boost { background: #fdf0e2; }
.mg-square.hole { background: #f2e6e6; }

.mg-tokens-in-square {
    position: absolute;
    bottom: 2px;
    left: 0;
    right: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2px;
    padding: 0 2px;
}

.mg-start-area {
    width: 100%;
    max-width: 640px;
    background: var(--white);
    border: 1.5px solid var(--pink-light);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 12px;
    color: #7a4a55;
    font-weight: 600;
}

/* ── Action + log ─────────────────────────────── */
.mg-action-row { text-align: center; }

.mg-btn {
    font-family: 'Bebas Neue', sans-serif;
    letter-spacing: 1.5px;
    font-size: 18px;
    background: var(--pink-deep);
    color: var(--white);
    border: none;
    border-radius: 999px;
    padding: 12px 30px;
    cursor: pointer;
    box-shadow: 0 4px 14px var(--shadow);
    transition: transform 0.15s, box-shadow 0.15s;
}

.mg-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 20px var(--shadow); }
.mg-btn:active { transform: translateY(0); }
.mg-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.mg-btn.secondary {
    background: var(--white);
    color: var(--text-pink);
    border: 2px solid var(--pink-mid);
    box-shadow: none;
}

.mg-btn.secondary:hover { background: var(--pink-deep); color: var(--white); }

.mg-btn.small {
    font-size: 14px;
    padding: 8px 18px;
    letter-spacing: 1px;
}

.mg-log {
    width: 100%;
    max-width: 640px;
    background: var(--white);
    border: 1.5px solid var(--pink-light);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 12.5px;
    max-height: 120px;
    overflow-y: auto;
    color: #7a4a55;
}

.mg-log p { margin: 2px 0; }
.mg-log p.hl { color: var(--pink-deep); font-weight: 700; }

/* ── Overlays / modals ────────────────────────── */
.mg-overlay {
    position: fixed;
    inset: 0;
    background: rgba(224, 48, 96, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    padding: 16px;
    z-index: 500;
}

.mg-overlay.show { opacity: 1; pointer-events: auto; }

.mg-modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 26px 22px;
    text-align: center;
    max-width: 380px;
    width: 100%;
    border: 3px solid var(--pink-mid);
    box-shadow: 0 14px 30px rgba(224, 48, 96, 0.28);
    transform: scale(0.88) translateY(10px);
    transition: transform 0.25s ease;
}

.mg-overlay.show .mg-modal { transform: scale(1) translateY(0); }

.mg-modal h2 {
    font-family: 'Bebas Neue', sans-serif;
    letter-spacing: 2px;
    color: var(--text-pink);
    margin: 0 0 4px;
    font-size: 24px;
}

.mg-modal p.desc { margin: 0 0 14px; font-size: 13px; color: #7a4a55; }

.mg-mini-stats {
    display: flex;
    justify-content: center;
    gap: 14px;
    margin-bottom: 12px;
    font-family: 'Kanit', sans-serif;
    font-weight: 700;
    font-size: 13px;
    color: var(--text-pink);
}

.mg-mini-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 0 auto 14px;
    max-width: 280px;
}

.mg-card {
    aspect-ratio: 1 / 1;
    position: relative;
    perspective: 700px;
    cursor: pointer;
}

.mg-card-inner {
    position: absolute;
    inset: 0;
    transform-style: preserve-3d;
    transition: transform 0.4s cubic-bezier(.2, .9, .3, 1.1);
    border-radius: 12px;
}

.mg-card.flipped .mg-card-inner,
.mg-card.matched .mg-card-inner { transform: rotateY(180deg); }

.mg-face {
    position: absolute;
    inset: 0;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    backface-visibility: hidden;
}

.mg-face-back {
    background: linear-gradient(155deg, var(--pink-mid) 0%, var(--pink-deep) 100%);
    border: 2px solid #b3244a;
}

.mg-face-back::after { content: "🐰"; font-size: 17px; opacity: 0.9; }

.mg-face-front {
    background: #fff;
    border: 2px solid var(--pink-mid);
    transform: rotateY(180deg);
    font-size: 25px;
}

.mg-card.matched .mg-face-front { border-color: #f0b840; background: #fff8e6; }

.mg-card.wobble .mg-card-inner { animation: mgWobble 0.4s ease; }

@keyframes mgWobble {
    0%, 100% { transform: rotateY(180deg) translateX(0); }
    25% { transform: rotateY(180deg) translateX(-5px); }
    75% { transform: rotateY(180deg) translateX(5px); }
}

.mg-result-banner {
    font-family: 'Bebas Neue', sans-serif;
    letter-spacing: 1px;
    font-size: 26px;
    color: var(--pink-deep);
    margin: 6px 0 4px;
}

.mg-bunny-big { font-size: 42px; }

.mg-footer-controls { text-align: center; }

/* ── Responsive tightening for small phones ──── */
@media (max-width: 480px) {
    .mg-board { gap: 4px; padding: 6px; }
    .mg-square .mg-num { font-size: 9px; }
    .mg-square .mg-effect-icon { font-size: 12px; }
    .mg-token { width: 18px; height: 18px; font-size: 8px; }
    .mg-turn-banner .mg-turn-name { font-size: 18px; }
    .mg-mini-grid { max-width: 230px; gap: 8px; }
    .mg-count-row input[type="number"] { width: 64px; font-size: 18px; }
}

/* =========================================================
   LAPIN RACE — MOBILE FIRST RESPONSIVE PATCH
   ========================================================= */

.minigame-section {
    width: 100%;
    overflow-x: hidden;
}

.minigame-section .section-body {
    width: 100%;
    min-width: 0;
}

.mg-game,
.mg-setup,
.mg-player-strip,
.mg-board,
.mg-start-area,
.mg-log {
    max-width: 100%;
    min-width: 0;
}

/* Prevent controls from causing horizontal overflow */
.mg-count-row input[type="range"] {
    min-width: 0;
}

/* Touch-friendly controls */
.mg-btn,
.mg-start-btn,
.mg-preset-btn,
.mg-card {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Player strip becomes a horizontal touch scroller */
.mg-player-strip {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.mg-player-strip::-webkit-scrollbar {
    display: none;
}

@media (max-width: 768px) {
    .minigame-section .section-body {
        gap: 16px;
        padding-left: 10px;
        padding-right: 10px;
    }

    .minigame-section .title-card {
        width: 100%;
    }

    .minigame-section .title-card h1 {
        font-size: clamp(34px, 8vw, 52px);
        line-height: 1;
    }

    .minigame-section .title-card p {
        font-size: 12px;
        line-height: 1.6;
    }

    .mg-setup {
        width: 100%;
        max-width: 560px;
        padding: 20px 16px;
        margin-top: 0;
    }

    .mg-setup p.mg-lead {
        font-size: 13px;
        line-height: 1.7;
    }

    .mg-count-row {
        width: 100%;
        gap: 10px;
    }

    .mg-count-row input[type="number"] {
        flex: 0 0 68px;
        width: 68px;
    }

    .mg-presets {
        gap: 7px;
    }

    .mg-preset-btn {
        min-height: 40px;
        padding: 7px 13px;
    }

    .mg-start-btn {
        min-height: 48px;
        width: 100%;
    }

    .mg-game {
        width: 100%;
        gap: 12px;
    }

    .mg-turn-banner {
        max-width: 100%;
    }

    .mg-turn-name {
        max-width: 65vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        display: inline-block;
        vertical-align: bottom;
    }

    .mg-board {
        width: 100%;
        max-width: 640px;
        aspect-ratio: 6 / 5;
        gap: clamp(3px, 0.8vw, 6px);
        padding: clamp(5px, 1.2vw, 8px);
    }

    .mg-square {
        min-width: 0;
        min-height: 0;
        padding: 2px;
    }

    .mg-square .mg-num {
        font-size: clamp(8px, 2vw, 10px);
    }

    .mg-square .mg-effect-icon {
        font-size: clamp(10px, 3vw, 14px);
    }

    .mg-token {
        width: clamp(16px, 4.5vw, 22px);
        height: clamp(16px, 4.5vw, 22px);
        font-size: clamp(7px, 1.8vw, 10px);
    }

    .mg-start-area,
    .mg-log {
        width: 100%;
        max-width: 640px;
    }

    .mg-action-row {
        width: 100%;
    }

    .mg-action-row .mg-btn {
        width: 100%;
        max-width: 480px;
        min-height: 48px;
    }

    .mg-footer-controls {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }

    .mg-footer-controls .mg-btn {
        min-height: 42px;
    }

    .mg-modal {
        width: min(100%, 420px);
        max-height: calc(100dvh - 24px);
        overflow-y: auto;
    }
}

@media (max-width: 480px) {
    .minigame-section .section-body {
        padding-left: 7px;
        padding-right: 7px;
        gap: 12px;
    }

    .minigame-section .title-card {
        padding: 12px 8px;
    }

    .minigame-section .title-card h1 {
        font-size: clamp(30px, 10vw, 42px);
    }

    .minigame-section .title-card p {
        font-size: 11px;
    }

    .mg-setup {
        padding: 16px 12px;
        border-radius: 14px;
    }

    .mg-setup p.mg-lead {
        font-size: 12px;
        margin-bottom: 12px;
    }

    .mg-count-row {
        gap: 8px;
    }

    .mg-count-row input[type="number"] {
        flex: 0 0 58px;
        width: 58px;
        min-height: 42px;
        font-size: 18px;
        padding: 6px 2px;
    }

    .mg-count-row input[type="range"] {
        height: 28px;
    }

    .mg-presets {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px;
    }

    .mg-preset-btn {
        width: 100%;
        min-height: 40px;
        padding: 6px 4px;
        font-size: 12px;
    }

    .mg-start-btn {
        min-height: 50px;
        padding: 10px 16px;
        font-size: 20px;
    }

    .mg-turn-banner {
        width: 100%;
        padding: 6px 10px 6px 6px;
    }

    .mg-turn-banner .mg-turn-name {
        font-size: 18px;
        max-width: calc(100vw - 100px);
    }

    .mg-player-strip {
        width: 100%;
        padding: 4px 2px 9px;
        gap: 6px;
    }

    .mg-player-chip {
        min-height: 38px;
        padding: 5px 10px 5px 5px;
        font-size: 11px;
    }

    .mg-board {
        width: 100%;
        gap: 3px;
        padding: 4px;
        border-width: 2px;
        border-radius: 12px;
    }

    .mg-square {
        border-radius: 6px;
        padding: 1px;
    }

    .mg-square .mg-num {
        font-size: clamp(7px, 2.5vw, 10px);
    }

    .mg-square .mg-effect-icon {
        font-size: clamp(9px, 3.5vw, 14px);
    }

    .mg-token {
        width: clamp(14px, 4.7vw, 19px);
        height: clamp(14px, 4.7vw, 19px);
        font-size: 7px;
    }

    .mg-token::before,
    .mg-token::after {
        width: 5px;
        height: 9px;
        top: -5px;
    }

    .mg-start-area {
        min-height: 40px;
        padding: 7px;
        font-size: 11px;
    }

    .mg-action-row .mg-btn {
        width: 100%;
        min-height: 50px;
        padding: 10px 12px;
        font-size: 15px;
    }

    .mg-log {
        max-height: 130px;
        padding: 8px 10px;
        font-size: 11px;
    }

    .mg-footer-controls {
        display: grid;
        grid-template-columns: 1fr;
        gap: 7px;
    }

    .mg-footer-controls .mg-btn.small {
        width: 100%;
        min-height: 42px;
    }

    .mg-overlay {
        padding: 10px;
    }

    .mg-modal {
        width: 100%;
        max-width: 380px;
        max-height: calc(100dvh - 20px);
        padding: 20px 14px;
        border-width: 2px;
        border-radius: 16px;
    }

    .mg-modal h2 {
        font-size: 22px;
    }

    .mg-modal p.desc {
        font-size: 12px;
        line-height: 1.6;
    }

    .mg-mini-stats {
        flex-wrap: wrap;
        gap: 5px 12px;
        font-size: 11px;
    }

    .mg-mini-grid {
        width: min(100%, 270px);
        max-width: 270px;
        gap: 7px;
    }

    .mg-face-front {
        font-size: 22px;
    }
}

@media (max-width: 360px) {
    .minigame-section .section-body {
        padding-left: 5px;
        padding-right: 5px;
    }

    .mg-setup {
        padding: 14px 9px;
    }

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

    .mg-board {
        gap: 2px;
        padding: 3px;
    }

    .mg-token {
        width: 14px;
        height: 14px;
        font-size: 6px;
    }

    .mg-token::before,
    .mg-token::after {
        width: 4px;
        height: 8px;
        top: -4px;
    }

    .mg-mini-grid {
        max-width: 240px;
        gap: 6px;
    }

    .mg-face-front {
        font-size: 20px;
    }
}

/* Landscape phones: keep the board visible without making the modal too tall */
@media (max-width: 768px) and (orientation: landscape) {
    .mg-board {
        width: min(78vw, 600px);
    }

    .mg-modal {
        max-height: calc(100dvh - 12px);
        padding: 14px;
    }
}

@media (hover: none) and (pointer: coarse) {
    .mg-btn:hover,
    .mg-start-btn:hover,
    .mg-preset-btn:hover {
        transform: none;
    }

    .mg-btn:active,
    .mg-start-btn:active,
    .mg-preset-btn:active {
        transform: scale(.98);
    }
}

/* =========================================================
   PLAYER PROFILE EDITOR — LUNA LAPIN
   ========================================================= */

.mg-player-modal {
    max-width: 900px;
    max-height: min(90dvh, 900px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    text-align: left;
}

.mg-player-modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.mg-player-modal-head h2 {
    margin-bottom: 4px;
}

.mg-modal-close {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border: 2px solid var(--pink-mid);
    border-radius: 50%;
    background: var(--white);
    color: var(--text-pink);
    font-size: 25px;
    line-height: 1;
    cursor: pointer;
}

.mg-player-editor {
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 4px 4px 12px 2px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    min-height: 0;
}

.mg-player-editor-card {
    min-width: 0;
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    gap: 8px 12px;
    padding: 12px;
    background: #fff7f9;
    border: 1.5px solid var(--pink-light);
    border-radius: 14px;
}

.mg-player-editor-title {
    grid-column: 1 / -1;
    color: var(--text-pink);
    font-family: 'Kanit', sans-serif;
    font-weight: 800;
    font-size: 14px;
}

.mg-player-editor-preview {
    width: 64px;
    height: 64px;
    object-fit: cover;
    object-position: center;
    border-radius: 12px;
    background: var(--pink-light);
    border: 2px solid var(--pink-mid);
    user-select: none;
    -webkit-user-drag: none;
}

.mg-player-editor-body {
    min-width: 0;
}

.mg-player-name-label {
    display: block;
    margin-bottom: 5px;
    color: #7a4a55;
    font-family: 'Kanit', sans-serif;
    font-size: 11px;
    font-weight: 700;
}

.mg-player-name-input {
    display: block;
    width: 100%;
    min-width: 0;
    height: 38px;
    padding: 7px 10px;
    margin-bottom: 9px;
    border: 2px solid var(--pink-mid);
    border-radius: 9px;
    background: var(--white);
    color: #7a4a55;
    font-family: 'Kanit', sans-serif;
    font-size: 14px;
    outline: none;
}

.mg-player-name-input:focus {
    border-color: var(--pink-deep);
    box-shadow: 0 0 0 3px var(--shadow);
}

.mg-character-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(28px, 1fr));
    gap: 5px;
}

.mg-character-choice {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    padding: 2px;
    border: 2px solid transparent;
    border-radius: 8px;
    background: var(--white);
    cursor: pointer;
    overflow: hidden;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.mg-character-choice img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 5px;
    user-select: none;
    -webkit-user-drag: none;
}

.mg-character-choice.selected {
    border-color: var(--pink-deep);
    box-shadow: 0 0 0 2px rgba(224, 48, 96, .16);
}

.mg-character-choice.selected::after {
    content: '✓';
    position: absolute;
    right: 2px;
    bottom: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--pink-deep);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
}

.mg-character-choice.image-missing {
    opacity: .35;
}

.mg-character-choice:active {
    transform: scale(.95);
}

.mg-player-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--pink-light);
}

.mg-btn.danger {
    color: #b3244a;
    border-color: #f0a0b4;
}

.mg-btn.danger:hover {
    background: #b3244a;
    color: var(--white);
}

/* Token now uses the selected LUNA LAPIN image */
.mg-token {
    overflow: visible;
}

.mg-token img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    object-position: center;
    border-radius: 50%;
    user-select: none;
    -webkit-user-drag: none;
}

@media (max-width: 768px) {
    .mg-player-modal {
        max-width: 100%;
        width: 100%;
        max-height: calc(100dvh - 20px);
    }

    .mg-player-editor {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .mg-player-modal {
        padding: 14px 10px;
        border-radius: 14px;
    }

    .mg-player-modal-head {
        margin-bottom: 8px;
    }

    .mg-player-modal-head h2 {
        font-size: 21px;
    }

    .mg-player-modal-head .desc {
        font-size: 11px;
        line-height: 1.5;
    }

    .mg-modal-close {
        width: 34px;
        height: 34px;
        font-size: 22px;
    }

    .mg-player-editor {
        gap: 8px;
        padding-right: 1px;
    }

    .mg-player-editor-card {
        grid-template-columns: 54px minmax(0, 1fr);
        gap: 7px 9px;
        padding: 9px;
        border-radius: 11px;
    }

    .mg-player-editor-preview {
        width: 54px;
        height: 54px;
    }

    .mg-player-editor-title {
        font-size: 12px;
    }

    .mg-player-name-input {
        height: 36px;
        font-size: 13px;
        margin-bottom: 7px;
    }

    .mg-character-grid {
        grid-template-columns: repeat(7, minmax(25px, 1fr));
        gap: 3px;
    }

    .mg-character-choice {
        border-width: 1.5px;
        border-radius: 6px;
    }

    .mg-character-choice img {
        border-radius: 4px;
    }

    .mg-character-choice.selected::after {
        width: 13px;
        height: 13px;
        font-size: 8px;
        right: 1px;
        bottom: 1px;
    }

    .mg-player-modal-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .mg-player-modal-actions .mg-btn {
        width: 100%;
        min-height: 44px;
        padding: 9px 8px;
        font-size: 14px;
    }
}
