/* Shared art direction: evergreen, parchment and a little lantern gold.
   Kept separate from map/sprite geometry so the game layers remain stable. */
:root {
  color-scheme: light;
  --bg: #edece3;
  --glass: #fffcf4;
  --glass-strong: #f3f1e6;
  --glass-soft: #f7f5ed;
  --text: #293e34;
  --muted: #738072;
  --line: #d8dece;
  --accent: #397156;
  --accent-2: #bca267;
  --danger: #bc5660;
  --gold: #b68b35;
  --px-dark: #526c57;
  --px-light: #e6ead9;
  --px-surface: #fffdf6;
  --px-surface-2: #eff1e6;
  --px-well: #e9eddf;
  --cream-panel: #fffcf4;
  --cream-panel-2: #f3f4eb;
  --cream-line: #dce1d1;
  --cream-line-strong: #b9c7b0;
  --cream-text: #293e34;
  --cream-muted: #677764;
  --shadow: 0 4px 18px #253d3010;
}

body {
  background: radial-gradient(ellipse at 0 0, #dde7d6, transparent 52%), #efeee6;
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body::after { background: none; }
button, input, select, textarea { font-family: inherit; }
button { transition: background .16s, border-color .16s, transform .16s, box-shadow .16s; }
button:not(:disabled):active { transform: translateY(1px); }
button:disabled { opacity: .48; cursor: not-allowed; }
:focus-visible { outline: 3px solid #b79042 !important; outline-offset: 3px; }
::selection { background: #dce8cc; color: #193e35; }
* { scrollbar-width: thin; scrollbar-color: #b8c5ac transparent; }
.app { width: min(1600px, calc(100% - 48px)); padding: 22px 0; }
.app:has(.auth-view:not(.hidden)) { width: min(1120px, calc(100% - 48px)); }
.eyebrow, .section-label, .profile-label, .social-tab,
.admin-monster-table th, .admin-log-tag, .target-detail-subtitle,
.target-detail-chip b, .bld-row b, .role-pick .role-pick-text b {
  color: #50734f !important;
  text-shadow: none;
}
.section-label { font-size: 12px; letter-spacing: 1px; }
.eyebrow { font-size: 10px; font-weight: 700; letter-spacing: 2px; }

/* Consistent controls and surfaces, including generated game dialogs. */
.auth-panel, .pet-panel, .social-panel, .log-panel, .admin-panel,
.modal-panel, .modal-box, .tutorial-card, .cmd-menu, .obj-action-popup {
  background: var(--glass);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 18px;
  box-shadow: 0 12px 36px #233e3010;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.admin-control-card, .admin-section-block, .admin-brush-bar, .admin-table-wrap,
.admin-form-section, .admin-terrain-grid, .target-detail-card, .target-action-row,
.role-pick, .message, .log-group, .relationship, .memory-item, .obj-item,
.snapshot-row, .stat-details, .fusion-pet-card, .fusion-summary, .help-body pre {
  background: var(--glass-soft);
  box-shadow: none;
  border-radius: 12px;
}
.tab, .ghost, .ghost-btn, .danger-btn, .icon-btn, .user-chip, .circ-btn,
.care-btn, .command-btn, .forage-btn, .command-set-btn, .terrain-tool,
.terrain-rotation-tool, .place-tab, .pixel-tool-btn, .pixel-action-btn,
.log-filter-clear, .mobile-panel-close, .cmd-menu-head, .target-action-mode {
  background: #f4f4e9 !important;
  border: 1px solid #d3dcc7 !important;
  color: #3d5944 !important;
  border-radius: 10px;
  box-shadow: 0 2px 0 #dce1ce;
  text-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.tab:hover, .ghost:hover:not(:disabled), .ghost-btn:hover, .circ-btn:hover,
.care-btn:hover:not(:disabled), .command-btn:hover:not(:disabled),
.role-pick:hover, .target-action-mode:hover, .social-tab:hover,
.admin-monster-table tbody tr:hover, .admin-log-row:hover, .cmd-menu-item:hover {
  background: #e6edda !important;
}
.primary, .tab.active, button.ghost.active, .terrain-tool.active,
.terrain-rotation-tool.active, .place-tab.active, .social-tab.active {
  background: #2e654d !important;
  border: 1px solid #28583f !important;
  color: #fff9df !important;
  border-radius: 10px;
  text-shadow: none;
  box-shadow: 0 3px 0 #1c4936;
}
.primary:hover:not(:disabled) { background: #39765a !important; }
.danger-btn, .circ-btn--danger { color: #a44e50 !important; }
input, select, textarea {
  background: #fffef9 !important;
  border: 1px solid #ccd5c0 !important;
  color: #293e34 !important;
  border-radius: 10px;
  box-shadow: inset 0 2px 3px #233e3004;
}
input::placeholder, textarea::placeholder { color: #8c9685; }
.help-body h3 { border-left-color: #b89b53 !important; }
.modal, .tutorial-overlay { background: #102a2480; backdrop-filter: blur(5px); }
.modal-panel { max-height: 88dvh; }
.modal-panel h3, .modal-panel h2 { color: #315440; }
.modal-actions { gap: 10px; }
.toast {
  background: #234d3e !important;
  border: 1px solid #739277 !important;
  border-radius: 12px;
  color: #fff9e6 !important;
  box-shadow: 0 8px 32px #102c3430;
  padding: 14px 22px;
}

/* The welcome screen is an illustrated entry to the world. */
.auth-view {
  min-height: calc(100dvh - 44px);
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  align-content: center;
  align-items: stretch;
  gap: 0;
  position: relative;
}
.auth-story {
  position: relative;
  width: 100%;
  min-height: 680px;
  overflow: hidden;
  background: #193e35;
  border-radius: 24px 0 0 24px;
  color: #fff7da;
}
.story-brand { position: absolute; z-index: 2; top: 30px; left: 34px; display: flex; align-items: center; gap: 10px; letter-spacing: 3px; font-size: 12px; font-weight: 700; }
.brand-mark { display: inline-grid; place-items: center; width: 36px; height: 36px; color: #e7d193; border: 1px solid #d6c38a60; border-radius: 12px; font-size: 22px; flex-shrink: 0; }
.forest-scene { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 65%; }
.auth-story::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(150deg, #10271e90, transparent 28%);
}
.auth-panel {
  width: 100%; min-height: 680px; padding: 65px 52px 40px;
  border-radius: 0 24px 24px 0; border: 0; box-shadow: none;
}
.game-logo { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; margin-bottom: 30px; text-align: left; }
.game-logo .game-logo-emoji { font-size: 28px; padding: 10px; background: #ecf0df; border-radius: 15px; text-shadow: none; }
.game-logo h2 { font-family: "Songti SC", serif; font-size: 32px; font-weight: 700; letter-spacing: 3px; }
.auth-panel .tabs { background: #eef0e4; border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 26px; }
.auth-panel .tab { box-shadow: none; border: 0 !important; background: transparent !important; font-size: 12px; }
.auth-panel .tab.active { background: #fffdf5 !important; color: #2d583e !important; box-shadow: 0 2px 8px #183d3210; }
.auth-panel label { font-size: 12px; color: #4a614b; gap: 9px; margin-bottom: 18px; }
.auth-panel input { min-height: 46px; font-size: 13px; }
.auth-actions { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 26px; }
.auth-actions .primary, .auth-actions .guest-observe-btn { min-height: 46px; width: 100%; font-size: 13px; }
.auth-actions .guest-observe-btn { background: transparent !important; box-shadow: none; }
.app-copyright { color: #50634f; }
.author-link { color: #365e47; font-weight: 700; text-decoration: underline; text-underline-offset: 0.18em; }
.author-link:hover { color: #193e35; }
.auth-copyright { grid-column: 1 / -1; margin-top: 20px; font-size: 10px; letter-spacing: 1px; }

/* Game shell: the map and the companion panel share the first viewport. */
.world-view { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; }
.topbar, .world-stats-bar, .journey-strip, .admin-panel { grid-column: 1 / -1; }
.topbar {
  padding: 16px 24px; margin: 0; border: 1px solid #244b3e; border-radius: 18px;
  background: #193e35; box-shadow: 0 5px 0 #d9decc;
}
.topbar-brand { display: flex; align-items: center; gap: 12px; color: #fff4d5; text-shadow: none; font-size: 20px; letter-spacing: 3px; white-space: nowrap; }
.topbar-brand small { display: block; margin-top: 4px; font-size: 8px; color: #b7c9ae; font-weight: 500; letter-spacing: 2px; }
.top-actions { gap: 9px; }
.topbar .circ-btn { width: auto; min-width: 36px; height: 36px; padding: 0 10px; min-height: 36px; color: #e8e9cf !important; background: #315448 !important; border-color: #567360 !important; box-shadow: none; font-size: 13px; }
.world-stats-bar { margin: 0; padding: 4px 3px; border: 0; background: none; box-shadow: none; gap: 8px; border-radius: 0; }
.world-stats-bar > span { background: #e5e9db !important; border: 1px solid #d9dfcc !important; color: #556b50 !important; box-shadow: none; border-radius: 7px; padding: 6px 10px; font-size: 11px; }
.world-stats-bar b { color: #2a523b; }
.world-stats-bar .stats-resource { background: #f6ebc9 !important; border-color: #e8dab2 !important; color: #8c6d2d !important; }
.world-stats-bar .mobile-event-chip { display: none; }
.journey-strip { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 3px 2px 7px; }
.journey-strip > div { display: flex; align-items: center; gap: 12px; min-width: 0; }
.journey-icon { display: grid; place-items: center; background: #e2e7d5; color: #6e8559; width: 43px; height: 43px; border-radius: 50%; font-size: 25px; flex-shrink: 0; }
.journey-strip h2 { font-size: 17px; font-weight: 650; line-height: 1.5; }
.journey-strip p { font-size: 11px; color: var(--muted); margin-top: 3px; }
.journey-strip .ghost { padding: 0 15px; font-size: 11px; white-space: nowrap; box-shadow: none; background: transparent !important; }
.world-panel-frame { display: flex; flex-direction: column; min-width: 0; height: max(540px, calc(100dvh - 260px)); border: 1px solid #b7c7aa; border-radius: 18px; overflow: hidden; background: #f6f6e9; box-shadow: 0 5px 0 #d5ddc8; }
.map-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 14px 18px; min-height: 64px; flex-shrink: 0; background: #fffdf3; border-bottom: 1px solid #d3ddc5; }
.map-heading .eyebrow { font-size: 8px; letter-spacing: 2px; color: #8c9a7a !important; }
.map-heading h2 { font-size: 15px; letter-spacing: 1px; margin-top: 3px; }
.sync-status { font-size: 10px; color: #6d8262; display: inline-flex; align-items: center; gap: 6px; text-align: right; }
.sync-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #83a665; flex-shrink: 0; }
.sync-status[data-state="paused"]::before { background: #b69c5b; }
.sync-status[data-state="error"]::before { background: #bf6f52; }
.world-panel { width: 100% !important; max-width: none; height: auto !important; min-height: 0; flex: 1; border: 0 !important; border-radius: 0; box-shadow: none; background: #698c59; cursor: grab; }
.world-panel-frame .map-toolbar { top: 78px; left: 12px; right: auto; width: max-content; max-width: calc(100% - 24px); padding: 3px; background: #fffcf0df; border: 1px solid #c5d3b9; border-radius: 11px; box-shadow: 0 3px 8px #25452f15; }
.map-toolbar .map-tgl, .map-filter-toggle { background: #fffdf0 !important; border-color: #b8c9a7 !important; color: #315b3b; border-radius: 9px; box-shadow: 0 2px 4px #163c2526; }
.map-toolbar .map-tgl.on { background: #e2ebd1 !important; }
.map-control-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; min-height: 48px; flex-shrink: 0; background: #fffdf3; border-top: 1px solid #d3ddc5; }
.map-control-hint { font-size: 10px; color: #8b947f; }
kbd { font: inherit; font-size: 9px; border: 1px solid #cbd5bf; border-radius: 4px; padding: 1px 4px; color: #839176; }
.map-control-hint kbd { margin-left: 9px; }
.map-controls { display: flex; align-items: center; gap: 5px; }
.map-controls button { display: grid; place-items: center; background: #eef1e3; color: #4a6c42; border: 1px solid #d7dec9; border-radius: 8px; width: 31px; height: 31px; font-size: 18px; }
.map-controls button:hover { background: #dce7cf; }
.map-controls output { width: 42px; text-align: center; font-size: 10px; font-variant-numeric: tabular-nums; color: #67785a; }
.panel-nav { display: flex; gap: 5px; padding: 8px; background: #e6eadb; border-bottom: 1px solid #d5ddc8; flex-shrink: 0; }
.panel-nav button { flex: 1; min-height: 39px; background: transparent; border: 0; border-radius: 9px; color: #738269; font-size: 12px; white-space: nowrap; }
.panel-nav button.active { background: #fffdf3; color: #2e5940; box-shadow: 0 2px 5px #2a4f3312; }
.panel-nav kbd { margin-left: 4px; }
.bottom-grid { display: flex; flex-direction: column; gap: 0; margin: 0; min-width: 0; height: max(540px, calc(100dvh - 260px)); border: 1px solid #d0dac3; border-radius: 18px; background: #fffcf4; overflow: hidden; align-items: stretch; }
.bottom-grid > .pet-panel, .bottom-grid > .social-panel, .bottom-grid > .log-panel { display: none; min-height: 0; overflow-y: auto; border: 0; border-radius: 0; box-shadow: none; padding: 18px; flex: 1; }
.bottom-grid[data-mobile-active-panel="pet"] > .pet-panel { display: flex; flex-direction: column; }
.pet-panel > * { flex-shrink: 0; }
.bottom-grid[data-mobile-active-panel="social"] > .social-panel { display: flex; }
.bottom-grid[data-mobile-active-panel="log"] > .log-panel { display: flex; flex-direction: column; }
.pet-team-head { padding-bottom: 12px; border-bottom: 1px solid #e0e5d5; }
.pet-team-head .ghost { min-height: 32px; font-size: 11px; }
.pet-title { margin-top: 5px; }
.pet-title h3 { color: #36533d; font-size: 22px; }
.pet-chip { background: #f0f3e8; border-color: #d5dfc8; box-shadow: none; border-radius: 10px; padding: 8px; }
.pet-chip.active { background: #e1ebd5; border-color: #8caa74; box-shadow: inset 3px 0 0 #71945e; }
.pet-basic-chip, .pet-extra-chip, .profile-row, .profile-family-avatar { background: #f0f2e7 !important; border-color: #d9e0cd !important; color: #526849 !important; }
.detail-box, .stat-quick-row .stat.stat-compact { background: #f4f5eb; border-color: #dce2cf; box-shadow: none; }
.pet-group-head, .stat.stat-compact b { background: #eaf0df; border-color: #d2dfc3; color: #557346; }
.pet-group-count, .ability-chip, .last-act-chip { background: #edf0e2; border-color: #d6e0c7; color: #627651; }
.pet-quick-actions .career-badge { background: #f7efda; border-color: #e6d9b7; }
.pet-overview-art .pixel-pet.large { box-shadow: 0 6px 18px #52673718; }
.bar, .s-bar, .obj-bar, .rel-bar { border: 0; border-radius: 6px; box-shadow: inset 0 1px 2px #34572c15; }
.bar::after, .s-bar::after, .obj-bar::after, .rel-bar::after { opacity: .2; }
.world-stats-bar > span::after { display: none; }
.pet-basic-chip small, .pet-extra-chip small, .profile-family-row > span { color: #809271; }
.pet-care-actions { gap: 8px; }
.care-btn { min-height: 39px; font-size: 12px; }
.command-grid { gap: 7px; }
.command-btn { min-height: 36px; font-size: 11px; padding: 6px; }
.more-actions { border-top: 1px solid #e0e5d5; margin-top: 14px; padding-top: 12px; }
.more-actions summary { cursor: pointer; color: #657b58; font-size: 11px; }
.more-actions summary span { font-size: 10px; color: #929c86; margin-left: 6px; }
.more-actions[open] .command-grid { margin-top: 12px; }
.social-tabs { background: #ecf0e1; border-radius: 10px; gap: 3px; }
.social-tab { font-size: 12px; padding: 8px 12px; }
.log-panel .panel-head { flex-wrap: wrap; gap: 10px; }
.log-panel .panel-actions { flex-wrap: wrap; }
.messages { max-height: none; }
.log-group-head { border-radius: 10px; }
.log-pet-name { color: #456340; }
.admin-panel { padding: 24px; margin-top: 6px; }
body:not(.admin-tools-open) #adminPanel { display: none; }
.admin-panel > .panel-head { flex-wrap: wrap; gap: 10px; }
.admin-tabs { gap: 8px; }
.admin-tabs .tab { font-size: 12px; }
body.map-immersive .world-view { grid-template-columns: minmax(0, 1fr); }
body.map-immersive .bottom-grid { display: none; }
body.map-immersive #mapImmersiveBtn { background: #315e46; color: #fff; }
body.is-observer .bottom-grid { display: flex; }
body.is-observer .bottom-grid > .log-panel { display: flex; }

@media (max-width: 1100px) and (min-width: 901px) {
  .app { width: calc(100% - 28px); }
  .world-view { grid-template-columns: minmax(0, 1fr) 320px; gap: 12px; }
  .map-control-hint { font-size: 0; }
  .map-control-hint kbd { display: none; }
}
@media (max-width: 900px) {
  .app, .app:has(.auth-view:not(.hidden)) { width: 100%; padding: 0; }
  .auth-view { min-height: 100dvh; padding: 24px; grid-template-columns: 1fr; gap: 0; }
  .auth-story { display: block; width: min(440px, 100%); height: clamp(110px, 19dvh, 154px); min-height: 0; border-radius: 18px 18px 0 0; }
  .auth-story .forest-scene { object-position: 50% 64%; }
  .story-brand { top: 14px; left: 18px; }
  .auth-story::after { background: linear-gradient(100deg, #10271e85, transparent 58%); }
  .auth-panel { width: min(440px, 100%); min-height: 0; border-radius: 0 0 18px 18px; padding: 20px 24px; border: 1px solid #d3ddc5; }
  .game-logo { margin-bottom: 24px; }
  .auth-copyright { margin-top: 18px; }
  .world-view { display: flex; gap: 0; padding: 8px 10px calc(72px + env(safe-area-inset-bottom)); height: var(--app-viewport-height); min-height: 0; overflow: hidden; }
  .topbar { padding: 10px 12px; border-radius: 14px; flex-shrink: 0; }
  .topbar-brand { font-size: 17px; letter-spacing: 2px; gap: 8px; }
  .topbar-brand small { font-size: 6px; letter-spacing: 1px; }
  .brand-mark { width: 29px; height: 29px; border-radius: 9px; font-size: 18px; }
  .topbar .circ-btn { min-width: 32px; width: auto; height: 32px; min-height: 32px; padding: 0 8px; }
  .top-actions { gap: 5px; }
  .top-actions #worldEventBadge { display: none; }
  .world-stats-bar .mobile-event-chip { display: inline-flex; background: #f6ebc9 !important; }
  .world-stats-bar { flex-shrink: 0; padding: 10px 0 7px; flex-wrap: nowrap; overflow-x: auto; min-height: 42px; gap: 5px; }
  .world-stats-bar > span { flex-shrink: 0; font-size: 10px; padding: 4px 7px; }
  .journey-strip { flex-shrink: 0; padding: 6px 1px 12px; gap: 8px; }
  .journey-icon { display: none; }
  .journey-strip h2 { font-size: 13px; }
  .journey-strip p { font-size: 10px; line-height: 1.5; }
  .journey-strip .ghost { min-height: 34px; padding: 0 9px; font-size: 10px; }
  .world-panel-frame { flex: 1; height: auto; min-height: 100px; border-radius: 14px; }
  .map-heading { padding: 9px 12px; min-height: 47px; }
  .map-heading h2 { font-size: 13px; }
  .map-heading .eyebrow { display: none; }
  .sync-status { font-size: 9px; }
  .world-panel-frame .map-toolbar { top: 59px; }
  .map-control-bar { padding: 5px 8px; min-height: 43px; }
  .map-control-hint { font-size: 9px; }
  .desktop-map-shortcut { display: none; }
  .map-control-hint kbd { display: none; }
  #mapImmersiveBtn { display: none; }
  .map-controls { gap: 4px; }
  .map-controls button { width: 34px; height: 32px; }
  .map-controls output { width: 33px; }
  .minimap { top: auto !important; left: auto !important; right: 12px; bottom: 53px !important; }
  .panel-nav { display: none; }
  .bottom-grid { height: auto; position: fixed; left: 8px; right: 8px; width: auto; bottom: calc(68px + env(safe-area-inset-bottom)); max-height: 72dvh; padding: 10px 0 0; border: 1px solid #c5d1b8; border-radius: 18px 18px 8px 8px; box-shadow: 0 -12px 40px #16392830; }
  .bottom-grid > .pet-panel, .bottom-grid > .social-panel, .bottom-grid > .log-panel { padding: 24px 18px 18px; max-height: 72dvh; flex: auto; }
  .mobile-panel-close { top: 8px; right: 8px; z-index: 5; width: 30px; height: 30px; }
  .mobile-map-hud { left: 8px; right: 8px; bottom: 0; border: 1px solid #d4dcc7; border-bottom: 0; border-radius: 18px 18px 0 0; background: #fffcf4; box-shadow: 0 -4px 20px #254c3010; padding: 5px 5px calc(5px + env(safe-area-inset-bottom)); }
  .mobile-map-menu-btn { border-radius: 11px; height: 52px; color: #89947b; }
  .mobile-map-menu-btn.active { background: #e6edda; color: #3e633a; box-shadow: inset 0 -2px 0 #85a46a; }
  .mobile-map-menu-btn span { font-size: 19px; }
  .mobile-map-menu-btn b { font-size: 10px; }
  .mobile-panel-backdrop { background: #143b2870; backdrop-filter: blur(2px); }
  .care-btn, .command-btn, .forage-btn { min-height: 44px; font-size: 12px; }
  .admin-panel { padding: 16px; }
  body.admin-tools-open #adminPanel { position: fixed; inset: 78px 8px calc(70px + env(safe-area-inset-bottom)); z-index: 150; margin: 0; overflow: auto; overscroll-behavior: contain; box-shadow: 0 8px 30px #183f3430; }
  .admin-tabs { display: flex; overflow-x: auto; }
  .admin-tabs .tab { flex-shrink: 0; min-width: 70px; padding: 5px 9px; }
  .modal-panel { border-radius: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
body.page-inactive *, body.page-inactive *::before, body.page-inactive *::after { animation-play-state: paused !important; }

/* Compact reading scale; native controls retain comfortable hit targets. */
html { font-size:14px; -webkit-text-size-adjust:100%; text-size-adjust:100%; }
body { font-size:13px; line-height:1.55; }
.bottom-grid, .modal-panel, .modal-box, .cmd-menu, .obj-action-popup { font-size:13px; }
.bottom-grid p, .modal-panel p, .help-body, .log-pet-lines, .log-pet-body, .message { font-size:13px; line-height:1.6; overflow-wrap:anywhere; }
.pet-title h3, .profile-name, .modal-panel h2, .modal-panel h3, .hatch-prompt-copy h3 { font-size:17px; line-height:1.4; }
.detail-box b, .profile-row, .relationship, .memory-item, .target-detail-chip { font-size:12px; }
.section-label, .profile-label, .log-group-head, .log-pet-head { font-size:12px; letter-spacing:.3px; }
.modal-panel label, .modal-panel button, .modal-box button, .bottom-grid button { font-size:12px; }
.modal-panel { padding:18px; border-radius:16px; }
.modal-panel .panel-head { margin-bottom:12px; }
.modal-actions { gap:8px; flex-wrap:wrap; }
.log-pet-card { padding:8px; border-radius:12px; }
.log-pet-avatar { width:28px; height:28px; flex:0 0 28px; }
.help-body h3 { font-size:15px; }
@media(max-width:900px) {
  .modal-panel { width:calc(100% - 24px); max-height:calc(100dvh - 32px); padding:16px; }
  /* 16px avoids Safari's automatic focus zoom without disabling user zoom. */
  input, select, textarea, .auth-panel input, .modal-panel input, .modal-panel select, .modal-panel textarea { font-size:16px; }
  .modal-panel button, .care-btn, .command-btn, .forage-btn { min-height:40px; }
  .pixel-pet.pet-sprite-avatar.large { width:76px; height:76px; }
}
/* Long names remain readable in narrow profile cards. */
.modal-panel.pet-profile-panel { min-width:0; max-width:min(420px, calc(100vw - 24px)); }
.profile-row b { white-space:normal; overflow:visible; text-overflow:clip; overflow-wrap:anywhere; }
@media(max-width:600px) {
  .profile-row { flex-direction:column; align-items:flex-start; gap:2px; }
  .profile-row .profile-label { min-width:0; }
}
@media(max-width:600px) {
  .modal:has(.pet-profile-panel) { padding:12px; }
  .modal-panel.pet-profile-panel { width:100%; }
  #petProfileBody { grid-template-columns:minmax(0, 1fr); gap:10px; }
  .profile-side { display:flex; justify-content:center; align-items:center; }
  .profile-meta { grid-template-columns:repeat(2,minmax(0,1fr)); gap:6px; }
  .profile-row { flex-direction:row; align-items:baseline; gap:6px; }
  .profile-row .profile-label { flex-shrink:0; }
  .profile-career-rarity { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
/* Slightly denser interface, while keeping form text and touch targets usable. */
html {font-size:13px;}
body,.bottom-grid,.modal-panel,.modal-box,.cmd-menu,.obj-action-popup {font-size:12px;}
.bottom-grid p,.modal-panel p,.help-body,.log-pet-lines,.log-pet-body,.message {font-size:12px;line-height:1.55;}
.pet-title h3,.profile-name,.modal-panel h2,.modal-panel h3 {font-size:16px;}
