header h1 a { color: inherit; text-decoration: none; }
#match-rules-link { color: #efc883; }
#home { display: block; max-width: 76rem; padding: clamp(1.5rem, 4vw, 3rem) clamp(1rem, 4vw, 2rem); }
.home-intro { margin-bottom: 1.8rem; }
.account-panel { max-width: 36rem; margin: 0 auto; }
.account-panel > h2 { margin-bottom: .75rem; }
#account-form, #account-session { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .65rem; }
#account-form label { display: grid; gap: .25rem; font-size: .9rem; }
#account-form input { min-width: 0; width: 12rem; max-width: 100%; padding: .4rem .55rem; border: 1px solid #839282; border-radius: .35rem; background: #242e28; color: inherit; }
#account-session { align-items: center; }
#account-edit-dialog { width: min(26rem, calc(100vw - 2rem)); color: inherit; background: #242e28; border: 1px solid #839282; border-radius: .55rem; }
#account-edit-dialog::backdrop { background: #111b; }
#account-edit-form { display: grid; gap: .65rem; }
#account-edit-form label { display: grid; gap: .25rem; }
#account-edit-form input { width: 100%; min-width: 0; padding: .4rem .55rem; border: 1px solid #839282; border-radius: .35rem; background: #181e1b; color: inherit; }
#account-edit-error { color: #ffbf9f; }
#account-message, #lobby-message { font-size: .9rem; color: #efc883; }
#matchmaking h4 { margin-top: .9rem; }
#matchmaking-hint { color: #d9d2bd; font-size: .9rem; }
#host-settings { margin-block: 1rem; padding: .85rem; border: 1px solid #536055; border-radius: .45rem; background: #1c251f; }
#matchmaking #host-settings-title { margin: 0 0 .7rem; }
#host-fields { margin: 0; padding: 0; min-width: 0; border: 0; }
.host-settings-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: .65rem; }
.host-settings-grid label { display: grid; gap: .3rem; align-content: start; min-width: 0; font-size: .875rem; color: #ded7c2; }
.host-settings-grid :is(input, select) { box-sizing: border-box; width: 100%; min-width: 0; min-height: 2.35rem;
  padding: .35rem .45rem; border: 1px solid #839282; border-radius: .35rem; background: #242e28; color: #f6edda; font: inherit; }
#random-champions-count, #difficulty-match-limit, #royal-deck-size { grid-column: span 2; }
.host-submit { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .7rem; margin-top: .75rem; }
.host-submit small { color: #d9d2bd; }
#lobby-message:empty { margin: 0; }
@media (min-width: 42rem) {
  .host-settings-grid { grid-template-columns: minmax(0, .8fr) minmax(0, 1.5fr) repeat(2, minmax(0, 1fr)); }
}
.match-list { margin: .25rem 0 0; padding: 0; list-style: none; }
.match-list li { display: flex; align-items: center; justify-content: space-between; gap: .65rem; border-bottom: 1px solid #536055; padding: .6rem 0; }
.match-list small { display: block; color: #d9d2bd; font-size: .875rem; }
.match-list .room-list-entry { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; }
.room-list-entry strong { overflow-wrap: anywhere; }
.room-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: .35rem; }
.room-rules { grid-column: 1 / -1; color: #ded7c2; font-size: .875rem; }
.room-rules summary { color: #efc883; cursor: pointer; width: fit-content; }
.room-rules dl { display: grid; grid-template-columns: minmax(0, 7rem) minmax(0, 1fr); gap: .4rem .65rem;
  margin: .45rem 0 0; padding: .65rem; background: #1c251f; border-radius: .4rem; }
.room-rules dt { font-weight: 650; }
.room-rules dd { margin: 0; overflow-wrap: anywhere; }
#join-notice { position: fixed; z-index: 20; inset: auto 1rem 1rem auto; max-width: min(24rem, calc(100vw - 2rem));
  box-sizing: border-box; display: flex; align-items: start; gap: .65rem; padding: .75rem;
  border: 1px solid #d58c72; border-radius: .5rem; background: #382b27; box-shadow: 0 .2rem 1rem #0007; }
#join-notice p { margin: 0; color: #ffe2cc; overflow-wrap: anywhere; }
#join-notice button { flex: none; font-size: .875rem; }
@media (max-width: 760px) {
  #join-notice { bottom: calc(4.5rem + env(safe-area-inset-bottom)); }
}
.button-link { display: inline-block; border: 1px solid #839282; border-radius: .4rem; background: #2d3b32; color: inherit; text-decoration: none; padding: .45rem .75rem; }
.button-link:hover { background: #44594a; }
.home-intro h2 { font-size: clamp(2.25rem, 6vw, 4.25rem); letter-spacing: -.045em; }
.home-intro p, .library p, #army-instructions { color: #d9d2bd; }
#lobby-nav { display: flex; gap: .4rem; margin: 0 auto 1.2rem; max-width: 40rem; }
#lobby-nav a { flex: 1; text-align: center; color: #f6edda; text-decoration: none; font-weight: 650;
  padding: .65rem .5rem; border-radius: .4rem; border: 1px solid #536055; background: #242e28; }
#lobby-nav a[aria-current=page] { background: #edc57c; color: #242218; border-color: #edc57c; }
#play-page { display: grid; gap: 1rem; max-width: 48rem; margin: auto; }
#matchmaking-hint a { color: #efc883; }
#lobby-error { color: #ffbf9f; }
#leaderboard-list { display: grid; gap: .5rem; padding-inline-start: 2rem; margin: 0; }
#leaderboard-list:empty { display: none; }
#leaderboard-list li::marker { color: #efc883; font-weight: 700; }
.home-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(21rem, 31rem);
  grid-template-areas: "library army" "library deck"; grid-template-rows: auto 1fr; gap: 1rem 2rem; align-items: start; }
.catalog-panel { grid-area: library; }
.starting-army { grid-area: army; }
#deck-page .deck-panel { grid-area: deck; }
.catalog-heading { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: .85rem; }
.catalog-heading h3, .deck-panel h4 { margin: 0; font-family: Georgia, serif; color: #f6edda; font-size: 1.35rem; }
.catalog-heading label, .catalog-heading span { font-size: .875rem; color: #d9d2bd; white-space: nowrap; }
#champion-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem .6rem; margin-bottom: .85rem; }
:is(#champion-filters, .library-controls) label { min-width: 0; display: grid; gap: .25rem; color: #d9d2bd; font-size: .85rem; }
#champion-filters :is(input, select), #champion-sort { width: 100%; min-width: 0; border: 1px solid #839282; border-radius: .35rem; padding: .4rem; background: #242e28; color: inherit; font: inherit; }
#reset-champion-filters { grid-column: 1 / -1; justify-self: start; }
.library-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem; margin-bottom: .85rem; }
.library-controls label { flex: 1 1 11rem; }
.library-controls button { font-size: .875rem; }
.library { display: grid; align-items: start; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); gap: .75rem; }
.champion-card, .deck-panel { background: #242e28; border: 1px solid #536055; border-radius: .6rem; padding: 1rem; }
.champion-card { display: flex; flex-direction: column; align-items: flex-start; gap: .45rem; }
.champion-card h4 { margin: 0; font-size: 1.05rem; overflow-wrap: anywhere; }
.champion-card.is-compact { display: grid; grid-template-columns: 3rem minmax(min-content, 1fr) auto; align-items: center;
  gap: .15rem .45rem; padding: .65rem .75rem; }
.champion-card.is-compact .card-art { grid-row: span 2; }
.champion-card.is-compact .card-texture { width: 3rem; height: 3rem; }
.champion-card.is-compact h4 { grid-column: 2 / -1; align-self: end; }
.champion-card :is(.card-add, .card-detail-toggle) { min-height: 2rem; padding: .2rem .4rem; font-size: .8rem; }
.champion-card .card-add { justify-self: start; }
.champion-card .card-detail-toggle { justify-self: end; align-self: end; }
.champion-card.is-compact .card-detail-toggle { grid-column: 3; }
.card-details { display: grid; gap: .45rem; width: 100%; }
.champion-card small { color: #efc883; font-size: .875rem; }
.champion-card .champion-stats small { color: inherit; font-size: .78rem; }
.champion-card p { margin: 0 0 .4rem; }
.champion-card button { margin-top: .1rem; }
button:disabled { cursor: default; opacity: .55; }
#army-board { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); border: .35rem solid #536055; border-radius: .45rem; overflow: hidden; touch-action: manipulation; }
#army-board .square.eligible { box-shadow: inset 0 0 0 3px #376889; }
#army-board .square.eligible:hover { background: #b4d6e8; }
#army-board .square.drop-hover { background: #b4d6e8; box-shadow: inset 0 0 0 4px #376889; }
.black-setup #army-board .square.eligible { box-shadow: inset 0 0 0 3px #7b4248; }
.black-setup #army-board .square.eligible:hover { background: #d4a4a6; }
.black-setup #army-board .square.drop-hover { background: #d4a4a6; box-shadow: inset 0 0 0 4px #7b4248; }
.drag-source { cursor: grab; touch-action: none; user-select: none; }
.piece-texture.drag-source { pointer-events: auto; }
.is-dragging, .is-dragging .square { cursor: grabbing; }
.dragged-piece { position: fixed; z-index: 20; width: 4rem; height: 4rem; transform: translate(-50%, -50%); filter: drop-shadow(0 4px 5px #141c18b3); }
.card-art { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .4rem; width: 100%; }
.card-texture { justify-self: center; width: min(4rem, 100%); height: 4rem; }
.card-sprite-corner { display: grid; grid-template-columns: repeat(var(--sprite-columns), 1.35rem);
  align-self: end; justify-self: end; gap: .2rem; }
.card-sprite-corner .piece-texture { width: 1.35rem; height: 1.35rem; }
#army-instructions { font-size: .9rem; margin-top: .55rem; }
.card-place { justify-self: start; font-size: .875rem; }
.deck-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .45rem; }
.deck-list li { display: flex; align-items: center; justify-content: space-between; gap: .65rem; border-bottom: 1px solid #536055; padding: .48rem 0; min-height: 2.8rem; }
.deck-list li.empty { color: #c0bdab; font-size: .9rem; }
.deck-list small { display: block; color: #efc883; font-size: .875rem; }
.deck-list button { font-size: .875rem; }
.deck-list .deck-card-select { text-align: left; display: grid; grid-template-columns: 2rem 1fr; column-gap: .5rem; align-items: center; }
.deck-card-select .piece-texture { width: 2rem; height: 2rem; grid-row: span 2; }
.deck-card-select small { grid-column: 2; }
.home-actions { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: 1rem; }
#deck-match { background: #edc57c; border-color: #edc57c; color: #242218; font-weight: 650; }
#deck-match:hover { background: #f4d49b; }
#home-message { margin-top: .7rem; font-size: .9rem; color: #efc883; }
@media (max-width: 760px) {
  html:has(#home:not([hidden])) { scroll-padding-bottom: calc(4.5rem + env(safe-area-inset-bottom)); }
  html:has(#home:not([hidden]) #deck-page:not([hidden])) { scroll-padding-top: calc(min(39svh, 22rem) + 6rem); }
  #home { padding-bottom: calc(5.5rem + env(safe-area-inset-bottom)); }
  #lobby-nav { position: fixed; inset: auto 0 0; z-index: 10; max-width: none; margin: 0;
    padding: .45rem 1rem calc(.45rem + env(safe-area-inset-bottom)); background: #181e1b; border-top: 1px solid #536055; }
  .home-layout { display: flex; flex-direction: column; align-items: stretch; gap: 1rem; }
  .starting-army { order: -2; position: sticky; top: 0; z-index: 5; background: #181e1b;
    padding-block: .4rem; }
  .starting-army .catalog-heading { margin-bottom: .3rem; }
  #army-board { width: min(100%, 39svh, 22rem); margin-inline: auto; }
  #deck-page .deck-panel { order: -1; }
  #army-instructions { font-size: .75rem; }
  #champion-filters :is(input, select), #champion-sort, #account-form input { font-size: 1rem; }
}
