/* Self-hosted fonts (both SIL Open Font License 1.1, see /fonts) */
@font-face {
    font-family: 'Rajdhani';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('fonts/rajdhani-latin-500-normal.woff2') format('woff2');
}

@font-face {
    font-family: 'Rajdhani';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('fonts/rajdhani-latin-600-normal.woff2') format('woff2');
}

@font-face {
    font-family: 'Rajdhani';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('fonts/rajdhani-latin-700-normal.woff2') format('woff2');
}

@font-face {
    font-family: 'IBM Plex Mono';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('fonts/ibm-plex-mono-latin-400-normal.woff2') format('woff2');
}

@font-face {
    font-family: 'IBM Plex Mono';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('fonts/ibm-plex-mono-latin-500-normal.woff2') format('woff2');
}

@font-face {
    font-family: 'IBM Plex Mono';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('fonts/ibm-plex-mono-latin-600-normal.woff2') format('woff2');
}

:root {
    --bg: #0c0a0a;
    --panel: #171313;
    --panel-border: #2c2222;
    --red: #d81e2c;
    --red-dim: #7a1015;
    --red-glow: rgba(216, 30, 44, 0.35);
    --text: #f2ece4;
    --text-dim: #9c8f89;
    --mono-bg: #0a0808;
}

* {
    box-sizing: border-box;
}

html {
    overflow-y: scroll;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'IBM Plex Mono', monospace;
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 24px 80px;
    line-height: 1.5;
}

.top-nav {
    width: 100%;
    max-width: 900px;
    margin: 0 auto 32px;
    padding: 0;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-top: 2px solid var(--red);
    border-radius: 4px;
    display: flex;
    align-items: stretch;
    overflow: hidden;
}

.top-nav a {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    color: var(--text-dim);
    background: transparent;
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-decoration: none;
    border-right: 1px solid var(--panel-border);
    transition:
    background 0.15s ease,
    color 0.15s ease;
}

.top-nav a:last-child {
    border-right: none;
}

.top-nav a::before {
    content: "▮";
    color: var(--red-dim);
    font-size: 0.55rem;
    margin-right: 8px;

    transition: color 0.15s ease;
}

.top-nav a:hover {
    background: var(--mono-bg);
    color: var(--text);
}

.top-nav a:hover::before {
    color: var(--red);
}

.top-nav a.active {
    background: var(--mono-bg);
    color: var(--red);
}

.top-nav a.active::before {
    color: var(--red);
}

.top-nav a.active::after {
    content: "";
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 0;
    height: 2px;
    background: var(--red);
    box-shadow: 0 0 8px var(--red-glow);
}

@media (max-width: 600px) {
    .top-nav {
        flex-direction: column;
    }
    .top-nav a {
        justify-content: flex-start;
        border-right: none;
        border-bottom: 1px solid var(--panel-border);
    }
    .top-nav a:last-child {
        border-bottom: none;
    }
    .top-nav a.active::after {
        left: 0;
        right: auto;
        top: 0;
        bottom: 0;
        width: 2px;
        height: auto;
    }
}

::selection {
    background: var(--red-glow);
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--mono-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--panel-border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--red-dim);
}

header.page-header {
    border-bottom: 2px solid var(--red);
    padding-bottom: 14px;
    margin-bottom: 36px;
}

header.page-header h1 {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: 2rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    margin: 0;
    color: var(--text);
}

header.page-header .eyebrow {
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-top: 4px;
}

header.page-header .eyebrow::before {
    content: "▮ ";
    color: var(--red);
}

.panel {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-left: 3px solid var(--red);
    border-radius: 4px;
    padding: 22px 26px;
    margin-bottom: 28px;
}

.panel-title {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--red);
    margin: 0 0 14px;
    display: block;
}

.panel-title::before {
    content: "▪ ";
}

.field-note {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin: 0 0 14px;
    line-height: 1.5;
}

textarea, input[type="text"], input[type="number"] {
    background: var(--mono-bg);
    border: 1px solid var(--panel-border);
    color: var(--text);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.9rem;
    padding: 10px 12px;
    border-radius: 3px;
    width: 100%;
    max-width: 100%;
}

textarea:focus, input:focus {
    outline: none;
    border-color: var(--red);
    box-shadow: 0 0 0 3px var(--red-glow);
}

textarea {
    resize: vertical;
}

.row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}

.row input[type="text"] {
    width: auto;
    flex: 1 1 180px;
}

.row input[type="number"] { 
    width: auto;
    flex: 0 1 160px;
}

button {
    background: transparent;
    border: 1.5px solid var(--red);
    color: var(--red);
    font-family: 'Rajdhani', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 10px 18px;
    border-radius: 3px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    margin: 4px 6px 4px 0;
}

button:hover {
    background: var(--red);
    color: var(--bg);
}

button:active {
    background: var(--red-dim);
    border-color: var(--red-dim);
}

button.subtle {
    border-color: var(--panel-border);
    color: var(--text-dim);
}

button.subtle:hover {
    background: var(--panel-border);
    color: var(--text);
}

.btn-row {
    margin-top: 10px;
}

.btn-row.full button {
    width: 100%;
    margin: 0 0 12px;
}

progress {
    width: 100%;
    height: 14px;
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid var(--panel-border);
    border-radius: 2px;
    background: var(--mono-bg);
    overflow: hidden;
}

progress::-webkit-progress-bar {
    background: var(--mono-bg);
}

progress::-webkit-progress-value {
    background: repeating-linear-gradient(
        90deg,
        var(--red) 0px,
        var(--red) 14px,
        var(--red-dim) 14px,
        var(--red-dim) 16px
    );
    transition: width 0.2s ease;
}

progress::-moz-progress-bar {
    background: repeating-linear-gradient(
        90deg,
        var(--red) 0px,
        var(--red) 14px,
        var(--red-dim) 14px,
        var(--red-dim) 16px
    );
}

label {
    display: block;
}

pre#output {
    background: var(--mono-bg);
    border: 1px solid var(--panel-border);
    border-left: 3px solid var(--red-dim);
    border-radius: 3px;
    padding: 16px;
    margin-top: 16px;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.82rem;
    color: var(--text);
    max-height: 340px;
    overflow-y: auto;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    background: var(--mono-bg);
    border: 1px solid var(--panel-border);
    padding: 16px;
    border-radius: 4px;
    margin-bottom: 14px;
}

.grid-item {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 6px;
    border-radius: 3px;
    transition: background 0.15s ease;
}

.grid-item:hover {
    background: var(--panel);
}

.grid-item input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--bg);
    border: 1px solid var(--panel-border);
    border-radius: 2px;
    cursor: pointer;
    position: relative;
    display: grid;
    place-content: center;
    margin: 0;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.grid-item input[type="checkbox"]:hover {
    border-color: var(--red-dim);
}

.grid-item input[type="checkbox"]:focus {
    outline: none;
    border-color: var(--red);
    box-shadow: 0 0 0 3px var(--red-glow);
}

.grid-item input[type="checkbox"]:checked {
    border-color: var(--red);
    background: var(--red-dim);
    box-shadow: 0 0 8px var(--red-glow);
}

.grid-item input[type="checkbox"]::before {
    content: "";
    width: 8px;
    height: 8px;
    background: var(--text);
    transform: scale(0);
    transition: transform 0.1s ease-in-out;
}

.grid-item input[type="checkbox"]:checked::before {
    transform: scale(1);
}

.grid-item label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.9rem;
    color: var(--text-dim);
    cursor: pointer;
    user-select: none;
    transition: color 0.15s ease;
}

.grid-item input[type="checkbox"]:checked ~ label,

.grid-item:hover label {
    color: var(--text);
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--mono-bg);
    border: 1px solid var();
    border-left: 3px solid var(--red-dim);
    border-radius: 4px;
    overflow: hidden;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85rem;
}

.stats-table thead {
    background: var(--panel);
}

.stats-table th {
    color: var(--red);
    font-family: 'Rajdhani', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 10px 12px;
    border-bottom: 1px solid var(--panel-border);
    text-align: left;
}

.stats-table td {
    color: var(--text);
    padding: 9px 12px;
    border-bottom: 1px solid var(--panel-border);
}

.stats-table tbody tr:last-child td {
    border-bottom: none;
}

.stats-table tbody tr:hover {
    background: var(--panel);
}

.stats-table td:nth-child(2) {
    color: var(--red);
    text-align: right;
    font-weight: bold;
}

.stats-panel {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-left: 3px solid var(--red);
    border-radius: 4px;
    padding: 22px 26px;
    margin-bottom: 28px;
}

.stats-panel-title {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--red);
    margin-bottom: 14px;
}

.stats-panel-title::before {
    content: "▪ ";
}

.prize-condition-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    background: var(--mono-bg);
    border: 1px solid var(--panel-border);
    padding: 16px;
    border-radius: 4px;
}

.prize-stat {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.prize-label {
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-dim);
}

.prize-value {
    color: var(--red);
    font-size: 1.1rem;
    font-weight: bold;
}

@media (max-width: 600px) {
    .prize-condition-grid {
        grid-template-columns: 1fr;
    }
}

.prize-condition-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.prize-condition-row input {
    flex: 1;
}

.prize-condition-row select {
    background: var(--mono-bg);
    border: 1px solid var(--panel-border);
    color: var(--text);
    font-family: 'IBM Plex Mono', monospace;
    padding: 10px;
    border-radius: 3px;
}

.prize-condition-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.prize-condition-card {
    flex: 1;
    min-width: 180px;
    background: var(--mono-bg) !important;
    color: var(--text) !important;
}

.prize-condition-type {
    width: 160px;
    background: var(--mono-bg);
    border: 1px solid var(--panel-border);
    color: var(--text);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.9rem;
    padding: 10px 12px;
    border-radius: 3px;
}

.prize-condition-type:focus {
    outline: none;
    border-color: var(--red);
    box-shadow: 0 0 0 3px var(--red-glow);
}

.prize-condition-amount {
    width: 70px;
    text-align: center;
}

.prize-condition-type {
    appearance: none;
    -webkit-appearance: none;
    width: 170px;
    background: var(--mono-bg);
    border: 1px solid var(--panel-border);
    color: var(--text);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.9rem;
    padding: 10px 36px 10px 12px;
    border-radius: 3px;
    cursor: pointer;
    background-image:
    linear-gradient(
        45deg,
        transparent 50%,
        var(--text) 50%
        ),
    linear-gradient(
        135deg,
        var(--text) 50%,
        transparent 50%
    );
    background-position:
    calc(100% - 18px) calc(50% - 2px),
    calc(100% - 12px) calc(50% - 2px);
    background-size: 6px 6px;
    background-repeat: no-repeat;
}

.prize-condition-type:hover {
    border-color: var(--red-dim);
}

.prize-condition-type:focus {
    outline: none;
    border-color: var(--red);
    box-shadow: 0 0 0 3px var(--red-glow);
}

.condition-group {
    border: 1px solid var(--panel-border);
    border-left: 3px solid var(--red-dim);
    border-radius: 4px;
    padding: 12px;
    margin-bottom: 10px;
    background: var(--mono-bg);
}

.condition-group .condition-group {
    margin-top: 10px;
    margin-bottom: 0;
    background: var(--panel);
}

.condition-group-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.condition-group-header .condition-operator {
    width: auto;
    min-width: 190px;
}

.condition-group-children {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-left: 14px;
    border-left: 2px dashed var(--panel-border);
}

.condition-leaf-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.condition-leaf-row .condition-comparator,
.condition-leaf-row .condition-amount-type {
    width: auto;
    min-width: 130px;
}

.condition-leaf-row .condition-amount-value {
    width: 70px;
    flex: 0 0 70px;
}

.condition-leaf-row .condition-amount-cardref,
.condition-leaf-row .condition-card-name {
    flex: 1 1 180px;
    min-width: 150px;
}

.condition-progress-note {
    color: var(--red);
}

.equation-block {
    border: 1px solid var(--panel-border);
    border-left: 3px solid var(--red-dim);
    border-radius: 4px;
    padding: 10px;
    margin-bottom: 8px;
    background: var(--mono-bg);
}

.equation-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.expr-editor {
    display: inline-block;
    vertical-align: top;
    border: 1px dashed var(--panel-border);
    border-radius: 4px;
    padding: 8px;
    margin: 4px 0;
}

.expr-terms {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.term-editor {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    border: 1px solid var(--panel-border);
    border-radius: 4px;
    background: var(--panel);
}

.term-factor {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.value-slot {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.value-slot-slot {
    display: inline-block;
}

.value-slot .value-type,
.term-operator,
.term-join-operator,
.equation-comparator {
    width: auto;
    min-width: 100px;
}

.value-slot .value-number-input,
.value-slot .value-card-input {
    width: 130px;
}

.value-expr-wrap {
    display: block;
    margin-top: 6px;
    margin-left: 12px;
}

.panel-content div {
    width: 100%;
    max-width: 100%;
}

.panel-content video {
    width: 100%;
    height: auto;
    max-height: 100%;
    display: block;
}

.panel-content img {
    width: 100%;
    height: auto;
    max-height: 100%;
    display: block;
}

.toggle-arrow {
    color: red;
}

.panel-content {
    margin-top: 15px;
}

.footer-line {
    border: none;
    border-top: 1px solid #f2ece4;
    margin: 16px 0;
}

.hand-scope-select {
    width: auto;
    min-width: 170px;
    font-size: 0.8rem;
    color: var(--text-dim);
    border-style: dashed;
}

.hand-scope-select:hover,
.hand-scope-select:focus {
    color: var(--text);
}

.hand-scope-select.is-opening {
    color: var(--red);
    border-color: var(--red-dim);
    border-style: solid;
}

.value-slot .hand-scope-select {
    min-width: 150px;
}

@media (max-width: 600px) {
    .hand-scope-select {
        min-width: 0;
        flex: 1 1 100%;
    }
}

.not-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: auto;
    padding: 6px 10px;
    background: var(--mono-bg);
    border: 1px solid var(--panel-border);
    border-radius: 3px;
    cursor: pointer;
    user-select: none;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.not-toggle:hover {
    border-color: var(--red-dim);
}

.not-toggle span {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-dim);
    transition: color 0.15s ease;
}

.not-toggle input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    margin: 0;
    background: var(--bg);
    border: 1px solid var(--panel-border);
    border-radius: 2px;
    cursor: pointer;
    display: grid;
    place-content: center;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.not-toggle input[type="checkbox"]:focus {
    outline: none;
    border-color: var(--red);
    box-shadow: 0 0 0 3px var(--red-glow);
}

.not-toggle input[type="checkbox"]::before {
    content: "";
    width: 8px;
    height: 8px;
    background: var(--text);
    transform: scale(0);
    transition: transform 0.1s ease-in-out;
}

.not-toggle input[type="checkbox"]:checked {
    border-color: var(--red);
    background: var(--red-dim);
    box-shadow: 0 0 8px var(--red-glow);
}

.not-toggle input[type="checkbox"]:checked::before {
    transform: scale(1);
}

.not-toggle:has(input:checked) { border-color: var(--red); }
.not-toggle:has(input:checked) span { color: var(--red); }

.condition-group.is-negated,
.equation-block.is-negated {
    border-left-color: var(--red);
}

.condition-leaf-row.is-negated {
    padding-left: 8px;
    border-left: 2px solid var(--red);
}

.tutorial-clip {
    display: block;
    width: 100%;
    max-width: 800px;
    max-height: 80vh;
    height: auto;
    background: #000;
    border-radius: 6px;
}

#ptcgInfoBanner[hidden] {
    display: none;
}

#ptcgInfoBanner {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 1000;
    padding: 0 12px calc(12px + env(safe-area-inset-bottom, 0px));
    pointer-events: none;
}

#ptcgInfoBanner .info-inner {
    pointer-events: auto;
    max-width: 900px;
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-top: 2px solid var(--red);
    border-radius: 4px;
    box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.55);
    font-size: 0.8rem;
}

#ptcgInfoBanner p {
    margin: 0;
    flex: 1;
    color: var(--text-dim);
}

#ptcgInfoBanner b {
    color: var(--text);
    font-weight: 600;
}

#ptcgInfoBanner button {
    margin: 0;
    white-space: nowrap;
}

table {
  width: 100%;
  border-collapse: collapse;
}

table.show-line th, 
table.show-line td {
  border: 1px solid #ddd;
  padding: 8px;
  text-align: left;
  color: var(--text-dim);
}

table.show-line th {
  font-weight: bold;
}

