@font-face {
  font-family: 'Playfair Display';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url('../assets/fonts/playfair-display-latin-wght-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

@font-face {
  font-family: 'Playfair Display';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url('../assets/fonts/playfair-display-vietnamese-wght-normal.woff2') format('woff2');
  unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB;
}

@font-face {
  font-family: 'Playfair Display';
  font-style: italic;
  font-weight: 400 900;
  font-display: swap;
  src: url('../assets/fonts/playfair-display-latin-wght-italic.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

@font-face {
  font-family: 'Playfair Display';
  font-style: italic;
  font-weight: 400 900;
  font-display: swap;
  src: url('../assets/fonts/playfair-display-vietnamese-wght-italic.woff2') format('woff2');
  unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB;
}

:root {
  color-scheme: dark;
  --bg: #0d0c15;
  --surface: #151321;
  --surface-raised: #1b182a;
  --line: #2d283e;
  --text: #f3eff8;
  --muted: #afa6be;
  --gold: #eaca90;
  --violet: #bc9bf9;
  --success: #83d8b3;
  --danger: #f2a3a9;
  --page-gutter: clamp(.7rem, 2.8vw, 2.25rem);
  --page-width: 84rem;
  --panel-padding: clamp(.85rem, 2vw, 1.25rem);
  --display: 'Playfair Display', Georgia, serif;
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-synthesis: none;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 280px; }
button, select, textarea { font: inherit; }
button { color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; }
button, select, textarea, dialog { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, select:focus-visible, textarea:focus-visible, .table-wrap:focus-visible {
  outline: 2px solid var(--violet);
  outline-offset: 3px;
}
:focus:not(:focus-visible) { outline: none; }
h1, h2, h3, p { margin: 0; }
h2 { font-size: 1.12rem; font-weight: 650; letter-spacing: -.018em; }
[hidden] { display: none !important; }
.icon { display: inline-block; flex: none; vertical-align: middle; }
.visually-hidden, .skip-link:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link:focus { position: absolute; z-index: 10; top: .5rem; left: .5rem; padding: .5rem 1rem; background: var(--surface); color: var(--gold); }

.site-header { border-bottom: 1px solid #272234; background: #12101b; }
.site-header-inner, .layout, .site-footer { width: min(calc(100% - var(--page-gutter) * 2), var(--page-width)); margin-inline: auto; }
.site-header-inner { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; min-height: 4.5rem; gap: 1rem; }
.brand { justify-self: start; display: inline-flex; align-items: center; gap: .7rem; padding: 0; border: 0; background: none; text-align: left; }
.brand-mark { display: grid; place-items: center; width: 2.55rem; height: 2.55rem; border: 1px solid #5c4936; border-radius: .68rem; background: #261d20; color: var(--gold); }
.brand-mark .icon { width: 1.55rem; height: 1.55rem; }
.brand strong, .brand small { display: block; }
.brand strong { font: 700 1.23rem/1.16 var(--display); white-space: nowrap; }
.brand small { margin-top: .2rem; color: var(--gold); font-size: .59rem; font-weight: 650; letter-spacing: .16em; }
.site-nav { display: flex; gap: .35rem; }
.nav-link { display: flex; align-items: center; gap: .46rem; border: 1px solid transparent; border-radius: .5rem; background: none; padding: .59rem .78rem; color: var(--muted); font-size: .86rem; font-weight: 600; white-space: nowrap; }
.nav-link .icon, .source-toggle .icon { width: 1.05rem; height: 1.05rem; }
.nav-link:hover, .nav-link[aria-current] { background: #251c29; color: var(--gold); }
.nav-link[aria-current] { border-color: #483544; }
.source-toggle { justify-self: end; display: flex; align-items: center; gap: .5rem; padding: .52rem .67rem; border: 1px solid var(--line); border-radius: .5rem; background: #171422; color: var(--muted); font-size: .77rem; font-weight: 600; white-space: nowrap; }
.source-toggle:hover, .source-toggle.is-on { border-color: #694d91; color: var(--violet); }
.toggle-track { display: inline-flex; align-items: center; width: 1.76rem; height: .99rem; border: 1px solid #494059; border-radius: 1rem; background: #292435; }
.toggle-track::before { width: .62rem; height: .62rem; margin-left: .12rem; border-radius: 50%; background: #9285a1; content: ''; }
.is-on .toggle-track { background: #594879; }
.is-on .toggle-track::before { margin-left: .88rem; background: #e0caff; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: clamp(1.03rem, 2vw, 1.6rem); padding-top: clamp(1rem, 2vw, 1.6rem); }
.hero { position: relative; display: flex; align-items: center; min-height: 16.45rem; overflow: hidden; border: 1px solid #40334f; border-radius: .9rem; isolation: isolate; background: #100b1b; }
.hero::before, .hero::after { position: absolute; z-index: -1; inset: 0; content: ''; }
.hero::before { background: url('../assets/wing-hero.png') center 48% / cover no-repeat; }
.hero::after { background: linear-gradient(90deg, #100c1a 0%, #100c1af0 18%, #100c1a9c 38%, transparent 69%), linear-gradient(0deg, #0f0b17a0, transparent 38%); }
.hero-copy { padding: 2.15rem 2.45rem; }
.hero-eyebrow { display: flex; align-items: center; gap: .55rem; color: var(--gold); font-size: .7rem; font-weight: 700; letter-spacing: .17em; }
.hero-eyebrow > span { width: .42rem; height: .42rem; transform: rotate(45deg); background: var(--gold); box-shadow: 0 0 .7rem #eaca9070; }
.hero h1 { margin: .37rem 0 .67rem; font: 400 clamp(3.15rem, 6.2vw, 5.6rem)/1.12 var(--display); letter-spacing: -.055em; text-wrap: balance; }
.hero h1 em { color: var(--gold); font-weight: 400; }
.hero p { max-width: 25rem; color: #d0c6df; font-size: .96rem; line-height: 1.65; }
.hero-detail { position: absolute; right: 1.05rem; bottom: 1rem; display: flex; align-items: center; gap: .35rem; color: #e4be81a8; }
.hero-detail .icon { width: .8rem; height: .8rem; }
.hero-detail span { width: 1.3rem; height: 1px; background: #e4be8160; }
.page-intro { padding: 1.15rem 0 .1rem; }
.page-intro h1 { margin-bottom: .25rem; font: 400 clamp(2.3rem, 5vw, 3.8rem)/1.12 var(--display); letter-spacing: -.05em; }
.page-intro p { color: var(--muted); }

.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .7rem; }
.section-heading h2 { font-size: 1.2rem; }
.section-meta { color: var(--muted); font-size: .78rem; }
.player-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .85rem; }
.player-card { display: flex; align-items: center; gap: .72rem; min-width: 0; min-height: 5rem; padding: .8rem .95rem; border: 1px solid var(--line); border-radius: .72rem; background: var(--surface); text-align: left; }
.player-card:hover { border-color: #705790; background: #1b172a; }
.player-card[aria-pressed="true"] { border-color: #8c6a43; background: linear-gradient(108deg, #302131 0%, #1c1727 63%); box-shadow: inset 0 0 0 1px #eaca9010; }
.player-icon, .heading-icon, .recipe-icon { flex: none; display: grid; place-items: center; width: 2.55rem; height: 2.55rem; border: 1px solid #59446d; border-radius: .65rem; background: #2b203d; color: var(--violet); }
.player-card-2 .player-icon { color: #edc898; border-color: #625137; background: #332535; }
.player-card-3 .player-icon { color: #e8a4ad; border-color: #634452; background: #352438; }
.player-text { flex: 1; min-width: 0; }
.player-text strong, .player-text small { display: block; }
.player-text strong { font-size: .96rem; font-weight: 650; overflow-wrap: anywhere; }
.player-text small { display: flex; align-items: center; gap: .43rem; margin-top: .27rem; color: var(--muted); font-size: .73rem; }
.class-label { border: 1px solid #4b3a64; border-radius: .25rem; padding: .03rem .33rem; background: #28203a; color: #d6baff; font-size: .65rem; font-weight: 700; }
.player-card-2 .class-label, .player-card-3 .class-label { border-color: #5e443c; background: #302329; color: var(--gold); }
.player-status { padding: .25rem .48rem; border: 1px solid #6b5038; border-radius: .33rem; color: var(--gold); font-size: .68rem; white-space: nowrap; }
.player-status i, .result-tag i { display: inline-block; width: .32rem; height: .32rem; margin: 0 .35rem .12rem 0; border-radius: 50%; background: currentColor; }
.player-arrow { color: #83728f; }
.player-arrow .icon { width: 1rem; height: 1rem; }

.session-status { display: grid; gap: .72rem; padding: .74rem 1.05rem; }
.session-status-row { display: flex; align-items: center; gap: .72rem; }
.session-status-copy { flex: 1; min-width: 0; }
.session-status-copy h2 { font-size: .96rem; }
.session-status-copy p { margin-top: .14rem; color: var(--muted); font-size: .78rem; }
.session-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: end; gap: .62rem; }
.session-open { color: var(--success); font-size: .75rem; white-space: nowrap; }
.session-open i { display: inline-block; width: .38rem; height: .38rem; margin: 0 .33rem .09rem 0; border-radius: 50%; background: currentColor; }

.chaos-summary { min-width: 0; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: .65rem; background: var(--surface); }
.chaos-summary h3 { font-size: .84rem; font-weight: 650; }
.chaos-totals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .45rem; margin: .5rem 0 0; }
.chaos-totals > div { padding: .35rem .55rem; border-left: 1px solid var(--line); }
.chaos-totals dt { color: var(--muted); font-size: .72rem; line-height: 1.25; }
.chaos-totals dd { margin: .12rem 0 0; font-size: 1.07rem; font-weight: 650; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.chaos-totals small { color: var(--muted); font-size: .65rem; font-weight: 500; }
.session-status > .chaos-summary { border-width: 1px 0 0; border-radius: 0; padding: .65rem 0 0; }
.history-panel > .chaos-summary { margin: 0 1.25rem .92rem; background: var(--surface-raised); }
.chaos-positive { color: var(--success); }
.chaos-negative { color: var(--danger); }

.work-grid { display: grid; grid-template-columns: minmax(0, 1.91fr) minmax(0, 1fr); align-items: start; gap: 1.1rem; }
.panel { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: .8rem; background: var(--surface); }
.panel-head { display: flex; align-items: center; gap: .78rem; padding: 1.16rem var(--panel-padding) .92rem; }
.panel-head > div { min-width: 0; }
.panel-head p { margin-top: .14rem; color: var(--muted); font-size: .8rem; line-height: 1.4; }
.heading-icon { width: 2.45rem; height: 2.45rem; border-color: #5b4837; background: #2b2227; color: var(--gold); }
.round-chip { flex: none; margin-left: auto; border: 1px solid #50405e; border-radius: .34rem; background: #241d34; padding: .29rem .53rem; color: #d8c3fb; font-size: .73rem; font-weight: 650; }
.materials-body { display: grid; gap: .82rem; padding: 0 var(--panel-padding) var(--panel-padding); }
.base-wing-picker { display: grid; gap: .5rem; padding-bottom: .82rem; border-bottom: 1px solid var(--line); }
.base-wing-picker h3 { font-size: .85rem; font-weight: 650; }
.base-wing-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .45rem; }
.base-wing-card { display: flex; align-items: center; gap: .42rem; min-width: 0; min-height: 2.6rem; padding: .46rem .52rem; border: 1px solid var(--line); border-radius: .46rem; background: var(--surface-raised); text-align: left; }
.base-wing-card:hover, .base-wing-card[aria-pressed="true"] { border-color: #99794e; background: #2a2030; color: var(--gold); }
.base-wing-card strong { font-size: .77rem; line-height: 1.25; }
.base-wing-card .wing-label { flex: none; }
.category-filter { display: flex; flex-wrap: wrap; gap: .36rem; }
.filter-chip { padding: .37rem .62rem; border: 1px solid var(--line); border-radius: .4rem; background: #191623; color: var(--muted); font-size: .76rem; white-space: nowrap; }
.filter-chip span { padding-left: .32rem; opacity: .8; font-size: .68rem; }
.filter-chip:hover, .filter-chip[aria-pressed="true"] { border-color: #765c40; background: #332636; color: var(--gold); }
.item-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .46rem; }
.item-card { display: flex; align-items: center; gap: .48rem; min-width: 0; min-height: 3.47rem; padding: .42rem .5rem; border: 1px solid #322b43; border-radius: .5rem; background: var(--surface-raised); text-align: left; }
.item-card:hover { border-color: #796089; background: #231c31; }
.item-card[aria-pressed="true"] { border-color: #99794e; background: #2a2030; }
.item-icon { flex: none; display: grid; place-items: center; width: 1.82rem; height: 1.82rem; border-radius: .37rem; background: #2e263d; color: #dbc1ff; }
.item-icon .icon { width: 1.03rem; height: 1.03rem; }
.item-icon-1, .item-icon-2 { background: #312837; color: #edc88f; }
.item-icon-3, .item-icon-4 { background: #223139; color: #a2d3c7; }
.item-icon-5 { background: #292640; color: #b4bffd; }
.item-text { min-width: 0; flex: 1; }
.item-text strong { display: block; overflow-wrap: anywhere; font-size: .78rem; line-height: 1.27; font-weight: 620; }
.item-text small { display: block; margin-top: .14rem; color: var(--muted); font-size: .68rem; }
.item-tick { width: .88rem; height: .88rem; color: var(--gold); }

.material-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr)); gap: .6rem; padding: .7rem; border: 1px solid var(--line); border-radius: .55rem; background: var(--surface-raised); }
.material-controls label { min-width: 0; }
.material-controls .custom-line { grid-column: 1 / -1; }
.material-controls textarea { min-height: 2.35rem; padding-block: .45rem; }
.material-controls [data-line-error] { display: block; color: var(--danger); }

.recipe-block { display: grid; gap: .72rem; }
.reuse-note { min-width: 0; padding: .7rem .78rem; border: 1px solid #6b5237; border-radius: .55rem; background: #2b222b; }
.reuse-head { display: flex; flex-wrap: wrap; align-items: center; gap: .52rem; }
.reuse-head > div { flex: 1 1 9rem; }
.reuse-head h3 { color: var(--gold); font-size: .84rem; font-weight: 650; }
.reuse-head p { color: var(--muted); font-size: .73rem; }
.reuse-icon { color: var(--gold); }
.reuse-icon .icon { width: 1.05rem; height: 1.05rem; }
.reuse-rounds { display: grid; gap: .4rem; max-height: 11.5rem; overflow: auto; margin: .52rem 0 0; padding: .5rem 0 0; border-top: 1px solid #55433f; list-style: none; scrollbar-color: #7e6751 #292130; }
.reuse-rounds li { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .48rem; align-items: start; color: var(--muted); font-size: .76rem; overflow-wrap: anywhere; }
.reuse-round { color: var(--gold); font-weight: 650; white-space: nowrap; }
.reuse-rounds small { display: block; color: var(--gold); margin-top: .13rem; }

.recipe { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; padding: .67rem .78rem; border: 1px solid #4a394b; border-radius: .55rem; background: linear-gradient(90deg, #252032, #211a2a); }
.recipe-content, .dialog-recipe { display: flex; flex: 1 1 12rem; align-items: center; gap: .6rem; min-width: 0; }
.recipe-icon { width: 2.15rem; height: 2.15rem; border-color: #624e40; background: #342838; color: var(--gold); }
.recipe-icon .icon { width: 1.12rem; height: 1.12rem; }
.recipe-label, .dialog-recipe small { display: block; margin-bottom: .14rem; color: var(--muted); font-size: .69rem; }
.recipe strong, .dialog-recipe strong { display: block; color: var(--text); font-size: .8rem; font-weight: 650; overflow-wrap: anywhere; }
.recipe strong i { padding-inline: .09rem; color: var(--gold); font-style: normal; }
.recipe-placeholder { color: var(--muted); font-weight: 400; }
.recipe-actions, .data-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 2.35rem; padding: .46rem .73rem; border: 1px solid transparent; border-radius: .43rem; font-size: .8rem; font-weight: 650; text-align: center; }
.button.prediction-shortcut { display: none; }
.button .icon { width: .98rem; height: .98rem; }
.button-primary { border-color: #eac784; background: linear-gradient(110deg, #edd5a2, #d9af70); color: #271b20; }
.button-primary:hover:not(:disabled) { background: #f2d6a0; }
.button-primary:disabled { border-color: #625246; background: #514333; color: #e2ccad; }
.button-secondary { border-color: #463b55; background: #211a2d; color: #ddd2ec; }
.button-secondary:hover { border-color: #7b6594; background: #2b2239; }
.button-danger { border-color: #6f4552; background: #35212d; color: var(--danger); }
.button-danger:hover:not(:disabled) { background: #472632; }
.icon-button { display: inline-grid; place-items: center; width: 2.15rem; height: 2.15rem; border: 1px solid var(--line); border-radius: .45rem; background: #1c1728; color: var(--muted); }
.icon-button:hover { border-color: #665272; color: var(--text); }
.icon-button.danger-hover:hover { border-color: #7c4e59; color: var(--danger); }
.icon-button .icon { width: .96rem; height: .96rem; }

.history-head > .button { margin-left: auto; }
.history-empty { display: flex; justify-content: center; align-items: center; gap: .75rem; min-height: 5.35rem; padding: .9rem 1.25rem 1.2rem; border-top: 1px solid var(--line); color: var(--muted); }
.history-empty > .icon { color: var(--violet); }
.history-empty strong { color: var(--text); font-size: .85rem; font-weight: 650; }
.history-empty p { margin-top: .17rem; font-size: .8rem; }
.history-filters { display: flex; flex-wrap: wrap; align-items: end; gap: .64rem; padding: 0 var(--panel-padding) .92rem; }
.history-filters label { width: min(100%, 13rem); min-width: 0; }
.history-filters label:first-child { width: min(100%, 18rem); }
label, legend { color: var(--text); font-size: .82rem; font-weight: 600; }
select, textarea { width: 100%; margin-top: .28rem; padding: .46rem .61rem; border: 1px solid #45364f; border-radius: .45rem; background: #1c1728; color: var(--text); font-size: .82rem; }
select { min-height: 2.35rem; }
textarea { min-height: 5.25rem; resize: vertical; }
textarea::placeholder { color: #9f94ad; }
.table-wrap { position: relative; max-width: 100%; overflow: auto; scrollbar-color: #645477 #211b2c; }
.history-table { width: 100%; border-collapse: collapse; text-align: left; font-size: .8rem; }
.history-table th, .history-table td { padding: .62rem .8rem; border-top: 1px solid var(--line); }
.history-table :is(th, td):where(:first-child) { padding-left: var(--panel-padding); }
.history-table :is(th, td):where(:last-child) { padding-right: var(--panel-padding); }
.history-table thead { background: var(--surface-raised); }
.history-table thead th { color: var(--muted); font-weight: 600; white-space: nowrap; }
.history-table small { display: block; margin-top: .12rem; color: var(--muted); font-size: .72rem; }
.history-formula { min-width: 10.5rem; max-width: 31rem; overflow-wrap: anywhere; }
.history-time { white-space: nowrap; font-variant-numeric: tabular-nums; }
.history-table tbody tr:hover { background: #191625; }
.history-mobile-label { display: none; }
.history-round { color: var(--gold); }
.history-player { min-width: 4rem; }
.history-formula-outcome { display: inline-block; }
.formula-success { color: var(--success); }
.formula-fail { color: var(--danger); }
.history-chaos-change { min-width: 6.5rem; max-width: 14rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.chaos-no-change { color: var(--muted); }
.text-link { padding: 0; border: 0; background: none; font-size: inherit; font-weight: 650; text-align: left; }
.text-link:hover { color: var(--gold); text-decoration: underline; }
.chaos-edit { display: block; margin-top: .2rem; color: var(--gold); font-size: .72rem; }
.result-tag, .wing-label { display: inline-block; padding: .19rem .45rem; border: 1px solid currentColor; border-radius: .3rem; font-size: .71rem; white-space: nowrap; }
.result-success { background: #182d2a; color: var(--success); border-color: #36534b; }
.result-fail { background: #32212c; color: var(--danger); border-color: #673944; }
.wing-label { border-color: #514162; background: #2a2238; color: var(--violet); font-weight: 700; }
.wing-label-dk { color: var(--gold); }
.wing-label-eff { color: var(--success); }
.wing-label-dw { color: #9bc6ff; }

.data-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.data-body { padding: 0 var(--panel-padding) var(--panel-padding); }
.data-body p { margin-bottom: .7rem; color: var(--muted); font-size: .85rem; }
.data-counts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; margin: 0 0 .8rem; }
.data-counts > div { padding: .7rem; border: 1px solid var(--line); border-radius: .5rem; background: var(--surface-raised); }
.data-counts dt { color: var(--muted); font-size: .74rem; }
.data-counts dd { margin: .12rem 0 0; color: var(--gold); font-size: 1.35rem; font-weight: 650; }
.data-reset { grid-column: 1 / -1; }
.data-reset .heading-icon { border-color: #634450; background: #342231; color: var(--danger); }
.status-banner { display: flex; align-items: center; gap: .6rem; padding: .65rem .92rem; border: 1px solid #544270; border-radius: .55rem; background: #211934; color: #dec9ff; font-size: .83rem; overflow-wrap: anywhere; }
.status-banner.is-error { border-color: #744a57; background: #35212c; color: var(--danger); }
.site-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .6rem; margin-top: 1.75rem; padding: 1rem 0 1.6rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .72rem; }
.site-footer .icon { width: .95rem; height: .95rem; margin-right: .26rem; color: var(--gold); }

dialog { width: min(calc(100% - 1.75rem), 32rem); max-height: calc(100vh - 1.75rem); max-height: calc(100dvh - 1.75rem); overflow: auto; overscroll-behavior-y: contain; padding: 0; border: 1px solid #5b4a6c; border-radius: .8rem; background: #191525; color: var(--text); box-shadow: 0 1rem 6rem #000b; }
dialog::backdrop { background: #090710c4; }
.dialog-head { display: flex; justify-content: space-between; align-items: start; gap: .65rem; padding: 1.05rem 1.15rem .87rem; border-bottom: 1px solid var(--line); }
.dialog-head h2 { font-size: 1.25rem; }
.dialog-head p { margin-top: .18rem; color: var(--muted); font-size: .78rem; overflow-wrap: anywhere; }
.dialog-form { display: grid; gap: .73rem; padding: .95rem 1.15rem 1.1rem; }
.dialog-form p { color: var(--muted); font-size: .86rem; }
.dialog-form fieldset { min-width: 0; margin: 0; padding: .25rem 0 0; border: 0; }
.dialog-form legend { padding: 0; }
.dialog-recipe { padding: .66rem; border: 1px solid #4f3a53; border-radius: .5rem; background: #261d33; }
.form-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .42rem; }
.wing-choices { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.choice { display: flex; align-items: center; gap: .34rem; min-height: 2.64rem; padding: .37rem .45rem; border: 1px solid #3e334d; border-radius: .45rem; background: #211a2e; cursor: pointer; }
.choice:has(input:checked) { border-color: #8b6a47; color: var(--gold); }
.choice input { flex: none; margin: 0; accent-color: var(--gold); }
.dialog-form .form-hint { margin-top: -.36rem; font-size: .74rem; }
.chaos-entry { display: grid; gap: .34rem; }
.chaos-entry input[type="text"] { width: 100%; min-height: 2.38rem; margin-top: .28rem; padding: .45rem .61rem; border: 1px solid #45364f; border-radius: .45rem; background: #1c1728; color: var(--text); font: inherit; font-variant-numeric: tabular-nums; }
.chaos-entry input[type="text"]:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; }
.chaos-entry input[aria-invalid="true"] { border-color: var(--danger); }
.chaos-preview { font-size: .8rem; font-weight: 650; }
.dialog-form .form-error { color: var(--danger); }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: .45rem; padding-top: .35rem; }
.toast { position: fixed; z-index: 3; right: 1.1rem; bottom: 1.1rem; max-width: min(26rem, calc(100% - 2.2rem)); padding: .65rem .94rem; border: 1px solid #4c7868; border-radius: .5rem; background: #1b2c2a; color: #bdedd7; box-shadow: 0 .4rem 2rem #0006; font-size: .86rem; overflow-wrap: anywhere; pointer-events: none; }
.toast-error { border-color: #85515e; background: #35212d; color: var(--danger); }

@media (min-width: 80rem) {
  .item-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 64rem) {
  .work-grid { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
  .item-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .player-card { padding-inline: .65rem; }
  .player-status { padding-inline: .32rem; }
}

@media (max-width: 58rem) {
  .history-table-wrap { overflow: visible; padding: 0 var(--panel-padding) var(--panel-padding); }
  .history-table { display: block; }
  .history-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .history-table tbody { display: grid; gap: .68rem; }
  .history-table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1.12fr) minmax(0, .9fr) minmax(0, 1fr);
    grid-template-areas: "round round time" "formula formula formula" "result wing rate" "chaos chaos actions";
    gap: .6rem .4rem;
    min-width: 0;
    padding: .76rem .72rem;
    border: 1px solid var(--line);
    border-radius: .55rem;
    background: var(--surface-raised);
  }
  .history-table tbody tr > :is(th, td) { min-width: 0; max-width: none; padding: 0; border: 0; white-space: normal; }
  .history-round { grid-area: round; display: flex; flex-wrap: wrap; align-content: start; align-items: baseline; gap: .12rem .45rem; }
  .history-round > span { font-size: .92rem; }
  .history-round small { margin: 0; }
  .history-player { min-width: 0; }
  .history-formula { grid-area: formula; }
  .history-formula .text-link { font-size: .87rem; }
  .history-formula small { color: #c8bfd5; line-height: 1.5; }
  .history-result { grid-area: result; }
  .history-wing { grid-area: wing; }
  .history-rate { grid-area: rate; }
  .history-time { grid-area: time; color: var(--muted); text-align: right; font-size: .73rem; }
  .history-chaos-change { grid-area: chaos; }
  .history-actions { grid-area: actions; align-self: end; justify-self: end; }
  .history-mobile-label { display: block; margin-bottom: .2rem; color: var(--muted); font-size: .72rem; }
  .history-table tbody tr > .history-chaos-change { padding-top: .45rem; border-top: 1px solid var(--line); }
  .history-chaos-change .chaos-edit { min-height: 2.25rem; margin-top: .35rem; padding: .25rem .62rem; border: 1px solid #574563; border-radius: .4rem; background: #211a2d; }
}

@media (min-width: 41rem) and (max-width: 58rem) {
  .history-table tbody { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 56rem) {
  .work-grid { grid-template-columns: minmax(0, 1fr); }
  .item-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .button.prediction-shortcut { display: inline-flex; justify-self: start; min-height: 2.75rem; }
}

@media (max-width: 52rem) {
  .site-header-inner { grid-template-columns: minmax(0, 1fr) auto; gap: .5rem 1rem; padding: .62rem 0 .5rem; }
  .site-nav { grid-row: 2; grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .nav-link { min-width: 0; justify-content: center; padding-inline: .35rem; }
  .source-toggle { grid-column: 2; grid-row: 1; }
}

@media (max-width: 48rem) {
  .hero { min-height: 13.6rem; }
  .hero-copy { padding: 1.7rem 1.3rem; }
  .hero::before { background-position: 59% 50%; }
  .hero::after { background: linear-gradient(90deg, #100c1af5, #100c1ab0 43%, #100c1a33 90%); }
  .player-grid { gap: .48rem; }
  .player-card { flex-wrap: wrap; gap: .42rem; padding: .55rem; }
  .player-icon { width: 2rem; height: 2rem; border-radius: .5rem; }
  .player-icon .icon { width: 1rem; height: 1rem; }
  .player-text { flex: 1 1 5rem; }
  .player-status, .player-arrow { display: none; }
}

@media (max-width: 35rem) {
  .item-grid, .history-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .history-filters label, .history-filters label:first-child { width: 100%; }
  .history-filters label:first-child, .history-filters .button { grid-column: 1 / -1; }
  .data-grid { grid-template-columns: minmax(0, 1fr); }
  .player-card { flex-direction: column; flex-wrap: nowrap; align-items: start; min-height: auto; }
  .player-text { flex: 1 1 auto; max-width: 100%; }
  .player-text strong { font-size: .83rem; }
  .player-text small { flex-wrap: wrap; gap: .18rem .3rem; font-size: .68rem; }
}

@media (max-width: 28rem) {
  .nav-link { gap: .28rem; font-size: .75rem; }
  .nav-link .icon { width: .88rem; height: .88rem; }
  .hero { min-height: 10.75rem; }
  .hero-copy { padding: 1.2rem 1rem; }
  .hero p { max-width: 17.4rem; font-size: .86rem; }
  .hero h1 { font-size: clamp(2.45rem, 11.2vw, 3rem); }
  .session-status { padding: .7rem .8rem; }
  .session-status-row { flex-wrap: wrap; }
  .session-actions { width: 100%; justify-content: space-between; }
  .session-actions > .button:only-child { width: 100%; }
  .panel-head { padding-block: .95rem .8rem; }
  .base-wing-card { align-items: start; flex-direction: column; gap: .29rem; }
  .recipe-actions { width: 100%; }
  .recipe-actions .button { flex: 1 1 auto; }
  .history-head > .button { padding-inline: .34rem; font-size: .71rem; }
  .history-head > .button .icon { display: none; }
  .history-panel > .chaos-summary { margin-inline: var(--panel-padding); }
  .chaos-totals { gap: .22rem; }
  .chaos-totals > div { padding-inline: .35rem; }
  .chaos-totals dd { font-size: .95rem; }
}

@media (max-width: 22.5rem) {
  .site-header-inner { grid-template-columns: minmax(0, 1fr) auto; gap: .48rem .5rem; }
  .brand { gap: .45rem; }
  .brand-mark { width: 2.08rem; height: 2.08rem; }
  .brand-mark .icon { width: 1.25rem; height: 1.25rem; }
  .brand strong { font-size: 1.05rem; }
  .source-toggle { gap: .35rem; padding-inline: .42rem; }
  .nav-link .icon { display: none; }
  .round-chip { max-width: 6rem; text-align: center; }
  .item-card { gap: .34rem; }
  .item-icon { width: 1.6rem; height: 1.6rem; }
  .history-filters > label:has([data-filter="baseWingClass"]) { grid-column: 1 / -1; }
}

@media (pointer: coarse) {
  .button, .choice, .nav-link, .base-wing-card, .source-toggle, .filter-chip { min-height: 2.75rem; }
  .icon-button { width: 2.75rem; height: 2.75rem; }
  .history-chaos-change .chaos-edit { min-height: 2.75rem; }
  .material-controls :is(select, textarea), .history-filters select, .dialog-form :is(select, input[type="text"]) { min-height: 2.75rem; font-size: 1rem; }
}

@media (max-height: 30rem) and (orientation: landscape) {
  .hero { min-height: 9.75rem; }
  .hero h1 { font-size: clamp(2.65rem, 6.2vw, 4rem); }
  .hero-copy { padding-block: 1.1rem; }
  dialog { max-height: calc(100vh - 1rem); max-height: calc(100dvh - 1rem); scroll-padding-block: .6rem; }
  .dialog-head { padding-block: .72rem .6rem; }
  .dialog-form { gap: .58rem; padding-block: .7rem .8rem; }
}

@media (prefers-reduced-motion: no-preference) {
  .button, .nav-link, .player-card, .item-card, .filter-chip { transition: color .16s, border-color .16s, background-color .16s; }
}
