:root {
    --silicio-red: #c70039;
    --silicio-red-bright: #ff315c;
    --silicio-cyan: #00d4aa;
    --silicio-gold: #ffd166;
    --ink: #12151f;
    --muted: #5e6472;
    --line: #1d2330;
    --paper: #ffffff;
    --page-bg: #05060a;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--page-bg);
    overflow-x: hidden;
}

body {
    min-height: 100%;
    margin: 0;
    overflow-x: hidden;
    font-family: "Inter", Arial, sans-serif;
    color: #ffffff;
    background:
        radial-gradient(circle at 14% 10%, rgba(0, 212, 170, 0.18), transparent 28rem),
        radial-gradient(circle at 88% 8%, rgba(199, 0, 57, 0.2), transparent 26rem),
        linear-gradient(180deg, #05060a 0%, #0a0f18 48%, #05060a 100%);
}

a {
    color: inherit;
}

button,
input,
select,
textarea {
    font: inherit;
}

.silicio-topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 82px;
    padding: 0.75rem clamp(1rem, 4vw, 3rem);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(5, 6, 10, 0.86);
    backdrop-filter: blur(18px);
}

.silicio-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    color: #ffffff;
    font-weight: 900;
    text-decoration: none;
    letter-spacing: 0.01em;
}

.silicio-brand img {
    display: block;
    width: 56px;
    height: 56px;
    object-fit: contain;
}

.silicio-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.silicio-nav a {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.8rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.78);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 800;
}

.silicio-nav a:hover {
    border-color: rgba(0, 212, 170, 0.5);
    color: #ffffff;
}

.sheet-app {
    width: min(1540px, 100%);
    margin: 0 auto;
    padding: clamp(1.25rem, 4vw, 3rem);
}

.sheet-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1.5rem;
    align-items: end;
    margin-bottom: 1.5rem;
}

.sheet-kicker {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    margin-bottom: 0.75rem;
    padding: 0.45rem 0.7rem;
    border: 1px solid rgba(0, 212, 170, 0.36);
    border-radius: 999px;
    background: rgba(0, 212, 170, 0.08);
    color: #34f3d2;
    font-size: 0.75rem;
    font-weight: 900;
    text-transform: uppercase;
}

.sheet-hero h1 {
    margin: 0;
    font-size: clamp(2.5rem, 7vw, 5rem);
    line-height: 0.95;
    letter-spacing: 0;
}

.sheet-hero p {
    max-width: 760px;
    margin: 1rem 0 0;
    color: rgba(255, 255, 255, 0.72);
    font-size: 1.06rem;
    line-height: 1.7;
}

.sheet-hero-actions,
.sheet-actions {
    display: grid;
    gap: 0.65rem;
}

.sheet-hero-actions {
    min-width: 260px;
}

.sheet-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    min-height: 44px;
    padding: 0.7rem 0.95rem;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
    font-weight: 900;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.sheet-button:hover,
.sheet-button:focus-visible {
    transform: translateY(-2px);
    border-color: rgba(0, 212, 170, 0.55);
    background: rgba(0, 212, 170, 0.11);
    outline: none;
}

.sheet-button-primary {
    border-color: rgba(255, 209, 102, 0.45);
    background: linear-gradient(135deg, rgba(199, 0, 57, 0.85), rgba(255, 49, 92, 0.72));
    box-shadow: 0 18px 45px rgba(199, 0, 57, 0.22);
}

.sheet-button-accent {
    border-color: rgba(0, 212, 170, 0.46);
    background: rgba(0, 212, 170, 0.14);
    color: #dcfff7;
}

.sheet-workspace {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
}

.sheet-workspace > * {
    min-width: 0;
}

.sheet-side-panel {
    position: sticky;
    top: 100px;
    display: grid;
    gap: 1rem;
}

.panel-card {
    min-width: 0;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.025)),
        rgba(8, 12, 20, 0.84);
    box-shadow: 0 24px 65px rgba(0, 0, 0, 0.28);
    padding: 1rem;
}

.panel-card h2 {
    margin: 0 0 0.85rem;
    color: #ffffff;
    font-size: 1rem;
}

.pgn-output {
    width: 100%;
    min-height: 270px;
    resize: vertical;
    padding: 0.85rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.3);
    color: #e9fff9;
    line-height: 1.5;
}

.sheet-status {
    min-height: 1.3rem;
    margin: 0.75rem 0 0;
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.9rem;
    line-height: 1.45;
}

.sheet-status.is-error {
    color: #ff9aad;
}

.sheet-status.is-success {
    color: #70f5dc;
}

.sheet-paper {
    width: min(100%, 210mm);
    max-width: 100%;
    min-height: 297mm;
    margin: 0 auto;
    padding: 10mm 9mm 8mm;
    border-radius: 8px;
    background: var(--paper);
    color: var(--ink);
    box-shadow: 0 32px 90px rgba(0, 0, 0, 0.45);
}

.paper-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1rem;
    align-items: start;
    padding-bottom: 0.45rem;
    border-bottom: 3px solid var(--silicio-red);
}

.paper-brand {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.paper-brand img {
    width: 34mm;
    height: 34mm;
    object-fit: contain;
    background: #000000;
    border-radius: 6px;
}

.paper-brand p {
    margin: 0;
    color: var(--silicio-red);
    font-size: 1.62rem;
    font-weight: 900;
    line-height: 1.05;
}

.paper-brand h2 {
    margin: 0.25rem 0;
    color: var(--ink);
    font-size: 1.38rem;
    line-height: 1.15;
}

.paper-brand span {
    color: var(--silicio-red);
    font-size: 0.88rem;
    font-weight: 800;
}

.paper-mark {
    display: grid;
    place-items: center;
    min-width: 30mm;
    min-height: 12mm;
    border: 1px solid rgba(199, 0, 57, 0.34);
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(199, 0, 57, 0.08), rgba(0, 212, 170, 0.08));
    color: var(--silicio-red);
    font-size: 0.72rem;
    font-weight: 900;
    text-transform: uppercase;
}

.players-grid,
.meta-grid {
    display: grid;
    gap: 0.55rem;
    margin-top: 0.65rem;
}

.players-grid {
    grid-template-columns: 1fr 1fr;
}

.meta-grid {
    grid-template-columns: 1.2fr 0.65fr 0.65fr 0.85fr 0.95fr;
}

.field {
    display: grid;
    gap: 0.2rem;
    min-width: 0;
}

.field-wide {
    grid-column: span 2;
}

.field span {
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 900;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.field input,
.field select {
    width: 100%;
    min-height: 32px;
    padding: 0.22rem 0.35rem;
    border: 0;
    border-bottom: 2px solid var(--line);
    border-radius: 0;
    background: rgba(199, 0, 57, 0.035);
    color: var(--ink);
    font-weight: 700;
    outline: none;
}

.field input:focus,
.field select:focus,
.move-input:focus {
    border-color: var(--silicio-red);
    box-shadow: 0 2px 0 rgba(199, 0, 57, 0.12);
}

.moves-section {
    margin-top: 0.75rem;
}

.moves-scroll {
    max-width: 100%;
    overflow-x: visible;
}

.moves-pages {
    display: grid;
    gap: 0.9rem;
}

.moves-page {
    min-width: 0;
}

.moves-list {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto repeat(30, minmax(28px, auto));
    grid-auto-flow: column;
    column-gap: 1rem;
    font-size: 0.84rem;
}

.move-row-header,
.move-row {
    min-width: 0;
    display: grid;
    grid-template-columns: 2.1rem minmax(0, 1.35fr) minmax(3.4rem, 0.45fr) minmax(0, 1.35fr) minmax(3.4rem, 0.45fr);
    gap: 0.36rem;
    align-items: end;
}

.move-row-header {
    min-height: 26px;
    align-items: center;
    padding: 0 0.35rem;
    border-radius: 8px 8px 0 0;
    background: var(--silicio-red);
    color: #ffffff;
    font-size: 0.66rem;
    font-weight: 900;
    text-transform: uppercase;
}

.move-row {
    padding: 0.12rem 0.35rem;
    border-bottom: 1px solid rgba(18, 21, 31, 0.38);
}

.move-number {
    color: var(--muted);
    font-weight: 900;
    text-align: right;
}

.move-cell {
    min-width: 0;
}

.move-label {
    display: none;
}

.move-input {
    width: 100%;
    height: 25px;
    border: 0;
    border-bottom: 1px solid transparent;
    border-radius: 0;
    background: transparent;
    color: var(--ink);
    font-weight: 700;
    outline: none;
}

.move-time {
    color: #404653;
    font-size: 0.78rem;
}

.move-cell.is-invalid .move-input {
    border-color: #d71945;
    background: rgba(215, 25, 69, 0.08);
}

.add-moves-row {
    display: flex;
    justify-content: center;
    margin-top: 0.75rem;
}

.add-moves-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.42rem;
    min-height: 34px;
    padding: 0.45rem 0.75rem;
    border: 1px solid rgba(199, 0, 57, 0.2);
    border-radius: 999px;
    background: rgba(199, 0, 57, 0.045);
    color: var(--silicio-red);
    font-size: 0.78rem;
    font-weight: 900;
    cursor: pointer;
}

.add-moves-button:hover,
.add-moves-button:focus-visible {
    border-color: rgba(199, 0, 57, 0.48);
    background: rgba(199, 0, 57, 0.08);
    outline: none;
}

.sheet-modal-open {
    overflow: hidden;
}

.silicio-modal-layer[hidden] {
    display: none;
}

.silicio-modal-layer {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    display: grid;
    place-items: center;
    padding: 1rem;
    visibility: hidden;
    pointer-events: none;
    isolation: isolate;
    transition: visibility 0s linear 0.18s;
}

.silicio-modal-layer.is-open {
    visibility: visible;
    pointer-events: auto;
    transition-delay: 0s;
}

.silicio-modal-backdrop {
    position: absolute;
    inset: 0;
    z-index: 0;
    opacity: 0;
    background:
        radial-gradient(circle at 22% 18%, rgba(0, 212, 170, 0.14), transparent 21rem),
        radial-gradient(circle at 78% 10%, rgba(199, 0, 57, 0.2), transparent 22rem),
        rgba(3, 5, 10, 0.92);
    backdrop-filter: blur(16px);
    transition: opacity 0.18s ease;
}

.silicio-modal-layer.is-open .silicio-modal-backdrop {
    opacity: 1;
}

.silicio-modal {
    position: relative;
    z-index: 1;
    isolation: isolate;
    width: min(440px, 100%);
    padding: 1.25rem;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    overflow: hidden;
    background: #070b13;
    box-shadow: 0 36px 120px rgba(0, 0, 0, 0.72), 0 0 0 1px rgba(0, 212, 170, 0.08);
    color: #ffffff;
    transform: translateY(8px) scale(0.98);
    transition: transform 0.18s ease;
}

.silicio-modal::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    border-radius: inherit;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.012)),
        linear-gradient(180deg, rgba(199, 0, 57, 0.08), rgba(0, 212, 170, 0.04)),
        repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 22px),
        #070b13;
    pointer-events: none;
}

.silicio-modal-layer.is-open .silicio-modal {
    transform: translateY(0) scale(1);
}

.silicio-modal::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    z-index: 2;
    height: 3px;
    border-radius: 8px 8px 0 0;
    background: linear-gradient(90deg, var(--silicio-red), var(--silicio-cyan), var(--silicio-gold));
    pointer-events: none;
}

.silicio-modal > * {
    position: relative;
    z-index: 1;
}

.silicio-modal-close {
    position: absolute;
    top: 0.72rem;
    right: 0.72rem;
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.055);
    color: rgba(255, 255, 255, 0.78);
    cursor: pointer;
}

.silicio-modal-close:hover,
.silicio-modal-close:focus-visible {
    border-color: rgba(0, 212, 170, 0.48);
    color: #ffffff;
    outline: none;
}

.silicio-modal-symbol {
    display: inline-grid;
    place-items: center;
    width: 46px;
    height: 46px;
    margin-bottom: 0.85rem;
    border: 1px solid rgba(199, 0, 57, 0.32);
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(199, 0, 57, 0.2), rgba(0, 212, 170, 0.08));
    color: #ff6f91;
    font-size: 1.05rem;
}

.silicio-modal-kicker {
    margin: 0 2.6rem 0.35rem 0;
    color: #34f3d2;
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.silicio-modal h2 {
    margin: 0;
    color: #ffffff;
    font-size: 1.45rem;
    line-height: 1.1;
}

.silicio-modal p {
    margin: 0.8rem 0 0;
    color: rgba(255, 255, 255, 0.76);
    line-height: 1.55;
}

.silicio-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.65rem;
    margin-top: 1.15rem;
}

.silicio-modal-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0.66rem 0.95rem;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
    font-weight: 900;
    cursor: pointer;
}

.silicio-modal-button:hover,
.silicio-modal-button:focus-visible {
    border-color: rgba(0, 212, 170, 0.5);
    outline: none;
}

.silicio-modal-button-danger {
    border-color: rgba(255, 209, 102, 0.32);
    background: linear-gradient(135deg, rgba(199, 0, 57, 0.92), rgba(255, 49, 92, 0.78));
    box-shadow: 0 14px 34px rgba(199, 0, 57, 0.24);
}

.signature-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    min-height: 21mm;
    margin-top: 0.65rem;
    border: 2px solid var(--line);
    align-items: end;
}

.signature-row div {
    padding: 0.35rem;
    color: var(--ink);
    font-weight: 900;
}

@media (max-width: 1120px) {
    .sheet-hero,
    .sheet-workspace {
        grid-template-columns: 1fr;
    }

    .sheet-paper {
        order: 1;
    }

    .sheet-side-panel {
        order: 2;
        position: static;
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 760px) {
    .silicio-topbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.75rem;
        min-height: 0;
        padding: 0.75rem;
    }

    .silicio-nav {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        justify-content: flex-start;
        gap: 0.4rem;
    }

    .silicio-nav a {
        min-width: 0;
        padding-inline: 0.45rem;
        font-size: 0.78rem;
        white-space: nowrap;
    }

    .silicio-brand img {
        width: 46px;
        height: 46px;
    }

    .sheet-hero {
        gap: 1rem;
        margin-bottom: 1rem;
    }

    .sheet-hero h1 {
        font-size: clamp(2rem, 14vw, 3.1rem);
        line-height: 1;
    }

    .sheet-hero p {
        margin-top: 0.7rem;
        font-size: 0.95rem;
        line-height: 1.55;
    }

    .sheet-hero-actions {
        min-width: 0;
    }

    .sheet-app {
        width: 100%;
        padding: 0.75rem;
    }

    .sheet-workspace {
        display: flex;
        flex-direction: column;
        gap: 0.9rem;
    }

    .sheet-side-panel {
        width: 100%;
        grid-template-columns: 1fr;
    }

    .sheet-button {
        width: 100%;
        min-width: 0;
    }

    .sheet-paper {
        width: 100%;
        padding: 0.85rem;
        min-height: 0;
        border-radius: 8px;
    }

    .paper-head,
    .players-grid,
    .meta-grid {
        grid-template-columns: 1fr;
    }

    .field-wide {
        grid-column: auto;
    }

    .paper-brand {
        align-items: flex-start;
    }

    .paper-brand img {
        width: 72px;
        height: 72px;
    }

    .paper-brand p {
        font-size: 1.25rem;
    }

    .paper-brand h2 {
        font-size: 1.05rem;
    }

    .paper-brand span {
        font-size: 0.74rem;
    }

    .paper-mark {
        min-width: 0;
        min-height: 0;
        padding: 0.55rem 0.65rem;
    }

    .field input,
    .field select {
        min-height: 40px;
        padding: 0.35rem 0.45rem;
    }

    .moves-section {
        margin-top: 0.9rem;
    }

    .moves-pages {
        gap: 0;
    }

    .moves-list {
        display: grid;
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        grid-auto-flow: row;
        gap: 0;
        font-size: 0.78rem;
    }

    .move-row-header {
        display: grid;
        grid-template-columns: 1.8rem minmax(0, 1fr) minmax(3.55rem, 0.52fr) minmax(0, 1fr) minmax(3.55rem, 0.52fr);
        gap: 0.22rem;
        min-height: 28px;
        padding: 0 0.22rem;
        border-radius: 6px 6px 0 0;
        font-size: 0.57rem;
    }

    .moves-page:not(:first-child) .move-row-header,
    .moves-page .move-row-header:not(:first-child) {
        display: none;
    }

    .move-row {
        display: grid;
        grid-template-columns: 1.8rem minmax(0, 1fr) minmax(3.55rem, 0.52fr) minmax(0, 1fr) minmax(3.55rem, 0.52fr);
        gap: 0.22rem;
        min-height: 32px;
        padding: 0.08rem 0.22rem;
        border: 0;
        border-bottom: 1px solid rgba(18, 21, 31, 0.34);
        border-radius: 0;
        background: transparent;
    }

    .move-row:nth-child(even) {
        background: rgba(18, 21, 31, 0.035);
    }

    .move-number {
        grid-column: auto;
        align-self: end;
        padding-bottom: 0.42rem;
        text-align: right;
        color: var(--muted);
        font-size: 0.76rem;
    }

    .move-number::before {
        content: none;
    }

    .move-cell {
        display: block;
        min-width: 0;
    }

    .move-label {
        display: none;
    }

    .move-input {
        height: 29px;
        padding: 0.18rem 0.2rem;
        border: 0;
        border-bottom: 1px solid rgba(18, 21, 31, 0.62);
        border-radius: 0;
        background: transparent;
    }

    .move-time {
        font-size: 0.72rem;
    }

    .add-moves-row {
        justify-content: flex-end;
        margin-top: 0.55rem;
    }

    .add-moves-button {
        min-height: 32px;
        width: auto;
        max-width: 100%;
        padding: 0.38rem 0.62rem;
        font-size: 0.72rem;
    }

    .silicio-modal-layer {
        align-items: center;
        padding: 0.75rem;
    }

    .silicio-modal {
        padding: 1rem;
        max-height: calc(100vh - 1.5rem);
        overflow: auto;
    }

    .silicio-modal h2 {
        font-size: 1.22rem;
    }

    .silicio-modal-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .silicio-modal-button {
        width: 100%;
    }

    .signature-row {
        grid-template-columns: 1fr;
        gap: 0;
        min-height: 0;
    }

    .signature-row div {
        min-height: 52px;
        border-bottom: 1px solid rgba(18, 21, 31, 0.22);
    }

    .signature-row div:last-child {
        border-bottom: 0;
    }
}

@media print {
    @page {
        size: A4;
        margin: 7mm;
    }

    html,
    body {
        width: 210mm;
        min-height: 297mm;
        background: #ffffff !important;
    }

    body {
        color: var(--ink);
    }

    .no-print {
        display: none !important;
    }

    .sheet-app,
    .sheet-workspace {
        display: block;
        width: auto;
        margin: 0;
        padding: 0;
    }

    .sheet-paper {
        width: 100%;
        min-height: auto;
        margin: 0;
        padding: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .paper-brand img {
        width: 30mm;
        height: 30mm;
    }

    .paper-brand p {
        font-size: 1.45rem;
    }

    .paper-brand h2 {
        font-size: 1.2rem;
    }

    .field input,
    .field select,
    .move-input {
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    .moves-list {
        font-size: 0.76rem;
    }

    .move-row-header,
    .move-row {
        grid-template-columns: 2rem minmax(0, 1.35fr) minmax(3rem, 0.45fr) minmax(0, 1.35fr) minmax(3rem, 0.45fr);
        gap: 0.28rem;
    }

    .move-input {
        height: 20px;
    }

    .signature-row {
        min-height: 17mm;
        break-inside: avoid;
    }
}
