html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    /* Full-screen game shell: no page scroll/rubber-band behind the fixed .rh-root, so the arena
       never reflows and the canvas keeps a constant size (matches the JS viewer's locked body). */
    height: 100%;
    margin: 0;
    overflow: hidden;
    overscroll-behavior: none;
}

h1:focus {
    outline: none;
}

a, .btn-link {
    color: #0071c1;
}

.btn-primary {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.content {
    padding-top: 1.1rem;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBh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I5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto 0 auto;
}

    .loading-progress circle {
        fill: none;
        stroke: #e0e0e0;
        stroke-width: 0.6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: #1b6ec2;
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Loading");
    }

code {
    color: #c02d76;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}
/* ==================== Roundhouse .NET viewer ====================
   Ported from viewer/index.html so the .NET page reads identically to the JS one.
   Scoped under .rh-root so it never fights the Blazor/bootstrap shell. */
.rh-root {
  position: fixed; inset: 0; z-index: 100;
  background: #0c0f13; color: #cdd6e0;
  font: 13px/1.4 -apple-system, system-ui, "Segoe UI", monospace;
  overflow: hidden; display: flex; flex-direction: column;
  -webkit-user-select: none; user-select: none; touch-action: manipulation;
}
.rh-root * { box-sizing: border-box; }
.rh-root h1 { font-size: 20px; margin: 0 0 2px; color: #7fb4ff; text-align: center; }
.rh-root h2 { font-size: 11px; margin: 0 0 6px; color: #8a94a3; text-transform: uppercase; letter-spacing: 1px; }
.rh-root a { color: #7fb4ff; text-decoration: none; }
.rh-root button {
  font: inherit; padding: 10px 14px; min-height: 44px;
  background: #23303f; border: 1px solid #33465c; color: #cdd6e0;
  border-radius: 6px; cursor: pointer;
}
.rh-root button:hover:not(:disabled) { background: #2c3d51; }
.rh-root button:disabled { opacity: 0.4; cursor: default; }
.rh-root button.primary { background: #2b6cb0; border-color: #3b82c4; color: #fff; font-weight: bold; }
.rh-root button.primary:hover:not(:disabled) { background: #3178bd; }
.rh-root button.link { background: none; border: none; color: #7fb4ff; min-height: auto; padding: 6px 2px; }
.rh-root input[type=text], .rh-root input[type=number], .rh-root select {
  font: inherit; width: 100%; padding: 10px;
  background: #1b212a; border: 1px solid #2c343f; color: #cdd6e0; border-radius: 6px;
}

.rh-root .game-status {
  flex: 1 1 0; min-width: 0; font-size: 11px; color: #9aa6b4;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rh-root .lobby-hint { font-size: 11px; color: #8a94a3; text-align: center; min-height: 14px; }
.rh-root .screen { flex: 1 1 auto; min-height: 0; }
.rh-root .screen:not(.active) { display: none; }

/* ---------- LOBBY ---------- */
/* margin:auto on the card (below), NOT align-items/justify-content:center on the container: once the
   card grows taller than the viewport — e.g. Match settings expanded — container-centering parks its
   top above the scroll origin where overflow-y:auto can't reach it, cropping the heading (#236). The
   viewport-locked .rh-root hides this at desktop sizes but not at short ones; margin:auto keeps an
   overflowing card scrollable to its top, matching #historyScreen and the JS viewer. */
.rh-root #lobbyScreen { display: flex; padding: 16px; overflow-y: auto; }
.rh-root #lobbyScreen:not(.active) { display: none; }
.rh-root #lobbyScreen .lobby-card { margin: auto; }
.rh-root .lobby-card { width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: 12px; }
.rh-root .btn-row { display: flex; gap: 8px; }
.rh-root .btn-row > button { flex: 1; }
.rh-root #playerLine { font-size: 11px; color: #9aa6b4; text-align: center; }
.rh-root #opponentInfo, .rh-root #lobbyState { font-size: 12px; color: #9aa6b4; text-align: center; min-height: 16px; }
.rh-root #readyBtn { width: 100%; }
.rh-root details.settings { background: #12161c; border: 1px solid #232a33; border-radius: 8px; padding: 10px 12px; }
.rh-root details.settings summary { cursor: pointer; color: #8a94a3; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }
.rh-root details.settings label { display: block; margin: 12px 0 4px; font-size: 12px; color: #9aa6b4; }
.rh-root #deckSection { background: #12161c; border: 1px solid #232a33; border-radius: 8px; padding: 10px 12px; }
.rh-root .deck-head { display: flex; justify-content: space-between; align-items: center; }
.rh-root .deck-head h2 { margin: 0; }
.rh-root #deckGrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 8px 0 4px; }
.rh-root .deck-slot { min-height: 46px; padding: 6px 2px; font-size: 11px; white-space: pre-line; text-align: center; line-height: 1.25; }
.rh-root .lobby-foot { display: flex; justify-content: space-between; align-items: center; font-size: 12px; }
.rh-root #engineVersion { font-size: 10px; color: #5b6472; text-align: center; word-break: break-all; }

/* ---------- MATCH HISTORY ---------- */
.rh-root #historyScreen { display: flex; padding: 16px; overflow-y: auto; }
.rh-root #historyScreen:not(.active) { display: none; }
/* margin:auto, not container centering: an overflowing card stays scrollable to its top */
.rh-root #historyScreen .lobby-card { margin: auto; }
.rh-root .replay-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 12px; border-bottom: 1px solid #1b2129; }
.rh-root .replay-info { flex: 1 1 auto; color: #c9d1d9; }
.rh-root .replay-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.rh-root .history-pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; font-size: 12px; color: #9aa6b4; }
.rh-root .history-pager button[disabled] { opacity: 0.35; cursor: default; }

/* ---------- GAME ---------- */
.rh-root #gameScreen { position: relative; flex-direction: column; }
.rh-root #gameScreen.active { display: flex; }
.rh-root #rh-arena-canvas { flex: 1 1 auto; width: 100%; min-height: 0; display: block; background: #0c0f13; cursor: crosshair; touch-action: none; }
/* Message bar (visualization.md § 10) — band 1 of the three-band game screen. Every chrome
   text surface lives here so none is ever drawn over the arena. Its height is CONSTANT:
   a message must not resize the field under the player's finger mid-drop. */
.rh-root #messageBar {
  flex: 0 0 auto; height: 34px; display: flex; align-items: center; gap: 6px;
  padding: 0 6px; background: #12161c; border-bottom: 1px solid #232a33; overflow: hidden;
}
.rh-root #replayBar { flex: 2 1 0; min-width: 0; display: flex; align-items: center; gap: 6px; }
.rh-root #replayInfo {
  flex: 1 1 0; min-width: 0; font-size: 11px; color: #c9d3de;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rh-root .bar-btn {
  flex: 0 0 auto; min-height: 0; height: 24px; padding: 0 8px;
  font-size: 11px; border-radius: 5px;
}
.rh-root #overlayBtn.icon-btn {
  flex: 0 0 auto; min-height: 0; width: 26px; height: 26px; padding: 0;
  font-size: 15px; line-height: 1; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.rh-root #overlayPanel {
  position: absolute; top: 40px; right: 8px; width: 214px; max-height: 78%; overflow-y: auto;
  background: rgba(18, 22, 28, 0.96); border: 1px solid #2c343f; border-radius: 8px;
  padding: 12px; z-index: 6;
}
.rh-root #overlayPanel:not(.open) { display: none; }
/* demo-scope.md 3.2a's second rule, shared with the Node viewer (rules.md 8, 16): a control
   that ends the match is separated from the option toggles by at least one empty row, and the
   row is the target rather than the ~13px browser-default box (#501, #503). */
.rh-root #overlayPanel label {
  display: flex; align-items: center; gap: 8px;
  min-height: 44px; margin: 4px 0; font-size: 12px; cursor: pointer;
}
.rh-root #overlayPanel label input[type="checkbox"] { width: 20px; height: 20px; flex: none; }
.rh-root #overlayPanel #surrenderBtn { width: 100%; margin-top: 44px; }
.rh-root button.danger { background: #7d2b2b; border-color: #a83a3a; color: #fff; }
.rh-root button.danger:hover:not(:disabled) { background: #8f3232; }

.rh-root #countdown { position: absolute; inset: 0; z-index: 8; display: none; align-items: center; justify-content: center; pointer-events: none; }
.rh-root #countdown.show { display: flex; }
.rh-root .cd-num {
  font-size: 130px; font-weight: 800; color: #fff;
  text-shadow: 0 0 40px rgba(127,180,255,0.85), 0 4px 12px rgba(0,0,0,0.6);
  animation: rh-cdpop 0.9s cubic-bezier(.2,.8,.2,1) both;
}
.rh-root .cd-num.start { font-size: 92px; color: #7feca0; text-shadow: 0 0 40px rgba(90,220,140,0.9), 0 4px 12px rgba(0,0,0,0.6); }
@keyframes rh-cdpop {
  0%   { transform: scale(2.4); opacity: 0; }
  25%  { opacity: 1; }
  80%  { transform: scale(1); opacity: 1; }
  100% { transform: scale(1); opacity: 0.9; }
}

.rh-root .debug-hud { flex: 0 0 auto; font: 11px/1.4 monospace; color: #9aa6b4; white-space: nowrap; }
.rh-root #hud { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 8px; background: #12161c; border-top: 1px solid #232a33; }
.rh-root #elixirWrap { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; }
.rh-root #elixir { width: 64px; height: 12px; background: #2a1440; border: 1px solid #52306e; border-radius: 3px; position: relative; overflow: hidden; }
.rh-root #elixirFill { height: 100%; width: 0; background: linear-gradient(90deg,#b24bd8,#e05bff); transition: width .15s; }
.rh-root #elixirText { font-size: 11px; white-space: nowrap; }
.rh-root #handBar { display: flex; gap: 6px; flex: 1 1 auto; opacity: 0.5; }
.rh-root .card { flex: 1 1 0; min-width: 0; min-height: 46px; padding: 6px 2px; white-space: pre-line; text-align: center; font-size: 11px; }
.rh-root .card.armed { background: #4a5d20; border-color: #8bc34a; }
.rh-root .card.next { flex: 0 0 auto; width: 52px; opacity: 0.5; border-left: 2px solid #33465c; margin-left: 2px; }

.rh-root #recovery { display: none; position: absolute; inset: 0; z-index: 11; align-items: center; justify-content: center; background: rgba(0,0,0,0.82); }
.rh-root #recovery.show { display: flex; }
.rh-root .recovery-inner { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 24px; max-width: 420px; }
.rh-root #recoveryText { font-size: 20px; color: #fff; text-align: center; line-height: 1.4; }
.rh-root #recovery button { min-width: 200px; }
.rh-root #result { display: none; position: absolute; inset: 0; z-index: 10; align-items: center; justify-content: center; background: rgba(0,0,0,0.72); }
.rh-root #result.show { display: flex; }
.rh-root .result-inner { display: flex; flex-direction: column; align-items: center; gap: 22px; padding: 24px; }
.rh-root #resultText { font-size: 40px; font-weight: bold; color: #fff; text-align: center; }
.rh-root #backToLobbyBtn { min-width: 200px; }
.rh-root .rh-err { color: #f85149; }

@media (min-width: 760px) {
  .rh-root #resultText { font-size: 52px; }
  .rh-root #gameScreen.active {
    width: 100%; max-width: 520px; margin: 0 auto;
    border-left: 1px solid #232a33; border-right: 1px solid #232a33;
  }
}
