:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --paper: #ffffff;
  --paper-soft: #fbfcfa;
  --ink: #1b211e;
  --muted: #68716c;
  --line: #d9dfd7;
  --line-strong: #c7d0c5;
  --green: #168556;
  --green-soft: #e4f5ec;
  --red: #c84646;
  --red-soft: #fde8e5;
  --blue: #2f67c5;
  --blue-soft: #e5efff;
  --amber: #b97715;
  --violet: #6c5fd4;
  --shadow: 0 18px 50px rgba(25, 35, 29, 0.1);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
  scroll-behavior: smooth;
}

body {
  overflow-x: hidden;
  min-width: 320px;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(47, 103, 197, 0.08), transparent 340px),
    linear-gradient(180deg, #ffffff 0, var(--bg) 330px);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  font-weight: 800;
  cursor: pointer;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    background 140ms ease,
    border-color 140ms ease;
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(47, 103, 197, 0.26);
  outline-offset: 3px;
}

button:active {
  transform: translateY(1px);
}

a {
  color: inherit;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  max-width: 100%;
  margin: 0 auto;
  padding: 28px 0 34px;
}

.is-hidden {
  display: none !important;
}

.app-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 12px 0 20px;
}

.subject-menu {
  display: grid;
  gap: 14px;
}

.menu-header {
  justify-content: space-between;
  padding-bottom: 16px;
}

.menu-header .brand {
  flex: 1 1 auto;
}

.menu-header .profile-button {
  margin-left: auto;
}

.ladder-dashboard {
  display: block;
}

.ladder-brand {
  display: grid;
  gap: 6px;
}

.ladder-brand .eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.subject-home-link {
  border: none;
  background: transparent;
  padding: 0;
  text-align: left;
  cursor: pointer;
  color: inherit;
  font: inherit;
  transition: color 0.16s ease, transform 0.16s ease;
}

.subject-home-link:hover {
  color: var(--blue);
}

.subject-home-link:hover .eyebrow {
  color: var(--blue);
}

.subject-home-link:active {
  transform: translateY(1px);
}

.subject-menu-button {
  display: inline-flex;
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(47, 103, 197, 0.34);
  border-radius: 50%;
  background: linear-gradient(180deg, #ffffff, var(--blue-soft));
  color: var(--blue);
  padding: 0;
  font-size: 1.7rem;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 12px 28px rgba(47, 103, 197, 0.18);
}

.subject-menu-button:hover {
  border-color: rgba(47, 103, 197, 0.5);
  background: var(--blue-soft);
  color: #2456a8;
  box-shadow: 0 16px 34px rgba(47, 103, 197, 0.24);
}

.trainer-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 12px 0 20px;
}

.brand,
.trainer-title-block {
  min-width: 0;
}

.brand {
  flex: 1 1 330px;
  min-width: min(100%, 330px);
}

.eyebrow,
.status-label {
  display: block;
  margin: 0 0 5px;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2.15rem, 4.7vw, 4.1rem);
  line-height: 0.96;
  letter-spacing: 0;
}

.brand h1 {
  white-space: nowrap;
}

.trainer-title-block h1 {
  font-size: clamp(1.45rem, 3vw, 2.6rem);
  line-height: 1.04;
  max-width: 760px;
}

.summary {
  display: grid;
  grid-template-columns: repeat(3, 92px);
  flex: 0 0 auto;
  gap: 8px;
}

.summary-item {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  padding: 10px 12px;
}

.summary-value {
  display: block;
  font-size: 1.5rem;
  line-height: 1;
  font-weight: 800;
}

.summary-label {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.primary-button,
.secondary-button,
.danger-button,
.icon-button,
.profile-button {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  text-decoration: none;
  white-space: nowrap;
}

.primary-button {
  background: var(--ink);
  color: #fff;
  padding: 0 18px;
  box-shadow: 0 12px 26px rgba(27, 33, 30, 0.16);
}

.primary-button:hover {
  background: #303a35;
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  padding: 0 16px;
}

.secondary-button:hover {
  border-color: var(--line-strong);
  box-shadow: 0 12px 28px rgba(25, 35, 29, 0.08);
}

.danger-button {
  background: var(--red);
  color: #fff;
  padding: 0 16px;
}

.icon-button {
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-size: 1.45rem;
  line-height: 1;
}

.profile-button {
  gap: 9px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  padding: 6px 12px 6px 7px;
  box-shadow: 0 10px 26px rgba(25, 35, 29, 0.06);
}

.profile-button:hover {
  border-color: var(--line-strong);
  box-shadow: 0 12px 28px rgba(25, 35, 29, 0.09);
}

.profile-avatar {
  display: inline-flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue-soft), var(--green-soft));
  color: var(--blue);
  font-size: 0.86rem;
  font-weight: 800;
  text-transform: uppercase;
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-label {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-strip {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 14px;
  margin: 4px 0 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 15px 16px;
  box-shadow: var(--shadow);
}

.status-strip strong {
  font-size: 1.08rem;
}

.subject-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 14px;
}

.subject-picker.is-home {
  grid-template-columns: repeat(auto-fit, minmax(190px, 238px));
  justify-content: start;
  gap: 14px;
  margin: 4px 0 16px;
}

.subject-card {
  position: relative;
  display: grid;
  min-height: 118px;
  align-content: start;
  gap: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  padding: 14px;
  text-align: left;
  box-shadow: 0 14px 34px rgba(25, 35, 29, 0.08);
}

.subject-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(180deg, rgba(14, 18, 16, 0.04) 0%, rgba(14, 18, 16, 0.08) 42%, rgba(14, 18, 16, 0.62) 100%);
  opacity: 0;
  pointer-events: none;
}

.subject-card > :not(.subject-card-image) {
  position: relative;
  z-index: 2;
}

.subject-card-image {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  pointer-events: none;
}

.subject-picker.is-home .subject-card {
  aspect-ratio: 3 / 4;
  min-height: 0;
  grid-template-rows: auto auto auto auto auto;
  align-content: start;
  gap: 7px;
  border-color: rgba(47, 103, 197, 0.2);
  background:
    linear-gradient(180deg, #ffffff 0%, #fbfcff 100%),
    var(--paper);
  color: var(--ink);
  padding: 10px;
  text-shadow: none;
  box-shadow:
    0 20px 48px rgba(25, 35, 29, 0.12),
    0 0 0 1px rgba(255, 255, 255, 0.88) inset;
}

.subject-picker.is-home .subject-card::before {
  opacity: 0;
}

.subject-picker.is-home .subject-card-image {
  position: relative;
  inset: auto;
  z-index: 1;
  display: block;
  aspect-ratio: 1.15 / 1;
  border: 1px solid rgba(25, 35, 29, 0.08);
  border-radius: 7px;
  opacity: 1;
  object-fit: cover;
  object-position: center 20%;
  box-shadow: 0 8px 20px rgba(25, 35, 29, 0.1);
}

.subject-card.is-active {
  border-color: rgba(47, 103, 197, 0.28);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(245, 249, 255, 0.94)),
    var(--paper);
}

.subject-picker.is-home .subject-card.is-active {
  border-color: rgba(47, 103, 197, 0.44);
  background:
    linear-gradient(180deg, #ffffff 0%, #f6f9ff 100%),
    var(--paper);
  box-shadow:
    0 22px 52px rgba(47, 103, 197, 0.16),
    0 0 0 1px rgba(47, 103, 197, 0.16) inset;
}

.subject-card.is-disabled {
  background: #eff2ee;
  color: var(--muted);
  opacity: 1;
  box-shadow: none;
  cursor: not-allowed;
}

.subject-card-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  padding: 4px 8px;
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
  text-shadow: none;
}

.subject-card.is-disabled .subject-card-badge {
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
}

.subject-card strong {
  max-width: calc(100% - 92px);
  font-size: 1.08rem;
  line-height: 1.08;
}

.subject-picker.is-home .subject-card strong {
  max-width: 100%;
  font-size: 1.12rem;
  line-height: 1.04;
}

.subject-card small {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.subject-picker.is-home .subject-card small {
  color: var(--muted);
  font-size: 0.82rem;
}

.subject-progress {
  height: 8px;
  margin-top: auto;
  overflow: hidden;
  border-radius: 999px;
  background: #e4ebe2;
}

.subject-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--green));
}

.subject-card.is-disabled .subject-progress span {
  background: #c8d0c7;
}

.subject-card em {
  color: var(--muted);
  font-size: 0.78rem;
  font-style: normal;
  font-weight: 900;
}

.subject-picker.is-home .subject-card em {
  color: var(--muted);
}

.subject-poll {
  display: grid;
  gap: 12px;
  margin: 0 0 14px;
  border: 1px solid rgba(47, 103, 197, 0.18);
  border-radius: 8px;
  background: var(--paper);
  padding: 14px;
  box-shadow: 0 14px 34px rgba(25, 35, 29, 0.07);
}

.subject-poll-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.subject-poll .subject-card-badge {
  position: static;
  display: inline-flex;
  width: fit-content;
  margin: 0 0 7px;
}

.subject-poll strong,
.subject-poll small {
  display: block;
}

.subject-poll strong {
  font-size: 1.02rem;
  line-height: 1.12;
}

.subject-poll small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.subject-poll-form {
  display: grid;
  gap: 12px;
}

.subject-poll-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.subject-poll-option {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-soft);
  padding: 9px 10px;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 800;
  cursor: pointer;
}

.subject-poll-option:has(input:checked) {
  border-color: rgba(47, 103, 197, 0.36);
  background: var(--blue-soft);
  color: var(--blue);
}

.subject-poll-option input {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
}

.subject-poll-actions {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.source-pill {
  border: 1px solid rgba(47, 103, 197, 0.2);
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  padding: 9px 12px;
  font-size: 0.82rem;
  font-weight: 800;
  text-decoration: none;
}

.royale-entry {
  margin: 0 0 14px;
}

.royale-entry-button {
  display: grid;
  width: 100%;
  min-width: 0;
  min-height: 72px;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  border: 1px solid rgba(27, 33, 30, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(47, 103, 197, 0.11), rgba(22, 133, 86, 0.1)),
    var(--paper);
  color: var(--ink);
  padding: 16px 18px;
  text-align: left;
  box-shadow: 0 16px 42px rgba(25, 35, 29, 0.08);
}

.royale-entry-button span {
  font-size: clamp(1.1rem, 2vw, 1.44rem);
  font-weight: 900;
}

.royale-entry-button strong {
  justify-self: end;
  max-width: 100%;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  padding: 7px 10px;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
}

.source-control {
  min-width: 250px;
}

.source-switch {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 250px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #eef2ec;
  padding: 4px;
}

.source-switch-thumb {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc(50% - 4px);
  border-radius: 999px;
  background: var(--paper);
  box-shadow: 0 8px 22px rgba(25, 35, 29, 0.12);
  transition: transform 180ms ease;
}

.source-switch[data-source="shkolkovo"] .source-switch-thumb {
  transform: translateX(100%);
}

.source-switch.is-single-source {
  grid-template-columns: 1fr;
  width: auto;
  min-width: 168px;
  max-width: 100%;
}

.source-switch.is-single-source .source-switch-thumb {
  display: none;
}

.source-option {
  position: relative;
  z-index: 1;
  min-height: 34px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.86rem;
  box-shadow: none;
}

.source-option-badge {
  display: inline-flex;
  align-items: center;
  min-height: 16px;
  margin-left: 5px;
  border-radius: 999px;
  background: rgba(47, 103, 197, 0.12);
  color: var(--blue);
  padding: 0 6px;
  font-size: 0.64rem;
  font-weight: 900;
  text-transform: uppercase;
  vertical-align: 1px;
}

.source-option.is-active {
  color: var(--ink);
}

.task-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(258px, 1fr));
  gap: 14px;
}

.battle {
  width: min(100%, 980px);
  margin: 0 auto;
}

.battle-timer {
  display: inline-flex;
  min-width: 82px;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font-size: 1.16rem;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(25, 35, 29, 0.07);
}

.battle-panel {
  display: grid;
  gap: 14px;
}

.royale-panel {
  align-items: start;
}

.battle-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 16px;
  box-shadow: 0 16px 42px rgba(25, 35, 29, 0.08);
}

.battle-card h2 {
  margin: 0 0 8px;
  font-size: 1.32rem;
}

.battle-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.royale-lobby-card {
  display: grid;
  gap: 10px;
}

.royale-players {
  display: grid;
  gap: 8px;
}

.royale-players.is-compact {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.royale-player-row,
.royale-room-row,
.royale-placement {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-soft);
  padding: 10px;
}

.royale-player-row.is-you {
  border-color: rgba(47, 103, 197, 0.34);
  background: #f6f9ff;
}

.royale-player-row.is-eliminated,
.royale-placement.is-eliminated {
  border-color: rgba(211, 47, 47, 0.42);
  background: #fff4f4;
}

.royale-player-row.is-eliminated .friend-main strong,
.royale-placement.is-eliminated .friend-main strong,
.royale-player-row.is-eliminated .royale-player-score strong {
  color: #9f1d1d;
}

.royale-player-row.is-eliminated .friend-main span,
.royale-placement.is-eliminated .friend-main span {
  color: #b13636;
}

.royale-player-row.is-ghost,
.royale-placement.is-ghost {
  border-style: dashed;
}

.royale-player-row.is-left,
.royale-placement.is-left {
  opacity: 0.72;
}

.royale-player-score {
  display: grid;
  justify-items: end;
  gap: 1px;
  min-width: 54px;
}

.royale-player-score strong {
  font-size: 1.04rem;
}

.royale-player-score span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.royale-placements {
  display: grid;
  gap: 8px;
}

.royale-placement > strong:first-child {
  display: inline-flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
}

.battle-reconnect-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid rgba(47, 103, 197, 0.24);
  border-radius: 8px;
  background: #f6f9ff;
  padding: 10px;
}

.battle-reconnect-card div {
  display: grid;
  gap: 2px;
}

.battle-reconnect-card strong {
  font-weight: 900;
}

.battle-reconnect-card span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.battle-rule-chip {
  display: inline-flex;
  width: fit-content;
  border: 1px solid rgba(47, 103, 197, 0.2);
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  padding: 5px 9px;
  margin: 0 0 10px;
  font-size: 0.76rem;
  font-weight: 900;
}

.battle-status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.fighter-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-soft);
  padding: 10px;
}

.fighter-avatar {
  display: inline-flex;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue-soft), var(--green-soft));
  color: var(--blue);
  font-size: 0.84rem;
  font-weight: 800;
  text-transform: uppercase;
}

.fighter-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.fighter-name {
  min-width: 0;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.fighter-state {
  border-radius: 999px;
  background: #eff2ee;
  color: var(--muted);
  padding: 6px 9px;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  white-space: nowrap;
}

.fighter-state.is-ready {
  background: var(--green-soft);
  color: var(--green);
}

.battle-actions,
.battle-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.battle-answer-form {
  position: sticky;
  bottom: 14px;
  z-index: 4;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  border: 1px solid rgba(199, 208, 197, 0.92);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  padding: 10px;
  box-shadow: 0 18px 44px rgba(25, 35, 29, 0.14);
  backdrop-filter: blur(12px);
}

.battle-answer-form input,
.invite-link-input {
  min-width: 0;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 14px;
  font-weight: 700;
}

.invite-box {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.round-recap {
  display: grid;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-soft);
  padding: 12px;
}

.round-recap-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-weight: 800;
}

.round-recap-row strong {
  color: var(--ink);
}

.battle-result {
  border-color: rgba(47, 103, 197, 0.24);
  background: linear-gradient(180deg, #ffffff, #f6f9ff);
}

.battle-result.is-win {
  border-color: rgba(22, 133, 86, 0.36);
  background: linear-gradient(180deg, #ffffff, #f4fbf7);
}

.battle-result.is-loss {
  border-color: rgba(200, 70, 70, 0.38);
  background: linear-gradient(180deg, #ffffff, #fff7f6);
}

.battle-full-review {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 16px;
  box-shadow: 0 16px 42px rgba(25, 35, 29, 0.08);
}

.battle-full-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.battle-full-head h2 {
  margin: 0;
  font-size: 1.2rem;
}

.battle-full-head strong {
  border-radius: 8px;
  background: var(--paper-soft);
  padding: 8px 12px;
  font-size: 1.2rem;
}

.battle-result-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.battle-result-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.battle-result-table th,
.battle-result-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

.battle-result-table th {
  background: var(--paper-soft);
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
}

.battle-result-table tr:last-child td {
  border-bottom: 0;
}

.battle-result-table .is-wrong {
  color: #b54343;
  font-weight: 900;
}

.battle-personal-reviews {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.battle-player-review {
  display: grid;
  gap: 8px;
  align-content: start;
}

.battle-player-review h3 {
  margin: 0;
  font-size: 1rem;
}

.battle-task-detail {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-soft);
  overflow: hidden;
}

.battle-task-detail.is-wrong {
  border-color: rgba(200, 70, 70, 0.72);
  box-shadow: inset 0 0 0 1px rgba(200, 70, 70, 0.18);
}

.battle-task-detail summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  cursor: pointer;
  padding: 10px 12px;
  font-weight: 900;
}

.battle-task-detail summary::-webkit-details-marker {
  display: none;
}

.battle-task-detail summary span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.battle-task-detail summary strong {
  color: var(--muted);
  white-space: nowrap;
}

.battle-task-detail[open] {
  background: #fff;
}

.battle-task-detail > .question-panel,
.battle-task-detail > .solution-body,
.battle-detail-answers {
  margin: 0 12px 12px;
}

.battle-detail-answers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 34px auto 0;
  color: rgba(27, 33, 30, 0.62);
}

.footer-rule {
  width: min(110px, 18vw);
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(104, 113, 108, 0.32), transparent);
}

.kaizer-link {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  transition:
    color 140ms ease,
    transform 140ms ease;
}

.kaizer-link:hover {
  color: rgba(27, 33, 30, 0.84);
  transform: translateY(-1px);
}

.kaizer-link:hover .kaizer-mark {
  opacity: 1;
}

.kaizer-mark {
  display: inline-flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid rgba(27, 33, 30, 0.08);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(25, 35, 29, 0.12);
  opacity: 0.9;
}

.kaizer-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.kaizer-wordmark {
  font-family: Manrope, Inter, system-ui, sans-serif;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  white-space: nowrap;
}

.task-card {
  display: grid;
  min-width: 0;
  min-height: 286px;
  grid-template-rows: auto auto auto auto auto 1fr auto;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 16px;
  box-shadow: 0 12px 34px rgba(25, 35, 29, 0.06);
}

.task-card.is-done {
  border-color: rgba(22, 133, 86, 0.32);
  background: linear-gradient(180deg, #ffffff, #f7fcf9);
}

.task-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.task-num,
.task-state {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.task-num {
  color: var(--blue);
}

.task-state {
  border-radius: 999px;
  background: #eff2ee;
  color: var(--muted);
  padding: 6px 9px;
}

.task-card.is-done .task-state {
  background: var(--green-soft);
  color: var(--green);
}

.task-card.is-self-check .task-state {
  background: #fff6d6;
  color: #9b7310;
}

.task-card h2 {
  min-height: 52px;
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.22;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.task-source {
  min-height: 36px;
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.task-practice-mark {
  display: inline-flex;
  width: max-content;
  min-height: 18px;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  background: #fff7df;
  color: #a66d04;
  padding: 2px 7px;
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1;
}

.task-practice-mark.is-empty {
  visibility: hidden;
}

.task-progress {
  overflow: hidden;
  height: 12px;
  border-radius: 999px;
  background: #edf1eb;
}

.task-progress-fill {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--green));
  transition: width 180ms ease;
}

.task-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

.task-stats div {
  min-width: 0;
  border-radius: 8px;
  background: var(--paper-soft);
  padding: 8px 9px;
}

.task-stats strong,
.task-stats span {
  display: block;
}

.task-stats strong {
  font-size: 1.05rem;
}

.task-stats span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
}

.train-button {
  width: 100%;
  align-self: end;
}

.battle-waiting {
  display: flex;
  min-height: 34px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-radius: 8px;
  background: #f3f6f1;
  color: var(--muted);
  padding: 8px 10px;
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.battle-waiting strong {
  color: var(--blue);
  font-size: 0.95rem;
}

.task-card.is-self-check .battle-waiting strong {
  color: #9b7310;
}

.task-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  align-self: end;
}

.task-actions .train-button {
  align-self: auto;
}

.skeleton-card {
  min-height: 190px;
}

.trainer {
  width: min(100%, 980px);
  margin: 0 auto;
}

.trainer-header {
  grid-template-columns: auto 1fr auto;
}

.source-link {
  min-width: 102px;
}

.source-link.is-disabled {
  pointer-events: none;
  opacity: 0.55;
  box-shadow: none;
}

.ladder-bar {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 14px;
  box-shadow: var(--shadow);
}

.streak-score {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 86px;
}

.streak-score span {
  font-size: 2.2rem;
  line-height: 1;
  font-weight: 800;
}

.streak-score small {
  color: var(--muted);
  font-weight: 800;
}

.step-rail {
  display: grid;
  grid-template-columns: repeat(10, minmax(13px, 1fr));
  gap: 7px;
}

.step-rail span {
  height: 13px;
  border-radius: 999px;
  background: #e7ece4;
  box-shadow: inset 0 0 0 1px rgba(25, 35, 29, 0.04);
}

.step-rail .is-filled {
  background: linear-gradient(90deg, var(--blue), var(--green));
}

.step-rail .is-current {
  background: var(--amber);
}

.step-rail .is-failed {
  background: var(--red);
}

.question-panel {
  position: relative;
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 18px;
  box-shadow: 0 16px 42px rgba(25, 35, 29, 0.08);
}

.question-draw-tools {
  position: absolute;
  top: 50%;
  left: 0;
  z-index: 5;
  display: grid;
  gap: 5px;
  transform: translate(calc(-100% + 12px), -50%);
}

.draw-tool-button {
  display: grid;
  width: 25px;
  min-width: 25px;
  height: 34px;
  min-height: 34px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0;
  box-shadow: 6px 8px 16px rgba(25, 35, 29, 0.08);
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.draw-tool-button[aria-pressed="true"] {
  transform: translateX(1px);
}

.draw-hand-button {
  border-color: rgba(47, 103, 197, 0.28);
  background: #e8f0ff;
  color: var(--blue);
}

.draw-hand-button[aria-pressed="true"] {
  border-color: rgba(47, 103, 197, 0.3);
  background: var(--blue);
  color: #fff;
}

.draw-toggle-button {
  border-color: rgba(184, 74, 74, 0.3);
  background: #fff1f1;
  color: #c85c5c;
}

.draw-toggle-button[aria-pressed="true"] {
  border-color: rgba(184, 74, 74, 0.34);
  background: #c85c5c;
  color: #fff;
}

.draw-eraser-button {
  border-color: rgba(185, 134, 18, 0.34);
  background: #fff6d6;
  color: #b98612;
}

.draw-eraser-button[aria-pressed="true"] {
  border-color: rgba(185, 134, 18, 0.34);
  background: #d6a51d;
  color: #fff;
}

.draw-size-control {
  position: relative;
  display: grid;
}

.draw-size-button {
  display: grid;
  width: 25px;
  min-width: 25px;
  height: 25px;
  min-height: 25px;
  place-items: center;
  border: 1px solid rgba(112, 123, 116, 0.24);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 6px 8px 16px rgba(25, 35, 29, 0.08);
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.draw-size-button.is-draw-size {
  border-color: rgba(184, 74, 74, 0.24);
}

.draw-size-button.is-erase-size {
  border-color: rgba(185, 134, 18, 0.28);
}

.draw-size-button[aria-expanded="true"] {
  background: #fff;
  transform: translateX(1px);
}

.draw-size-dot {
  display: block;
  width: var(--draw-size-dot, 7px);
  height: var(--draw-size-dot, 7px);
  border-radius: 999px;
  background: #c85c5c;
  transition: width 0.16s ease, height 0.16s ease, background 0.16s ease;
}

.draw-size-button.is-erase-size .draw-size-dot {
  background: #d6a51d;
}

.draw-size-menu {
  position: absolute;
  top: 50%;
  left: calc(100% + 6px);
  z-index: 8;
  display: grid;
  gap: 4px;
  transform: translateY(-50%);
  border: 1px solid rgba(112, 123, 116, 0.2);
  border-radius: 999px;
  padding: 5px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 28px rgba(25, 35, 29, 0.15);
}

.draw-size-menu[hidden] {
  display: none !important;
}

.draw-size-choice {
  display: grid;
  width: 25px;
  min-width: 25px;
  height: 25px;
  min-height: 25px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0;
  background: transparent;
}

.draw-size-choice[aria-pressed="true"] {
  border-color: rgba(47, 103, 197, 0.24);
  background: #edf4ff;
}

.draw-size-choice-dot {
  display: block;
  width: var(--draw-size-choice-dot, 7px);
  height: var(--draw-size-choice-dot, 7px);
  border-radius: 999px;
  background: #c85c5c;
}

.draw-size-menu.is-erase-size .draw-size-choice-dot {
  background: #d6a51d;
}

.self-check-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.self-check-actions.is-hidden {
  display: none !important;
}

.draw-icon {
  display: block;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.05;
}

.question-canvas {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  pointer-events: none;
}

.question-panel.is-canvas-active .question-canvas {
  pointer-events: auto;
  touch-action: none;
}

.question-panel.is-draw-mode .question-canvas {
  cursor: crosshair;
}

.question-panel.is-erase-mode .question-canvas {
  cursor: cell;
}

.question-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.question-meta a {
  color: var(--blue);
  text-decoration: none;
}

.battle-code-hidden {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.question-body {
  min-height: 260px;
  color: #222825;
  font-size: 1rem;
  line-height: 1.62;
  overflow-wrap: anywhere;
}

.question-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.question-actions .primary-button {
  min-width: 138px;
}

.passage-panel {
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-soft);
  overflow: hidden;
}

.passage-panel summary {
  display: flex;
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 13px;
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
  list-style: none;
}

.passage-panel summary::-webkit-details-marker {
  display: none;
}

.passage-panel summary strong {
  color: var(--blue);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.passage-panel summary .open-label {
  display: none;
}

.passage-panel[open] summary {
  border-bottom: 1px solid var(--line);
}

.passage-panel[open] summary .closed-label {
  display: none;
}

.passage-panel[open] summary .open-label {
  display: inline;
}

.passage-body {
  max-height: min(58vh, 620px);
  overflow: auto;
  padding: 14px;
  background: #fff;
  color: #222825;
  font-size: 0.98rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.task-files {
  margin: 0 0 14px;
  padding: 12px;
  border: 1px solid #d5dde5;
  border-radius: 8px;
  background: #fbfcfd;
}

.task-files-title {
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.task-file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.task-file-link {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 8px 10px;
  border: 1px solid #c8d3df;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 800;
  text-decoration: none;
}

.task-file-link span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-file-link strong {
  color: var(--blue);
  font-size: 0.76rem;
  text-transform: uppercase;
}

.question-body p,
.passage-body p {
  margin: 0 0 0.82em;
}

.question-body img,
.passage-body img {
  max-width: 100%;
  height: auto;
}

.question-body:has(img),
.passage-body:has(img) {
  overflow: hidden;
}

.question-body:has(img) > p,
.passage-body:has(img) > p {
  margin: 0;
}

.question-body:has(img) img,
.passage-body:has(img) img {
  float: right;
  clear: right;
  max-width: min(420px, 46%);
  margin: 0 0 12px 24px;
}

.question-body table:has(img),
.passage-body table:has(img) {
  display: table;
  width: 100% !important;
  max-width: 100%;
  border-collapse: collapse;
  border: none;
}

.question-body table:has(img) td,
.question-body table:has(img) th,
.passage-body table:has(img) td,
.passage-body table:has(img) th {
  border: none;
  padding: 0;
  vertical-align: top;
}

.question-body table:has(img) td:first-child,
.passage-body table:has(img) td:first-child {
  padding-right: 24px;
}

.question-body table:has(img) td:last-child,
.passage-body table:has(img) td:last-child {
  width: 42%;
  text-align: right;
}

.question-body table:has(img) img,
.passage-body table:has(img) img {
  float: none;
  max-width: min(420px, 100%);
  margin: 0;
}

.question-body table:not(:has(img)),
.passage-body table:not(:has(img)) {
  display: block;
  width: 100% !important;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
}

.question-body table:not(:has(img)) tbody,
.passage-body table:not(:has(img)) tbody {
  display: table;
  min-width: 100%;
}

.question-body table:not(:has(img)) td,
.question-body table:not(:has(img)) th,
.passage-body table:not(:has(img)) td,
.passage-body table:not(:has(img)) th {
  border: 1px solid var(--line);
  padding: 7px 8px;
  vertical-align: top;
}

.question-body .left_margin,
.passage-body .left_margin {
  margin-left: 0;
}

.question-body img.math,
.passage-body img.math {
  display: inline-block;
  float: none;
  clear: none;
  width: auto;
  max-width: 100%;
  height: 1.45em;
  margin: 0 0.12em;
  vertical-align: -0.34em;
}

.solution-body img.math,
.correct-answer-value img.math {
  display: inline-block;
  float: none;
  clear: none;
  width: auto;
  max-width: 100%;
  height: 1.25em;
  margin: 0 0.1em;
  vertical-align: -0.26em;
}

.question-body img.math {
  height: 1.6em;
  vertical-align: -0.42em;
}

.question-body img.math-display,
.passage-body img.math-display,
.solution-body img.math-display,
.correct-answer-value img.math-display {
  display: block;
  float: none;
  clear: both;
  width: auto;
  max-width: 100%;
  height: auto;
  margin: 0.72em auto;
}

.math-fallback {
  display: inline;
  color: var(--ink);
  font-weight: 750;
  white-space: pre-wrap;
}

.math-fallback-display {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 0.72em auto;
  white-space: pre-wrap;
  text-align: center;
}

.image-fallback {
  display: grid;
  min-height: 96px;
  place-items: center;
  border: 1px dashed rgba(112, 123, 116, 0.42);
  border-radius: 8px;
  background: rgba(246, 248, 244, 0.86);
  color: var(--muted);
  padding: 14px;
  font-size: 0.86rem;
  font-weight: 800;
  text-align: center;
}

.answer-dock {
  position: sticky;
  bottom: 14px;
  z-index: 4;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 14px;
  border: 1px solid rgba(199, 208, 197, 0.92);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  padding: 10px;
  box-shadow: 0 18px 44px rgba(25, 35, 29, 0.14);
  backdrop-filter: blur(12px);
}

.answer-dock input {
  min-width: 0;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 14px;
  font-size: 1.02rem;
  font-weight: 700;
}

.feedback-panel {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 16px;
  box-shadow: 0 16px 42px rgba(25, 35, 29, 0.08);
}

.feedback-panel.is-correct {
  border-color: rgba(22, 133, 86, 0.36);
  background: linear-gradient(180deg, #ffffff, #f4fbf7);
}

.feedback-panel.is-wrong {
  border-color: rgba(200, 70, 70, 0.38);
  background: linear-gradient(180deg, #ffffff, #fff7f6);
}

.feedback-head {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.result-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 1.35rem;
  font-weight: 800;
}

.feedback-panel.is-correct .result-mark {
  background: var(--green-soft);
  color: var(--green);
}

.feedback-panel.is-wrong .result-mark {
  background: var(--red-soft);
  color: var(--red);
}

.feedback-title,
.feedback-subtitle {
  margin: 0;
}

.feedback-title {
  font-size: 1.25rem;
  font-weight: 800;
}

.feedback-subtitle {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.answer-reveal {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  border-radius: 8px;
  background: var(--paper-soft);
  padding: 11px 12px;
  margin-bottom: 12px;
}

.answer-reveal + .answer-reveal {
  margin-top: -4px;
}

.answer-reveal span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
}

.answer-reveal strong,
.correct-answer-value {
  overflow-wrap: anywhere;
}

.correct-answer-value img {
  max-width: 100%;
  height: auto;
  vertical-align: middle;
}

.solution-body {
  color: #26312d;
  line-height: 1.58;
  overflow-wrap: anywhere;
}

.solution-body img {
  max-width: 100%;
  height: auto;
}

.battle-review-panel {
  margin-top: 14px;
}

.battle-review-question {
  margin: 0 0 12px;
  box-shadow: none;
}

.solution-body p {
  margin: 0 0 0.78em;
}

.solution-body table {
  display: block;
  width: 100% !important;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
}

.solution-body tbody {
  display: table;
  min-width: 100%;
}

.solution-body td,
.solution-body th {
  border: 1px solid var(--line);
  padding: 7px 8px;
}

.session-mistakes {
  display: grid;
  gap: 9px;
  margin-top: 14px;
}

.session-mistakes h3 {
  margin: 0;
  font-size: 1rem;
}

.session-mistake-item {
  overflow: hidden;
  border: 1px solid rgba(200, 70, 70, 0.28);
  border-radius: 8px;
  background: #fff;
}

.session-mistake-item summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 44px;
  cursor: pointer;
  padding: 10px 12px;
  font-weight: 900;
  list-style: none;
}

.session-mistake-item summary::-webkit-details-marker {
  display: none;
}

.session-mistake-item summary span {
  color: var(--muted);
  font-size: 0.84rem;
  overflow-wrap: anywhere;
}

.session-mistake-item summary strong {
  color: var(--red);
  white-space: nowrap;
}

.session-mistake-answers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 0 12px 12px;
}

.session-mistake-answers .answer-reveal {
  margin: 0;
}

.session-mistake-question {
  margin: 0 12px 12px;
  box-shadow: none;
}

.feedback-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.loading {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(245, 247, 244, 0.72);
  backdrop-filter: blur(8px);
}

.loading-card {
  display: grid;
  width: min(360px, calc(100vw - 40px));
  gap: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.loading-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.loader {
  width: 24px;
  height: 24px;
  border: 3px solid var(--line);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 720ms linear infinite;
}

.loading-progress {
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: #edf1eb;
}

.loading-progress span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--green));
  transition: width 240ms ease;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 40;
  max-width: min(380px, calc(100vw - 40px));
  border-radius: 8px;
  background: #1f2925;
  color: #fff;
  padding: 14px 16px;
  box-shadow: 0 20px 46px rgba(0, 0, 0, 0.22);
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.confirm-dialog,
.account-dialog,
.battle-dialog,
.training-dialog,
.leaderboard-dialog,
.friends-dialog,
.username-dialog,
.admin-dialog {
  width: min(430px, calc(100% - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
  box-shadow: 0 26px 76px rgba(0, 0, 0, 0.24);
}

.account-dialog,
.battle-dialog,
.training-dialog,
.friends-dialog,
.username-dialog {
  width: min(620px, calc(100% - 32px));
}

.royale-dialog {
  width: min(760px, calc(100% - 32px));
}

.leaderboard-dialog,
.admin-dialog {
  width: min(920px, calc(100% - 32px));
}

.confirm-dialog::backdrop,
.account-dialog::backdrop,
.battle-dialog::backdrop,
.training-dialog::backdrop,
.leaderboard-dialog::backdrop,
.friends-dialog::backdrop,
.username-dialog::backdrop,
.admin-dialog::backdrop {
  background: rgba(18, 24, 21, 0.44);
}

.confirm-dialog form {
  padding: 22px;
}

.confirm-dialog h2 {
  margin: 0 0 8px;
  font-size: 1.28rem;
}

.confirm-dialog p {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.45;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.account-shell {
  padding: 20px;
}

.battle-setup,
.leaderboard-shell,
.friends-shell,
.username-shell,
.admin-shell {
  padding: 20px;
}

.royale-setup {
  display: grid;
  gap: 14px;
}

.royale-mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef2ec;
  padding: 5px;
}

.royale-mode-tab {
  min-height: 40px;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}

.royale-mode-tab.is-active {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 8px 20px rgba(25, 35, 29, 0.1);
}

.royale-dialog-panel {
  display: grid;
  gap: 12px;
}

.royale-dialog-panel h3,
.royale-dialog-subhead h3 {
  margin: 0;
  font-size: 1rem;
}

.royale-dialog-subhead {
  margin-bottom: 0;
}

.dialog-note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.royale-room-list {
  display: grid;
  max-height: 360px;
  gap: 8px;
  overflow: auto;
}

.royale-room-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.royale-room-row div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.royale-room-row strong,
.royale-room-row span {
  overflow-wrap: anywhere;
}

.royale-room-row span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.royale-task-picker {
  display: grid;
  max-height: 260px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  overflow: auto;
  padding-right: 2px;
}

.royale-task-option {
  display: grid;
  min-height: 104px;
  align-content: start;
  gap: 4px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-soft);
  color: var(--ink);
  padding: 10px;
  text-align: left;
  box-shadow: none;
}

.royale-task-option.is-active {
  border-color: rgba(47, 103, 197, 0.44);
  background: #f6f9ff;
  box-shadow: inset 0 0 0 1px rgba(47, 103, 197, 0.16);
}

.royale-task-option strong {
  color: var(--blue);
}

.royale-task-option span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.3;
  overflow-wrap: anywhere;
  white-space: normal;
}

.dialog-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.dialog-top h2 {
  margin: 0;
  font-size: 1.35rem;
}

.close-dialog-button {
  width: 42px;
  height: 42px;
  min-height: 42px;
  font-size: 1.6rem;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef2ec;
  padding: 5px;
  margin-bottom: 14px;
}

.auth-tab {
  min-height: 38px;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}

.auth-tab.is-active {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 8px 20px rgba(25, 35, 29, 0.1);
}

.auth-form,
.profile-form {
  display: grid;
  gap: 12px;
}

.auth-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.92rem;
  font-weight: 700;
}

.text-button {
  min-height: auto;
  justify-self: start;
  border: 0;
  background: transparent;
  color: var(--blue);
  padding: 0;
  box-shadow: none;
  font-size: 0.9rem;
  font-weight: 900;
}

.text-button:hover {
  text-decoration: underline;
  box-shadow: none;
}

.auth-forgot-button {
  margin-top: -4px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.field input,
.field select {
  min-width: 0;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 13px;
  font-weight: 700;
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-size: 0.86rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.form-message.is-success {
  color: var(--green);
}

.profile-head {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: center;
  margin-bottom: 16px;
}

.avatar-upload {
  position: relative;
  display: grid;
  width: 82px;
  height: 82px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue-soft), var(--green-soft));
  color: var(--blue);
  cursor: pointer;
}

.avatar-upload img {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-upload.has-photo img {
  display: block;
}

.avatar-upload.has-photo span {
  display: none;
}

.avatar-upload input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.avatar-upload span {
  font-size: 1.6rem;
  font-weight: 800;
  text-transform: uppercase;
}

.profile-name,
.profile-email,
.profile-username {
  margin: 0;
}

.profile-name {
  font-size: 1.3rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.profile-email {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.profile-username {
  margin-top: 4px;
  color: var(--blue);
  font-size: 0.9rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.profile-form {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  margin-bottom: 14px;
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.profile-stats div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-soft);
  padding: 11px;
}

.profile-stats strong,
.profile-stats span {
  display: block;
}

.profile-stats strong {
  font-size: 1.35rem;
}

.profile-stats span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.profile-chart {
  min-height: 190px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  overflow: hidden;
}

.profile-chart svg {
  display: block;
  width: 100%;
  height: 180px;
}

.profile-chart text {
  fill: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.profile-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

.dialog-note {
  margin: -4px 0 14px;
  color: var(--muted);
  line-height: 1.45;
  font-weight: 700;
}

.username-shell {
  display: grid;
  gap: 12px;
}

.username-field input {
  font-weight: 800;
  text-transform: lowercase;
}

#friendsButton {
  position: relative;
}

#friendsButton.has-activity::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
}

.friends-login-card {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
  border: 1px solid rgba(47, 103, 197, 0.2);
  border-radius: 8px;
  background: var(--blue-soft);
  padding: 12px;
}

.friends-login-card span,
.friend-status {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.friends-login-card strong {
  color: var(--blue);
  font-size: 1.1rem;
  overflow-wrap: anywhere;
}

.friend-add-form,
.battle-friend-invite {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.friends-sections {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.friends-section {
  display: grid;
  gap: 8px;
}

.friends-section h3 {
  margin: 0;
  font-size: 0.98rem;
}

.friend-list {
  display: grid;
  gap: 8px;
}

.friend-row,
.battle-invite-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-soft);
  padding: 10px;
}

.friend-main {
  min-width: 0;
}

.friend-main strong,
.friend-main span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.friend-main span {
  margin-top: 3px;
  color: var(--blue);
  font-size: 0.82rem;
  font-weight: 800;
}

.friend-main .friend-meta {
  display: flex;
  min-width: 0;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px 7px;
  margin-top: 3px;
  overflow: visible;
  white-space: normal;
}

.friend-main .friend-meta > span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 0;
}

.friend-main .friend-meta .friend-identity {
  color: var(--blue);
}

.friend-main .friend-extra-badge,
.friend-main .activity-status,
.friend-main .device-badge {
  display: inline-flex;
  flex: 0 1 auto;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.friend-main .friend-extra-badge {
  max-width: min(220px, 100%);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  padding: 3px 7px;
  font-size: 0.72rem;
  line-height: 1.15;
}

.friend-main .friend-status-line {
  display: flex;
  min-width: 0;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 4px;
  overflow: visible;
  white-space: normal;
}

.friend-main .device-badge {
  display: inline-grid;
  width: 24px;
  height: 22px;
  place-items: center;
  border-radius: 6px;
  background: rgba(47, 103, 197, 0.08);
  color: var(--blue);
  overflow: visible;
}

.friend-main .device-badge i {
  position: relative;
  display: block;
  transform: translateY(2px);
}

.friend-main .device-badge.is-desktop i {
  width: 13px;
  height: 8px;
  border: 1.8px solid currentColor;
  border-radius: 3px;
}

.friend-main .device-badge.is-desktop i::after {
  position: absolute;
  left: 50%;
  bottom: -5px;
  width: 8px;
  height: 1.8px;
  border-radius: 999px;
  background: currentColor;
  content: "";
  transform: translateX(-50%);
}

.friend-main .device-badge.is-mobile i {
  width: 9px;
  height: 14px;
  border: 1.8px solid currentColor;
  border-radius: 4px;
}

.friend-main .device-badge.is-mobile i::after {
  position: absolute;
  left: 50%;
  bottom: 1px;
  width: 3px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  content: "";
  transform: translateX(-50%);
}

.friend-main .activity-status {
  max-width: min(260px, 100%);
  color: var(--blue);
  font-size: 0.74rem;
  line-height: 1.2;
  opacity: 0.72;
}

.friend-main .activity-status.is-training,
.friend-main .activity-status.is-review {
  color: var(--blue);
}

.friend-main .activity-status.is-battle {
  color: var(--blue);
}

.friend-main .activity-status.is-royale {
  color: var(--blue);
}

.friend-main .activity-status.is-afk {
  color: #1e5fce;
}

.online-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 4;
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--paper);
  background: #9aa39e;
  box-shadow: 0 1px 2px rgba(25, 35, 29, 0.18);
  pointer-events: none;
}

.online-dot.is-online {
  background: var(--green);
  box-shadow: 0 1px 2px rgba(22, 133, 86, 0.22);
}

.online-dot.is-offline {
  background: #9aa39e;
  box-shadow: 0 1px 2px rgba(154, 163, 158, 0.22);
}

.online-dot.is-afk {
  background: #2367d6;
  box-shadow: 0 1px 2px rgba(35, 103, 214, 0.22);
}

.friend-avatar,
.battle-toast-avatar {
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue-soft), var(--green-soft));
  color: var(--blue);
  font-weight: 900;
  text-transform: uppercase;
}

.avatar-shell {
  position: relative;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  overflow: visible;
  flex: 0 0 auto;
}

.friend-avatar {
  width: 42px;
  height: 42px;
}

.friend-avatar img,
.battle-toast-avatar img {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

.friend-actions {
  display: flex;
  gap: 7px;
}

.friend-actions button {
  min-height: 36px;
  padding: 0 11px;
  font-size: 0.82rem;
}

.battle-invite-row {
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.battle-invite-stack {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 55;
  display: grid;
  gap: 10px;
  width: min(340px, calc(100vw - 36px));
  pointer-events: none;
}

.battle-invite-toast {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  padding: 10px;
  box-shadow: 0 18px 48px rgba(25, 35, 29, 0.18);
  opacity: 0;
  pointer-events: auto;
  transform: translateY(-10px);
  transition:
    opacity 220ms ease,
    transform 220ms ease;
}

.battle-invite-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.battle-invite-toast.is-hiding {
  opacity: 0;
  transform: translateY(-10px);
}

.battle-toast-avatar {
  width: 38px;
  height: 38px;
}

.battle-toast-text {
  min-width: 0;
}

.battle-toast-text strong,
.battle-toast-text span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.battle-toast-text span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.battle-invite-toast button {
  min-height: 34px;
  padding: 0 11px;
  font-size: 0.82rem;
}

.battle-friend-panel {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.battle-friend-panel h3 {
  margin: 0;
  font-size: 0.98rem;
}

.admin-grid {
  display: grid;
  gap: 12px;
}

.admin-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-soft);
  padding: 12px;
}

.admin-card h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.admin-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.admin-metric {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.admin-metric strong,
.admin-metric span {
  display: block;
}

.admin-metric strong {
  font-size: 1.25rem;
}

.admin-metric span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.admin-list {
  display: grid;
  gap: 8px;
  max-height: 330px;
  overflow: auto;
  padding-right: 4px;
}

.admin-poll-table {
  display: grid;
  gap: 8px;
  margin: 10px 0 12px;
}

.admin-poll-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(120px, 2fr) 52px;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 9px 10px;
}

.admin-poll-row strong,
.admin-poll-row span,
.admin-poll-row em {
  display: block;
}

.admin-poll-row strong {
  font-size: 0.9rem;
}

.admin-poll-row span,
.admin-poll-row em {
  color: var(--muted);
  font-size: 0.76rem;
  font-style: normal;
  font-weight: 800;
}

.admin-poll-row em {
  color: var(--blue);
  text-align: right;
}

.admin-poll-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5ebe3;
}

.admin-poll-bar span {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--green));
}

.admin-poll-recent {
  max-height: 210px;
}

.admin-user-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(170px, auto);
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.admin-user-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.admin-user-stats span,
.admin-event-row span,
.admin-event-row strong {
  border-radius: 999px;
  background: var(--paper-soft);
  padding: 5px 8px;
}

.admin-event-row {
  display: grid;
  grid-template-columns: 120px auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 9px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.admin-event-row strong {
  color: var(--blue);
}

.time-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin-bottom: 12px;
}

.battle-rule-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin: 0 0 12px;
}

.time-option,
.battle-rule-option {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-soft);
  color: var(--muted);
  box-shadow: none;
}

.time-option.is-active,
.battle-rule-option.is-active {
  border-color: rgba(47, 103, 197, 0.34);
  background: var(--blue-soft);
  color: var(--blue);
}

.leaderboard-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin-bottom: 12px;
}

.leaderboard-tab {
  min-height: 40px;
  border: 1px solid var(--line);
  background: var(--paper-soft);
  color: var(--muted);
  box-shadow: none;
}

.leaderboard-tab.is-active {
  border-color: rgba(47, 103, 197, 0.34);
  background: var(--blue-soft);
  color: var(--blue);
}

.leaderboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.leaderboard-column {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-soft);
  padding: 12px;
}

.leaderboard-column h3 {
  margin: 0 0 10px;
  font-size: 0.95rem;
}

.leaderboard-column-wide h3 {
  margin-bottom: 4px;
  font-size: 1.12rem;
}

.leaderboard-column-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.leaderboard-column-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.4;
}

.leaderboard-list {
  display: grid;
  gap: 8px;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  min-width: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.leaderboard-row span:nth-child(2) {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-row-detailed {
  grid-template-columns: 34px auto minmax(0, 1fr) auto;
  align-items: center;
  min-height: 86px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 11px 10px;
}

.leaderboard-rank {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  background: var(--paper-soft);
  color: var(--muted);
  align-self: center;
}

.leaderboard-score {
  display: grid;
  justify-items: end;
  gap: 2px;
  align-self: center;
  color: var(--ink);
  text-align: right;
  white-space: nowrap;
}

.leaderboard-score strong {
  font-size: 0.95rem;
}

.leaderboard-score span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  opacity: 0.72;
}

.flash-correct {
  animation: correctPulse 620ms ease;
}

.flash-wrong {
  animation: wrongShake 560ms ease;
}

@keyframes correctPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(22, 133, 86, 0.28);
    border-color: rgba(22, 133, 86, 0.7);
  }
  100% {
    box-shadow: 0 16px 42px rgba(25, 35, 29, 0.08);
    border-color: var(--line);
  }
}

@keyframes wrongShake {
  0%,
  100% {
    transform: translateX(0);
    border-color: var(--line);
  }
  14%,
  42%,
  70% {
    transform: translateX(-8px);
    border-color: rgba(200, 70, 70, 0.78);
  }
  28%,
  56%,
  84% {
    transform: translateX(8px);
    border-color: rgba(200, 70, 70, 0.78);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 820px) {
  .shell {
    width: min(100% - 22px, 680px);
    padding-top: 16px;
  }

  .app-header,
  .trainer-header {
    grid-template-columns: 1fr;
  }

  .app-header {
    align-items: stretch;
  }

  .brand,
  .summary {
    flex: 1 1 100%;
    width: 100%;
  }

  .brand {
    min-width: 0;
  }

  .brand h1 {
    white-space: normal;
  }

  .app-header > .profile-button,
  .app-header > .secondary-button {
    flex: 1 1 calc(50% - 8px);
  }

  .menu-header > .profile-button {
    flex: 0 1 auto;
  }

  .trainer-header {
    grid-template-columns: auto 1fr;
  }

  .source-link {
    grid-column: 1 / -1;
    width: 100%;
  }

  .summary {
    grid-template-columns: repeat(3, 1fr);
  }

  .royale-entry-button {
    grid-template-columns: minmax(0, 1fr);
  }

  .royale-entry-button strong {
    justify-self: start;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .status-strip,
  .subject-poll-options,
  .ladder-bar,
  .battle-status-grid,
  .battle-personal-reviews,
  .session-mistake-answers,
  .leaderboard-grid,
  .leaderboard-tabs {
    grid-template-columns: 1fr;
  }

  .source-control,
  .source-switch,
  .source-pill {
    width: 100%;
  }

  .admin-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-user-row,
  .admin-event-row {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .admin-user-stats {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .answer-dock,
  .battle-answer-form {
    grid-template-columns: 1fr;
  }

  .site-footer {
    margin-top: 28px;
  }
}

@media (max-width: 520px) {
  .subject-picker {
    grid-template-columns: 1fr;
  }

  .subject-picker.is-home {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .subject-card {
    min-height: 108px;
  }

  .subject-picker.is-home .subject-card {
    min-height: 0;
    padding: 12px;
  }

  .subject-picker.is-home .subject-card strong {
    font-size: 1.04rem;
  }

  .summary,
  .task-grid,
  .task-stats,
  .task-actions,
  .time-picker,
  .battle-rule-picker,
  .battle-detail-answers {
    grid-template-columns: 1fr;
  }

  .task-card {
    min-height: 0;
  }

  .app-header > .profile-button,
  .app-header > .secondary-button {
    flex-basis: calc(50% - 6px);
    padding-inline: 10px;
  }

  .profile-label {
    max-width: min(128px, 42vw);
  }

  .status-strip {
    padding: 13px;
  }

  .royale-entry-button {
    gap: 9px;
    padding: 14px;
  }

  .royale-entry-button span {
    font-size: 1.14rem;
  }

  .task-card h2,
  .task-source {
    min-height: 0;
  }

  .step-rail {
    gap: 5px;
  }

  .question-panel,
  .feedback-panel {
    padding: 14px;
  }

  .question-body:has(img) img,
  .passage-body:has(img) img {
    float: none;
    display: block;
    max-width: 100%;
    margin: 14px auto 0;
  }

  .question-body table:has(img),
  .passage-body table:has(img) {
    display: block;
  }

  .question-body table:has(img) tr,
  .passage-body table:has(img) tr {
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  .question-body table:has(img) td,
  .passage-body table:has(img) td {
    display: block;
    width: 100% !important;
    padding: 0 !important;
    text-align: left !important;
  }

  .question-body img.math,
  .passage-body img.math {
    display: inline-block;
    width: auto;
    max-width: 100%;
    height: 1.45em;
    margin: 0 0.12em;
    vertical-align: -0.34em;
  }

  .solution-body img.math,
  .correct-answer-value img.math {
    display: inline-block;
    width: auto;
    max-width: 100%;
    height: 1.25em;
    margin: 0 0.1em;
    vertical-align: -0.26em;
  }

  .question-body img.math {
    height: 1.6em;
    vertical-align: -0.42em;
  }

  .question-body img.math-display,
  .passage-body img.math-display,
  .solution-body img.math-display,
  .correct-answer-value img.math-display {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    margin: 0.72em auto;
  }

  .question-draw-tools {
    position: fixed;
    top: 48vh;
    left: 8px;
    gap: 5px;
    transform: translateY(-50%);
  }

  .draw-tool-button {
    width: 24px;
    min-width: 24px;
    height: 32px;
    min-height: 32px;
    border-radius: 10px;
  }

  .draw-size-button {
    width: 24px;
    min-width: 24px;
    height: 24px;
    min-height: 24px;
  }

  .draw-size-menu {
    left: calc(100% + 5px);
    padding: 4px;
  }

  .draw-size-choice {
    width: 24px;
    min-width: 24px;
    height: 24px;
    min-height: 24px;
  }

  .feedback-actions,
  .dialog-actions,
  .subject-poll-head,
  .subject-poll-actions,
  .profile-form,
  .profile-stats,
  .friend-add-form,
  .battle-friend-invite {
    display: grid;
    grid-template-columns: 1fr;
  }

  .friend-row,
  .battle-invite-row,
  .battle-invite-toast {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .friend-actions,
  .battle-invite-row .friend-actions,
  .battle-invite-toast button,
  .admin-event-row span,
  .admin-event-row strong {
    grid-column: 1 / -1;
  }

  .leaderboard-row-detailed {
    grid-template-columns: 30px 42px minmax(0, 1fr) auto;
    min-height: 84px;
    align-items: center;
    gap: 7px;
    overflow: hidden;
    padding: 10px 8px;
  }

  .leaderboard-row-detailed .leaderboard-rank {
    width: 28px;
    height: 28px;
  }

  .leaderboard-row-detailed .friend-main .friend-meta {
    gap: 4px;
  }

  .leaderboard-row-detailed .friend-main .activity-status {
    max-width: 100%;
  }

  .leaderboard-row-detailed .leaderboard-score {
    justify-items: end;
    min-width: 58px;
    text-align: right;
  }

  .leaderboard-row-detailed .leaderboard-score strong {
    font-size: 0.9rem;
  }

  .admin-metrics {
    grid-template-columns: 1fr;
  }

  .admin-poll-row {
    grid-template-columns: 1fr;
  }

  .admin-poll-row em {
    text-align: left;
  }

  .site-footer {
    gap: 10px;
  }

  .footer-rule {
    width: 44px;
  }
}
