* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 20% 10%, rgba(108, 170, 255, 0.24), transparent 34rem),
        linear-gradient(145deg, #07131f, #132821 48%, #0b121d);
    color: #f8fafc;
    font-family: "Segoe UI", "Yu Gothic", "Meiryo", sans-serif;
}

.match-log-page {
    width: min(1180px, calc(100vw - 32px));
    margin: 0 auto;
    padding: 28px 0 48px;
}

.match-log-header,
.match-log-summary,
.match-log-controls,
.match-log-search,
.match-log-board,
.match-log-score-panel,
.match-log-timeline {
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: rgba(9, 20, 30, 0.62);
    backdrop-filter: blur(8px);
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.24);
}

.match-log-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 24px;
    border-radius: 14px;
}

.match-log-header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
}

.match-log-eyebrow {
    margin: 0 0 4px;
    color: #93c5fd;
    font-size: 0.78rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

h1,
h2,
h3 {
    margin: 0;
}

h1 {
    font-size: clamp(1.8rem, 4vw, 3rem);
}

.match-log-home,
.match-log-list-back,
.match-log-list-open,
.match-log-form button,
.match-log-controls button {
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 999px;
    color: #f8fafc;
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.86), rgba(37, 99, 235, 0.82));
    text-decoration: none;
    font-weight: 700;
    cursor: pointer;
}

.match-log-home {
    font: inherit;
}

.match-log-home,
.match-log-list-back {
    padding: 10px 18px;
}

.match-log-search {
    margin-top: 18px;
    padding: 20px;
    border-radius: 14px;
}

.match-log-search-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.match-log-search-header button {
    flex: 0 0 auto;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 999px;
    padding: 9px 15px;
    color: #f8fafc;
    background: rgba(14, 165, 233, 0.32);
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.match-log-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 310px;
    margin-top: 14px;
    padding: 10px;
    overflow: auto;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.38);
}

.match-log-list-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    width: 100%;
    border: 1px solid rgba(125, 211, 252, 0.18);
    border-radius: 10px;
    padding: 11px 12px;
    color: #f8fafc;
    background: rgba(255, 255, 255, 0.07);
    font: inherit;
    text-align: left;
}

.match-log-list-item:hover {
    border-color: rgba(56, 189, 248, 0.58);
    background: rgba(14, 165, 233, 0.18);
}

.match-log-list-item.has-diagnostics {
    border-color: rgba(250, 204, 21, 0.36);
    background: linear-gradient(90deg, rgba(250, 204, 21, 0.11), rgba(255, 255, 255, 0.07));
}

.match-log-list-main {
    font-weight: 900;
}

.match-log-list-body {
    display: grid;
    min-width: 0;
    gap: 5px;
}

.match-log-list-open {
    padding: 9px 14px;
    font: inherit;
    white-space: nowrap;
}

.match-log-list-open:disabled {
    cursor: not-allowed;
    filter: grayscale(1);
    opacity: 0.52;
}

.match-log-list-meta,
.match-log-list-message,
.match-log-code-search p {
    color: #bfdbfe;
    font-size: 0.9rem;
}

.match-log-code-search {
    margin-top: 18px;
}

.match-log-code-search h3 {
    font-size: 1rem;
}

.match-log-code-search p {
    margin: 5px 0 0;
}

.match-log-form {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.match-log-form input {
    flex: 1;
    min-width: 0;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 10px;
    padding: 12px 14px;
    color: #f8fafc;
    background: rgba(15, 23, 42, 0.78);
    font: inherit;
    text-transform: uppercase;
}

.match-log-form button,
.match-log-controls button {
    padding: 10px 16px;
    font: inherit;
}

.match-log-status {
    min-height: 1.4em;
    margin: 10px 0 0;
    color: #facc15;
}

.match-log-result {
    margin-top: 18px;
}

body.match-log-replay-mode .match-log-page {
    width: min(1760px, calc(100vw - 20px));
    padding: 14px 0 28px;
}

.hidden {
    display: none !important;
}

.match-log-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 18px 20px;
    border-radius: 14px;
}

.match-log-summary > div:first-child {
    min-width: 0;
}

.match-log-kpis {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.match-log-kpis span,
.match-log-step,
.match-log-zone {
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.1);
    color: #dbeafe;
    font-weight: 700;
}

.match-log-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
    padding: 12px;
    border-radius: 14px;
}

.match-log-replay-layout,
.match-log-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 16px;
    margin-top: 16px;
}

.match-log-replay-main {
    display: grid;
    gap: 14px;
    min-width: 0;
}

.match-log-board,
.match-log-score-panel,
.match-log-timeline {
    border-radius: 14px;
    padding: 16px;
}

.match-log-step-label {
    margin: 10px 0 14px;
    padding: 12px 14px;
    border-left: 4px solid #38bdf8;
    border-radius: 8px;
    background: rgba(14, 165, 233, 0.13);
    color: #e0f2fe;
    font-weight: 800;
}

.match-log-step-diagnostics {
    margin: -4px 0 14px;
    padding: 10px 12px;
    border: 1px solid rgba(250, 204, 21, 0.35);
    border-radius: 10px;
    background: rgba(113, 63, 18, 0.24);
    color: #fef3c7;
}

.match-log-step-diagnostics strong {
    display: block;
    margin-bottom: 6px;
}

.match-log-step-diagnostics ul {
    display: grid;
    gap: 5px;
    margin: 0;
    padding-left: 18px;
}

.match-log-player-block {
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.06);
}

.match-log-player-block + .match-log-center,
.match-log-center + .match-log-player-block {
    margin-top: 12px;
}

.match-log-hand,
.match-log-place {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 12px;
    min-height: 150px;
    margin-top: 8px;
}

.match-log-card-face.cg-card-shell {
    flex: 0 0 auto;
}

.match-log-card-face .cg-card-face {
    pointer-events: none;
}

.match-log-card-fallback,
.match-log-empty {
    max-width: 180px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 6px 8px;
    background: rgba(15, 23, 42, 0.78);
    color: #f8fafc;
    font-size: 0.86rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.match-log-empty {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 86px;
    min-height: 42px;
    color: #bfdbfe;
    background: rgba(15, 23, 42, 0.42);
    white-space: normal;
}

.match-log-stack {
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 148px;
    border: 1px solid rgba(125, 211, 252, 0.24);
    border-radius: 10px;
    padding: 9px;
    background: rgba(8, 47, 73, 0.36);
}

.match-log-stack-label {
    flex-basis: 100%;
    color: #bae6fd;
    font-size: 0.75rem;
    font-weight: 800;
}

.match-log-center {
    display: flex;
    justify-content: center;
    gap: 10px;
}

#match-log-timeline-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 640px;
    margin: 12px 0 0;
    padding: 0;
    overflow: auto;
    list-style: none;
}

.match-log-score-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.match-log-score-panel-header span {
    color: #bfdbfe;
    font-size: 0.9rem;
    font-weight: 800;
}

.match-log-score-cards {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(120px, 0.8fr) minmax(0, 1fr);
    gap: 12px;
    margin-top: 14px;
}

.match-log-score-card {
    display: grid;
    justify-items: center;
    gap: 4px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 14px;
    padding: 12px 10px;
    background: rgba(15, 23, 42, 0.42);
    box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.035);
}

.match-log-score-card-label {
    color: #cbd5e1;
    font-size: 0.76rem;
    font-weight: 900;
    letter-spacing: 0.08em;
}

.match-log-score-card strong {
    color: #f8fafc;
    font-size: clamp(2rem, 5vw, 3.4rem);
    line-height: 1;
    font-weight: 950;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
}

.match-log-score-card small {
    color: #dbeafe;
    font-size: 0.78rem;
    font-weight: 800;
}

.match-log-score-card.is-player {
    border-color: rgba(56, 189, 248, 0.32);
    background: linear-gradient(180deg, rgba(14, 165, 233, 0.22), rgba(15, 23, 42, 0.36));
}

.match-log-score-card.is-opponent {
    border-color: rgba(251, 113, 133, 0.32);
    background: linear-gradient(180deg, rgba(244, 63, 94, 0.20), rgba(15, 23, 42, 0.36));
}

.match-log-score-card.is-diff {
    border-color: rgba(250, 204, 21, 0.32);
    background: linear-gradient(180deg, rgba(250, 204, 21, 0.16), rgba(15, 23, 42, 0.36));
}

.match-log-score-cards[data-leader="player"] .match-log-score-card.is-player,
.match-log-score-cards[data-leader="opponent"] .match-log-score-card.is-opponent {
    border-color: rgba(250, 204, 21, 0.68);
    box-shadow:
        0 0 20px rgba(250, 204, 21, 0.18),
        inset 0 0 20px rgba(255, 255, 255, 0.045);
}

.match-log-score-graph {
    min-height: 138px;
    margin-top: 12px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 12px;
    padding: 12px;
    background:
        linear-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px),
        rgba(15, 23, 42, 0.34);
    background-size: 100% 25%, 10% 100%, auto;
}

.match-log-score-svg {
    display: block;
    width: 100%;
    height: 116px;
    overflow: visible;
}

.match-log-score-line {
    fill: none;
    stroke-width: 2.7;
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
}

.match-log-score-line.is-player {
    stroke: #38bdf8;
}

.match-log-score-line.is-opponent {
    stroke: #fb7185;
}

.match-log-score-marker {
    stroke: rgba(250, 204, 21, 0.95);
    stroke-width: 1.7;
    stroke-dasharray: 2.4 2.4;
    vector-effect: non-scaling-stroke;
}

.match-log-timeline-group {
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: 12px;
    padding: 9px;
    background: rgba(255, 255, 255, 0.055);
}

.match-log-timeline-group.has-active {
    border-color: rgba(56, 189, 248, 0.48);
    background: rgba(14, 165, 233, 0.12);
}

.match-log-timeline-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 7px;
}

.match-log-timeline-group-title {
    color: #e0f2fe;
    font-size: 0.92rem;
    font-weight: 900;
}

.match-log-timeline-group-count {
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    padding: 2px 7px;
    color: #bae6fd;
    background: rgba(15, 23, 42, 0.36);
    font-size: 0.72rem;
    font-weight: 800;
}

.match-log-timeline-steps {
    display: grid;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.match-log-timeline-step {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 9px;
    padding: 8px 9px;
    background: rgba(255, 255, 255, 0.07);
    cursor: pointer;
}

.match-log-timeline-step.has-diagnostics {
    border-color: rgba(250, 204, 21, 0.48);
    background: rgba(250, 204, 21, 0.11);
}

.match-log-timeline-step:hover {
    border-color: rgba(56, 189, 248, 0.42);
    background: rgba(14, 165, 233, 0.14);
}

.match-log-timeline-step.is-active {
    border-color: rgba(56, 189, 248, 0.84);
    background: rgba(14, 165, 233, 0.22);
}

.match-log-timeline-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    border-radius: 999px;
    padding: 3px 7px;
    color: #e0f2fe;
    background: rgba(148, 163, 184, 0.22);
    font-size: 0.68rem;
    font-weight: 900;
}

.match-log-timeline-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.match-log-timeline-diagnostic {
    border: 1px solid rgba(250, 204, 21, 0.35);
    border-radius: 999px;
    padding: 2px 7px;
    color: #fef3c7;
    background: rgba(113, 63, 18, 0.42);
    font-size: 0.68rem;
    font-weight: 900;
}

.match-log-timeline-step.is-draw .match-log-timeline-badge,
.match-log-timeline-step.is-turn-end .match-log-timeline-badge {
    color: #cbd5e1;
    background: rgba(148, 163, 184, 0.18);
}

.match-log-timeline-step.is-draw,
.match-log-timeline-step.is-turn-end {
    opacity: 0.82;
}

.match-log-timeline-step.is-turn-start .match-log-timeline-badge {
    color: #dbeafe;
    background: rgba(37, 99, 235, 0.32);
}

.match-log-timeline-step.is-turn-start {
    background: rgba(37, 99, 235, 0.11);
}

.match-log-timeline-step.is-act .match-log-timeline-badge {
    color: #fef3c7;
    background: rgba(245, 158, 11, 0.32);
}

.match-log-timeline-step.is-inscription-act .match-log-timeline-badge {
    color: #fecdd3;
    background: rgba(225, 29, 72, 0.32);
}

.match-log-timeline-step.is-place .match-log-timeline-badge {
    color: #dcfce7;
    background: rgba(34, 197, 94, 0.28);
}

.match-log-timeline-step.is-fusion .match-log-timeline-badge {
    color: #f5d0fe;
    background: rgba(168, 85, 247, 0.34);
}

.match-log-timeline-step.is-inscription .match-log-timeline-badge {
    color: #cffafe;
    background: rgba(6, 182, 212, 0.28);
}

.match-log-timeline-step.is-choice .match-log-timeline-badge {
    color: #dbeafe;
    background: rgba(59, 130, 246, 0.28);
}

.match-log-timeline-step.is-end .match-log-timeline-badge {
    color: #ffe4e6;
    background: rgba(244, 63, 94, 0.32);
}

@media (max-width: 860px) {
    .match-log-replay-layout,
    .match-log-layout {
        grid-template-columns: 1fr;
    }

    .match-log-summary,
    .match-log-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .match-log-kpis {
        justify-content: flex-start;
    }

    .match-log-list-item {
        grid-template-columns: 1fr;
    }

    .match-log-list-open {
        justify-self: flex-start;
    }

    .match-log-score-cards {
        grid-template-columns: 1fr;
    }
}
