/* Shared responsive UI. Load after the legacy stylesheet and page-local styles.
   Content determines control height; only artwork and scrollable lists are bounded. */
:root {
  color-scheme: dark;
  --bg0: #0c1421;
  --bg1: #101b2b;
  --text: #edf3fa;
  --muted: #a9b8ce;
  --gold1: #f0d38e;
  --gold2: #dfb861;
  --ui-bg: #0c1421;
  --ui-bg-soft: #101b2b;
  --ui-surface: #172336;
  --ui-surface-strong: #1c2c42;
  --ui-panel: #172336;
  --ui-text: #edf3fa;
  --ui-muted: #a9b8ce;
  --ui-border: #ffffff20;
  --ui-border-strong: #ffffff38;
  --ui-accent: #e8c577;
  --ui-accent-2: #8ab9e8;
  --ui-radius: 16px;
  --ui-radius-sm: 10px;
  --ui-control-height: 46px;
  --ui-control-padding-x: 16px;
  --ui-shadow: 0 8px 24px #00000020;
  --ui-shadow-soft: 0 4px 12px #00000018;
}

html {
  height: auto;
  min-height: 100%;
  font-size: 16px;
  background: var(--ui-bg);
  overflow-x: visible;
  scroll-padding-top: 24px;
}
body {
  height: auto;
  min-height: 100vh;
  min-height: 100svh;
  overflow: visible;
  background: radial-gradient(ellipse at top left, #1b304b 0, transparent 65%), var(--ui-bg);
  color: var(--ui-text);
  line-height: 1.65;
}
body.container,
body.game-home.container,
body.admin.container,
body.character-status-page.container {
  width: calc(100% - 48px);
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px 0 56px;
}
*, *::before, *::after { box-sizing: border-box; }
main, section, header, nav, form, fieldset, label, article { min-width: 0; }
img, video { max-width: 100%; }
/* Author styles must never reveal controls that application logic has hidden. */
[hidden] { display: none !important; }
h1, h2, h3, p, label, button, a, span, strong, small, td, th, dd {
  overflow-wrap: anywhere;
  word-break: normal;
}
h1, .game-brand__title, .admin-header h1 {
  font-size: clamp(1.5rem, 2.5vw, 2.2rem);
  line-height: 1.35;
  letter-spacing: .015em;
  text-shadow: none;
}
h2, .game-panel__title, .admin-section-title {
  font-size: clamp(1.125rem, 1.6vw, 1.5rem);
  line-height: 1.5;
}
h3 { line-height: 1.5; }
p { line-height: 1.7; }
.muted, .game-panel__text, .game-brand__login { color: var(--ui-muted); }
.game-brand__sub, .game-panel__label { margin-bottom: 6px; color: var(--ui-accent); }
.game-brand__login { margin: 8px 0 0; }

/* Controls grow to fit translated, long or zoomed labels. */
button:not(.battle-modal-close):not(.game-gacha-btn),
.btn, .admin .btn, .link, .game-mini-btn, .battle-lobby-btn,
.card-shop-btn, .bulk-btn, .bulk-button-link, .template-primary-btn,
.template-apply-btn, .admin-secondary-btn, .admin-danger-btn, .btn-primary,
.exchange-submit, .toggle-active-btn, .battle-sub-btn, .battle-surrender-btn,
.post-battle-actions .link-btn, .game-home-nav__link, .admin-nav__link {
  height: auto;
  min-height: 46px;
  max-width: 100%;
  padding: 10px 16px;
  white-space: normal;
  line-height: 1.5;
  text-overflow: clip;
  overflow: visible;
  border-radius: var(--ui-radius-sm);
}
button, .btn, .link { font: inherit; font-weight: 700; }
button { box-shadow: none; }
button:disabled, input:disabled, select:disabled { opacity: .5; cursor: not-allowed; }
button:hover, .link:hover { transform: none; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid #9ad8ff;
  outline-offset: 3px;
}
input:not([type]), input[type="text"], input[type="password"], input[type="number"],
input[type="email"], input[type="search"], input[type="datetime-local"], input[type="file"],
select, textarea {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  font: inherit;
  font-size: 1rem;
  line-height: 1.5;
  min-height: 46px;
  height: auto;
  padding: 10px 12px;
  border: 1px solid var(--ui-border-strong);
  border-radius: 10px;
  background: #0f1b2b;
  color: var(--ui-text);
  box-shadow: none;
}
select { padding-right: 30px; }
textarea { resize: vertical; }
label { font-size: .875rem; line-height: 1.6; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--ui-accent); }

/* One page rhythm and navigation across the collection, shop and lobby. */
.game-home-header, .admin-header, body.container > header.row,
.character-status-page .status-header {
  position: relative;
  overflow: visible;
  margin: 0 0 24px;
  padding: clamp(18px, 2.5vw, 28px);
  background: #17263b;
  border: 1px solid var(--ui-border);
  border-radius: 18px;
  box-shadow: var(--ui-shadow);
}
.game-home-header::before, .game-home-header::after,
body.container > header.row::after { display: none; }
.game-home-header__top { gap: 20px; flex-direction: row; flex-wrap: wrap; align-items: center; }
.game-home-header__top > .game-brand { flex: 1 1 260px; }
.game-home-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 18px;
  border-top: 1px solid var(--ui-border);
}
.game-home-nav .game-home-nav__link {
  flex: 1 1 110px;
  width: auto;
  min-width: 0;
  min-height: 44px;
  padding: 10px 14px;
  color: var(--ui-text);
  background: #ffffff06;
  border: 1px solid transparent;
  box-shadow: none;
  text-decoration: none;
}
.game-home-nav .game-home-nav__link:hover { background: #ffffff10; border-color: var(--ui-border); }
.game-home-nav .game-home-nav__link.is-current {
  color: #1a2432;
  background: var(--ui-accent);
  border-color: var(--ui-accent);
}
.game-home-nav .game-home-nav__link--logout { color: #c1ccda; flex-grow: 0; }
.game-home-main, .catalog-main, .card-shop-main, .battle-lobby-main { display: grid; gap: 24px; }
.game-panel, .card, .admin .card {
  padding: clamp(16px, 2.4vw, 26px);
  border-radius: 16px;
  border: 1px solid var(--ui-border);
  background: var(--ui-surface);
  box-shadow: var(--ui-shadow-soft);
  backdrop-filter: none;
}
.game-panel__head, .catalog-section-head, .card-shop-section-head,
.battle-lobby-section-head, .battle-selected-box__head, .panel-heading {
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.game-panel__head > :first-child, .catalog-section-head > :first-child,
.card-shop-section-head > :first-child, .battle-lobby-section-head > :first-child { flex: 1 1 220px; }
.game-ticket-panel, .card-shop-chip-panel, .catalog-complete-panel, .battle-lobby-status-panel, .battle-guide-summary-panel {
  width: auto;
  max-width: 100%;
  min-width: 0;
  padding: 14px 20px;
  background: #0f1b2b;
  color: var(--ui-text);
  border: 1px solid #e8c57740;
  border-radius: 12px;
  box-shadow: none;
}
.game-ticket-panel__value, .card-shop-chip-panel__value,
.catalog-complete-panel__value, .battle-lobby-status-panel__value,
.battle-guide-summary-panel__value { color: var(--ui-accent); line-height: 1.3; font-variant-numeric: tabular-nums; }
.game-ticket-panel__label, .card-shop-chip-panel__label,
.catalog-complete-panel__label, .battle-lobby-status-panel__label,
.battle-guide-summary-panel__label { color: var(--ui-muted); opacity: 1; }
.catalog-complete-panel__sub, .battle-lobby-status-panel__sub, .battle-guide-summary-panel__sub { color: var(--ui-muted); }

/* Intrinsic columns can shrink to the available width, never below the page. */
.catalog-grid, .card-shop-grid, .battle-card-grid.battle-lobby-card-grid,
.game-inventory-grid .grid, .game-gacha-result .grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
  align-items: stretch;
  gap: 16px;
}
.game-inventory-grid { display: block; }
.catalog-summary-grid, .catalog-rarity-grid, .card-shop-rate-grid,
.battle-guide-card-grid, .battle-guide-card-grid3, .battle-guide-toc-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr));
  gap: 12px;
}
.catalog-summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.catalog-card, .card-shop-card, .battle-lobby-card, .game-home .chip {
  gap: 0;
  padding: 0;
  border-radius: 14px;
  border: 1px solid var(--ui-border);
  background: #101c2d;
  box-shadow: none;
}
.catalog-card:hover, .card-shop-card:hover, .battle-lobby-card:hover,
.game-home .chip:hover { transform: none; border-color: #e8c57785; }
.catalog-card__image, .card-shop-card__image, .battle-lobby-card__image {
  aspect-ratio: 4 / 3;
  height: auto;
  max-height: none;
  min-height: 0;
  padding: 12px;
  background: #0b1422;
}
.catalog-card__image img, .card-shop-card__image img, .battle-lobby-card__image img,
.game-home .chimg {
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: contain;
  object-position: center;
}
.game-home .chip > .chimg, .game-home .chip > a > .chimg { height: 220px; padding: 12px; background: #0b1422; }
.catalog-card__body, .card-shop-card__body, .battle-lobby-card__body,
.game-home .chip > div { padding: 14px; }
.catalog-card__name, .card-shop-card__name, .battle-lobby-card__name,
.game-home .name, .skill-character-card__body strong, .skill-forget-card strong,
.skill-learn-card strong, .skill-compare-card strong {
  display: block;
  min-height: 0;
  max-height: none;
  height: auto;
  overflow: visible;
  white-space: normal;
  text-overflow: clip;
  -webkit-line-clamp: unset;
  font-size: 1rem;
  line-height: 1.6;
}
.catalog-card__body, .card-shop-card__body, .battle-lobby-card__body { flex: 1; }
.catalog-filter, .card-shop-filter {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  gap: 14px;
}
.catalog-filter label, .card-shop-filter label { min-height: 0; }
.card-shop-action-row { display: flex; flex-wrap: wrap; gap: 10px; }
.card-shop-action-row > * { flex: 1 1 90px; }
.game-gacha-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.game-gacha-btn { height: auto; min-height: 86px; padding: 18px; line-height: 1.5; overflow: visible; }
.game-gacha-btn__main, .game-gacha-btn__sub { white-space: normal; line-height: 1.6; }
.game-gacha-btn__main { font-size: 1.125rem; }
.game-gacha-btn__sub { font-size: .875rem; }
.gacha-video-overlay { padding: 16px; overflow-y: auto; }
.gacha-video-box { position: relative; max-width: 100%; max-height: 90svh; }
.gacha-video-box .gacha-video { max-height: 88vh; max-height: 88svh; width: 100%; object-fit: contain; }
.gacha-video-box .gacha-video-skip { position: absolute; top: 12px; right: 12px; z-index: 2; width: auto; color: #fff; background: #0c1421e8; border-color: #ffffff66; }
.summer-challenge-progress__meta { gap: 8px; flex-wrap: wrap; }
.battle-lobby-bottom-grid, .battle-guide-layout { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.battle-lobby-pick { position: relative; min-width: 0; margin: 0; }
.battle-lobby-pick > input.battle-character-checkbox {
  display: block;
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
}
.battle-lobby-pick:has(input:focus-visible) { outline: 3px solid #9ad8ff; outline-offset: 4px; border-radius: 14px; }
.battle-lobby-card__body .battle-lobby-tags { display: flex; flex-wrap: wrap; }
.battle-lobby-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.battle-selected-list { display: flex; flex-wrap: wrap; }
.battle-selected-chip { min-width: 0; max-width: 100%; white-space: normal; }
.battle-request-card, .battle-opponent-card { overflow: visible; }

/* Skill editor: three stages on wide screens; no fixed-width track sum. */
.skill-character-select-form { grid-template-columns: minmax(0, 1fr) auto; }
.skill-character-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.skill-training-shell { padding: 12px; background: #0f1b2b; border-color: var(--ui-border); }
.skill-training-shell .skill-training-layout { grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr) minmax(0, 1fr); }
.skill-training-shell .skill-training-panel { min-height: 0; grid-template-rows: auto 1fr; }
.skill-training-shell .skill-training-panel--learn { grid-template-rows: auto auto 1fr; }
.skill-training-shell .skill-training-panel--detail { grid-column: auto; grid-template-rows: auto auto 1fr auto; }
.skill-training-shell .skill-forget-list { align-content: start; grid-auto-rows: max-content; }
.skill-customize-page .skill-training-shell button.skill-forget-card,
.skill-customize-page .skill-training-shell button.skill-learn-card {
  display: grid;
  height: auto;
  min-height: max-content;
  align-content: start;
  text-align: left;
  padding: 12px;
}
.skill-training-shell .skill-forget-card__marker { display: none; }
.skill-training-shell .skill-forget-card [data-slot-detail],
.skill-training-shell .skill-learn-card__effect {
  display: block;
  overflow: visible;
  white-space: normal;
  -webkit-line-clamp: unset;
  line-height: 1.6;
}
.skill-training-shell .skill-learn-toolbar { grid-template-columns: minmax(0, 1fr); }
.skill-training-shell .skill-learn-grid { max-height: 640px; max-height: min(65svh, 640px); align-content: start; grid-auto-rows: max-content; }
.skill-training-shell .skill-training-panel--detail .skill-training-compare { grid-template-columns: 1fr; }
.skill-training-shell .skill-training-panel--detail .skill-cost-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.skill-training-shell .skill-training-panel--detail .skill-training-actions { grid-template-columns: 1fr; }
.skill-training-statusbar span { line-height: 1.5; border-radius: 8px; }
.skill-attribute-chip, .skill-role-chip, .skill-equipped-chip { white-space: normal; line-height: 1.4; }

/* Character details: titles, skills and effects remain fully readable. */
.character-status-page .status-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); min-height: 0; gap: 20px; }
.character-status-page .status-screen { overflow: visible; padding: 0; border: 0; background: none; box-shadow: none; }
.character-status-page .status-screen::before, .character-status-page .status-screen::after { display: none; }
.character-status-page .move-panel { background: var(--ui-surface); border-radius: 16px; grid-template-rows: auto auto 1fr; }
.character-status-page .profile-panel { border-radius: 16px; }
.character-status-page .move-list { overflow: visible; max-height: none; align-content: start; padding: 0; }
.character-status-page button.move-option { display: grid; height: auto; min-height: 64px; padding: 12px; grid-template-columns: 34px minmax(0, 1fr); gap: 8px 12px; }
.character-status-page .move-option::before { display: none; }
.character-status-page .move-option:hover, .character-status-page .move-option.is-selected { transform: none; }
.character-status-page .move-power { grid-column: 2; justify-self: start; width: auto; text-align: left; }
.character-status-page .move-name, .character-status-page .move-detail-stat strong,
.character-status-page .profile-move-chip span:last-child {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.6;
}
.character-status-page .move-detail-box { min-height: 0; align-content: start; }
.character-status-page .move-detail-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.character-status-page .move-detail-stat:last-child { grid-column: 1 / -1; }
.character-status-page .profile-hero { grid-template-columns: minmax(100px, .85fr) minmax(0, 1fr); gap: 16px; }
.character-status-page .profile-image-frame { width: 100%; height: 240px; }
.character-status-page .profile-image-frame .status-image { width: 100%; height: 100%; max-height: 100%; object-fit: contain; }
.character-status-page .profile-name-block h2 { line-height: 1.5; overflow-wrap: anywhere; }
.character-status-page .profile-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 16px; }
.character-status-page .profile-stat-row { gap: 6px; }
.character-status-page .profile-move-grid { grid-template-columns: 1fr; }
.character-status-page .status-chip { line-height: 1.5; white-space: normal; }

/* Tables scroll inside their own region; the document stays at viewport width. */
.ui-table-scroll { width: 100%; max-width: 100%; min-width: 0; overflow-x: auto; overscroll-behavior-x: contain; border-radius: 10px; }
.ui-table-scroll > table { min-width: 620px; width: 100%; }
.ui-scroll-hint { margin: 6px 0; color: var(--ui-muted); font-size: .8125rem; }
.ui-skip-link { position: fixed; top: -120px; left: 16px; z-index: 10000; padding: 12px 18px; border-radius: 8px; background: #f0d38e; color: #101925; }
.ui-skip-link:focus { top: 12px; }
.exchange-page > .card { margin-bottom: 20px; }
.exchange-source-row { display: grid; grid-template-columns: 48px minmax(0, 1fr) 88px; gap: 12px; align-items: center; margin: 12px 0; }
.exchange-source-row input.consume-input { width: 100% !important; }
body.container.auth-page { max-width: 560px; padding-top: clamp(24px, 8vh, 80px); }
.auth-page > header.row { background: none; box-shadow: none; border: 0; padding: 0; align-items: end; }
.auth-card .auth-form { display: grid; gap: 18px; margin: 0; }
.auth-card .auth-form label { margin: 0; }
.auth-card .auth-form > button { margin-top: 6px; }
.auth-card .auth-form > p { margin: 0; }
.error[role="alert"] { padding: 12px; background: #ef6b7b15; border: 1px solid #ef6b7b55; border-radius: 10px; }

@media (max-width: 1100px) {
  .skill-training-shell .skill-training-layout { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .skill-training-shell .skill-training-panel--detail { grid-column: 1 / -1; }
  .skill-training-shell .skill-training-panel--detail .skill-training-compare { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
  .skill-training-shell .skill-training-panel--detail .skill-training-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 800px) {
  body.container, body.game-home.container, body.admin.container, body.character-status-page.container { width: calc(100% - 32px); padding: 18px 0 40px; }
  .character-status-page .status-grid, .battle-lobby-bottom-grid, .battle-guide-layout { grid-template-columns: 1fr; }
  .character-status-page .status-header { flex-wrap: wrap; }
  .skill-training-shell .skill-training-layout { grid-template-columns: 1fr; }
  .skill-training-shell .skill-training-panel--detail { grid-column: auto; }
  .skill-training-shell .skill-forget-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .skill-training-shell .skill-learn-toolbar { grid-template-columns: minmax(0, 1fr) minmax(110px, .6fr); }
  .skill-training-shell .skill-learn-grid { max-height: 520px; }
  .battle-lobby-guide-panel, .catalog-summary-panel, .card-shop-guide { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  body.container, body.game-home.container, body.admin.container, body.character-status-page.container { width: calc(100% - 24px); padding-top: 12px; }
  .game-home-header, .admin-header { padding: 16px; }
  .game-home-header__top > .game-brand { flex-basis: 100%; }
  .game-home-nav .game-home-nav__link { flex-basis: calc(50% - 8px); }
  .game-home-nav .game-home-nav__link--logout { flex-grow: 1; }
  .game-ticket-panel, .card-shop-chip-panel, .catalog-complete-panel, .battle-lobby-status-panel, .battle-guide-summary-panel { width: 100%; }
  .catalog-summary-grid, .catalog-rarity-grid, .card-shop-rate-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .game-gacha-actions { grid-template-columns: 1fr; }
  .skill-character-select-form, .skill-current-layout { grid-template-columns: 1fr; }
  .skill-training-shell .skill-forget-list, .skill-training-shell .skill-learn-toolbar,
  .skill-training-shell .skill-training-panel--detail .skill-training-compare,
  .skill-training-shell .skill-training-panel--detail .skill-training-actions { grid-template-columns: 1fr; }
  .character-status-page .profile-hero { grid-template-columns: 1fr; }
  .character-status-page .profile-stat-grid { grid-template-columns: 1fr; }
  .character-status-page .profile-image-frame { height: 280px; }
  .character-status-page .status-nav { width: 100%; }
  .character-status-page .status-nav .link { flex: 1 1 110px; }
  .exchange-source-row { grid-template-columns: 40px minmax(0, 1fr); }
  .exchange-source-row > :last-child { grid-column: 2; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
