:root {
    --game-primary: #c90c0f;
    --game-secondary: #f4c430;
    --c4-wood-dark: #3b2414;
    --c4-wood: #6b3f22;
    --c4-frame: #6a8499;
    --c4-frame-mid: #58758c;
    --c4-frame-dark: #456274;
    --c4-red: #c90c0f;
    --c4-yellow: #f4c430;
}

body.c4-page {
    margin: 0;
    min-height: 100vh;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    color: #f8f4ea;
    background:
        radial-gradient(circle at 14% 10%, rgba(244, 196, 48, 0.16), transparent 42%),
        radial-gradient(circle at 88% 8%, rgba(201, 12, 15, 0.22), transparent 46%),
        linear-gradient(180deg, #2a1810 0%, #4a2c18 46%, #1a120c 100%);
}

body.c4-page.game-menu-active {
    overflow-y: auto;
    overflow-x: hidden;
}

body.c4-page.game-menu-active #game-header {
    display: none !important;
}

.c4-page .game-screen {
    display: none;
    min-height: 100vh;
}

.c4-page .game-screen.active {
    display: block;
}

body.c4-page.with-game-header .c4-shell {
    padding-top: 5.5rem;
}

.c4-shell {
    max-width: min(920px, 96vw);
    margin: 0 auto;
    padding: 1.1rem 0.75rem 2.5rem;
}

.c4-hud {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0 auto 0.85rem;
    padding: 0.55rem 0.7rem;
    background: linear-gradient(180deg, #5a351c, #3b2414);
    border: 3px solid #1a120c;
    border-radius: 12px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 10px 24px rgba(0, 0, 0, 0.35);
}

.c4-lcd {
    min-width: 6.2rem;
    padding: 0.2rem 0.45rem;
    background: #140414;
    color: #f5c518;
    font-family: "Courier New", ui-monospace, monospace;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-align: center;
    border-radius: 6px;
    box-shadow: inset 0 0 0 2px #7f1d1d, inset 0 8px 16px rgba(0, 0, 0, 0.45);
}

.c4-lcd span {
    display: block;
    font-size: 0.62rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #fca5a5;
}

.c4-chip {
    padding: 0.45rem 0.7rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: #fde68a;
    font-weight: 700;
}

.c4-chip.is-busy {
    background: #b91c1c;
    color: #fff;
}

.c4-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.45rem;
    margin: 0 auto 0.85rem;
}

.c4-tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.75rem;
    border-radius: 999px;
    border: 1px solid rgba(244, 196, 48, 0.35);
    background: rgba(26, 18, 12, 0.75);
    color: #f8fafc;
    font-weight: 700;
    cursor: pointer;
}

.c4-tool-btn:hover {
    border-color: #f4c430;
    color: #fde68a;
    background: rgba(26, 18, 12, 0.95);
}

.c4-tool-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.c4-table {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.c4-board-wrap {
    width: min(78vh, 94vw, 560px);
    padding: 0.7rem 0.7rem 1.1rem;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.16), transparent 42%),
        linear-gradient(180deg, #7a96ab, #4e6d84 58%, #3f5d73);
    border: 6px solid #355168;
    border-radius: 18px 18px 28px 28px;
    box-shadow: 0 22px 44px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.c4-board {
    position: relative;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    aspect-ratio: 7 / 6;
    background: linear-gradient(180deg, #7a96ab, #5c7a90 55%, #4a6a80);
    border: 4px solid #3d586c;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: inset 0 8px 16px rgba(15, 32, 48, 0.32);
}

.c4-col {
    position: relative;
    display: flex;
    flex-direction: column-reverse;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    min-width: 0;
}

.c4-col:focus-visible {
    outline: 3px solid #f4c430;
    outline-offset: -3px;
    z-index: 3;
}

.c4-col.is-legal:hover,
.c4-col.is-hot {
    background: rgba(255, 255, 255, 0.08);
}

.c4-col.is-full {
    cursor: not-allowed;
}

.c4-slot {
    position: relative;
    flex: 1 1 0;
    min-height: 0;
}

.c4-slot::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 48%, transparent 41%, rgba(255, 255, 255, 0.16) 42%, #6d8799 43%, #4a667a 100%);
    z-index: 2;
    pointer-events: none;
}

.c4-disc {
    position: absolute;
    inset: 8%;
    border-radius: 50%;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    user-select: none;
    isolation: isolate;
    transform: translateY(var(--drop-from, 0px));
}

.c4-disc.is-dropping {
    animation: c4-drop var(--drop-ms, 420ms) cubic-bezier(0.2, 0.85, 0.3, 1.08) both;
}

.c4-disc.red {
    background:
        radial-gradient(circle at 32% 28%, #ff7a7a, #c90c0f 54%, #7f0508);
    box-shadow:
        inset 0 -5px 10px rgba(0, 0, 0, 0.35),
        inset 0 4px 6px rgba(255, 255, 255, 0.22),
        0 3px 5px rgba(0, 0, 0, 0.28);
}

.c4-disc.yellow {
    background:
        radial-gradient(circle at 32% 28%, #ffe566, #f4c430 54%, #b8860b);
    box-shadow:
        inset 0 -5px 10px rgba(0, 0, 0, 0.28),
        inset 0 4px 6px rgba(255, 255, 255, 0.28),
        0 3px 5px rgba(0, 0, 0, 0.28);
}

.c4-disc.is-ghost {
    opacity: 0.38;
    pointer-events: none;
}

.c4-disc.is-win {
    box-shadow:
        0 0 0 3px #fde68a,
        0 0 16px rgba(253, 230, 138, 0.85),
        inset 0 -5px 10px rgba(0, 0, 0, 0.35);
    animation: c4-win-pulse 0.9s ease-in-out infinite;
}

.c4-disc-badge {
    width: 68%;
    height: 68%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
}

.c4-disc-logo {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transform: rotate(var(--rot, 0deg));
}

.c4-hint {
    margin: 0.85rem 0 0;
    text-align: center;
    color: #fde68a;
    font-size: 0.95rem;
}

.c4-settings-panel {
    margin-top: 0.4rem;
    padding: 0.9rem 1rem;
    background: rgba(15, 23, 42, 0.45);
    border: 1px solid rgba(244, 196, 48, 0.22);
    border-radius: 12px;
}

.c4-settings-panel__title {
    font-weight: 700;
    margin-bottom: 0.55rem;
    color: #f5c518;
}

.c4-settings-panel__label {
    margin: 0.35rem 0 0.4rem;
    font-weight: 600;
}

.c4-settings-panel__buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-bottom: 0.75rem;
}

.c4-page .difficulty-pill {
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    padding: 0.5rem 0.85rem;
    background: rgba(255, 255, 255, 0.05);
    color: #f8fafc;
    font-weight: 600;
    cursor: pointer;
}

.c4-page .difficulty-pill:hover {
    border-color: #f4c430;
    color: #fde68a;
    background: rgba(201, 12, 15, 0.22);
}

.c4-page .difficulty-pill.is-selected {
    background: #f4c430;
    color: #1e1b4b;
    border-color: #f4c430;
}

.c4-page .modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    z-index: 12000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.c4-page .party-overlay {
    z-index: 13000;
}

.c4-page .modal-content {
    background: #fff;
    color: #1a1a1a;
    border-radius: 1rem;
    max-width: 640px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.c4-page .modal-large { max-width: 760px; }

.c4-page .modal-header,
.c4-page .modal-footer {
    padding: 1.1rem 1.4rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.c4-page .modal-header { border-bottom: 2px solid #eee; }
.c4-page .modal-header h2 { margin: 0; color: #c90c0f; font-size: 1.35rem; }

.c4-page .modal-close {
    background: #fff;
    border: 2px solid #c90c0f;
    color: #c90c0f;
    border-radius: 8px;
    cursor: pointer;
    padding: 0.35rem 0.55rem;
}

.c4-page .modal-close:hover {
    background: #c90c0f;
    color: #fff;
}

.c4-page .modal-body { padding: 1.2rem 1.4rem; }
.c4-page .modal-footer { border-top: 2px solid #eee; justify-content: flex-end; }

.c4-page .help-section { margin-bottom: 1.1rem; }
.c4-page .help-section h3 { color: #c90c0f; margin: 0 0 0.4rem; }
.c4-page .help-section ul { margin: 0.3rem 0 0; padding-left: 1.2rem; }

.c4-page .stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.c4-page .stat-card {
    background: #f8fafc;
    border-radius: 12px;
    padding: 0.85rem;
    text-align: center;
}

.c4-page .stat-value { font-size: 1.6rem; color: #c90c0f; font-weight: 700; }
.c4-page .stat-label { color: #64748b; font-size: 0.85rem; }

.c4-page .win-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
    text-align: center;
}

.c4-page .win-stat strong { display: block; font-size: 1.35rem; color: #c90c0f; }
.c4-page .win-stat span { color: #64748b; font-size: 0.82rem; }

.c4-page .result-message { font-size: 1.05rem; margin: 0 0 1rem; }

.c4-page .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.65rem 1.1rem;
    border-radius: 0.55rem;
    border: 2px solid transparent;
    font-weight: 700;
    cursor: pointer;
}

.c4-page .btn-primary {
    background: #c90c0f;
    color: #fff;
}

.c4-page .btn-primary:hover {
    background: #a00a0c;
    color: #fff;
}

.c4-page .btn-secondary {
    background: #fff;
    color: #c90c0f;
    border-color: #c90c0f;
}

.c4-page .btn-secondary:hover {
    background: #c90c0f;
    color: #fff;
}

.c4-page .difficulty-stats {
    display: grid;
    gap: 0.45rem;
}

.c4-page .difficulty-stats div {
    display: flex;
    justify-content: space-between;
    padding: 0.45rem 0.6rem;
    background: #f8fafc;
    border-radius: 8px;
}

@keyframes c4-drop {
    0% { transform: translateY(var(--drop-from, -220px)); }
    84% { transform: translateY(5px); }
    100% { transform: translateY(0); }
}

@keyframes c4-win-pulse {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.18); }
}

@media (prefers-reduced-motion: reduce) {
    .c4-disc.is-dropping,
    .c4-disc.is-win {
        animation: none;
        transform: none;
    }
}

@media (max-width: 640px) {
    .c4-tool-btn span { display: none; }
    .c4-lcd { min-width: 4.6rem; font-size: 1rem; }
}

#settingsModal .c4-settings-panel__title {
    color: #c90c0f;
}
#settingsModal .c4-settings-panel__label {
    color: #1a1a1a;
}
#settingsModal .difficulty-pill {
    background: #f1f5f9;
    color: #0f172a;
    border-color: #cbd5e1;
}
#settingsModal .difficulty-pill:hover {
    background: #e2e8f0;
    color: #0f172a;
    border-color: #c90c0f;
}
#settingsModal .difficulty-pill.is-selected {
    background: #c90c0f;
    color: #fff;
    border-color: #c90c0f;
}
