.evmg-game,
.evmg-game * {
    box-sizing: border-box;
}

.evmg-modal,
.evmg-modal *,
.evmg-loading,
.evmg-loading * {
    box-sizing: border-box;
}

.evmg-game {
    position: relative;
    width: 100%;
    max-width: 980px;
    margin: 24px auto;
    padding: clamp(18px, 4vw, 38px);
    overflow: hidden;
    isolation: isolate;
    border-radius: 22px;
    background: var(--evmg-bg, #000);
    color: var(--evmg-text, #fff);
    font-family: Arial, Helvetica, sans-serif;
    text-align: center;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .22);
}

.evmg-game[hidden],
.evmg-game [hidden] {
    display: none !important;
}

.evmg-title {
    margin: 0 0 10px;
    color: inherit;
    font-size: clamp(25px, 4vw, 42px);
    line-height: 1.12;
}

.evmg-intro {
    max-width: 760px;
    margin: 0 auto 20px;
    color: inherit;
    opacity: .88;
    font-size: clamp(15px, 2.2vw, 18px);
}

.evmg-info {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin: 18px 0;
}

.evmg-info-chip {
    display: inline-flex;
    gap: 5px;
    align-items: center;
    padding: 9px 14px;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 999px;
    background: var(--evmg-panel, #222);
    color: inherit;
    font-size: 14px;
}

.evmg-voucher-chip {
    position: relative;
    cursor: help;
    outline: none;
}

.evmg-voucher-chip:focus-visible {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--evmg-accent, #28a745) 45%, transparent);
}

.evmg-voucher-info-icon {
    margin-left: 2px;
    font-size: 15px;
    opacity: .85;
}

.evmg-voucher-tooltip {
    position: absolute;
    z-index: 80;
    top: calc(100% + 10px);
    left: 50%;
    display: grid;
    width: min(330px, calc(100vw - 30px));
    gap: 7px;
    padding: 14px;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 14px;
    background: #111;
    color: #fff;
    box-shadow: 0 14px 38px rgba(0, 0, 0, .42);
    text-align: left;
    line-height: 1.35;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translate(-50%, -5px);
    transition: opacity .16s ease, transform .16s ease, visibility .16s ease;
}

.evmg-voucher-tooltip::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    border: 7px solid transparent;
    border-bottom-color: #111;
    transform: translateX(-50%);
}

.evmg-voucher-tooltip-list {
    display: grid;
    gap: 4px;
}

.evmg-voucher-tooltip-list span {
    display: block;
    padding: 6px 8px;
    border-radius: 8px;
    background: rgba(255, 255, 255, .08);
}

.evmg-voucher-tooltip small {
    opacity: .72;
}

.evmg-voucher-chip:hover .evmg-voucher-tooltip,
.evmg-voucher-chip:focus .evmg-voucher-tooltip,
.evmg-voucher-chip:focus-within .evmg-voucher-tooltip,
.evmg-voucher-chip.is-open .evmg-voucher-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
}

.evmg-start-button,
.evmg-submit-highscore,
.evmg-submit-coupon,
.evmg-new-game,
.evmg-close-modal {
    appearance: none;
    border: 0;
    border-radius: 12px;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    transition: transform .18s ease, background .18s ease, opacity .18s ease;
}

.evmg-start-button {
    display: block;
    min-width: min(100%, 360px);
    margin: 30px auto;
    padding: 24px 36px;
    background: var(--evmg-accent, #28a745);
    color: #fff;
    font-size: clamp(23px, 4vw, 36px);
    text-transform: uppercase;
    letter-spacing: .04em;
    box-shadow: 0 0 30px color-mix(in srgb, var(--evmg-accent, #28a745) 58%, transparent);
    animation: evmg-pulse 1.8s infinite;
}

.evmg-start-button:hover,
.evmg-start-button:focus-visible,
.evmg-submit-highscore:hover,
.evmg-submit-coupon:hover,
.evmg-new-game:hover {
    background: var(--evmg-accent-hover, #34c759);
    transform: translateY(-2px) scale(1.02);
}

.evmg-start-button:focus-visible,
.evmg-card:focus-visible,
.evmg-dialog button:focus-visible,
.evmg-dialog input:focus-visible,
.evmg-dialog a:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 3px;
}

@keyframes evmg-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.035); }
}

.evmg-play-stage {
    width: 100%;
    scroll-margin-block: 14px;
}

.evmg-result {
    min-height: 28px;
    margin: 8px 0 16px;
    color: #ffe600;
    font-weight: 700;
}

.evmg-board-shell {
    position: relative;
    width: min(100%, 700px);
    max-width: 100%;
    margin: 0 auto 26px;
}

.evmg-board {
    display: grid;
    grid-template-columns: repeat(var(--evmg-active-columns, var(--evmg-columns, 4)), minmax(0, 1fr));
    gap: clamp(5px, 1.2vw, 11px);
    width: 100%;
    margin: 0;
}

.evmg-stage-overlay {
    position: absolute;
    inset: 0;
    z-index: 15;
    display: grid;
    place-items: center;
    padding: 14px;
    border-radius: var(--evmg-radius, 10px);
    background: rgba(0, 0, 0, .18);
    pointer-events: none;
}

.evmg-stage-overlay[hidden] {
    display: none !important;
}

.evmg-stage-overlay-box {
    display: grid;
    gap: 6px;
    min-width: min(88%, 320px);
    padding: 14px 18px;
    border: 1px solid rgba(255, 255, 255, .28);
    border-radius: 14px;
    background: rgba(0, 0, 0, .82);
    color: #fff;
    box-shadow: 0 12px 34px rgba(0, 0, 0, .38);
    text-align: center;
}

.evmg-stage-overlay-text {
    font-size: clamp(16px, 2.5vw, 22px);
    font-weight: 700;
    line-height: 1.25;
}

.evmg-stage-overlay-countdown {
    min-height: 1em;
    color: #ffe600;
    font-size: clamp(30px, 7vw, 54px);
    line-height: 1;
}

.evmg-stage-overlay-countdown:empty {
    display: none;
}

.evmg-stage-retry {
    pointer-events: auto;
    appearance: none;
    min-width: min(100%, 230px);
    margin: 8px auto 0;
    padding: 12px 18px;
    border: 0;
    border-radius: 11px;
    background: var(--evmg-accent, #28a745);
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}

.evmg-stage-retry:hover,
.evmg-stage-retry:focus-visible {
    background: var(--evmg-accent-hover, #34c759);
}

.evmg-card {
    position: relative;
    aspect-ratio: 1 / 1;
    min-width: 0;
    padding: 0;
    border: 0;
    border-radius: var(--evmg-radius, 10px);
    background: transparent;
    cursor: pointer;
    perspective: 900px;
}

.evmg-card-inner {
    position: absolute;
    inset: 0;
    display: block;
    transform-style: preserve-3d;
    transition: transform .5s cubic-bezier(.2, .75, .25, 1);
}

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

.evmg-card.is-matched {
    cursor: default;
    filter: drop-shadow(0 0 10px rgba(40, 167, 69, .78));
}

.evmg-card-face {
    position: absolute;
    inset: 0;
    display: block;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, .34);
    border-radius: var(--evmg-radius, 10px);
    backface-visibility: hidden;
}

.evmg-card-back {
    background-color: var(--evmg-panel, #222);
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
}

.evmg-card-front {
    transform: rotateY(180deg);
    background: #fff;
}

.evmg-card-front img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.evmg-highscores {
    width: min(100%, 460px);
    margin: 28px auto 0;
}

.evmg-highscores h3 {
    margin: 0 0 12px;
    color: inherit;
}

.evmg-table-wrap {
    overflow-x: auto;
    border-radius: 12px;
}

.evmg-highscores table {
    width: 100%;
    margin: 0;
    border-collapse: collapse;
    background: var(--evmg-panel, #222);
    color: inherit;
}

.evmg-highscores th,
.evmg-highscores td {
    padding: 9px 10px;
    border: 1px solid rgba(255, 255, 255, .18);
    text-align: center;
}

.evmg-highscores tbody tr:nth-child(1) {
    background: #d5af21;
    color: #111;
    font-weight: 700;
}

.evmg-highscores tbody tr:nth-child(2) {
    background: #bfc3c8;
    color: #111;
}

.evmg-highscores tbody tr:nth-child(3) {
    background: #b7793c;
    color: #111;
}


.evmg-highscore-extra[hidden] {
    display: none !important;
}

.evmg-highscore-toggle {
    display: block;
    width: 100%;
    margin: 10px 0 0;
    padding: 10px 14px;
    border: 1px solid rgba(255, 255, 255, .24);
    border-radius: 10px;
    background: var(--evmg-panel, #222);
    color: inherit;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}

.evmg-highscore-toggle:hover,
.evmg-highscore-toggle:focus-visible {
    border-color: var(--evmg-accent, #28a745);
    outline: none;
}

.evmg-highscore-toggle[hidden] {
    display: none !important;
}

.evmg-loading {
    position: fixed;
    inset: 0;
    z-index: 999998;
    display: grid;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    place-items: center;
    padding: 18px;
    background: rgba(0, 0, 0, .76);
    color: #fff;
}

.evmg-loading[hidden] {
    display: none !important;
}

.evmg-loading-panel {
    display: flex;
    width: min(100%, 360px);
    flex-direction: column;
    gap: 16px;
    align-items: center;
    justify-content: center;
    padding: 26px 22px;
    border: 1px solid rgba(255, 255, 255, .24);
    border-radius: 18px;
    background: rgba(0, 0, 0, .88);
    box-shadow: 0 22px 64px rgba(0, 0, 0, .5);
    font-size: 20px;
    font-weight: 700;
    text-align: center;
}

.evmg-spinner {
    width: 48px;
    height: 48px;
    border: 5px solid rgba(255, 255, 255, .3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: evmg-spin .8s linear infinite;
}

@keyframes evmg-spin {
    to { transform: rotate(360deg); }
}

body.evmg-modal-open {
    overflow: hidden;
}

.evmg-modal {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: grid;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    place-items: center;
    padding: 18px;
}

.evmg-modal[hidden],
.evmg-modal [hidden],
.evmg-highscore-form[hidden],
.evmg-coupon-form[hidden],
.evmg-stage-retry[hidden],
.evmg-new-game[hidden] {
    display: none !important;
}

.evmg-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .76);
    backdrop-filter: blur(4px);
}

.evmg-dialog {
    position: relative;
    z-index: 1;
    width: min(100%, 470px);
    max-height: calc(100vh - 36px);
    max-height: calc(100dvh - 36px);
    overflow-x: hidden;
    overflow-y: auto;
    padding: 26px;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 18px;
    background: var(--evmg-panel, #222);
    color: var(--evmg-text, #fff);
    box-shadow: 0 24px 70px rgba(0, 0, 0, .52);
    text-align: left;
}

.evmg-dialog h3 {
    margin: 0 0 12px;
    color: #ffe600;
    font-size: 28px;
    text-align: center;
}

.evmg-status-message,
.evmg-form-status {
    margin: 10px 0;
    text-align: center;
}

.evmg-form-status {
    min-height: 24px;
    color: #ff9898;
}

.evmg-form-status.is-success {
    color: #8df09b;
}

.evmg-highscore-form,
.evmg-coupon-form {
    display: grid;
    gap: 12px;
    margin: 18px 0;
}

.evmg-dialog label {
    display: grid;
    gap: 7px;
    color: inherit;
    font-weight: 700;
}

.evmg-dialog input[type="text"],
.evmg-dialog input[type="email"] {
    width: 100%;
    padding: 12px 13px;
    border: 1px solid rgba(255, 255, 255, .28);
    border-radius: 9px;
    background: #fff;
    color: #111;
    font: inherit;
}

.evmg-consent-label {
    grid-template-columns: auto 1fr !important;
    align-items: start;
    font-size: 13px;
    font-weight: 400 !important;
    line-height: 1.4;
}

.evmg-consent-label input {
    margin-top: 3px;
}

.evmg-consent-label a {
    color: inherit;
    text-decoration: underline;
}

.evmg-submit-highscore,
.evmg-submit-coupon,
.evmg-new-game {
    padding: 12px 16px;
    background: var(--evmg-accent, #28a745);
    color: #fff;
}

.evmg-close-modal {
    padding: 12px 16px;
    background: rgba(255, 255, 255, .12);
    color: inherit;
}

.evmg-dialog-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 16px;
}

.evmg-dialog button:disabled {
    cursor: wait;
    opacity: .55;
}

.evmg-confetti {
    position: fixed;
    inset: 0;
    z-index: 1000000;
    overflow: hidden;
    pointer-events: none;
}

.evmg-confetti span {
    position: absolute;
    top: -8vh;
    font-size: 18px;
    animation-name: evmg-fall;
    animation-timing-function: cubic-bezier(.2, .7, .3, 1);
    animation-fill-mode: forwards;
}

@keyframes evmg-fall {
    to {
        top: 108vh;
        transform: translateX(50px) rotate(720deg);
        opacity: .3;
    }
}

@media (max-width: 680px) {
    .evmg-game {
        margin: 12px auto;
        padding: 17px 10px 24px;
        border-radius: 14px;
    }

    .evmg-board {
        gap: 5px;
    }

    .evmg-stage-overlay-box {
        min-width: min(94%, 300px);
        padding: 12px 14px;
    }

    .evmg-info-chip {
        padding: 7px 10px;
        font-size: 12px;
    }

    .evmg-start-button {
        width: calc(100% - 20px);
        padding: 20px 14px;
    }

    .evmg-dialog {
        padding: 21px 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .evmg-start-button,
    .evmg-card-inner,
    .evmg-confetti span,
    .evmg-spinner {
        animation: none !important;
        transition: none !important;
    }
}


/* v1.1.2 – Neustart, vollständige Bestenliste und Gutschein-Hoveranzeige */
.evmg-emergency-restart {
    appearance: none;
    padding: 8px 13px;
    border: 1px solid rgba(255, 255, 255, .26);
    border-radius: 999px;
    background: rgba(255, 255, 255, .10);
    color: inherit;
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.2;
    transition: background .15s ease, border-color .15s ease, transform .15s ease;
}

.evmg-emergency-restart:hover,
.evmg-emergency-restart:focus-visible {
    border-color: var(--evmg-accent, #28a745);
    background: rgba(255, 255, 255, .18);
    outline: none;
    transform: translateY(-1px);
}

.evmg-highscores.is-expanded .evmg-table-wrap {
    max-height: min(65vh, 720px);
    overflow-y: auto;
}

.evmg-highscore-extra:not([hidden]) {
    display: table-row;
}

@media (max-width: 680px) {
    .evmg-emergency-restart {
        width: 100%;
        justify-content: center;
        text-align: center;
    }

    .evmg-highscores.is-expanded .evmg-table-wrap {
        max-height: 58vh;
    }
}
