/* ==========================================================================
   BITR TOWN
   16-bit JRPG look: blue gradient menu windows with a silver frame, a white
   pointing-hand cursor, pixel fonts, and a title screen.
   Fonts: DotGothic16 and Press Start 2P (SIL OFL, files in assets/fonts).
   ========================================================================== */
@font-face { font-family: 'DotGothic16'; src: url('../assets/fonts/dotgothic16-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Press Start 2P'; src: url('../assets/fonts/press-start-2p-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }

:root {
  --win-top: #4a63d8;
  --win-mid: #2338a8;
  --win-bot: #0d1a66;
  --frame: #e9ebf5;
  --frame-dark: #8d93b3;
  --ink: #ffffff;
  --ink-dim: #c9d0ff;
  --ink-shadow: #0a1040;
  --gold: #f2c14e;
  --pixel: 'DotGothic16', 'Trebuchet MS', system-ui, sans-serif;
  --arcade: 'Press Start 2P', 'Courier New', monospace;
  --hand: url('../assets/town-hand.svg');
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b0f2a; }
body {
  font-family: var(--pixel);
  font-size: 18px;
  color: var(--ink);
  -webkit-font-smoothing: none;
  font-synthesis: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, a { font: inherit; color: inherit; }
[hidden] { display: none !important; }

#town {
  position: fixed; inset: 0;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
  outline: none;
}

.skip-link {
  position: fixed; left: 8px; top: -60px; z-index: 400;
  padding: 8px 12px; background: var(--win-mid); border: 2px solid var(--frame);
}
.skip-link:focus { top: 8px; }

/* ---- The window ---------------------------------------------------------- */
.win {
  position: relative;
  color: var(--ink);
  background: linear-gradient(180deg, var(--win-top) 0%, var(--win-mid) 38%, var(--win-bot) 100%);
  border: 3px solid var(--frame);
  border-radius: 7px;
  box-shadow:
    0 0 0 2px #1b1d33,
    inset 0 0 0 1px var(--frame-dark),
    inset 0 0 0 3px #1a2470,
    4px 5px 0 2px rgba(0, 0, 0, 0.35);
  text-shadow: 2px 2px 0 var(--ink-shadow);
}

/* The pointing-hand cursor on whatever is selected. */
.menu-item {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 6px 10px 6px 34px;
  text-align: left;
  background: none; border: 0; border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  text-shadow: 2px 2px 0 var(--ink-shadow);
}
.menu-item::before {
  content: '';
  position: absolute; left: 4px; top: 50%;
  width: 24px; height: 17px;
  margin-top: -9px;
  background: var(--hand) center / contain no-repeat;
  image-rendering: pixelated;
  opacity: 0;
}
.menu-item:hover::before, .menu-item:focus::before, .menu-item.is-current::before { opacity: 1; }
.menu-item.is-current::before { animation: none; }
.menu-item:focus-visible::before { animation: hand 0.6s steps(2) infinite; }
.menu-item:hover, .menu-item:focus { background: rgba(255, 255, 255, 0.08); outline: none; }
.menu-item:focus-visible { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.55); }
@keyframes hand { 50% { transform: translateX(-3px); } }

.menu-link { color: var(--gold); text-decoration: underline; text-underline-offset: 3px; }
.menu-link.small { font-size: 0.8em; margin-left: 6px; }
.menu-link:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

@font-face { font-family: 'Cinzel'; src: url('../assets/fonts/cinzel-latin-600-normal.woff2') format('woff2'); font-weight: 600; font-display: block; }

/* ---- Title screen ---------------------------------------------------------
   Drawn on a low-resolution canvas (js/town/title.js); the button sits on top. */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.title {
  position: fixed; inset: 0; z-index: 300;
  background: #05061a;
  cursor: pointer;
  transition: opacity 0.6s steps(6);
}
.title.is-gone { opacity: 0; pointer-events: none; }
.title-canvas { position: absolute; inset: 0; display: block; image-rendering: pixelated; image-rendering: crisp-edges; }
.title-start {
  position: absolute; left: 50%; top: 76%;
  transform: translateX(-50%);
  font: 400 clamp(12px, 2.4vw, 16px)/1 var(--arcade);
  letter-spacing: 0.12em;
  color: #fff;
  text-shadow: 2px 2px 0 #1b1240, 0 0 0 #000;
  background: none; border: 0; padding: 14px 18px;
  text-transform: uppercase;
  cursor: pointer;
  opacity: 0;
}
.title.is-drawn .title-start { animation: start-in 0s 2.6s forwards, blink 1.2s steps(2) 2.6s infinite; }
@keyframes start-in { to { opacity: 1; } }
.title-start:focus-visible { outline: 2px dashed #fff; outline-offset: 6px; }
@keyframes blink { 50% { opacity: 0; } }

/* ---- HUD ----------------------------------------------------------------- */
.hud {
  position: fixed; left: 0; right: 0; top: 0; z-index: 50;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  pointer-events: none;
  opacity: 0; transition: opacity 0.4s ease;
}
body.is-playing .hud { opacity: 1; }
.hud > * { pointer-events: auto; }
.hud-brand { display: grid; place-items: center; min-height: 44px; padding: 6px 12px; text-decoration: none; color: var(--gold); }
.hud-brand svg { display: block; filter: drop-shadow(2px 2px 0 var(--ink-shadow)); }
.hud-brand:focus-visible { outline: none; box-shadow: 0 0 0 2px #1b1d33, 0 0 0 5px #fff; }
.hud-buttons { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.hud-btn {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 6px 12px;
  font-size: 17px; text-decoration: none; cursor: pointer;
}
.hud-btn:hover, .hud-btn:focus-visible { filter: brightness(1.18); outline: none; }
.hud-btn:focus-visible { box-shadow: 0 0 0 2px #1b1d33, 0 0 0 5px #fff; }
.hud-icon { font-size: 18px; line-height: 1; width: 18px; text-align: center; }
#btn-music[aria-pressed='false'] .hud-icon { opacity: 0.45; }
.hud-svg { height: 18px; fill: currentColor; shape-rendering: crispEdges; filter: drop-shadow(1px 1px 0 var(--ink-shadow)); }
#btn-music[aria-pressed='false'] .sound-waves { display: none; }

.area {
  position: fixed; left: 50%; top: 76px; z-index: 40;
  margin: 0; padding: 10px 22px;
  transform: translateX(-50%);
  font: 400 13px/1.3 var(--arcade);
  letter-spacing: 0.06em;
  white-space: nowrap;
  pointer-events: none;
}
.area.is-showing { animation: area-in 2.2s ease both; }
@keyframes area-in { 0% { opacity: 0; transform: translate(-50%, -8px); } 12%, 80% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }

.hint {
  position: fixed; left: 16px; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 40;
  width: fit-content;
  margin: 0 auto; padding: 8px 14px;
  font-size: 17px; text-align: center;
  background: rgba(10, 16, 64, 0.82);
  border: 2px solid rgba(233, 235, 245, 0.7);
  border-radius: 6px;
  text-shadow: 2px 2px 0 var(--ink-shadow);
  pointer-events: none;
}

/* ---- Name tags ----------------------------------------------------------- */
.name-tags { position: fixed; inset: 0; z-index: 10; pointer-events: none; overflow: hidden; opacity: 0; transition: opacity 0.4s; }
body.is-playing .name-tags { opacity: 1; }
.name-tag {
  position: absolute; left: 0; top: 0;
  padding: 1px 7px 2px;
  font-size: 14px;
  color: #fff;
  background: rgba(10, 16, 64, 0.72);
  border: 2px solid var(--accent, #fff);
  border-radius: 4px;
  text-shadow: 1px 1px 0 #000;
  white-space: nowrap;
  opacity: 0.7;
  transition: opacity 0.2s;
}
.name-tag.is-near { opacity: 1; }

/* ---- Dialogue box -------------------------------------------------------- */
.dialog {
  position: fixed; z-index: 120;
  left: 50%; bottom: max(14px, env(safe-area-inset-bottom));
  width: min(760px, calc(100vw - 24px));
  min-height: 132px;
  transform: translateX(-50%);
  padding: 14px 22px 18px;
  font-size: 21px; line-height: 1.45;
}
.dialog-name { margin: 0 0 4px; font: 400 13px/1.4 var(--arcade); color: var(--gold); letter-spacing: 0.06em; }
.dialog-text { margin: 0; min-height: 2.9em; }
.dialog-choices { display: grid; gap: 2px; margin-top: 8px; max-width: 280px; }
.dialog-advance {
  position: absolute; inset: 0;
  background: none; border: 0; cursor: pointer;
  display: flex; align-items: flex-end; justify-content: flex-end;
  padding: 0 16px 8px 0;
}
.dialog-choices:not([hidden]) ~ .dialog-advance { pointer-events: none; }
.dialog-advance:focus-visible { outline: none; }
.dialog-more { font-size: 14px; animation: blink 0.8s steps(2) infinite; }
.dialog-choices { position: relative; z-index: 1; }

/* ---- Full-screen menus --------------------------------------------------- */
.screen {
  position: fixed; inset: 0; z-index: 130;
  display: grid; place-items: center;
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
  background: rgba(4, 6, 24, 0.55);
}

/* Profile: header, command list on the left, page on the right (FF style). */
.profile {
  --accent: var(--gold);
  display: grid;
  grid-template-columns: 170px 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas: 'head head' 'tabs page';
  gap: 10px;
  width: min(880px, 100%);
  height: min(640px, 100%);
}
#profile.is-opening .profile > * { animation: win-open 0.22s steps(4) both; }
#profile.is-opening .profile-tabs { animation-delay: 0.05s; }
#profile.is-opening .profile-page { animation-delay: 0.1s; }
@keyframes win-open { from { transform: scaleY(0.05); opacity: 0.4; } }

.profile-head { grid-area: head; display: flex; align-items: center; gap: 16px; padding: 10px 16px; }
.profile-face { width: 64px; height: 64px; object-fit: cover; border: 3px solid var(--frame); border-radius: 4px; box-shadow: 0 0 0 2px #1b1d33; background: #1a2470; }
.profile-name { margin: 0; font: 400 clamp(20px, 3.4vw, 28px)/1.2 var(--arcade); color: #fff; }
.profile-job { margin: 6px 0 0; font-size: 18px; color: var(--accent); }
.profile-head::after { content: ''; position: absolute; left: 12px; right: 12px; bottom: 6px; height: 3px; background: var(--accent); border-radius: 2px; opacity: 0.9; }

.profile-tabs { grid-area: tabs; display: flex; flex-direction: column; gap: 2px; padding: 10px 8px; align-self: start; }
.tab { font-size: 19px; }
.tab.is-current { color: var(--gold); }
.tab-close { margin-top: 10px; color: var(--ink-dim); }

.profile-page {
  grid-area: page;
  overflow-y: auto;
  padding: 18px 22px 22px;
  font-size: 18px; line-height: 1.45;
  scrollbar-width: thin; scrollbar-color: #e9ebf5 transparent;
}
.profile-page:focus-visible { outline: 2px dashed rgba(255, 255, 255, 0.6); outline-offset: -8px; }
.profile-page h3 { margin: 18px 0 8px; font: 400 12px/1.5 var(--arcade); color: var(--gold); letter-spacing: 0.05em; }
.profile-page h3:first-child { margin-top: 0; }
.page-foot { margin: 14px 0 0; font-size: 15px; color: var(--ink-dim); }
.empty { color: var(--ink-dim); }

/* Status */
.status { display: grid; grid-template-columns: 168px 1fr; gap: 18px 22px; align-items: start; }
.status-portrait img { display: block; width: 160px; height: 160px; object-fit: cover; border: 3px solid var(--frame); border-radius: 4px; box-shadow: 0 0 0 2px #1b1d33, 4px 4px 0 2px rgba(0, 0, 0, 0.35); background: #1a2470; }
.status-stats { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.status-stats div { min-width: 0; }
.status-stats dt { font: 400 10px/1.6 var(--arcade); color: var(--ink-dim); letter-spacing: 0.06em; text-transform: uppercase; }
.status-stats dd { margin: 2px 0 0; font-size: 20px; }
.status-wide { grid-column: 1 / -1; }
.chip { display: inline-block; margin: 4px 6px 0 0; padding: 1px 8px; font-size: 16px; border: 2px solid var(--accent); border-radius: 4px; background: rgba(0, 0, 0, 0.18); }
.status-doing { grid-column: 1 / -1; margin: 0; padding: 10px 14px; color: var(--ink-dim); border-left: 3px solid var(--accent); background: rgba(0, 0, 0, 0.15); }
.status-quote { grid-column: 1 / -1; margin: 0; font-size: 20px; }
.status-quote-name { color: var(--gold); }

/* Songs */
.song-group + .song-group { margin-top: 10px; }
.song-list { list-style: none; margin: 0; padding: 0; }
.song { justify-content: space-between; }
.song-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song-time { flex: none; color: var(--ink-dim); font-size: 16px; }

/* Games */
.game-art { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-bottom: 4px; }
.game-art figure { margin: 0; }
.game-art figure.wide { grid-column: 1 / -1; }
.game-art img { display: block; width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border: 2px solid var(--frame); border-radius: 3px; background: #1a2470; }
.game-art .wide img { aspect-ratio: 3.1 / 1; }
.game-art figcaption { margin-top: 4px; font-size: 14px; color: var(--ink-dim); }
.game-list { list-style: none; margin: 0; padding: 0; }
.game-list li { display: flex; gap: 12px; padding: 5px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.12); }
.game-rank { width: 22px; color: var(--gold); font-family: var(--arcade); font-size: 11px; padding-top: 4px; }

/* osu! */
.osu-head { display: flex; gap: 14px; align-items: center; }
.osu-head img { border: 3px solid var(--frame); border-radius: 4px; background: #1a2470; }
.osu-name { margin: 0; font-size: 22px; }
.osu-name span { font-size: 15px; color: var(--ink-dim); margin-left: 6px; }
.osu-stats { margin: 4px 0 0; font-size: 16px; color: var(--ink-dim); }
.osu-stats b { color: #fff; }
.osu-plays { list-style: none; margin: 0; padding: 0; }
.osu-plays a { display: flex; align-items: center; gap: 12px; padding: 7px 6px; text-decoration: none; border-bottom: 1px solid rgba(255, 255, 255, 0.12); border-radius: 4px; }
.osu-plays a:hover, .osu-plays a:focus-visible { background: rgba(255, 255, 255, 0.08); outline: none; }
.osu-plays a:focus-visible { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.55); }
.osu-grade { flex: none; width: 36px; text-align: center; font: 400 14px/1 var(--arcade); color: #f2c14e; }
.osu-grade.silver { color: #e4e8f4; }
.osu-map { flex: 1; min-width: 0; display: grid; }
.osu-map b, .osu-map span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.osu-map b { font-weight: 400; }
.osu-map > span { font-size: 15px; color: var(--ink-dim); }
.osu-mods { color: #ff9ccb !important; }
.osu-pp { flex: none; font-size: 18px; color: #ff66aa; }

/* Links */
.link-list { list-style: none; margin: 0; padding: 0; }
.menu-item.link { flex-wrap: wrap; gap: 0 12px; }
.link-url { font-size: 15px; color: var(--ink-dim); }

/* Party */
.party { width: min(560px, 100%); max-height: 100%; overflow-y: auto; padding: 18px 16px 14px; }
.party-title { margin: 0 0 10px 10px; font: 400 14px/1.4 var(--arcade); color: var(--gold); }
.party-list { list-style: none; margin: 0; padding: 0; }
.party-row { display: grid; grid-template-columns: 32px 1fr auto; grid-template-rows: auto auto; column-gap: 14px; min-height: 64px; }
.party-row canvas { grid-row: 1 / 3; width: 32px; height: 48px; image-rendering: pixelated; }
.party-name { font-size: 21px; color: #fff; }
.party-job { grid-column: 2; font-size: 16px; color: var(--ink-dim); }
.party-home { grid-column: 3; grid-row: 1 / 3; font-size: 15px; color: var(--ink-dim); }
.party-close { margin-top: 6px; color: var(--ink-dim); }

.flag { display: inline-block; width: 24px; height: 18px; margin-right: 8px; vertical-align: -3px; border: 2px solid #1b1d33; image-rendering: auto; }

/* Items */
.items { width: min(900px, 100%); height: min(640px, calc(100vh - 24px)); height: min(640px, calc(100dvh - 24px)); display: flex; flex-direction: column; padding: 16px 16px 12px; }
.items-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.items-head .party-title { margin-bottom: 0; }
.items-count { margin-left: 10px; font-size: 10px; color: var(--ink-dim); }
.items-kinds, .items-owners { display: flex; flex-wrap: wrap; gap: 2px; }
.items-kinds .menu-item, .items-owners .menu-item { width: auto; min-height: 38px; padding: 4px 10px 4px 30px; font-size: 17px; }
.items-kinds .menu-item::before, .items-owners .menu-item::before { left: 2px; width: 22px; }
.items-owners { margin: 8px 0 10px; padding-bottom: 10px; border-bottom: 2px solid rgba(233, 235, 245, 0.35); }
.items-owners img { width: 22px; height: 22px; object-fit: cover; border: 2px solid var(--accent, var(--frame)); border-radius: 2px; }
.items-owners .is-current, .items-kinds .is-current { color: var(--gold); background: rgba(0, 0, 0, 0.22); }
.items-owners .is-current:not(:hover):not(:focus)::before, .items-kinds .is-current:not(:hover):not(:focus)::before { opacity: 0; }
.items-kinds .menu-item:disabled { opacity: 0.4; cursor: default; }
.items-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 300px); gap: 16px; }
.items-list { list-style: none; margin: 0; padding: 0 4px 0 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #e9ebf5 transparent; }
.item { min-height: 36px; padding-top: 4px; padding-bottom: 4px; }
.item-icon { flex: none; width: 16px; height: 16px; color: var(--accent); shape-rendering: crispEdges; }
.item-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-owner { flex: none; font-size: 15px; color: var(--ink-dim); }
.item[aria-current], .item:focus .item-title { color: var(--gold); }
.items-detail { overflow-y: auto; padding: 4px 4px 4px 16px; border-left: 2px solid rgba(233, 235, 245, 0.35); }
.item-art { width: 100%; max-width: 220px; aspect-ratio: 1; margin: 0 auto 10px; border: 3px solid var(--frame); border-radius: 3px; box-shadow: 0 0 0 2px #1b1d33, 4px 4px 0 2px rgba(0, 0, 0, 0.3); background: #1a2470; overflow: hidden; }
.item-art.is-game { aspect-ratio: 2 / 3; max-width: 170px; }
.item-art img { display: block; width: 100%; height: 100%; object-fit: cover; }
.item-kind { margin: 0; font: 400 9px/1.6 var(--arcade); color: var(--ink-dim); text-transform: uppercase; letter-spacing: 0.06em; }
.item-name { margin: 2px 0 8px; font-size: 21px; font-weight: 400; line-height: 1.25; }
.item-row { margin: 8px 0 0; }
.item-label { font: 400 9px/1.6 var(--arcade); color: var(--ink-dim); text-transform: uppercase; }
.chips { display: flex; flex-wrap: wrap; }
.who-chip { width: auto; min-height: 36px; padding-top: 3px; padding-bottom: 3px; font-size: 17px; }
.who-chip img { width: 24px; height: 24px; object-fit: cover; border: 2px solid var(--accent); border-radius: 2px; }
.item-play { margin-top: 12px; border: 2px solid var(--frame); background: rgba(0, 0, 0, 0.2); }

/* World map */
.world { width: min(760px, 100%); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); display: flex; flex-direction: column; padding: 16px 16px 12px; overflow: hidden; }
.world-body { flex: 1; min-height: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 20px; align-items: center; }
.world-globe { display: block; width: 288px; height: 288px; image-rendering: pixelated; border: 3px solid var(--frame); border-radius: 4px; box-shadow: 0 0 0 2px #1b1d33; background: #03050f; }
.world-list { list-style: none; margin: 0; padding: 0 4px 0 0; overflow-y: auto; max-height: 100%; scrollbar-width: thin; scrollbar-color: #e9ebf5 transparent; }
.world-list ul { list-style: none; margin: 0; padding: 0; }
.world-name { margin: 10px 0 2px 6px; font: 400 11px/1.5 var(--arcade); color: var(--gold); display: flex; align-items: center; }
.world-country:first-child .world-name { margin-top: 0; }
.world-name img { width: 28px; height: 21px; margin-right: 10px; border: 2px solid #1b1d33; }
.world-member { min-height: 40px; }
.world-member img { width: 28px; height: 28px; object-fit: cover; border: 2px solid var(--accent); border-radius: 2px; }
.world-job { margin-left: auto; font-size: 15px; color: var(--ink-dim); }
.world-note { margin: 10px 0 0; }

/* Help */
.help { width: min(520px, 100%); max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); overflow-y: auto; overscroll-behavior: contain; padding: 18px 20px 14px; }
.help h2 { margin: 0 0 12px; font: 400 14px/1.4 var(--arcade); color: var(--gold); }
.help dl { margin: 0 0 8px; }
.help dl div { padding: 6px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.12); }
.help dt { font: 400 10px/1.6 var(--arcade); color: var(--ink-dim); text-transform: uppercase; }
.help dd { margin: 2px 0 0; }

/* ---- Music player (the live site's dock as a menu window) ---------------- */
.player {
  --accent: var(--gold);
  position: fixed; z-index: 60;
  right: max(12px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom));
  width: min(460px, calc(100vw - 24px));
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  grid-template-areas: 'face main controls' 'face main vol' 'status status status';
  column-gap: 12px; row-gap: 2px; align-items: center;
  padding: 9px 12px 9px 10px;
  visibility: hidden; opacity: 0; transition: opacity 0.4s ease;
}
body.is-playing .player { visibility: visible; opacity: 1; }
.player-face { grid-area: face; align-self: center; width: 44px; height: 44px; object-fit: cover; border: 2px solid var(--frame); border-radius: 3px; box-shadow: 0 0 0 2px #1b1d33; background: #1a2470; }
.player-main { grid-area: main; min-width: 0; }
.player-track { display: flex; align-items: baseline; gap: 8px; margin: 0; font-size: 17px; white-space: nowrap; }
.player-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.player-artist { flex: none; font-size: 15px; color: var(--accent); }
.player-eq { flex: none; display: inline-flex; align-items: flex-end; gap: 2px; width: 14px; height: 12px; }
.player-eq i { width: 3px; height: 3px; background: var(--accent); }
.player[data-state='playing'] .player-eq i { animation: eq 0.5s steps(3) infinite alternate; }
.player-eq i:nth-child(2) { animation-delay: -0.2s !important; }
.player-eq i:nth-child(3) { animation-delay: -0.35s !important; }
@keyframes eq { from { height: 3px; } to { height: 12px; } }
.player-bar { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.player-time { flex: none; font: 400 9px/1 var(--arcade); color: var(--ink-dim); min-width: 4.2ch; }
.player-time:last-child { text-align: right; }
.player-controls { grid-area: controls; display: flex; gap: 4px; }
.pbtn {
  display: grid; place-items: center;
  width: 36px; height: 36px; padding: 0;
  background: rgba(0, 0, 0, 0.25); border: 2px solid var(--frame); border-radius: 4px;
  cursor: pointer; color: #fff;
}
.pbtn svg { width: 18px; height: 18px; fill: currentColor; shape-rendering: crispEdges; filter: drop-shadow(1px 1px 0 var(--ink-shadow)); }
.pbtn:hover, .pbtn:focus-visible { background: rgba(255, 255, 255, 0.16); outline: none; }
.pbtn:focus-visible { box-shadow: 0 0 0 2px #fff; }
.pbtn-main { color: var(--gold); }
.player[data-state='loading'] .pbtn-main svg { animation: blink 0.5s steps(2) infinite; }
.player-vol { grid-area: vol; display: flex; align-items: center; gap: 6px; font: 400 8px/1 var(--arcade); color: var(--ink-dim); text-transform: uppercase; }
.player-vol .gauge { width: 112px; }
.player-status { grid-area: status; margin: 6px 0 0; font-size: 15px; color: #ffd3d3; }
.sc-frame { position: fixed; left: -9999px; top: -9999px; width: 320px; height: 166px; border: 0; opacity: 0; pointer-events: none; }

/* ATB-style gauge used for the scrub bar and volume. */
.gauge {
  --fill: 0%;
  -webkit-appearance: none; appearance: none;
  flex: 1; min-width: 0; height: 22px; margin: 0; padding: 0;
  background: transparent; cursor: pointer;
}
.gauge:disabled { cursor: default; }
.gauge::-webkit-slider-runnable-track {
  height: 10px; border: 2px solid var(--frame); border-radius: 2px;
  background:
    repeating-linear-gradient(90deg, transparent 0 7px, rgba(13, 26, 102, 0.85) 7px 8px),
    linear-gradient(90deg, var(--gold) 0 var(--fill), #0a1040 var(--fill));
  box-shadow: 0 0 0 1px #1b1d33;
}
.gauge::-moz-range-track {
  height: 6px; border: 2px solid var(--frame); border-radius: 2px;
  background:
    repeating-linear-gradient(90deg, transparent 0 7px, rgba(13, 26, 102, 0.85) 7px 8px),
    linear-gradient(90deg, var(--gold) 0 var(--fill), #0a1040 var(--fill));
}
.gauge::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 8px; height: 16px; margin-top: -5px; background: #fff; border: 2px solid #1b1d33; border-radius: 1px; }
.gauge::-moz-range-thumb { width: 6px; height: 14px; background: #fff; border: 2px solid #1b1d33; border-radius: 1px; }
.gauge:disabled::-webkit-slider-thumb { background: var(--frame-dark); }
.gauge:focus { outline: none; }
.gauge:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

body.is-playing .hint { bottom: calc(96px + max(16px, env(safe-area-inset-bottom))); }

/* Song rows (profile Songs page and the track list) */
.song-mark { flex: none; width: 10px; height: 10px; margin-right: -2px; }
.song.is-playing .song-mark { background: var(--gold); clip-path: polygon(0 0, 100% 50%, 0 100%); animation: blink 0.8s steps(2) infinite; }
.song.is-loading .song-mark { background: var(--ink-dim); animation: blink 0.4s steps(2) infinite; }
.song.is-playing .song-title { color: var(--gold); }
.song-who { color: var(--ink-dim); font-size: 15px; }

/* Track list */
.jukebox { width: min(620px, 100%); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); display: flex; flex-direction: column; padding: 18px 16px 14px; }
.jukebox-list { overflow-y: auto; min-height: 0; padding-right: 4px; scrollbar-width: thin; scrollbar-color: #e9ebf5 transparent; }
.jukebox h3 { display: flex; align-items: center; gap: 8px; margin: 14px 0 4px 6px; font: 400 11px/1.5 var(--arcade); color: var(--accent, var(--gold)); }
.jukebox h3 img { width: 24px; height: 24px; object-fit: cover; border: 2px solid var(--frame); border-radius: 2px; }
.jukebox .song-group:first-child h3 { margin-top: 0; }

/* Leaving for the music room */
body::after { content: ''; position: fixed; inset: 0; z-index: 500; background: #000; opacity: 0; pointer-events: none; transition: opacity 0.45s steps(5); }
body.is-leaving::after { opacity: 1; }

.noscript { position: fixed; inset: auto 16px 16px; z-index: 600; padding: 12px; background: #0d1a66; border: 3px solid #fff; }
.noscript a { color: var(--gold); }
.town-audio-controls { display: grid; gap: 12px; margin: 20px 0; }
.town-audio-controls label { display: flex; align-items: center; gap: 12px; }
.town-audio-controls .gauge { flex: 1; min-width: 60px; }
.town-audio-controls a { color: var(--gold); font-size: 12px; }

@media (max-width: 1080px) {
  .hud-btn .hud-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* ---- Phones -------------------------------------------------------------- */
@media (max-width: 699px) {
  body { font-size: 17px; }
  .hud { padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); }
  .hud-buttons { gap: 5px; flex-wrap: nowrap; }
  .hud-btn { padding: 6px 9px; }
  .hud-btn .hud-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .hud-brand { padding: 6px 8px; }
  .hud-brand svg { width: 56px; height: 22px; }
  .area { top: 70px; font-size: 11px; }
  .screen { padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom)); place-items: stretch; }
  .profile {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
    grid-template-areas: 'head' 'tabs' 'page';
    gap: 8px;
    height: 100%;
  }
  .profile-head { padding: 8px 12px; gap: 12px; }
  .profile-face { width: 48px; height: 48px; }
  .profile-tabs { flex-direction: row; flex-wrap: wrap; padding: 4px; gap: 0; }
  .tab { width: auto; flex: 1 0 auto; min-height: 40px; padding: 6px 8px 6px 28px; font-size: 17px; }
  .tab::before { left: 2px; width: 22px; }
  .tab-close { margin: 0; }
  .profile-page { padding: 14px 14px 18px; }
  .status { grid-template-columns: 1fr; }
  .status-portrait img { width: 120px; height: 120px; }
  .party { align-self: center; }
  .items { height: calc(100vh - 16px); height: calc(100dvh - 16px); padding: 12px 10px 8px; }
  .items-head { gap: 4px; }
  .items-owners { flex-wrap: nowrap; overflow-x: auto; margin: 6px 0 8px; padding-bottom: 6px; scrollbar-width: none; }
  .items-owners .menu-item { flex: none; }
  .items-body { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); gap: 8px; }
  .items-detail { order: -1; border-left: 0; border-bottom: 2px solid rgba(233, 235, 245, 0.35); padding: 0 0 8px; display: grid; grid-template-columns: 84px 1fr; gap: 12px; align-items: start; max-height: 44vh; }
  .item-art, .item-art.is-game { margin: 0; max-width: none; }
  .item-name { font-size: 19px; }
  .world { padding: 12px 10px 8px; align-self: center; max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); }
  .world-body { grid-template-columns: 1fr; gap: 10px; overflow-y: auto; }
  .world-globe { width: 192px; height: 192px; margin: 0 auto; }
  .world-list { overflow: visible; max-height: none; }
  .party-row { grid-template-columns: 32px 1fr; }
  .party-home { grid-column: 2; grid-row: auto; }
  .help { align-self: center; }
  .dialog { font-size: 19px; padding: 12px 16px 16px; min-height: 120px; }
  .player {
    left: max(8px, env(safe-area-inset-left)); right: max(8px, env(safe-area-inset-right)); bottom: max(8px, env(safe-area-inset-bottom));
    width: auto;
    grid-template-columns: 40px minmax(0, 1fr) auto;
    grid-template-areas: 'face main controls' 'status status status';
    column-gap: 10px; padding: 7px 8px;
  }
  .player-face { width: 40px; height: 40px; }
  .player-vol, #player-prev { display: none; }
  .player-track { font-size: 16px; }
  .player-artist { font-size: 14px; }
  .pbtn { width: 40px; height: 40px; }
  body.is-playing .hint { bottom: calc(80px + max(8px, env(safe-area-inset-bottom))); }
}

@media (prefers-reduced-motion: reduce) {
  .player[data-state='playing'] .player-eq i, .player[data-state='loading'] .pbtn-main svg, .song.is-playing .song-mark, .song.is-loading .song-mark,
  .title-start, .dialog-more, .menu-item:focus-visible::before { animation: none; }
  .title { transition: none; }
  .title-start { opacity: 1; }
  .area.is-showing { animation: none; }
  body::after { transition: none; }
}

@media (max-width: 380px) {
  .hud { gap: 4px; }
  .hud-buttons { gap: 3px; }
  .hud-brand { padding: 6px 4px; }
  .hud-brand svg { width: 40px; }
  .hud-btn { padding: 6px; }
}

/* Menu windows never grow past the screen, even with a long row inside. */
.screen > .win { min-width: 0; max-width: 100%; }
