/* Title flow screens for match mode and online room selection. */
.match-mode-container,
.online-room-container {
    width: 680px;
    max-width: none;
    padding: 34px;
    text-align: center;
    color: #f8fafc;
    background: rgba(15, 23, 42, 0.78);
    border: 1px solid rgba(226, 232, 240, 0.24);
    border-radius: 8px;
    box-shadow: 0 18px 48px rgba(2, 6, 23, 0.34);
    backdrop-filter: blur(16px);
}

.online-room-container {
    width: 760px;
}

.match-mode-title,
.online-room-title {
    margin: 0 0 22px;
    font-size: 2.2rem;
    color: #f8fafc;
    letter-spacing: 0;
}

.match-mode-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.cpu-rule-mode-container {
    width: 780px;
}

.cpu-rule-mode-lead {
    margin: -10px 0 20px;
    color: rgba(226, 232, 240, 0.86);
    font-size: 0.98rem;
}

.cpu-match-settings-form {
    margin: 0 0 18px;
}

.cpu-difficulty-group {
    margin: 0;
    padding: 14px;
    text-align: left;
    border: 1px solid rgba(226, 232, 240, 0.18);
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.36);
}

.cpu-difficulty-group legend {
    padding: 0 6px;
    color: rgba(226, 232, 240, 0.84);
    font-weight: 800;
    font-size: 0.88rem;
}

.cpu-difficulty-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.cpu-difficulty-choice {
    position: relative;
    min-height: 82px;
    padding: 15px 16px 15px 48px;
    display: flex;
    align-items: center;
    color: #e2e8f0;
    overflow: hidden;
    border: 1px solid rgba(226, 232, 240, 0.20);
    border-radius: 8px;
    background: rgba(2, 6, 23, 0.36);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
    cursor: pointer;
    transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.cpu-difficulty-choice::before {
    content: "";
    position: absolute;
    inset: 0;
    opacity: 0.28;
    transition: opacity 0.16s ease;
}

.cpu-difficulty-choice::after {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    background: var(--cpu-difficulty-accent);
    box-shadow: 0 0 18px var(--cpu-difficulty-glow);
}

.cpu-difficulty-choice input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.cpu-difficulty-check {
    position: absolute;
    left: 16px;
    top: 50%;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(226, 232, 240, 0.44);
    border-radius: 999px;
    transform: translateY(-50%);
}

.cpu-difficulty-choice input:checked + .cpu-difficulty-check {
    border-color: rgba(255, 255, 255, 0.92);
    background: var(--cpu-difficulty-accent);
    box-shadow: 0 0 18px var(--cpu-difficulty-glow);
}

.cpu-difficulty-choice input:checked + .cpu-difficulty-check::after {
    content: "";
    position: absolute;
    left: 4px;
    top: 1px;
    width: 5px;
    height: 10px;
    border: solid #020617;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.cpu-difficulty-choice:hover {
    transform: translateY(-1px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 12px 24px rgba(2, 6, 23, 0.22);
}

.cpu-difficulty-choice:has(input:checked) {
    border-color: var(--cpu-difficulty-accent);
    background: var(--cpu-difficulty-selected-bg);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 0 0 1px var(--cpu-difficulty-soft), 0 16px 30px rgba(2, 6, 23, 0.26);
}

.cpu-difficulty-choice:has(input:focus-visible) {
    outline: 2px solid var(--cpu-difficulty-accent);
    outline-offset: 3px;
}

.cpu-difficulty-choice:has(input:checked)::before {
    opacity: 0.46;
}

.cpu-difficulty-choice-weak {
    --cpu-difficulty-accent: #38bdf8;
    --cpu-difficulty-soft: rgba(56, 189, 248, 0.28);
    --cpu-difficulty-glow: rgba(56, 189, 248, 0.42);
    --cpu-difficulty-selected-bg: rgba(14, 116, 144, 0.26);
}

.cpu-difficulty-choice-weak::before {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.82), rgba(14, 165, 233, 0.42));
}

.cpu-difficulty-choice-normal {
    --cpu-difficulty-accent: #4ade80;
    --cpu-difficulty-soft: rgba(74, 222, 128, 0.28);
    --cpu-difficulty-glow: rgba(74, 222, 128, 0.42);
    --cpu-difficulty-selected-bg: rgba(22, 101, 52, 0.28);
}

.cpu-difficulty-choice-normal::before {
    background: linear-gradient(135deg, rgba(22, 163, 74, 0.78), rgba(20, 184, 166, 0.34));
}

.cpu-difficulty-choice-strong {
    --cpu-difficulty-accent: #facc15;
    --cpu-difficulty-soft: rgba(250, 204, 21, 0.28);
    --cpu-difficulty-glow: rgba(250, 204, 21, 0.38);
    --cpu-difficulty-selected-bg: rgba(133, 77, 14, 0.28);
}

.cpu-difficulty-choice-strong::before {
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.72), rgba(245, 158, 11, 0.36));
}

.cpu-difficulty-choice-strongest {
    --cpu-difficulty-accent: #f87171;
    --cpu-difficulty-soft: rgba(248, 113, 113, 0.30);
    --cpu-difficulty-glow: rgba(248, 113, 113, 0.44);
    --cpu-difficulty-selected-bg: rgba(153, 27, 27, 0.28);
}

.cpu-difficulty-choice-strongest::before {
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.78), rgba(244, 63, 94, 0.34));
}

.cpu-difficulty-copy {
    position: relative;
    z-index: 1;
    min-width: 0;
    display: grid;
    gap: 5px;
}

.cpu-difficulty-label {
    min-width: 0;
    font-weight: 800;
    font-size: 1.08rem;
}

.cpu-difficulty-model {
    min-width: 0;
    color: rgba(248, 250, 252, 0.72);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0;
}

.cpu-rule-mode-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.match-mode-btn,
.cpu-rule-mode-btn,
.online-room-action-btn,
.match-back-btn {
    border: 0;
    cursor: pointer;
    font: inherit;
    transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.match-mode-btn {
    min-height: 158px;
    padding: 22px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
    color: #fff;
    border-radius: 8px;
    box-shadow: 0 12px 28px rgba(2, 6, 23, 0.26);
}

.cpu-rule-mode-btn {
    min-height: 176px;
    padding: 20px 18px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
    color: #fff;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 12px 28px rgba(2, 6, 23, 0.26);
}

.match-mode-btn.cpu {
    background: linear-gradient(180deg, #16a34a, #15803d);
}

.cpu-rule-mode-btn.basic {
    background: linear-gradient(180deg, #0ea5e9, #0369a1);
}

.cpu-rule-mode-btn.advanced {
    background: linear-gradient(180deg, #7c3aed, #5b21b6);
}

.cpu-rule-mode-btn.expert {
    background: linear-gradient(180deg, #f97316, #c2410c);
}

.match-mode-btn.online {
    background: linear-gradient(180deg, #2563eb, #1d4ed8);
}

.match-mode-btn:hover,
.cpu-rule-mode-btn:hover,
.online-room-action-btn:hover,
.match-back-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 32px rgba(2, 6, 23, 0.32);
}

.match-mode-btn-title {
    display: block;
    font-size: 1.45rem;
    font-weight: 800;
}

.match-mode-btn-sub {
    display: block;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.82);
}

.match-back-btn {
    min-width: 180px;
    padding: 12px 20px;
    color: #e2e8f0;
    background: rgba(148, 163, 184, 0.22);
    border: 1px solid rgba(226, 232, 240, 0.22);
    border-radius: 8px;
}

.online-room-layout {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.online-room-rule-panel {
    margin: -4px 0 18px;
    padding: 18px;
    text-align: left;
    background: rgba(15, 23, 42, 0.36);
    border: 1px solid rgba(226, 232, 240, 0.18);
    border-radius: 8px;
}

.online-room-rule-panel h3,
.online-room-confirm h3 {
    margin: 0 0 12px;
    font-size: 1.08rem;
    color: #f8fafc;
}

.online-room-rule-grid {
    display: grid;
    grid-template-columns: 1.35fr 0.95fr 1fr;
    gap: 12px;
}

.online-room-rule-group {
    min-width: 0;
    margin: 0;
    padding: 12px;
    display: grid;
    gap: 8px;
    border: 1px solid rgba(226, 232, 240, 0.18);
    border-radius: 8px;
    background: rgba(2, 6, 23, 0.20);
}

.online-room-rule-group legend {
    padding: 0 6px;
    color: rgba(226, 232, 240, 0.84);
    font-weight: 800;
    font-size: 0.86rem;
}

.online-room-choice {
    position: relative;
    min-height: 44px;
    padding: 9px 10px 9px 40px;
    display: grid;
    align-items: center;
    color: #e2e8f0;
    border: 1px solid rgba(226, 232, 240, 0.18);
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.34);
    cursor: pointer;
    transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.online-room-choice input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.online-room-choice strong,
.online-room-choice small {
    display: block;
}

.online-room-choice strong {
    font-size: 0.95rem;
}

.online-room-choice small {
    margin-top: 2px;
    color: rgba(226, 232, 240, 0.66);
    font-size: 0.75rem;
}

.online-room-choice-check {
    position: absolute;
    left: 12px;
    top: 50%;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    border: 2px solid rgba(226, 232, 240, 0.44);
    transform: translateY(-50%);
}

.online-room-choice input:checked + .online-room-choice-check {
    border-color: #86efac;
    background: #22c55e;
    box-shadow: 0 0 18px rgba(34, 197, 94, 0.36);
}

.online-room-choice input:checked + .online-room-choice-check::after {
    content: "";
    position: absolute;
    left: 4px;
    top: 1px;
    width: 5px;
    height: 10px;
    border: solid #052e16;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.online-room-choice:has(input:checked) {
    border-color: rgba(134, 239, 172, 0.72);
    background: rgba(22, 163, 74, 0.22);
}

.online-room-section {
    min-height: 176px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 14px;
    background: rgba(15, 23, 42, 0.46);
    border: 1px solid rgba(226, 232, 240, 0.20);
    border-radius: 8px;
}

.online-room-section h3 {
    margin: 0;
    font-size: 1.25rem;
    color: #f8fafc;
}

.online-room-action-btn {
    padding: 13px 18px;
    color: #fff;
    font-weight: 800;
    border-radius: 8px;
}

.online-room-action-btn.create {
    background: linear-gradient(180deg, #16a34a, #15803d);
}

.online-room-action-btn.join {
    background: linear-gradient(180deg, #2563eb, #1d4ed8);
}

.online-room-action-btn.secondary {
    color: #e2e8f0;
    background: rgba(148, 163, 184, 0.24);
    border: 1px solid rgba(226, 232, 240, 0.20);
}

.online-room-confirm {
    margin: 0 0 16px;
    padding: 16px;
    text-align: left;
    background: rgba(15, 23, 42, 0.54);
    border: 1px solid rgba(226, 232, 240, 0.22);
    border-radius: 8px;
}

.online-room-confirm.hidden {
    display: none;
}

.online-room-summary {
    margin: 0;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 14px;
    color: #e2e8f0;
}

.online-room-summary dt {
    color: rgba(226, 232, 240, 0.66);
    font-weight: 800;
}

.online-room-summary dd {
    margin: 0;
}

.online-room-confirm-actions {
    margin-top: 14px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.online-room-created {
    display: grid;
    gap: 4px;
    justify-items: center;
}

.online-room-created.hidden {
    display: none;
}

.online-room-created-label {
    font-size: 0.86rem;
    color: #cbd5e1;
}

.online-room-code {
    padding: 4px 16px;
    font-size: 2rem;
    line-height: 1.15;
    letter-spacing: 0.14em;
    color: #f8fafc;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(226, 232, 240, 0.24);
    border-radius: 8px;
}

.online-room-join-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: center;
}

.online-room-code-input {
    min-width: 0;
    padding: 12px 14px;
    color: #0f172a;
    background: #f8fafc;
    border: 1px solid rgba(226, 232, 240, 0.80);
    border-radius: 8px;
    font-size: 1.4rem;
    font-weight: 800;
    text-align: center;
    letter-spacing: 0.12em;
}

.online-room-status {
    min-height: 22px;
    margin: 0 0 18px;
    color: #cbd5e1;
}

.online-room-status.success {
    color: #86efac;
}

.online-room-status.error {
    color: #fca5a5;
}

@media (max-width: 720px) {
    .match-mode-container,
    .online-room-container {
        width: 92vw;
        padding: 24px;
    }

    .match-mode-actions,
    .cpu-rule-mode-actions,
    .cpu-difficulty-options,
    .online-room-rule-grid,
    .online-room-layout {
        grid-template-columns: 1fr;
    }

    .match-mode-btn,
    .cpu-rule-mode-btn {
        min-height: 126px;
    }
}
