:root {
  --canvas: #ded0b3;
  --paper: #f0e5cc;
  --plaster: #e6d6b8;
  --ink: #2b261e;
  --muted: #685b47;
  --line: #c4af89;
  --green: #263d32;
  --terracotta: #9c3d2c;
  --cream: #fff3d8;
  --ochre: #a27a46;
  --tournament-gold: #997337;
  --tournament-fine: #d3b77b;
  --tournament-blue: #263d75;
  --tournament-red: #7d2838;
  --mobile-nav-height: 65px;
  --mobile-nav-clearance: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom, 0px));
  --mobile-chat-height: clamp(285px, calc(100dvh - 162px - env(safe-area-inset-bottom, 0px)), 680px);
}

body { background: var(--canvas); font: 15px/1.45 "Trebuchet MS", Arial, sans-serif; }
main {
  max-width: var(--game-max-width, 1360px);
  padding: 27px 42px 38px;
  container: game / inline-size;
}
.paper {
  background: var(--paper);
  border: 1px solid #a68d67;
  border-radius: 0;
  box-shadow: none;
}

.site-header {
  background: var(--paper);
  border: 0;
  border-bottom: 1px solid #9a8061;
  box-shadow: none;
}

.header-inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  max-width: var(--game-max-width, 1360px);
  min-height: 73px;
  padding: 0 42px;
  gap: 26px;
}

.site-header .brand {
  justify-self: start;
  gap: 15px;
  color: var(--ink);
  font: 700 31px/1 var(--serif);
}

.site-header .brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-inline: 5px 2px;
  transform: rotate(45deg);
  clip-path: none;
  border: 1px solid var(--terracotta);
  outline: 1px solid var(--terracotta);
  outline-offset: -5px;
  background: transparent;
  color: var(--terracotta);
}

.site-header .brand-mark::before {
  content: "◇";
  transform: rotate(-45deg);
  font: 19px/1 var(--serif);
}

#nav {
  align-self: stretch;
  gap: clamp(14px, 2.2vw, 29px);
  padding: 0;
  background: transparent;
  box-shadow: none;
}

#nav a {
  min-height: 43px;
  padding: 0;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  font: inherit;
  font-weight: 580;
  white-space: nowrap;
}

#nav a:hover, #nav a.current { background: transparent; color: var(--ink); }
#nav a.current { border-bottom-color: var(--terracotta); box-shadow: none; font-weight: 700; }
#nav #navChat { display: var(--room-chat-link, none); }
#nav a::before {
  display: var(--mobile-tab-icons, none);
  width: 18px;
  height: 18px;
  font: 20px/18px var(--serif);
  text-align: center;
}
#navRoom::before { content: "⌂" / ""; }
#navChat::before { content: "▤" / ""; }
#navMe::before { content: "♟" / ""; }
#navHistory::before { content: "◷" / ""; }
#navFight::before { content: "⚔︎" / ""; }

#logout {
  grid-column: 3;
  justify-self: end;
  min-height: 38px;
  margin: 0;
  padding: 5px 0 5px 9px;
  border: 0;
  border-radius: 0;
  color: var(--ink);
  font: 700 16px/1 var(--serif);
  text-decoration: underline;
  text-underline-offset: 3px;
}

#logout:hover { background: transparent; color: var(--terracotta); }
#invitePanel { background: #f7ebd2; }
#invitePanel .buttons { flex-wrap: wrap; }

#room {
  --room-default-columns: minmax(0, .94fr) minmax(0, .98fr) minmax(0, 1.08fr);
  --room-default-areas: "arena arena chat" "profile roster chat";
  display: grid;
  grid-template-columns: var(--room-columns, var(--room-default-columns));
  grid-template-areas: var(--room-areas, var(--room-default-areas));
  align-items: stretch;
  gap: var(--room-gap, 18px);
}

#room[data-view="chat"] { grid-template-areas: var(--chat-view-areas, var(--room-areas, var(--room-default-areas))); }
#room[data-view="chat"] :is(#arena, #roster) { display: var(--room-in-chat, flex); }
#room:not([data-view="chat"]) #chat { display: var(--chat-in-room, flex); }

#room > .room-center, #room > .room-social { display: contents; }

#arena {
  position: relative;
  grid-area: arena;
  display: flex;
  align-items: flex-end;
  min-height: var(--arena-height, clamp(380px, 44dvh, 455px));
  isolation: isolate;
  overflow: hidden;
  border: 5px solid #3c3327;
  outline: 1px solid #504033;
  background: var(--green);
  color: var(--cream);
}

#arena .room-art, #arena::after {
  position: absolute;
  z-index: -1;
  inset: 0;
  width: 100%;
  height: 100%;
}

#arena .room-art { border: 0; aspect-ratio: auto; object-fit: cover; object-position: 54% 46%; }
#arena::after {
  background: linear-gradient(180deg, transparent 31%, #251b1245 54%, #211a12ef 100%);
  pointer-events: none;
  content: "";
}

#arena .arena-content { width: 100%; padding: 27px 30px 29px; }
#roomTitle {
  max-width: 690px;
  margin: 0;
  font: 700 clamp(38px, 4.7vw, 68px)/.99 var(--serif);
  letter-spacing: -.041em;
}

#arena #queueStatus {
  margin: 12px 0 0;
  color: #f5e5c4;
  font-weight: 700;
}

#join {
  min-height: 47px;
  margin-top: 20px;
  padding: 10px 24px;
  border: 1px solid #dda976;
  border-radius: 0;
  background: var(--terracotta);
  color: #fff0d6;
  font-weight: 700;
}

#join:not(:disabled):hover { background: #b14c37; }
#arena :focus-visible { outline-color: #f5d090; }
#queueStatus:empty { display: none; }

#roster {
  grid-area: roster;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 16px 16px 13px;
  box-shadow: inset 0 0 0 5px #e6d6b8;
}

#roster::before {
  flex: 0 0 7px;
  margin-bottom: 13px;
  background: repeating-linear-gradient(45deg, var(--terracotta) 0 2px, transparent 2px 6px, #6b7a56 6px 8px, transparent 8px 12px);
  opacity: .63;
  content: "";
}

#roster .top { align-items: baseline; margin-bottom: 11px; }
#roster h2, #chatTitle { font: 700 clamp(23px, 2.45vw, 30px)/1.1 var(--serif); }
#playerCount { color: var(--green); white-space: nowrap; }
#playerCount::before {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: #50683f;
  content: "";
}

#playerList {
  max-height: min(300px, 36dvh);
  padding: 0;
  border-bottom: 1px solid var(--line);
  scrollbar-width: thin;
}

#roster .player-row {
  min-height: 46px;
  padding: 8px 9px;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

#roster .player-row:hover { background: #dfe1cc; }
#roster .player-row > div { min-width: 0; }
#roster .player-row a {
  color: var(--ink);
  font: 700 19px/1.18 var(--serif);
  text-decoration: none;
}

#roster .player-row a:hover { color: var(--green); text-decoration: underline; }
#roster .player-row small { margin-top: 2px; font-size: 13px; }
#roster .player-row .sub {
  min-height: 36px;
  padding-inline: 8px;
  border-color: #b79f77;
  border-radius: 0;
  color: var(--green);
  font-size: 13px;
}

#roster .player-row .sub:hover { background: #eee0be; }
#roster #lastResult {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 5px 12px;
  margin-top: auto;
  padding: 13px 9px 5px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

#roster #lastResult a { color: #763727; }
#roster #lastResult a::before { content: "▸ "; }

#room #profile {
  --portrait-width: 98px;
  position: relative;
  grid-area: profile;
  display: var(--room-profile-display, block);
  min-height: 232px;
  padding: 14px 16px 15px calc(var(--portrait-width) + 16px);
  border-color: #947a58;
}

#room #profile .card-heading { margin-bottom: 9px; }
#room #profile .card-heading h2 {
  font: 700 clamp(24px, 2.55vw, 35px)/1 var(--serif);
}

#room #profile .card-heading a { color: var(--ink); text-decoration: none; }
#room #profile .card-heading a:hover { text-decoration: underline; }
#room #profile .portrait-frame {
  position: absolute;
  inset: 0 auto 0 0;
  display: grid;
  width: var(--portrait-width);
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-right: 1px solid var(--line);
  background: #cdb993;
  box-shadow: none;
}

#room #profile .person { width: 100%; height: 100%; object-fit: cover; object-position: 50% 32%; mix-blend-mode: multiply; }
#room #profile .barlabel { margin-block: 9px; font-size: 13px; }
#room #profile progress { height: 6px; border: 0; border-radius: 0; background: #d3c09d; }
#room #profile progress::-webkit-progress-bar { background: #d3c09d; }
#room #healthBar::-webkit-progress-value { background: var(--green); }
#room #healthBar::-moz-progress-bar { background: var(--green); }
#room #profile .statgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
#room #profile .statgrid div { padding: 4px 0; border-color: #d5c2a3; font-size: 13px; }
#room #profile .statgrid dt { min-width: 0; overflow-wrap: anywhere; }
#room #profile p { margin-top: 6px; font-size: 13px; }

#room #chat {
  grid-area: chat;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: var(--chat-panel-min-height, 0);
  padding: var(--chat-panel-padding, 20px 19px 18px);
  border-color: #947a58;
  box-shadow: inset 0 0 0 5px #e6d6b8;
}

#chatTitle { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
#chat .chat-window {
  flex: 1 1 0;
  min-width: 0;
  height: 0;
  min-height: 175px;
  margin-top: 12px;
  border-radius: 0;
  border-color: #d5c2a3;
  background: #f7ecd5;
}

#chat #chatMessages {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 11px;
  scrollbar-width: thin;
}
#chat #chatMessages:focus-visible { outline-color: var(--green); outline-offset: -2px; }
#chat .chat-message {
  flex: 0 0 auto;
  align-self: flex-start;
  max-width: min(96%, 460px);
  padding: 7px 10px 8px;
  border: 1px solid #d5c2a3;
  background: #fff3dc;
}
#chat .chat-message--own {
  align-self: flex-end;
  border-color: #bac4aa;
  background: #e4e6d3;
}
#chat .chat-meta { gap: 3px 14px; }
#chat .chat-meta strong { color: var(--green); }
#chat .chat-body { margin-top: 2px; font-size: 15px; }
#chat .chat-form { gap: 8px; margin-top: 11px; scroll-margin-bottom: var(--screen-bottom-offset, 0px); }
#chatInput { background: #fff5df; border-color: #b49b73; border-radius: 0; font-size: 16px; }
#chatSend { border-color: #263d32; border-radius: 0; background: var(--green); color: var(--cream); }
#chatSend:not(:disabled):hover { background: #365447; }

body:has(#battle:not([hidden])) {
  background:
    repeating-linear-gradient(15deg, #73563403 0 1px, transparent 1px 5px),
    radial-gradient(ellipse at 50% 28%, #fbf1db, transparent 68%),
    #ede2ca;
}
body:has(#battle:not([hidden])) .site-header { background: #f9f0db; border-bottom-color: #cbb186; }
body:has(#battle:not([hidden])) .brand-mark {
  border-color: var(--tournament-fine);
  outline-color: var(--tournament-blue);
  outline-offset: 2px;
  background: var(--tournament-blue);
  color: #f0d68e;
}
body:has(#battle:not([hidden])) .brand-mark::before { content: "✦"; }
body:has(#battle:not([hidden])) #nav a.current { border-bottom-color: var(--tournament-blue); color: var(--tournament-blue); }

#battle {
  max-width: 1232px;
  margin-inline: auto;
}

#battle > .page-heading {
  min-height: 75px;
  margin: 0 0 19px;
  background: transparent;
}

#battle h1 {
  font: 700 clamp(46px, 4.1vw, 62px)/.99 var(--serif);
  letter-spacing: -.055em;
}

#battle .round-timer {
  min-width: 172px;
  justify-content: space-between;
  padding: 8px 12px 9px;
  border: 0;
  border-block: 1px solid var(--tournament-fine);
  border-radius: 0;
  background: transparent;
  color: var(--tournament-red);
}

#battle .round-timer span { font-size: 12px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
#battle .round-timer strong { font: 700 26px/1 var(--serif); font-variant-numeric: tabular-nums; }
#battle .round-timer.urgent { border-color: var(--tournament-red); background: #f2dfd1; }

#battle .combat-layout {
  grid-template-columns: minmax(0, 2.1fr) minmax(0, 1fr);
  grid-template-areas: "folio folio" "move journal";
  gap: 27px 26px;
  align-items: stretch;
}

.tournament-folio {
  position: relative;
  grid-area: folio;
  display: grid;
  grid-template: "left scene right" minmax(0, 1fr) / 18% minmax(0, 1fr) 18%;
  min-width: 0;
  min-height: 365px;
  padding: 15px;
  border: 1px solid var(--tournament-gold);
  outline: 1px solid #e3cda2;
  outline-offset: 4px;
  background:
    linear-gradient(90deg, transparent 49.8%, #967b4633 50%, #fff8df55 50.2%, transparent 50.4%),
    linear-gradient(90deg, #ecdcb6, #f8edcf 20%, #f8edcf 80%, #ecdcb6);
  box-shadow: inset 0 0 22px #8667461a, 0 5px 16px #684a2c14;
}

.tournament-folio::before, .tournament-folio::after {
  position: absolute;
  top: -4px;
  width: 7px;
  height: 7px;
  transform: rotate(45deg);
  background: var(--tournament-gold);
  pointer-events: none;
  content: "";
}
.tournament-folio::before { left: -4px; }
.tournament-folio::after { right: -4px; }

.duel-illustration {
  --illumination: 24px;
  position: relative;
  grid-area: scene;
  width: 100%;
  min-width: 0;
  min-height: 330px;
  margin: 0;
  overflow: hidden;
  border: 1px solid #796038;
  background: #b6a076;
  box-shadow: 0 0 0 3px #f4e3b6, 0 0 0 4px var(--tournament-gold);
}

.duel-illustration img {
  position: absolute;
  inset: var(--illumination) 0 0;
  width: 100%;
  height: calc(100% - var(--illumination));
  object-fit: cover;
  object-position: center 74%;
}

.duel-illustration::before {
  position: absolute;
  inset: 0 0 auto;
  height: var(--illumination);
  border-bottom: 1px solid #aa7c35;
  background: url("/duel-miniature.webp") center top / 100% auto no-repeat;
  content: "";
}

.duel-illustration::after {
  position: absolute;
  inset: 5px;
  border: 1px solid #f5df9caa;
  box-shadow: 0 0 0 1px #4f432140;
  pointer-events: none;
  content: "";
}

#fighterLeft { --fight-side: var(--tournament-red); }
#fighterRight { --fight-side: var(--tournament-blue); }
.tournament-folio > :is(#fighterLeft, #fighterRight) { min-width: 0; }
.tournament-folio .fighter {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 12px 16px;
  border: 0;
  background: none;
  text-align: center;
}

.tournament-folio .fighter::before {
  flex: 0 0 62px;
  display: grid;
  place-items: center;
  width: 57px;
  margin-bottom: 11px;
  padding-bottom: 6px;
  border: 2px solid var(--tournament-gold);
  border-radius: 0 0 50% 50%;
  box-shadow: inset 0 0 0 2px #e6d09e55;
  background: var(--fight-side);
  color: #f0d696;
  font: 35px/1 var(--serif);
  content: "✦" / "";
}

#fighterRight .fighter::before { content: "✸" / ""; }
.tournament-folio .fighter .portrait-frame { display: none; }
.tournament-folio .fighter h2 {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: 100%;
  margin: 0 0 10px;
  color: var(--fight-side);
  font: 700 clamp(25px, 2.9vw, 41px)/1 var(--serif);
  letter-spacing: -.045em;
}

.tournament-folio .fighter h2 a { color: inherit; text-decoration: none; }
.tournament-folio .fighter h2 a:hover { text-decoration: underline; }
.tournament-folio .fighter h2 small, #fighterRight .fighter h2::before {
  order: -1;
  color: var(--fight-side);
  font: 750 11px/1.2 system-ui, sans-serif;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.tournament-folio .fighter h2 small.muted { margin: 0; }
#fighterRight .fighter h2::before { content: "Соперник"; }

.tournament-folio .hp-line {
  grid-template-columns: 1fr;
  width: 100%;
  max-width: 144px;
  margin: 0;
  color: var(--fight-side);
  font-size: 13px;
  font-weight: 750;
}

.tournament-folio .hp-line span:first-child { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.tournament-folio .hp-line span:last-of-type { text-align: center; }
.tournament-folio .hp-line span:last-of-type::after { content: " HP"; }
.tournament-folio .hp-line progress { height: 7px; border: 0; border-radius: 0; background: #d8c59d; }
.tournament-folio .hp-line progress::-webkit-progress-bar { background: #d8c59d; }
.tournament-folio .hp-line progress::-webkit-progress-value { background: var(--fight-side); }
.tournament-folio .hp-line progress::-moz-progress-bar { background: var(--fight-side); }

.tournament-folio .statgrid {
  width: 100%;
  max-width: 156px;
  margin-top: 9px;
}
.tournament-folio .statgrid div {
  padding: 1px 0;
  border-bottom-color: #d9c59e;
  color: #6a5940;
  font-size: 12px;
}
.tournament-folio .statgrid dt { min-width: 0; overflow-wrap: anywhere; text-align: left; }
.tournament-folio .fighter p { font-size: 12px; }

#battle #fightCenter, #battle .battle-log {
  padding: 20px 24px 18px;
  border: 0;
  border-block: 1px solid var(--tournament-gold);
  background: #fbf1d9a1;
}

#battle #status { color: #6a5940; font-size: 14px; }
#battle .action-stack { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 25px; margin-top: 12px; }
#battle .action-panel { padding: 0; border: 0; background: none; }
#battle .action-panel:first-child { --choice-ink: var(--tournament-red); --choice-wash: #f2dfd1; }
#battle .action-panel:last-child { --choice-ink: var(--tournament-blue); --choice-wash: #e7e4dc; }
#battle .action-panel legend, #battle .battle-log h2 {
  padding: 0;
  margin-bottom: 11px;
  font: 700 28px/1.1 var(--serif);
  letter-spacing: -.035em;
}
#battle .action-panel legend { color: var(--choice-ink); }
#battle .choices { grid-template-columns: minmax(0, 1fr); gap: 5px; }
#battle .choices button {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 39px;
  padding: 5px 12px;
  border: 1px solid #d9c7a6;
  border-radius: 0;
  background: #fbf2df;
  color: var(--ink);
  font-size: 14px;
  font-weight: 550;
  text-align: left;
}

#battle .choices button::before {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  transform: rotate(45deg);
  border: 1px solid #91744f;
  content: "";
}

#battle .choices button:hover { border-color: var(--choice-ink); }
#battle :is(#attacks, #blocks) button.selected {
  border-color: var(--choice-ink);
  background: var(--choice-wash);
  color: var(--choice-ink);
  font-weight: 750;
}
#battle .choices button.selected::before { border-color: var(--choice-ink); background: var(--choice-ink); }
#battle :focus-visible { outline-color: var(--tournament-blue); }

#battle #move {
  display: block;
  width: auto;
  min-width: 190px;
  margin: 17px 0 0 auto;
  padding: 8px 18px;
  border: 1px solid #1d2c53;
  border-radius: 0;
  background: var(--tournament-blue);
  box-shadow: inset 0 0 0 2px var(--tournament-blue), inset 0 0 0 3px #e3c67d70;
  color: #fff2d6;
  font-size: 14px;
  font-weight: 750;
}

#battle #move:not(:disabled):hover { background: #1d2c53; }
#battle .battle-log { padding-inline: 21px; }
#battle .logs { margin-top: 3px; max-height: 330px; scrollbar-width: thin; }
#battle .log { padding: 12px 0; border-top-color: #d7c39e; }
#battle .log strong { color: #6a5940; font-size: 12px; }
#battle .hitline { margin-block: 3px; font: 16px/1.4 var(--serif); }
#battle .hitline .damage { color: var(--tournament-red); white-space: nowrap; }

@media (min-width: 981px) {
  body:not(.mobile-design) #room {
    --room-clearance: 139px;
    height: max(550px, calc(100dvh - var(--room-clearance)));
    grid-template-rows: minmax(0, 1.22fr) minmax(0, 1fr);
  }

  body:not(.mobile-design) #game:has(> #invitePanel:not([hidden])) #room { --room-clearance: 224px; }
  body:not(.mobile-design) #room #arena { min-height: 0; }

  body:not(.mobile-design) #room #roster { min-height: 0; }
  body:not(.mobile-design) #roster h2 { font-size: clamp(22px, 1.95vw, 27px); }
  body:not(.mobile-design) #roster .top,
  body:not(.mobile-design) #roster #lastResult { flex-shrink: 0; }
  body:not(.mobile-design) #playerList { flex: 1 1 0; min-height: 0; max-height: none; }
  body:not(.mobile-design) #roster .player-row { min-height: 45px; padding-block: 4px; }
  body:not(.mobile-design) #roster .player-row > div {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 7px;
  }
  body:not(.mobile-design) #roster .player-row a { font-size: 17px; }
  body:not(.mobile-design) #roster .player-row small { margin: 0; }

  body:not(.mobile-design) #room #profile {
    min-height: 0;
    overflow: auto;
    scrollbar-width: thin;
    background: linear-gradient(90deg, #cdb993 0 var(--portrait-width), var(--paper) var(--portrait-width));
  }
  body:not(.mobile-design) #room #profile .portrait-frame {
    bottom: auto;
    height: 100%;
    max-height: 280px;
  }
}

@media (max-width: 980px) {
  main, .header-inner { padding-inline: 24px; }
  #room {
    --room-default-columns: minmax(0, 1.12fr) minmax(0, 1fr);
    --room-default-areas: "arena arena" "profile chat" "roster chat";
  }
  #roster { padding-inline: 15px; }
  #room #profile { --portrait-width: 83px; }
  #battle .combat-layout { gap: 21px 19px; }
  .tournament-folio { grid-template-columns: 18.5% minmax(0, 1fr) 18.5%; min-height: 320px; }
  .duel-illustration { min-height: 290px; }
  .tournament-folio .fighter { padding-inline: 11px; }
}

body.mobile-design {
  --game-max-width: 620px;
  --room-columns: minmax(0, 1fr);
  --room-areas: "arena" "roster";
  --chat-view-areas: "chat";
  --room-gap: 12px;
  --room-in-chat: none;
  --chat-in-room: none;
  --room-profile-display: none;
  --arena-height: clamp(285px, 86vw, 390px);
  --chat-panel-min-height: var(--mobile-chat-height);
  --chat-panel-padding: 14px;
  --mobile-tab-icons: block;
  --room-chat-link: grid;
  --screen-bottom-offset: var(--mobile-nav-clearance);
}

@media (max-width: 760px) {
  body {
    --room-columns: minmax(0, 1fr);
    --room-areas: "arena" "roster";
    --chat-view-areas: "chat";
    --room-gap: 12px;
    --room-in-chat: none;
    --chat-in-room: none;
    --room-profile-display: none;
    --arena-height: min(390px, 86vw);
    --chat-panel-min-height: var(--mobile-chat-height);
    --chat-panel-padding: 14px;
    --mobile-tab-icons: block;
    --room-chat-link: grid;
    --screen-bottom-offset: var(--mobile-nav-clearance);
  }
}

body.mobile-design main { padding: 15px 13px 29px; }
body.mobile-design:has(#nav:not([hidden])) main { padding-bottom: calc(20px + var(--screen-bottom-offset)); }
body.mobile-design .header-inner {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px 12px;
  min-height: 0;
  padding: 10px 14px;
}
body.mobile-design .site-header .brand { gap: 10px; font-size: 25px; }
body.mobile-design .site-header .brand-mark { width: 24px; height: 24px; }
body.mobile-design .site-header .brand-mark::before { font-size: 14px; }
body.mobile-design #logout { grid-column: 2; grid-row: 1; min-height: 32px; }
body.mobile-design #nav {
  position: fixed;
  z-index: 8;
  inset: auto 0 0;
  align-self: auto;
  justify-content: space-evenly;
  gap: 3px;
  width: min(100%, var(--game-max-width));
  min-height: var(--mobile-nav-height);
  margin-inline: auto;
  padding: 4px max(5px, env(safe-area-inset-right, 0px)) calc(4px + env(safe-area-inset-bottom, 0px)) max(5px, env(safe-area-inset-left, 0px));
  border-top: 1px solid #aa8e67;
  background: #f0e5cc;
  box-shadow: 0 -3px 14px #4a312219;
}
body.mobile-design #nav a {
  flex: 1 1 0;
  grid-template-rows: 18px auto;
  align-content: center;
  gap: 3px;
  min-width: 0;
  min-height: 52px;
  padding: 4px 2px;
  border: 0;
  font-size: clamp(11px, 3.1vw, 13px);
  line-height: 1.12;
  text-align: center;
  white-space: normal;
}
body.mobile-design #nav a.current { background: #e6d7b6; }
body.mobile-design #room #arena { border-width: 3px; }
body.mobile-design #arena .arena-content { padding: 19px; }
body.mobile-design #roomTitle { font-size: clamp(35px, 8.5vw, 49px); }
body.mobile-design #join { margin-top: 14px; }
body.mobile-design #roster #lastResult { margin-top: 3px; }

@media (max-width: 760px) {
  main { padding: 15px 13px 29px; }
  body:has(#nav:not([hidden])) main { padding-bottom: calc(20px + var(--screen-bottom-offset)); }
  .header-inner { grid-template-columns: minmax(0, 1fr) auto; gap: 9px 12px; min-height: 0; padding: 10px 14px; }
  .site-header .brand { gap: 10px; font-size: 25px; }
  .site-header .brand-mark { width: 24px; height: 24px; }
  .site-header .brand-mark::before { font-size: 14px; }
  #logout { grid-column: 2; grid-row: 1; min-height: 32px; }
  #nav {
    position: fixed;
    z-index: 8;
    inset: auto 0 0;
    align-self: auto;
    justify-content: space-evenly;
    gap: 3px;
    width: 100%;
    min-height: var(--mobile-nav-height);
    padding: 4px max(5px, env(safe-area-inset-right, 0px)) calc(4px + env(safe-area-inset-bottom, 0px)) max(5px, env(safe-area-inset-left, 0px));
    border-top: 1px solid #aa8e67;
    background: #f0e5cc;
    box-shadow: 0 -3px 14px #4a312219;
  }
  #nav a {
    flex: 1 1 0;
    grid-template-rows: 18px auto;
    align-content: center;
    gap: 3px;
    min-width: 0;
    min-height: 52px;
    padding: 4px 2px;
    border: 0;
    font-size: clamp(11px, 3.1vw, 13px);
    line-height: 1.12;
    text-align: center;
    white-space: normal;
  }
  #nav a.current { background: #e6d7b6; }
  #room #arena { border-width: 3px; }
  #arena .arena-content { padding: 19px; }
  #roomTitle { font-size: clamp(35px, 8.5vw, 49px); }
  #arena #queueStatus { margin-top: 9px; }
  #join { margin-top: 14px; }
  #room #roster { padding: 16px 13px 13px; }
  #playerList { max-height: min(320px, 48dvh); }
  #roster #lastResult { margin-top: 3px; }
  #nav:has(#navFight:not([hidden])) { display: flex; }
}

@container game (max-width: 734px) {
  #characterDetail { grid-template-columns: minmax(0, 1fr); }
  .character-details { border-inline-start: 0; padding-inline-start: 0; }
  #battle > .page-heading { position: sticky; top: 0; z-index: 2; min-height: 54px; margin-bottom: 12px; padding: 3px 0; gap: 8px; background: #f3ead5f2; }
  #battle h1 { font-size: clamp(35px, 7.7vw, 49px); }
  #battle .round-timer { min-width: 116px; padding: 5px 6px; gap: 5px; }
  #battle .round-timer span { font-size: 10px; letter-spacing: .06em; }
  #battle .round-timer strong { font-size: 21px; }
  #battle .combat-layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "folio" "move" "journal"; gap: 16px; }
  .tournament-folio {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto auto;
    grid-template-areas: "scene scene" "left right";
    min-height: 0;
    padding: 9px 9px 11px;
  }
  .duel-illustration { --illumination: 15px; height: clamp(175px, 56vw, 330px); min-height: 0; }
  .tournament-folio #fighterRight { border-inline-start: 1px solid var(--tournament-fine); }
  .tournament-folio .fighter { justify-content: flex-start; margin-top: 6px; padding: 12px 9px 5px; }
  .tournament-folio .fighter::before { display: none; }
  .tournament-folio .fighter h2 { margin-bottom: 7px; font-size: clamp(24px, 6.7vw, 31px); }
  .tournament-folio .hp-line { gap: 4px; }
  .tournament-folio .hp-line progress { height: 5px; }
  #battle #fightCenter, #battle .battle-log { padding: 13px 12px 15px; }
  #battle .action-stack { gap: 10px; }
  #battle .action-panel legend, #battle .battle-log h2 { font-size: 23px; }
  #battle .choices button { min-height: 42px; padding: 5px 6px; gap: 6px; font-size: 13px; }
  #battle #move { width: 100%; min-width: 0; margin-top: 13px; }
}

@container game (max-width: 344px) {
  #battle h1 { font-size: 32px; }
  #battle .round-timer { min-width: 103px; }
}
