/* One dark neon identity for the home, Luogo segreto and the role page (Chi sono? already has it).
   Loaded last: it recolours surfaces and text, it does not change layout. */

:root {
    --th-bg: #0b0f1e;
    --th-bg-glow: #1d2550;
    --th-surface: #151b31;
    --th-surface-2: #1d2547;
    --th-field: #0f1428;
    --th-line: #34407a;
    --th-text: #e9ecf8;
    --th-muted: #b9c1e0;
    --th-accent: #22d3ee;
    --th-on-accent: #04121a;
    --th-focus: #ffd700;
    --th-accent-hover: #67e8f9;
    --th-danger: #ff9b8f;
    --th-placeholder: #8f99c4;
}

body {
    background: radial-gradient(circle at 20% 0%, var(--th-bg-glow) 0%, var(--th-bg) 60%) fixed;
    background-color: var(--th-bg);
    color: var(--th-text);
}

/* Surfaces that were grey-green or white. */
:is(.modal-content, .email-modal-content, .alert-modal-content, .reveal-panel, .luogo-card,
    .resume-banner, .persist-notice, .role-message, .role-message-panel, .setup-submit) {
    background: var(--th-surface);
    color: var(--th-text);
    border: 1px solid var(--th-line);
}

.setup-submit {
    border-width: 1px 0 0;
}

.role-message-panel .role-message {
    border: 0;
}

/* Cards inside the surfaces. */
:is(.role-card, .story-content, .role-guide-card, .role-guide-card:hover, .vote-option, .vote-option:hover,
    .glitch-rules-box, .glitch-game-order-box, .glitch-voting-box, #glitchPlayOrderList ol, .narrator-guide,
    .narrator-step, .narrator-next, .narrator-card, .game-tracker, .composition-roles li, .words-summary) {
    background: var(--th-surface-2);
    color: var(--th-text);
    border-color: var(--th-line);
}

/* Text inside dark surfaces follows the surface; the old dark-on-light colours would vanish. */
:is(.modal-content, .email-modal-content, .alert-modal-content, .reveal-panel, .luogo-card, .resume-banner,
    .persist-notice, .role-message-panel)
    :is(h1, h2, h3, h4, p, li, label, legend, summary, strong, em, small, td, th, .role-name, .role-description,
        .reveal-hint, .reveal-progress, .field-hint, .roster-count, .roster-remembered, .click-to-hide) {
    color: inherit;
}

:is(.role-description, .reveal-hint, .reveal-progress, .field-hint, .roster-count, .roster-remembered,
    .click-to-hide, .composition-lead, .glitch-words-chosen) {
    color: var(--th-muted);
}

#glitchPlayOrderList li {
    border-color: var(--th-line);
}

/* Fields. */
:is(.modal-content, .email-modal-content, .luogo-card) :is(input[type="text"], input[type="number"],
    input[type="email"], select, textarea) {
    background: var(--th-field);
    color: var(--th-text);
    border-color: var(--th-line);
}

:is(.modal-content, .email-modal-content, .luogo-card) ::placeholder {
    color: var(--th-placeholder);
    opacity: 1;
}

.choice-seg {
    border-color: var(--th-line);
}

.choice-seg label {
    background: var(--th-field);
    color: var(--th-text);
}

/* S2: one filled primary action; everything else is outlined. */
:is(.btn-primary, .reveal-next, .home-start-link, .game-card-play) {
    background: var(--th-accent);
    color: var(--th-on-accent);
    border: 0;
    font-weight: 700;
}

.choice-seg label:has(input:checked),
.luogo-quick-pick[aria-pressed="true"],
.players-filter button[aria-pressed="true"],
.glitch-steps li[aria-current="step"] {
    background: var(--th-accent);
    color: var(--th-on-accent);
}

:is(.btn-secondary, .btn-close, .btn-add-player, .luogo-quick-pick, .roster-row .btn-remove-player, .invite-button) {
    background: transparent;
    color: var(--th-text);
    border: 2px solid currentColor;
}

.roster-row .btn-remove-player {
    color: var(--th-danger);
}

.roster-row .btn-remove-player:hover:not(:disabled) {
    background: var(--th-danger);
    color: var(--th-on-accent);
}

.reveal-next:disabled,
.btn-primary:disabled {
    background: transparent;
    color: var(--th-muted);
    border: 2px dashed var(--th-line);
    cursor: not-allowed;
}

.glitch-steps li {
    background: var(--th-surface-2);
    color: var(--th-muted);
}

.glitch-first-tag {
    background: var(--th-accent);
    color: var(--th-on-accent);
}

/* Links and link-like buttons. */
:is(.howto-button.howto-link, .roster-clear, .narrator-next-actions .btn-link, .role-more summary, .glitch-words-change) {
    color: var(--th-accent);
}

.close {
    color: var(--th-muted);
}

/* Headings that had their own light-theme colour. */
#resultsModal h2 {
    color: var(--th-text);
}

/* Focus stays visible on the dark surfaces. */
:is(.modal-content, .reveal-panel, .luogo-card, .role-message-panel) :is(button, a, input, select, summary, [tabindex]):focus-visible {
    outline: 3px solid var(--th-focus);
    outline-offset: 2px;
}

.role-home-link {
    background: var(--th-accent);
    color: var(--th-on-accent);
}

.site-footer {
    background: transparent;
}

/* Hover and active keep the theme: the light-theme hover rules in style.css would otherwise
   paint the primary dark grey under its dark label. */
:is(.btn-primary, .reveal-next, .home-start-link, .game-card-play):is(:hover, :active):not(:disabled) {
    background: var(--th-accent-hover);
    color: var(--th-on-accent);
}

:is(.btn-secondary, .btn-close, .btn-add-player, .luogo-quick-pick, .invite-button):is(:hover, :active):not([aria-pressed="true"]) {
    background: var(--th-surface-2);
    color: var(--th-text);
}

/* Close buttons: the light-theme hover painted the × black on the dark surface. */
.close:is(:hover, :focus-visible) {
    color: var(--th-text);
}

.qr-close {
    color: var(--th-text);
}

/* The story button is a secondary action like the others (its gold fill read as a second primary). */
.btn-story {
    background: transparent;
    color: var(--th-text);
    border: 2px solid currentColor;
}

/* Victory: dark surface with a gold frame and title, so every button keeps its contrast. */
.victory-content {
    background: var(--th-surface);
    color: var(--th-text);
    border-color: var(--th-focus);
}

.victory-content :is(h2, strong) {
    color: var(--th-focus);
}

.victory-content p {
    color: var(--th-text);
}

/* Errors keep their colour on the dark surface (the broad inherit rule would make them plain text). */
:is(.modal-content, .luogo-card) .field-error,
.packs-errors {
    color: var(--th-danger);
}

/* Word packs modal (Glitch Mind). */
.packs-modal .modal-content {
    color: var(--th-text);
}

.packs-btn {
    background: transparent;
    color: var(--th-text);
    border-color: currentColor;
}

.packs-btn:hover {
    background: var(--th-surface-2);
}

.packs-danger {
    color: var(--th-danger);
}

.packs-primary {
    background: var(--th-accent);
    color: var(--th-on-accent);
    border-color: var(--th-accent);
}

.packs-primary:hover {
    background: var(--th-accent-hover);
}

:is(.packs-item, .packs-row) {
    border-color: var(--th-line);
}

/* Glitch guess: the box with name, role and word. */
.glitch-reveal-info {
    background: var(--th-surface-2);
    color: var(--th-text);
}

/* Save notices: their action button was dark on the dark surface. */
.persist-notice button {
    color: var(--th-text);
    border-color: currentColor;
}

.persist-notice button:hover {
    background: var(--th-surface-2);
}

/* Install banner: on the theme surface instead of the old blue-violet gradient. */
.install-banner-content {
    background: var(--th-surface);
    color: var(--th-text);
    border: 1px solid var(--th-line);
}

.btn-install {
    background: var(--th-accent);
    color: var(--th-on-accent);
}

.btn-install:hover {
    background: var(--th-accent-hover);
    color: var(--th-on-accent);
}

.btn-dismiss {
    background: transparent;
    color: var(--th-text);
    border-color: currentColor;
}

.btn-dismiss:hover {
    background: var(--th-surface-2);
}

/* NeonDM modals declare their light surface with !important: only !important can put them on the theme.
   Without it the theme's light text sat on that light surface. */
.neondm-modal-content {
    background: var(--th-surface) !important;
    color: var(--th-text);
}

/* Destructive actions in NeonDM: outlined like the other secondaries, in the danger colour. */
.btn-secondary.btn-danger {
    color: var(--th-danger);
}

.btn-secondary.btn-danger:is(:hover, :active) {
    background: var(--th-danger);
    color: var(--th-on-accent);
}

/* The confirm button of a destructive NeonDM dialog: the filled primary, in the danger colour. */
.btn-primary.btn-danger-fill:not(:disabled),
.btn-primary.btn-danger-fill:is(:hover, :active):not(:disabled) {
    background: var(--th-danger);
    color: var(--th-on-accent);
}

/* Inventory credits: the buttons sit on a gold panel, where the theme's light text would vanish. */
.neondm-credits .btn-secondary,
.neondm-credits .btn-secondary:is(:hover, :active) {
    color: var(--th-on-accent);
}

.neondm-credits .btn-secondary:is(:hover, :active) {
    background: rgb(4 18 26 / 15%);
}

/* Net Grid "Cambia modalità": magenta text on its own 20% magenta fill measured 4.4:1, below 4.5. */
.netgrid-back-btn {
    color: var(--th-text);
}
