/* "This or that" (duel.js): a quick tournament between new anime. The way in sits in Tonight's mode tabs;
   the tournament is a dialog: side by side on wide screens, two stacked halves on a phone. Ink and paper,
   the 比 (kurabe, compare) seal, 選 when a card is picked and 優勝 for the champion. */

/* ---------- The way in: a third tab after "New picks | From my shelf" ---------- */
.deck-modes .tot-entry { display: inline-flex; align-items: center; justify-content: center; gap: 8px; color: var(--paper); }
.tot-entry-mark { flex: none; color: var(--red); font: 400 17px/1 "Yu Mincho", "MS Mincho", serif; letter-spacing: 0; transition: transform .2s; }
.deck-modes .tot-entry:hover { color: var(--paper); background: rgba(239, 75, 63, .12); }
.deck-modes .tot-entry:hover .tot-entry-mark { transform: rotate(-8deg); }

/* ---------- The dialog ---------- */
html.tot-open { overflow: hidden; }
.tot-dialog { width: min(1060px, calc(100% - 32px)); max-width: none; max-height: calc(100dvh - 32px); margin: auto; padding: 0; border: 0; color: var(--paper); background: transparent; overflow: visible; }
.tot-dialog::backdrop { background: rgba(10, 10, 11, .9); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.tot-shell { position: relative; box-sizing: border-box; display: flex; flex-direction: column; max-height: calc(100dvh - 32px); overflow: auto; overscroll-behavior: contain; padding: 16px clamp(18px, 3.4vw, 40px) 26px; border: 1px solid #3b3935; background: var(--night); box-shadow: 14px 14px 0 #050505; }
.tot-head { position: relative; z-index: 2; display: flex; align-items: center; gap: 12px; min-height: 44px; }
.tot-kicker { display: flex; flex: 1; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-width: 0; margin: 0; color: var(--red); font: 800 12px/1.3 Arial, sans-serif; letter-spacing: .2em; text-transform: uppercase; }
.tot-mark { flex: none; display: grid; place-items: center; width: 34px; height: 34px; color: var(--paper); background: var(--red); font: 400 20px/1 "Yu Mincho", "MS Mincho", serif; letter-spacing: 0; }
.tot-round { color: #bdb9ae; }
.tot-round-dot { margin-right: 10px; color: #6a675f; }
.tot-round-kanji { margin-left: 4px; color: var(--red); font: 400 15px/1 "Yu Mincho", "MS Mincho", serif; letter-spacing: .05em; }
.tot-close { flex: none; width: 44px; height: 44px; padding: 0; border: 1px solid #3b3935; color: var(--paper); background: transparent; font: 400 28px/1 Georgia, serif; cursor: pointer; }
.tot-close:hover, .tot-close:focus-visible { border-color: var(--red); color: var(--red); outline: none; }
.tot-body { position: relative; z-index: 1; display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; }
.tot-step { min-width: 0; }
.tot-petals { position: absolute; inset: 0; z-index: 4; overflow: hidden; pointer-events: none; }
.tot-petals i { position: absolute; top: 0; left: 0; border-radius: 1px 7px; }

/* Loading, and the endings without a champion */
.tot-loading { display: grid; place-items: center; align-content: center; gap: 14px; min-height: 360px; text-align: center; }
.tot-loading-mark { display: grid; place-items: center; width: 74px; height: 74px; border-radius: 50%; color: var(--paper); background: var(--red); font: 400 36px/1 "Yu Mincho", "MS Mincho", serif; animation: tot-breathe 1.6s ease-in-out infinite; }
.tot-loading p { margin: 0; color: #bdb9ae; font: italic 17px/1.5 Georgia, serif; }
@keyframes tot-breathe { 50% { transform: scale(.92); opacity: .75; } }
.tot-empty { display: grid; justify-items: start; gap: 12px; max-width: 620px; padding: 34px 0 10px; }
.tot-empty-mark { display: grid; place-items: center; width: 64px; height: 64px; border: 2px solid var(--red); color: var(--red); font: 400 34px/1 "Yu Mincho", "MS Mincho", serif; transform: rotate(-6deg); }
.tot-empty h2 { margin: 6px 0 0; font: 400 clamp(32px, 5vw, 48px)/1.02 Georgia, serif; letter-spacing: -.04em; }
.tot-empty p { margin: 0; color: #bdb9ae; font: italic 17px/1.55 Georgia, serif; }
.tot-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.tot-row > button { min-height: 50px; padding: 0 22px; }
/* On night the ink-filled .primary would vanish: the way forward is red, like Play again (the deeper red keeps
   paper words above 4.5:1). */
.tot-row > .primary { background: var(--decision-tonight-fill, #c0392b); }
.tot-row > .primary:hover { color: var(--ink); background: var(--paper); }
.tot-plain { border: 1px solid #6a675f; color: var(--paper); background: transparent; font: 800 12px/1.2 Arial, sans-serif; letter-spacing: .1em; text-transform: uppercase; cursor: pointer; }
.tot-plain:hover { border-color: var(--red); color: var(--red); }

/* ---------- One duel ---------- */
.tot-duel { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; }
.tot-progress { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-top: 12px; }
.tot-pips { display: flex; flex-wrap: wrap; gap: 5px; margin: 0; padding: 0; list-style: none; }
.tot-pips li { width: 22px; height: 6px; background: #3b3935; }
.tot-pips li.done { background: var(--paper); }
.tot-pips li.now { background: var(--red); }
.tot-count { margin: 0; color: #bdb9ae; font: italic 15px/1.2 Georgia, serif; }
.tot-question { margin: 12px 0 0; font: 400 clamp(28px, 3.6vw, 42px)/1.04 Georgia, serif; letter-spacing: -.035em; overflow-wrap: anywhere; }
.tot-pair { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 40px; margin-top: 22px; }
.tot-vs { position: absolute; top: 38%; left: 50%; z-index: 3; display: grid; place-items: center; width: 58px; height: 58px; margin: -29px 0 0 -29px; border-radius: 50%; color: var(--paper); background: var(--red); font: 400 28px/1 "Yu Mincho", "MS Mincho", serif; box-shadow: 0 0 0 7px var(--night); pointer-events: none; }
.tot-slot { position: relative; display: flex; min-width: 0; }
.tot-slot.is-out { opacity: .35; }
.tot-card { position: relative; display: flex; flex: 1; flex-direction: column; min-width: 0; margin: 0; padding: 0; border: 0; color: var(--ink); background: var(--paper); box-shadow: 9px 9px 0 #050505; text-align: left; font: inherit; cursor: pointer; overflow: hidden; touch-action: manipulation; -webkit-tap-highlight-color: transparent; transition: box-shadow .15s; }
.tot-card:hover { box-shadow: 9px 9px 0 var(--red); }
.tot-card:focus-visible { outline: 3px solid var(--red); outline-offset: 4px; }
.tot-cover { position: relative; display: grid; place-items: center; flex: none; aspect-ratio: 5 / 4; overflow: hidden; background: var(--tot-tint, #cbc3ae); }
.tot-cover img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: 50% 24%; pointer-events: none; }
.tot-cover i, .tot-sheet > i { color: rgba(18, 18, 18, .35); font: normal 400 48px/1 "Yu Mincho", "MS Mincho", serif; }
.tot-caption { display: flex; flex: 1; flex-direction: column; align-items: flex-start; gap: 7px; min-width: 0; padding: 16px 18px 20px; }
/* The paper's red (decision.css on-paper Tonight), dark enough for small words. */
.tot-meta { color: #b5352a; font: 800 11px/1.35 Arial, sans-serif; letter-spacing: .14em; text-transform: uppercase; }
.tot-meta:empty, .tot-why:empty { display: none; }
.tot-title { display: -webkit-box; overflow: hidden; font: 400 clamp(22px, 2.3vw, 30px)/1.06 Georgia, serif; letter-spacing: -.03em; overflow-wrap: anywhere; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.tot-why { display: -webkit-box; overflow: hidden; color: #57534c; font: italic 15px/1.4 Georgia, serif; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tot-key { position: absolute; top: 10px; left: 10px; z-index: 1; min-width: 30px; padding: 4px 6px; border: 0; color: var(--paper); background: rgba(18, 18, 18, .78); text-align: center; font: 14px/1 Arial, sans-serif; }
.tot-details { position: absolute; top: 10px; right: 10px; z-index: 2; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px 0 11px; border: 1px solid rgba(18, 18, 18, .22); border-radius: 22px; color: var(--ink); background: rgba(242, 238, 223, .94); font: 800 11px/1 Arial, sans-serif; letter-spacing: .1em; text-transform: uppercase; cursor: pointer; touch-action: manipulation; }
.tot-details svg, .tot-text svg { flex: none; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.tot-details:hover { border-color: var(--red); color: var(--paper); background: var(--red); }
.tot-details:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.tot-stamp { position: absolute; top: 14px; left: 14px; z-index: 3; display: grid; place-items: center; width: 76px; height: 76px; border: 3px solid var(--red); border-radius: 8px; color: var(--red); background: rgba(242, 238, 223, .9); box-shadow: 3px 3px 0 rgba(18, 18, 18, .2); font: 400 46px/1 "Yu Mincho", "MS Mincho", serif; transform: rotate(-10deg); pointer-events: none; }
.tot-actions { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 28px; }
.tot-neither { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; min-width: 240px; min-height: 56px; padding: 8px 28px; border: 1px solid #6a675f; color: var(--paper); background: transparent; cursor: pointer; touch-action: manipulation; }
.tot-neither b { font: 800 12px/1 Arial, sans-serif; letter-spacing: .16em; text-transform: uppercase; }
.tot-neither small { color: #a9a59a; font: italic 14px/1.2 Georgia, serif; }
.tot-neither:hover { border-color: var(--red); }
.tot-neither:hover b { color: var(--red); }
.tot-neither:focus-visible { outline: 2px solid var(--paper); outline-offset: 3px; }
.tot-keys { margin: 0; color: #8a877f; text-align: center; font: italic 13px/1.6 Georgia, serif; }
.tot-dialog kbd { border-color: #5d5b56; color: #bdb9ae; font-size: 12px; }

/* ---------- The champion ---------- */
.tot-champion { display: grid; grid-template-columns: minmax(220px, 360px) minmax(0, 1fr); align-items: center; gap: clamp(22px, 5vw, 60px); padding-top: 10px; }
.tot-stage { position: relative; display: grid; place-items: center; min-height: 420px; }
.tot-sun { position: absolute; width: 92%; aspect-ratio: 1; border-radius: 50%; background: var(--red); }
.tot-sheet { position: relative; display: grid; place-items: center; width: min(250px, 74%); min-height: 200px; margin: 0; padding: 10px; background: var(--paper); box-shadow: 11px 11px 0 #050505; transform: rotate(-2deg); }
.tot-sheet img { display: block; width: 100%; aspect-ratio: 2 / 3; object-fit: cover; background: var(--tot-tint, #cbc3ae); cursor: zoom-in; }
.tot-crown { position: absolute; right: -28px; bottom: 26px; display: grid; justify-items: center; gap: 3px; padding: 9px 12px 7px; border: 3px solid var(--red); border-radius: 8px; color: var(--red); background: rgba(242, 238, 223, .93); box-shadow: 3px 3px 0 rgba(18, 18, 18, .22); transform: rotate(-12deg); pointer-events: none; }
.tot-crown b { font: 400 30px/1 "Yu Mincho", "MS Mincho", serif; letter-spacing: .04em; }
.tot-crown small { font: 800 9px/1 Arial, sans-serif; letter-spacing: .2em; text-transform: uppercase; }
/* The decision's own hanko once it is made: 否 passed, 保 saved, 今夜 tonight (decision.css inks). */
.tot-decided { position: absolute; top: 18px; left: -20px; display: none; place-items: center; min-width: 58px; height: 58px; padding: 0 6px; border: 3px solid currentColor; border-radius: 8px; background: rgba(242, 238, 223, .93); font: 400 32px/1 "Yu Mincho", "MS Mincho", serif; transform: rotate(8deg); pointer-events: none; }
.tot-decided.is-long { font-size: 24px; }
.tot-decided[data-decision] { display: grid; }
.tot-decided[data-decision="pass"] { color: var(--decision-stamp-pass, var(--ink)); }
.tot-decided[data-decision="maybe"] { color: var(--decision-stamp-save, #7a6a48); }
.tot-decided[data-decision="watch"] { color: var(--decision-stamp-tonight, var(--red)); }
.tot-copy { min-width: 0; }
.tot-champion-kicker { margin: 0; color: var(--red); font: 800 12px/1.4 Arial, sans-serif; letter-spacing: .2em; text-transform: uppercase; }
.tot-champion-title { margin: 10px 0 0; font: 400 clamp(36px, 5vw, 58px)/.98 Georgia, serif; letter-spacing: -.045em; overflow-wrap: anywhere; }
/* Focused from code so a screen reader starts here; it is not a control, so no ring. */
.tot-champion-title:focus { outline: none; }
.tot-champion-meta { display: inline-block; margin: 16px 0 0; padding: 6px 10px; color: var(--ink); background: var(--paper); font: 800 11px/1.35 Arial, sans-serif; letter-spacing: .12em; text-transform: uppercase; }
.tot-champion-why { margin: 14px 0 0; color: #d4cfc1; font: italic 17px/1.5 Georgia, serif; }
.tot-beat { margin: 8px 0 0; color: #8e8a81; font: italic 15px/1.5 Georgia, serif; }
.tot-decide-label { margin: 22px 0 8px; color: #bdb9ae; font: 800 11px/1.3 Arial, sans-serif; letter-spacing: .16em; text-transform: uppercase; }
.tot-decide-slot.is-saving { cursor: wait; }
.tot-decide-slot.is-saving .decision { opacity: .6; }
.tot-decide-fallback { display: flex; gap: 8px; }
.tot-decide-fallback button { flex: 1; min-height: 52px; border: 1px solid #6a675f; color: var(--paper); background: transparent; }
.tot-decide-fallback [aria-pressed="true"] { color: var(--ink); background: var(--paper); }
.tot-status { min-height: 1.5em; margin: 10px 0 0; color: #d4cfc1; font: 15px/1.5 Arial, sans-serif; }
.tot-after { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-top: 10px; }
.tot-again { min-height: 52px; padding: 0 26px; background: var(--decision-tonight-fill, #c0392b); }
.tot-again:hover { background: var(--paper); color: var(--ink); }
.tot-again:focus-visible, .tot-row .primary:focus-visible, .tot-plain:focus-visible { outline: 2px solid var(--paper); outline-offset: 3px; }
.tot-text { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 4px; border: 0; color: #d4cfc1; background: none; font: 15px/1.4 Arial, sans-serif; text-decoration: underline; text-decoration-color: rgba(239, 75, 63, .6); text-underline-offset: 4px; cursor: pointer; }
.tot-text:hover { color: var(--red); }
.tot-text:focus-visible { outline: 2px solid var(--paper); outline-offset: 3px; }

/* Keyboard hints only where there is a keyboard. */
@media (pointer: coarse) {
    .tot-keys, .tot-key { display: none; }
}

/* ---------- Phones: the whole screen, two stacked halves whose covers meet at the 比 seal ---------- */
@media (max-width: 760px) {
    .deck-modes.has-tot { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
    .deck-modes .tot-entry { flex-direction: column; gap: 2px; padding: 4px 10px; line-height: 1.05; }
    .tot-entry-mark { font-size: 15px; }

    .tot-dialog { width: 100%; height: 100%; max-height: none; margin: 0; }
    .tot-shell { min-height: 100%; height: 100%; max-height: none; padding: max(10px, env(safe-area-inset-top)) 16px calc(12px + env(safe-area-inset-bottom)); border: 0; box-shadow: none; }
    /* The round goes under the name, beside the seal. */
    .tot-kicker { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 3px 10px; font-size: 11px; letter-spacing: .16em; }
    .tot-mark { grid-row: span 2; width: 34px; height: 34px; font-size: 19px; }
    .tot-round-dot { display: none; }
    .tot-progress { margin-top: 8px; gap: 6px 12px; }
    .tot-pips li { width: 16px; height: 5px; }
    .tot-count { font-size: 14px; }
    .tot-question { margin-top: 6px; font-size: 22px; }
    .tot-pair { flex: 1 1 auto; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; min-height: 420px; margin-top: 12px; }
    .tot-vs { top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; font-size: 22px; box-shadow: 0 0 0 6px var(--night); }
    .tot-card { box-shadow: 6px 6px 0 #050505; }
    .tot-card:hover { box-shadow: 6px 6px 0 #050505; }
    .tot-cover { flex: 1 1 auto; min-height: 96px; aspect-ratio: auto; }
    .tot-caption { flex: none; gap: 4px; padding: 10px 14px 12px; }
    .tot-meta { font-size: 10px; letter-spacing: .12em; }
    .tot-title { font-size: 21px; -webkit-line-clamp: 2; }
    .tot-why { font-size: 14px; -webkit-line-clamp: 1; }
    /* The top card turns its caption up, so the two covers meet in the middle around the seal. */
    .tot-slot[data-side="0"] .tot-card { flex-direction: column-reverse; }
    .tot-slot[data-side="0"] .tot-details { top: auto; bottom: 10px; }
    .tot-details { right: 8px; min-height: 44px; padding: 0 12px 0 10px; }
    .tot-stamp { top: 50%; left: 50%; width: 64px; height: 64px; margin: -32px 0 0 -32px; font-size: 38px; }
    .tot-actions { margin-top: 14px; gap: 6px; }
    .tot-neither { width: 100%; min-height: 54px; }

    .tot-champion { grid-template-columns: 1fr; gap: 16px; padding-top: 4px; }
    .tot-stage { min-height: 250px; }
    .tot-sun { width: min(250px, 76%); }
    .tot-sheet { width: 148px; min-height: 150px; padding: 7px; }
    .tot-crown { right: -34px; bottom: 14px; padding: 7px 10px 5px; }
    .tot-crown b { font-size: 24px; }
    .tot-decided { left: -26px; min-width: 48px; height: 48px; font-size: 26px; }
    .tot-decided.is-long { font-size: 19px; }
    .tot-champion-title { margin-top: 6px; font-size: 34px; }
    .tot-champion-meta { margin-top: 12px; }
    .tot-champion-why { margin-top: 10px; font-size: 16px; }
    .tot-decide-label { margin-top: 16px; }
    .tot-after { margin-top: 6px; }
    .tot-again { flex: 1 1 160px; }
    .tot-loading { min-height: 60vh; }
}

/* A short phone (landscape, small screens): the halves keep their size and the page scrolls. */
@media (max-width: 760px) and (max-height: 600px) {
    .tot-pair { min-height: 520px; }
}

@media (prefers-reduced-motion: reduce) {
    .tot-loading-mark { animation: none; }
    .tot-entry-mark, .tot-card { transition: none; }
}
