:root {
  --bg: #0d1427;
  --surface: #eef2f7;
  --surface-alt: #e3e9f2;
  --surface-raised: #f8fafc;
  --header: #111f45;
  --accent: #205ad5;
  --accent-dark: #173b88;
  --text: #16233b;
  --text-muted: #42536e;
  --text-on-dark: #f7f9ff;
  --border: #657895;
  --border-strong: #324b73;
  --button-bg: #d6e3ff;
  --button-hover: #bcd0fa;
  --button-text: #142b59;
  --button-disabled-bg: #d9dfe9;
  --button-disabled-text: #47556b;
  --danger: #823c4c;
  --danger-bg: #fae9ec;
  --shadow: #060c1d;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { min-width: 0; }
body {
  margin: 0;
  padding: 8px 8px calc(12px + env(safe-area-inset-bottom));
  background: var(--bg);
  color: var(--text);
  font: 13px/1.35 Tahoma, Verdana, Arial, sans-serif;
}

button { font: inherit; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.game-shell {
  width: min(100%, 920px);
  margin: 0 auto;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  box-shadow: 2px 2px 0 var(--shadow);
  min-width: 0;
}

.site-header {
  background: var(--header);
  color: var(--text-on-dark);
  border-bottom: 2px solid var(--accent);
}
.brand-line {
  padding: 7px 10px;
  text-align: center;
}
.brand-line h1 { margin: 0; font: bold 20px/1.05 Georgia, "Times New Roman", serif; letter-spacing: .01em; overflow-wrap: anywhere; }

.tab-bar {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 2px;
  padding: 4px 5px 0;
  background: var(--header);
  border-bottom: 1px solid var(--border-strong);
}
.tab {
  min-width: 0;
  border: 1px solid var(--border-strong);
  border-bottom: 0;
  border-radius: 0;
  background: var(--accent-dark);
  color: var(--text-on-dark);
  padding: 6px 3px;
  font-weight: bold;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.tab.is-active { background: var(--surface); color: var(--text); border-top: 2px solid var(--accent); position: relative; top: 1px; }
.tab:hover:not(.is-active) { background: var(--accent); }

main { padding: 7px; min-height: 300px; }
.view-message { margin: 0; border-top: 0; overflow-wrap: anywhere; }
.small-button, .readonly-button {
  flex: none;
  border: 1px solid var(--border-strong);
  border-right-color: var(--header);
  border-bottom-color: var(--header);
  border-radius: 0;
  background: var(--button-bg);
  color: var(--button-text);
  padding: 3px 8px;
  cursor: pointer;
}
.small-button:hover:not(:disabled), .readonly-button:hover:not(:disabled) { background: var(--button-hover); }
.small-button:disabled, .readonly-button:disabled {
  border-color: var(--border);
  background: var(--button-disabled-bg);
  color: var(--button-disabled-text);
  cursor: default;
}
.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  background: var(--accent-dark);
  color: var(--text-on-dark);
  border: 1px solid var(--border-strong);
  padding: 5px 8px;
}
.panel-title h2 { font-size: 13px; line-height: 1.25; margin: 0; }
.panel-title span { font-size: 10px; opacity: .83; white-space: nowrap; }
.panel-body {
  border: 1px solid var(--border);
  border-top: 0;
  background: var(--surface);
  padding: 8px;
  min-width: 0;
}
#screen-home > .panel-body { border-top: 1px solid var(--border); }
.empty-content { color: var(--text-muted); }
.subheading {
  margin: 12px 0 5px;
  padding: 3px 6px;
  border-left: 4px solid var(--accent);
  background: var(--surface-alt);
  font-size: 12px;
}
.subheading:first-child { margin-top: 0; }
.data-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; border: 1px solid var(--border); background: var(--border); }
.data-cell { background: var(--surface-raised); padding: 5px 7px; min-width: 0; overflow-wrap: anywhere; }
.data-cell .label { display: block; color: var(--text-muted); font-size: 10px; margin-bottom: 1px; }
.data-cell .value { display: block; font-weight: bold; }
.home-profile { --gnome-size: clamp(125px, 27vw, 200px); display: grid; grid-template-columns: var(--gnome-size) minmax(0, 1fr); gap: 8px; align-items: start; min-width: 0; }
.gnome-image { display: block; width: var(--gnome-size); height: var(--gnome-size); aspect-ratio: 1 / 1; max-width: 100%; border: 1px solid var(--border-strong); object-fit: contain; image-rendering: pixelated; }
.home-profile-info { grid-template-columns: minmax(0, 1fr); min-width: 0; }
.home-profile-info .data-cell { display: grid; grid-template-columns: minmax(0, 42%) minmax(0, 1fr); align-items: baseline; gap: 8px; }
.home-profile-info .label { margin: 0; }
.home-profile-info .value { min-width: 0; overflow-wrap: anywhere; }
.notice { margin: 8px 0 0; padding: 6px 8px; border: 1px solid var(--border); background: var(--button-bg); }
.notice.bad { border-color: var(--danger); background: var(--danger-bg); color: var(--danger); }
.bootstrap-debug-code { display: block; margin-top: 4px; font-size: 11px; opacity: .75; }
.inventory-list { margin: 0; padding: 0; list-style: none; border: 1px solid var(--border); }
.inventory-list li { display: flex; justify-content: space-between; gap: 8px; padding: 4px 7px; background: var(--surface-raised); overflow-wrap: anywhere; }
.inventory-list li + li { border-top: 1px solid var(--border); }
.inventory-list strong { flex: none; }
.title-list { display: grid; gap: 1px; margin: 0; padding: 0; list-style: none; border: 1px solid var(--border); background: var(--border); }
.title-list li { min-width: 0; padding: 4px 7px; background: var(--surface-raised); overflow-wrap: anywhere; }
.title-name, .title-count { display: block; }
.title-name { font-weight: bold; }
.title-count { color: var(--text-muted); font-size: 10px; }
.title-list.compact { gap: 0; margin-top: 4px; border: 0; background: transparent; }
.title-list.compact li { padding: 1px 0; background: transparent; }
.title-list.compact .title-name { font-weight: normal; }
.hint { margin: 0 0 8px; color: var(--text-muted); font-size: 11px; }

.opponent-head, .opponent-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 5px 10px; }
.opponent-head { padding: 4px 7px; border: 1px solid var(--border); background: var(--surface-alt); font-weight: bold; font-size: 11px; }
.opponent-list { border: 1px solid var(--border); border-top: 0; }
.opponent-row { min-width: 0; padding: 6px 7px; background: var(--surface-raised); }
.opponent-row:nth-child(even) { background: var(--surface-alt); }
.opponent-name { min-width: 0; overflow-wrap: anywhere; font-weight: bold; }
.opponent-handle { display: block; color: var(--text-muted); font-size: 11px; font-weight: normal; }
.opponent-stats { display: block; margin-top: 3px; color: var(--text-muted); font-size: 10px; font-weight: normal; }
.opponent-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.opponent-actions button { white-space: normal; }
.duel-blocker { flex-basis: 100%; color: var(--text-muted); text-align: right; }
.inspect-back { margin-bottom: 7px; }
.hall-list { border: 1px solid var(--border); }
.hall-row { display: grid; grid-template-columns: 24px 36px minmax(0, 1fr) auto; gap: 6px; align-items: center; padding: 5px 7px; min-width: 0; background: var(--surface-raised); }
.hall-row + .hall-row { border-top: 1px solid var(--border); }
.hall-row:nth-child(even) { background: var(--surface-alt); }
.hall-rank { color: var(--accent-dark); font-weight: bold; text-align: center; }
.hall-avatar { display: block; width: 36px; height: 36px; aspect-ratio: 1 / 1; border: 1px solid var(--border-strong); object-fit: contain; image-rendering: pixelated; }
.gnome-image, .hall-avatar { background: #121a29; }
.hall-player { min-width: 0; overflow-wrap: anywhere; }
.hall-player strong, .hall-player small { display: block; }
.hall-player small { color: var(--text-muted); font-size: 10px; }
.boss-banner { display: flex; gap: 9px; align-items: center; min-width: 0; padding: 9px; border: 1px solid var(--border-strong); background: var(--header); color: var(--text-on-dark); }
.boss-emoji { flex: none; font-size: 26px; line-height: 1; }
.boss-identity { min-width: 0; overflow-wrap: anywhere; }
.boss-identity strong { display: block; font: bold 17px/1.15 Georgia, "Times New Roman", serif; }
.boss-identity small { display: block; margin-top: 3px; font-size: 11px; }
.boss-progress { display: block; width: 100%; height: 16px; margin: 7px 0; accent-color: var(--accent); border: 1px solid var(--border-strong); background: var(--surface-alt); }
.boss-team { margin: 0; padding: 0; list-style: none; border: 1px solid var(--border); }
.boss-team li { display: flex; justify-content: space-between; gap: 8px; padding: 5px 7px; min-width: 0; background: var(--surface-raised); }
.boss-team li + li { border-top: 1px solid var(--border); }
.boss-team li:nth-child(even) { background: var(--surface-alt); }
.boss-team-name { min-width: 0; overflow-wrap: anywhere; font-weight: bold; }
.boss-team-state { flex: 0 1 auto; min-width: 0; overflow-wrap: anywhere; color: var(--text-muted); font-size: 11px; text-align: right; }
.boss-action { display: flex; flex-wrap: wrap; gap: 5px; margin: 7px 0; }
.boss-action .small-button { min-width: 0; flex: 1 1 90px; overflow-wrap: anywhere; }
.boss-action .small-button.is-selected { background: var(--accent); color: var(--text-on-dark); }
.boss-result-outcome { display: block; margin: 7px 0; padding: 5px 8px; border: 1px solid var(--border-strong); font: bold 16px/1.1 Georgia, "Times New Roman", serif; }
.boss-result-outcome.victory { background: #dcebd8; color: #153f24; }
.boss-result-outcome.defeat { background: #eadada; color: #5a2020; }
.boss-chronicle, .boss-featured, .boss-verdict { margin: 6px 0 9px; border: 1px solid var(--border); background: var(--surface-raised); padding: 7px; min-width: 0; overflow-wrap: anywhere; }
.boss-chronicle-label { display: block; margin: 4px 0; color: var(--accent-dark); }
.boss-chronicle-entry { margin: 0; padding: 6px 0; line-height: 1.35; }
.boss-chronicle-entry + .boss-chronicle-entry { border-top: 1px solid var(--border); }
.boss-featured strong { display: block; }
.boss-featured p, .boss-verdict p { margin: 5px 0 0; line-height: 1.35; }

.duel-heading { margin: 0 0 8px; font-weight: bold; }
.duel-versus { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 6px; margin-bottom: 9px; }
.duel-player { min-width: 0; padding: 8px 6px; border: 1px solid var(--border); background: var(--surface-raised); text-align: center; overflow-wrap: anywhere; font-weight: bold; }
.duel-player small { display: block; margin-top: 3px; color: var(--text-muted); font-size: 10px; font-weight: normal; }
.versus { color: var(--accent-dark); font: bold 12px Georgia, serif; }
.action-box { margin-top: 10px; border: 1px solid var(--border-strong); background: var(--surface-alt); padding: 7px; }
.action-box h3 { margin: 0 0 3px; font-size: 12px; }
.action-box p { margin: 0 0 7px; font-size: 11px; color: var(--text-muted); }
.zone-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
.zone-row button { width: 100%; min-width: 0; padding: 5px 2px; white-space: normal; }
.round-list { display: grid; gap: 5px; }
.round-result { border: 1px solid var(--border); background: var(--surface-raised); padding: 6px 8px; overflow-wrap: anywhere; }
.round-result strong, .round-result small { display: block; }
.round-result strong { margin-bottom: 3px; }
.round-result small { margin-top: 3px; color: var(--text-muted); }
.round-prose, .duel-presentation { white-space: pre-line; overflow-wrap: anywhere; }
.round-prose { margin: 5px 0; }
.duel-finished > .small-button { margin-top: 9px; }
.previous-duel { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 7px; }
.previous-duel summary { cursor: pointer; font-weight: bold; }
.site-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; border-top: 1px solid var(--border); padding: 6px 9px; background: var(--surface-alt); color: var(--text-muted); font-size: 10px; }

@media (max-width: 560px) {
  .tab-bar { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .tab { grid-column: span 2; }
  .tab:nth-child(n + 4) { grid-column: span 3; }
}

@media (max-width: 480px) {
  .home-profile-info .data-cell { display: block; padding: 3px 5px; }
  .home-profile-info .label { line-height: 1.1; }
  .home-profile-info .value { font-size: 11px; line-height: 1.2; }
}

@media (max-width: 299px) {
  .home-profile { grid-template-columns: minmax(0, 1fr); }
  .gnome-image { width: min(var(--gnome-size), 100%); height: auto; }
}

@media (max-width: 420px) {
  body { padding: 4px 4px calc(8px + env(safe-area-inset-bottom)); }
  .brand-line { padding: 6px 8px; }
  .brand-line h1 { font-size: 17px; }
  main { padding: 5px; }
  .panel-body { padding: 6px; }
  .readonly-button { padding-inline: 5px; }
  .opponent-row { grid-template-columns: minmax(0, 1fr); }
  .opponent-actions { justify-content: flex-start; }
  .duel-blocker { text-align: left; }
  .tab { font-size: 12px; padding: 6px 1px; }
  .hall-row { grid-template-columns: 20px 32px minmax(0, 1fr); gap: 4px; padding: 5px; }
  .hall-avatar { width: 32px; height: 32px; }
  .hall-row .small-button { grid-column: 3; justify-self: start; }
}
