@font-face {
    font-family: 'pixel';
    src: url("resources/font/fusion_pixel.woff2");
}

@font-face {
    font-family: 'high-pixel';
    src: url("resources/font/Minecraft_AE.ttf");
}

@font-face {
    font-family: 'en-pixel';
    src: url("resources/font/enPixel.ttf");
}

:root {
    --SIZE: 10;
}

body {
    background-image: url(resources/img/bg.png);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    height: 100vh;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}


* {
    user-select: none;
    padding: 0;
    margin: 0;
    font-family: 'pixel', sans-serif;
}

.menu {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: fit-content;
    height: fit-content;
    padding: 48px 96px 56px;
    background-color: rgba(55, 81, 95, 0.86);
    border-radius: 12px;
    box-shadow: 0px 4px 8px 0px rgba(0, 0, 0, 0.45),
        0px 12px 18px -6px rgba(0, 0, 0, 0.35),
        0px -8px 0px 0px rgba(0, 0, 0, 0.28) inset;
    animation: floatingMenu 1s ease-in-out infinite;
}

.menu:hover {
    animation-play-state: paused;
}

.winner-event {
    color: #f4e8ff;
    font-size: 1.15em;
    line-height: 1.5;
    letter-spacing: 0.08em;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.45);
    white-space: nowrap;
}

.winner-caption {
    color: #ffe9a8;
    font-size: 1.35em;
    line-height: 1.4;
    letter-spacing: 0.12em;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}

.winner-name {
    color: white;
    font-size: 2.6em;
    line-height: 1.25;
    letter-spacing: 0.12em;
    margin-top: 28px;
    animation: goldTitle 1s infinite;
}

@keyframes goldTitle {
    0% {
        text-shadow: 0 0 0 #ffd700;
    }

    50% {
        text-shadow: 0 0 8px #ffd700;
    }

    100% {
        text-shadow: 0 0 0 #ffd700;
    }
}

@keyframes floatingMenu {
    0% {
        transform: translateY(0);
        background-color: rgba(55, 81, 95, 0.86);
    }

    50% {
        transform: translateY(-10px);
        background-color: rgba(55, 81, 95, 0.94);
    }

    100% {
        transform: translateY(0);
        background-color: rgba(55, 81, 95, 0.86);
    }
}

.settings-menu {
    display: none;
    color: #fff;
    gap: 18px;
    min-width: min(520px, 86vw);
    padding: 36px 48px 44px;
}

.settings-menu h2 {
    font-size: 1.8em;
    letter-spacing: 0.2em;
    text-shadow: 0px 2px 0px rgba(0, 0, 0, 0.35);
    margin-bottom: 4px;
}

.settings-group {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.settings-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.settings-row label,
.file-title {
    flex: 0 0 118px;
    text-align: right;
    font-size: 0.95em;
    color: #e8eef3;
}

.settings-menu input[type="text"] {
    flex: 1;
    height: 2.2rem;
    padding: 0 12px 3px;
    color: #fff;
    background-color: rgba(255, 255, 255, 0.14);
    border: none;
    border-radius: 5px;
    outline: none;
    box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.28),
        0px -3px 0px 0px rgba(0, 0, 0, 0.22) inset;
}

.settings-menu input[type="text"]::placeholder {
    color: rgba(255, 255, 255, 0.55);
}

.settings-menu input[type="text"]:focus {
    background-color: rgba(255, 255, 255, 0.22);
    box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.28),
        0px -3px 0px 0px rgba(0, 0, 0, 0.22) inset,
        0 0 0 2px rgba(120, 180, 220, 0.55);
}

.file-field {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.file-field input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.file-control {
    flex: 1;
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 10px;
}

.file-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    padding: 6px 16px 10px;
    font-size: 0.9em;
    line-height: 1.2;
    color: #fff;
    background-color: rgba(70, 130, 180, 0.88);
    border-radius: 5px;
    box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.4),
        0px 5px 8px -3px rgba(0, 0, 0, 0.28),
        0px -3px 0px 0px rgba(0, 0, 0, 0.25) inset;
}

.file-field:hover .file-button {
    background-color: rgba(60, 120, 170, 0.95);
}

.file-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.85em;
}

.file-name.selected {
    color: #d7f3ff;
}

.settings-actions {
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 4px;
}

.settings-actions .menu-button {
    margin: 0;
    min-width: 132px;
}

.settings-actions-secondary {
    margin-top: 0;
    padding-top: 18px;
    padding-bottom: 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.16);
}

.menu-button-ghost {
    background-color: rgba(255, 255, 255, 0.18);
}

.menu-button-ghost:hover {
    background-color: rgba(255, 255, 255, 0.28);
}

.menu-button-secondary {
    background-color: rgba(90, 120, 150, 0.85);
}

.menu-button-secondary:hover {
    background-color: rgba(80, 110, 140, 0.95);
}

.menu-button.menu-button-danger,
.menu-button.menu-button-danger:hover,
.menu-button.menu-button-danger:active {
    color: #ffb3b3;
}

.confirm-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.45);
    z-index: 2000;
}

.confirm-dialog {
    min-width: min(360px, 82vw);
    padding: 28px 32px 32px;
    color: #fff;
    text-align: center;
    background-color: rgba(55, 81, 95, 0.92);
    border-radius: 12px;
    box-shadow: 0px 4px 8px 0px rgba(0, 0, 0, 0.45),
        0px 12px 18px -6px rgba(0, 0, 0, 0.35),
        0px -8px 0px 0px rgba(0, 0, 0, 0.28) inset;
}

.confirm-dialog p {
    margin: 8px 0 20px;
    line-height: 1.6;
}

.confirm-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.confirm-actions .menu-button {
    margin: 0;
    min-width: 108px;
}


.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: -1;
}

.starting {
    position: fixed;
    top: 0;
    left: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    width: 100vw;
    background-color: #000;
    z-index: 999;
}

.starting * {
    display: none;
}

.start-menu h1 {
    text-shadow: none;
    margin-bottom: 16px;
}

.title-logo {
    display: block;
    width: min(300px, 42vw);
    height: auto;
    object-fit: contain;
    image-rendering: auto;
    margin: 0 auto;
}

.start-menu .title-logo {
    width: min(300px, 42vw);
}

.menu-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 44px 12px;
    font-size: 1.05em;
    line-height: 1.2;
    color: #fff;
    background-color: rgba(70, 130, 180, 0.8);
    /* 略微透明的蓝色 */
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
    outline: none;
    margin: 6px 0;
    box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.4),
        0px 6px 10px -3px rgba(0, 0, 0, 0.3),
        0px -4px 0px 0px rgba(0, 0, 0, 0.25) inset;
}

.menu-button:hover {
    background-color: rgba(60, 120, 170, 0.8);
    /* 略微透明的深蓝色 */
    outline: none;
    box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.4),
        0px 6px 10px -3px rgba(0, 0, 0, 0.3),
        0px -4px 0px 0px rgba(0, 0, 0, 0.25) inset,
        0 0 0 2px rgba(70, 130, 180, 0.8);
}

.menu-button:active {
    box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.35),
        0px -1px 0px 0px rgba(0, 0, 0, 0.2) inset;
}

.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 90%;
    max-height: 90%;
}

.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background-color: #4c6aaf;
    color: white;
    border-radius: 12px;
    box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.4),
        0px 7px 13px -3px rgba(0, 0, 0, 0.3),
        0px -4px 0px 0px rgba(0, 0, 0, 0.2) inset;
}

.tnt {
    position: relative;
    width: 35px;
    margin: 0 10px 4px;
}

.tnt img {
    display: block;
    width: 35px;
}

.tnt::after {
    content: attr(data-number);
    position: absolute;
    right: -2px;
    bottom: -2px;
    min-width: 1em;
    color: white;
    font-weight: bold;
    text-align: right;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
    pointer-events: none;
}

.team-info {
    display: flex;
    flex-direction: column;
    min-width: 168px;
}

.team-info.left {
    align-items: flex-start;
}

.team-info.right {
    align-items: flex-end;
}

.team-heading {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin: 4px 10px 8px;
}

.team-info.left .team-heading {
    justify-content: flex-start;
}

.team-info.right .team-heading {
    flex-direction: row-reverse;
    justify-content: flex-start;
}

.team-name {
    font-size: 1.28em;
    font-weight: bold;
    line-height: 1.15;
    margin: 0;
}

.team-score {
    font-size: 0.78em;
    font-weight: normal;
    letter-spacing: 0.04em;
    opacity: 0.88;
    white-space: nowrap;
}

.team-selected {
    color: #ff2d2d !important;
    animation: teamNameFlash 0.7s ease-in-out infinite;
}

@keyframes teamNameFlash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.25; }
}

.ship-health {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
}

.ship {
    height: 30px;
    width: 40px;
    margin: 0 10px;
}

.health {
    display: flex;
    margin-left: 5px;
}

.health img {
    width: 20px;
    height: 20px;
    margin-right: 2px;
    image-rendering: pixelated;
}

.game-title {
    text-align: center;
    flex-grow: 1;
}

h1 {
    font-size: 4em;
    text-shadow: 0px 1px 0px #c0c0c0,
        0px 2px 0px #b0b0b0,
        0px 3px 0px #a0a0a0,
        0px 4px 0px #909090,
        0px 5px 10px rgba(0, 0, 0, .4);
    margin-bottom: 10px;
}

.game-title small {
    color: #ccc;
}

.round-line {
    display: block;
}

.remaining-hint {
    display: block;
    margin-top: 4px;
    font-size: 0.85em;
    font-weight: bold;
    color: #ddd;
}

.settle-button {
    display: none;
    align-items: center;
    justify-content: center;
    margin-top: 8px;
    padding: 8px 32px 12px;
    font-size: 1.15em;
    line-height: 1.2;
    color: #fff;
    background-color: rgba(70, 130, 180, 0.9);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    outline: none;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.4),
        0px 6px 10px -3px rgba(0, 0, 0, 0.3),
        0px -4px 0px 0px rgba(0, 0, 0, 0.25) inset;
}

.settle-button:hover {
    background-color: rgba(60, 120, 170, 0.95);
    box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.4),
        0px 6px 10px -3px rgba(0, 0, 0, 0.3),
        0px -4px 0px 0px rgba(0, 0, 0, 0.25) inset,
        0 0 0 2px rgba(255, 255, 255, 0.35);
}

.settle-button:active {
    box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.35),
        0px -1px 0px 0px rgba(0, 0, 0, 0.2) inset;
}

.left .health {
    margin-left: 0;
    margin-right: 5px;
}

.right .health {
    flex-direction: row-reverse;
    margin-left: 5px;
    margin-right: 0;
}

.right .health img {
    margin-right: 0;
    margin-left: 2px;
}

.game-board {
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 12px;
    box-shadow: 0 4px 8px rgba(255, 255, 255, 0.6);
}

.grid {
    display: grid;
    grid-template-columns: repeat(var(--SIZE), 60px);
    grid-gap: 0;
}

.left-panel,
.right-panel {
    grid-template-rows: repeat(var(--SIZE), 60px);
}

.middle-panel {
    grid-template-columns: repeat(4, 60px);
}

.square {
    width: 60px;
    height: 60px;
    background-image: url('resources/img/Invicon_Water.webp');
}

.square.selected-col {
    filter: brightness(1.25);
    box-shadow: inset 0 0 0 2px #ffeb3b;
}

.square.selected-square {
    filter: brightness(1.15);
    outline: 3px solid #ffeb3b;
    outline-offset: -3px;
    z-index: 2;
    animation: selectedPulse 0.8s ease-in-out infinite;
}

@keyframes selectedPulse {
    0%, 100% { outline-color: #ffeb3b; }
    50% { outline-color: #ff9800; }
}


.health {
    width: 20px;
    height: 20px;
    background-size: cover;
    margin-left: 5px;
}

.quiz-area {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0px;
    left: 0;
    right: 0;
    background-color: #f7f7f7e6;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    padding: 20px;
    border-radius: 0 0 12px 12px;
    transition: height 0.8s ease, opacity 1s ease, transform 0.8s ease-in-out;
}

.quiz-area.quiz-area-hidden {
    pointer-events: none;
}

.player-panel {
    flex-basis: 20%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.panel-header {
    font-size: 1.2em;
    margin-bottom: 10px;
}

.player-choices {
    display: grid;
    grid-template-columns: 1fr;
    column-gap: 20px;
    row-gap: 8px;
    width: 56%;
}

.choice {
    background-color: #ffffff90;
    color: #333;
    padding: 10px 20px;
    margin: 5px;
    cursor: pointer;
    border: 2px solid rgba(55, 81, 95, 0.4);
    border-radius: 5px;
    flex-grow: 1;
    text-align: center;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.choice:hover {
    background-color: #4c8fd8;
    color: #fff;
    border-color: #2f6fb4;
    transform: scale(1.06);
    box-shadow: 0 4px 10px rgba(47, 111, 180, 0.35);
}

.choice.correct {
    background-color: #4CAF50;
    color: white;
}

.choice.wrong {
    background-color: #f44336;
    color: white;
}

.choice.correct-not-selected {
    background-color: #53ff9a;
    color: #888;
}

.question-panel {
    flex-basis: 60%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#question-content {
    font-family: 仿宋, FangSong, STFangsong, 'Songti SC', serif;
    font-weight: bold;
    font-size: 2em;
    text-align: center;
    width: 100%;
    margin-bottom: 20px;
    line-height: 1.45;
    word-break: break-word;
}

#question-content .plain-digit,
.choice-content .plain-digit {
    font-family: 仿宋, FangSong, STFangsong, 'Songti SC', serif;
}

#question-content .katex,
.choice-content .katex {
    font-size: 1.05em;
    font-family: KaTeX_Main, "Times New Roman", serif;
}

.katex * {
    font-family: unset;
}

#question-content .katex-display {
    margin: 0.4em 0;
    overflow-x: auto;
    overflow-y: hidden;
}

.latex-error {
    color: #c62828;
}

.question-body {
    display: flex;
    align-items: stretch;
    justify-content: center;
    width: 100%;
    gap: 16px;
    margin-bottom: 20px;
}

#question-choices {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    column-gap: 20px;
    row-gap: 8px;
    justify-items: center;
    width: 100%;
}

#question-images {
    display: none;
}

.question-body.has-images #question-choices,
.question-body.has-images #question-images {
    flex: 0 0 calc(50% - 8px);
    max-width: calc(50% - 8px);
}

.question-body.has-images #question-images {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 0;
}

.question-image {
    display: block;
    max-width: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    margin: 0 auto;
    image-rendering: auto;
}

.question-body.has-images .question-image {
    flex: 1 1 0;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 100%;
    min-height: 0;
}

.choice-content {
    font-family: 仿宋, FangSong, STFangsong, 'Songti SC', serif;
    font-weight: bold;
    font-size: 1.5em;
    text-align: center;
}

.quiz-round-info {
    width: 100%;
    margin-top: 18px;
    text-align: center;
    color: #333;
}

.quiz-round-info .remaining-hint {
    color: #444;
}

.skip-button,
.next-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    padding: 8px 20px 12px;
    font-size: 1em;
    line-height: 1.2;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    margin-top: 10px;
    outline: none;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.4),
        0px 6px 10px -3px rgba(0, 0, 0, 0.3),
        0px -4px 0px 0px rgba(0, 0, 0, 0.25) inset;
}

.skip-button {
    background-color: #f44336;
}

.skip-button:hover {
    background-color: #e53935;
}

.next-button {
    background-color: #4CAF50;
}

.next-button:hover {
    background-color: #45a049;
}

.skip-button:active,
.next-button:active {
    box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.35),
        0px -1px 0px 0px rgba(0, 0, 0, 0.2) inset;
}

.game-over {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    margin: auto;
    padding: 72px 80px;
    display: none;
    color: #333;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    height: fit-content;
    width: fit-content;
    overflow: hidden;
    isolation: isolate;
    background-color: transparent;
    background-image:
        linear-gradient(180deg, rgba(88, 18, 150, 0.16), rgba(42, 6, 88, 0.28)),
        url(resources/img/map_background.png);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    box-shadow:
        0 0 18px 2px rgba(168, 92, 255, 0.28),
        0 0 48px 10px rgba(112, 36, 196, 0.18),
        inset 0 0 36px rgba(140, 64, 255, 0.18);
    z-index: 1001;
}

.game-over::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 420%;
    height: 420%;
    pointer-events: none;
    z-index: 0;
    background-image: repeating-linear-gradient(
        90deg,
        rgba(176, 72, 255, 0) 0px,
        rgba(176, 72, 255, 0) 28px,
        rgba(186, 100, 255, 0.16) 52px,
        rgba(230, 180, 255, 0.42) 78px,
        rgba(255, 236, 255, 0.62) 96px,
        rgba(230, 180, 255, 0.42) 114px,
        rgba(186, 100, 255, 0.16) 140px,
        rgba(176, 72, 255, 0) 164px,
        rgba(176, 72, 255, 0) 220px
    );
    background-repeat: repeat;
    background-size: 220px 100%;
    mix-blend-mode: screen;
    opacity: 0.7;
    filter: blur(5px);
    animation: mcEnchantGlint 3.4s linear infinite;
}

.game-over>* {
    position: relative;
    z-index: 1;
    font-family: high-pixel, sans-serif;
    text-align: center;
}

@keyframes mcEnchantGlint {
    from {
        transform: translate(-50%, -50%) rotate(-45deg);
        background-position: 0 0;
    }

    to {
        transform: translate(-50%, -50%) rotate(-45deg);
        background-position: 220px 0;
    }
}

.winner-name.winner-editing {
    outline: none;
    min-width: 2em;
    caret-color: #333;
}

/* ---------- 新格式（编辑器 problems.json）的 Markdown 排版 ---------- */
#question-content.md-content ul,
#question-content.md-content ol {
    display: inline-block;
    text-align: left;
    margin: 0.2em 0;
    padding-left: 1.4em;
}

#question-content.md-content li { margin: 0.1em 0; }

#question-content.md-content table {
    margin: 0.35em auto;
    border-collapse: collapse;
    font-size: 0.72em;
    line-height: 1.4;
}

#question-content.md-content th,
#question-content.md-content td {
    border: 1px solid rgba(0, 0, 0, 0.35);
    padding: 0.12em 0.5em;
    text-align: center;
}

#question-content.md-content th { background: rgba(0, 0, 0, 0.05); }

#question-content.md-content blockquote {
    margin: 0.3em auto;
    padding: 0.1em 0.7em;
    border-left: 3px solid rgba(0, 0, 0, 0.3);
    text-align: left;
    font-style: normal;
    max-width: 90%;
}

#question-content.md-content h1,
#question-content.md-content h2,
#question-content.md-content h3 {
    margin: 0.15em 0;
    font-size: 1.02em;
    line-height: 1.35;
}

#question-content.md-content p { margin: 0 0 0.25em; }
#question-content.md-content p:last-child { margin-bottom: 0; }
#question-content.md-content img {
    max-width: 100%;
    max-height: 160px;
    object-fit: contain;
    vertical-align: middle;
}

.choice-content p { display: inline; margin: 0; }
.choice-content img {
    max-width: 100%;
    max-height: 48px;
    object-fit: contain;
    vertical-align: middle;
}
.choice-content ul,
.choice-content ol {
    display: inline-block;
    text-align: left;
    margin: 0;
    padding-left: 1.2em;
}

/* 新格式选项可能包含公式、长文本或图片，避免撑破卡片 */
.choice-content {
    max-width: 100%;
    overflow-wrap: anywhere;
}
