/* Focused HUD and menu cleanup. Keep the town's existing ink, paper and gold palette. */
body > header.player-hud {
  position: fixed !important;
  inset: calc(14px + env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) auto auto;
  height: auto !important;
  padding: 0 !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  z-index: 31;
  pointer-events: none;
}
body > header.player-hud .player { gap: 8px; pointer-events: auto; }
body > header.player-hud #avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: auto;
  min-height: 42px;
  padding: 7px 12px;
  border-radius: 14px;
}
body > header.player-hud #avatar::after { content: "Inventory"; font: 800 12px var(--ui-body); }
body > header.player-hud #character-profile { min-height: 42px; padding: 7px 13px; }
body > header.player-hud #xp { padding: 10px 13px; }
.world-shell, .first-playable > .world-shell { height: 100dvh; min-height: 0; }
.first-playable .world-top { top: 16px; left: 18px; right: 18px; }
.town-toolbar :is(#open-places, #open-session-menu), .madrid-clock { display: none !important; }
.town-toolbar { align-items: center; }
#playtest-tracker { top: 78px; }

/* Pause: a short primary action, a compact tools grid, and quieter secondary actions. */
#session-menu {
  width: min(600px, calc(100vw - 28px));
  max-width: 600px;
  max-height: calc(100dvh - 28px);
  padding: 24px;
  border-radius: 24px;
  overflow: auto;
}
#session-menu .welcome-dialog-head { margin-bottom: 18px; align-items: center; }
#session-menu .welcome-dialog-head h2 { margin: 5px 0 0; font-size: 32px; }
#session-menu .welcome-dialog-head small { letter-spacing: .1em; font-size: 11px; }
#session-menu .first-pause-actions { display: grid; gap: 18px; margin: 0; }
#session-menu :is(.session-primary, .session-grid, .session-secondary, .session-exit) { display: grid; gap: 9px; }
#session-menu :is(.session-grid, .session-secondary, .session-exit) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#session-menu .first-pause-actions button {
  min-height: 44px;
  padding: 11px 15px;
  border-width: 2px;
  border-radius: 13px;
  box-shadow: 0 2px 0 var(--ui-line);
  font-size: 14px;
}
#session-menu #session-resume { min-height: 54px; font-size: 17px; text-align: center; }
#session-menu #session-resume kbd { float: right; padding: 3px 6px; border: 1px solid #9c771d; border-radius: 5px; font: 700 11px var(--ui-body); }
#session-menu #session-mission { background: var(--ui-cream); }
#session-menu :is(.session-secondary, .session-exit) button { background: var(--ui-mist); font-size: 13px; }
#session-menu #session-quit { color: #923d3d; background: #fff1ec; }
#session-menu .session-more { margin: 18px 0 12px; padding-top: 14px; }
#session-menu .session-save-note { margin: 14px 0 0; font-size: 12px; line-height: 1.5; }
#session-menu > small:last-child { display: none; }

/* Character progress: give the level and next milestone room to breathe. */
#profile-dialog { width: min(700px, calc(100vw - 28px)); border: 2px solid var(--ui-line); background: var(--ui-paper); }
#profile-dialog .school-header { background: var(--ui-cream); color: var(--ui-ink); padding: 18px 24px; border-bottom: 2px solid var(--ui-line); }
#profile-dialog .school-header button { color: var(--ui-ink); background: white; border: 2px solid var(--ui-line); border-radius: 12px; }
#profile-body { padding: 24px; }
.profile-hero { padding: 22px; background: var(--ui-cream); border: 1px solid #ead9ad; border-radius: 18px; }
#profile-body .profile-rank { margin: 7px 0 12px; font-size: 25px; }
.profile-number { font: 600 clamp(34px, 5vw, 46px) var(--ui-display); color: var(--ui-ink); }
.profile-number small { font: 700 16px var(--ui-body); color: var(--ui-ink-soft); }
.profile-next { margin-top: 18px; }
#profile-body .profile-next progress { display: block; height: 14px; margin: 0; accent-color: var(--ui-teal-deep); border-radius: 999px; overflow: hidden; }
#profile-body .profile-next progress::-webkit-progress-bar { background: #e1ebe8; border-radius: 999px; }
#profile-body .profile-next progress::-webkit-progress-value { background: var(--ui-teal-deep); border-radius: 999px; }
#profile-body .profile-next progress::-moz-progress-bar { background: var(--ui-teal-deep); border-radius: 999px; }
.profile-next-line { display: flex; justify-content: space-between; gap: 12px; margin-top: 9px; font-size: 13px; color: var(--ui-ink-soft); }
.profile-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 20px 0; }
.profile-stat { display: grid; gap: 6px; padding: 17px 14px; border: 1px solid #d9e4e4; border-radius: 14px; background: #f3f8f8; }
.profile-stat :is(small, span) { font-size: 12px; color: var(--ui-ink-soft); }
.profile-stat strong { font: 600 23px var(--ui-display); overflow-wrap: anywhere; }
.profile-interests { margin: 20px 0; }
.profile-interests h3 { margin: 0 0 12px; font-size: 18px; }
#profile-body #interest-resume { padding: 10px 14px; border: 1px solid #9ebfb1; border-radius: 10px; background: #eaf5ef; color: var(--ui-ink); font-weight: 800; }
.profile-interest-list { display: flex; flex-wrap: wrap; gap: 8px; }
.profile-interest-list span { background: var(--ui-mist); border-radius: 999px; padding: 7px 11px; font-size: 13px; }
.profile-rules { padding: 16px 0; border-top: 1px solid #d9e4e4; }
.profile-rules summary { cursor: pointer; font-weight: 800; font-size: 14px; }
#profile-body .profile-rules p { font-size: 13px; line-height: 1.65; }
.profile-save-note { display: block; color: var(--ui-ink-soft); font-size: 12px; line-height: 1.5; }
.playtest-ready-rewards { display: grid; gap: 8px; margin: 18px 0; padding: 14px; background: var(--ui-cream); border: 1px solid #ead9ad; border-radius: 14px; }
.playtest-ready-rewards h3 { margin: 0 0 4px; font-size: 17px; }
.playtest-ready-rewards button { text-align: left; font-size: 13px; }

@media (max-width: 700px) {
  body > header.player-hud { inset: calc(9px + env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) auto auto; }
  body > header.player-hud #avatar::after { content: none; }
  body > header.player-hud #avatar { width: 40px; padding: 6px; }
  body > header.player-hud #character-title { display: none; }
  body > header.player-hud .player { gap: 6px; }
  .first-playable .world-top { top: 10px; left: 10px; }
  #playtest-tracker { top: 67px; }
  #session-menu { padding: 20px; }
  #profile-body { padding: 18px; }
  .profile-hero { padding: 18px; }
  .profile-stat { padding: 13px 10px; }
  .profile-stat strong { font-size: 20px; }
}
@media (max-width: 420px) {
  body > header.player-hud #xp { display: none; }
  .profile-stats { grid-template-columns: 1fr; }
  .profile-stat { grid-template-columns: 1fr auto; align-items: center; }
  .profile-next-line { flex-wrap: wrap; }
  #session-menu :is(.session-secondary, .session-exit) { grid-template-columns: 1fr; }
}
@media (max-width: 850px) {
  html:not(.touch-play) .first-playable .world-top { top: 72px; }
  html:not(.touch-play) .first-playable .town-toolbar { max-width: 100%; }
  html:not(.touch-play) #playtest-tracker { top: 130px; }
}
@media (max-width: 550px) {
  html:not(.touch-play) #playtest-tracker { top: 182px; }
}

/* Island actions share one dock. The town's E button gets a separate row only while the dock is visible. */
html:not(.touch-play) .isle-hud .ih-bar {
  left: 50%;
  right: auto;
  bottom: 18px;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 36px);
  flex-wrap: nowrap;
  justify-content: center;
  align-items: stretch;
  gap: 8px;
}
html:not(.touch-play) .isle-hud .ih-btn {
  min-width: 0;
  min-height: 54px;
  max-width: 180px;
  border-radius: 14px;
  padding: 7px 11px;
  flex-direction: row;
  gap: 7px;
}
html:not(.touch-play) .isle-hud .ih-btn b { font-size: 22px; flex: none; }
html:not(.touch-play) .isle-hud .ih-btn small { min-width: 0; font-size: 12px; line-height: 1.3; overflow-wrap: anywhere; }
html:not(.touch-play) .isle-hud .ih-help { bottom: 80px; max-width: calc(100% - 36px); white-space: normal; text-align: center; }
html:not(.touch-play) .world-shell:has(.isle-hud:not([hidden]) .ih-bar:not(:empty)) .bottom-hud {
  left: 18px;
  right: 18px;
  bottom: 114px;
  justify-content: center;
}
html:not(.touch-play) .world-shell:has(.isle-hud:not([hidden]) .ih-bar:not(:empty)) .bottom-hud #interact { min-width: 0; }
.world-shell:has(.isle-hud:not([hidden]) .ih-bar [data-id="interact"]) .bottom-hud #interact,
.world-shell:has(.isle-hud.asking:not([hidden])) .bottom-hud #interact { visibility: hidden; pointer-events: none; }
@media (max-width: 740px) {
  html:not(.touch-play) .world-shell:has(.isle-hud:not([hidden]) .ih-bar:not(:empty)) .bottom-hud { left: 18px; right: 170px; bottom: 140px; }
  html:not(.touch-play) .isle-hud .ih-bar { left: 18px; right: 170px; width: auto; max-width: none; transform: none; }
  html:not(.touch-play) .isle-hud .ih-btn { padding: 7px 8px; gap: 5px; }
  html:not(.touch-play) .isle-hud .ih-btn small { font-size: 11px; }
  html:not(.touch-play) .isle-hud .ih-help { bottom: 96px; }
  html:not(.touch-play) .isle-hud:has(.ih-bar > :nth-child(5)) .ih-btn { flex-direction: column; padding: 6px; gap: 3px; }
  html:not(.touch-play) .isle-hud:has(.ih-bar > :nth-child(5)) .ih-help { bottom: 122px; }
  html:not(.touch-play) .world-shell:has(.isle-hud:not([hidden]) .ih-bar > :nth-child(5)) .bottom-hud { bottom: 166px; }
}
