@font-face {
  font-family: "Barlow Condensed";
  src: url("assets/fonts/barlow-condensed-800.woff2") format("woff2");
  font-weight: 800;
  font-display: swap;
}

@font-face {
  font-family: "DM Sans";
  src: url("assets/fonts/dm-sans.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --background: #100d0b;
  --surface: #1d1712;
  --well: #15110e;
  --line: #493724;
  --gold-line: #795729;
  --text: #fff3dd;
  --muted: #c7b59b;
  --accent: #f7c66a;
  --focus: #ffe09a;
  --ease-out: cubic-bezier(.2, .72, .28, 1);
  --display: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  font: 16px/1.5 "DM Sans", system-ui, sans-serif;
  color: var(--text);
  background: var(--background);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; background: radial-gradient(ellipse at 64% 0%, #392519 0%, var(--background) 620px); }
button { font: inherit; }
h1, h2, p { margin: 0; }

.shell {
  width: min(1210px, 100%);
  margin: auto;
  padding: 0 clamp(14px, 3.4vw, 40px) 28px;
}

.site-bar, .site-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.site-bar { min-height: 73px; justify-content: space-between; padding: 11px 0; }
.site-brand { display: inline-flex; align-items: center; gap: 11px; color: #ffe4af; font: 800 1.62rem/1 var(--display); letter-spacing: .045em; text-transform: uppercase; }
.site-brand span { width: 12px; height: 12px; margin-inline: 4px; transform: rotate(45deg); border: 1px solid #ffdc8b; background: linear-gradient(155deg, #ffe9ad, #c87c25); box-shadow: 0 0 15px #d78a424d; }
.site-actions .download { min-height: 35px; padding: 5px 11px; font-size: .81rem; }
.download::before { content: "↓"; margin-right: 7px; color: var(--accent); }

.welcome-hero {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  align-items: center;
  min-height: 365px;
  margin-bottom: 16px;
  padding: clamp(24px, 4.1vw, 54px);
  overflow: hidden;
  border: 1px solid var(--gold-line);
  border-radius: 16px;
  background: #322014;
}

.hero-backdrop, .welcome-hero::before { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero-backdrop { z-index: -2; object-fit: cover; object-position: center 34%; }
.welcome-hero::before {
  content: "";
  z-index: -1;
  background: linear-gradient(90deg, #160e09 1%, #1a100af2 34%, #3520107a 76%, #1c110a70), linear-gradient(0deg, #1c100ae8, #2a160c24 69%);
}
.welcome-copy { z-index: 1; }
.welcome-kicker { margin-bottom: 6px; color: #ffd180; font-size: .82rem; font-weight: 700; letter-spacing: .17em; text-transform: uppercase; }
.welcome-copy h1 { color: #fff7e8; font: 800 clamp(3.65rem, 8vw, 7.25rem)/.8 var(--display); letter-spacing: -.025em; text-transform: uppercase; }
.welcome-copy h1 span { display: block; color: #ffc567; }
.welcome-description { max-width: 38ch; margin: 17px 0 19px; color: #f0d9b5; font-size: clamp(.9rem, 1.4vw, 1.05rem); }
.welcome-copy .button { gap: 12px; min-height: 43px; padding-inline: 16px; }
.hero-token { justify-self: center; width: min(100%, 370px); height: auto; margin: -28px 0; filter: drop-shadow(0 18px 24px #180b08a0); }
.profile-layout { display: grid; grid-template-columns: minmax(0, 2.12fr) minmax(0, 1fr); gap: 16px; scroll-margin: 16px; }
.token-preview { position: relative; min-height: 160px; margin: 0; overflow: hidden; isolation: isolate; }
.token-preview img { position: absolute; inset: 0; z-index: -2; width: 100%; height: 100%; object-fit: cover; object-position: 50% 47%; }
.token-preview::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(0deg, #170f08f7, #1a100a35 54%, transparent); }
.token-preview figcaption { position: absolute; inset: auto 16px 12px; color: #ffdfa1; font: 800 1.65rem/1 var(--display); letter-spacing: .015em; }

.lifetime { display: flex; align-items: center; gap: 7px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--well); }
.lifetime output { color: var(--accent); font: 800 1.55rem/1 var(--display); font-variant-numeric: tabular-nums; }
.lifetime span { color: var(--muted); font-size: .74rem; font-weight: 650; }
.workspace-bar, .capture-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.tabs { display: flex; min-width: 0; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 11px; background: var(--well); }
.tabs button { padding: 7px 13px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--muted); font-size: .875rem; font-weight: 700; cursor: pointer; }
.tabs button:hover { color: var(--text); border-color: var(--accent); }
.tabs button:is([aria-selected="true"], [aria-pressed="true"]) { border-color: var(--gold-line); background: #3a2a18; color: #ffdf99; box-shadow: inset 0 1px #ffcf7429; }
.capture-actions, .toolbar-actions, .route-actions, .overlay-settings { display: flex; flex-wrap: wrap; gap: 8px; }
.capture-actions:not(:has(button:not([hidden]))), .toolbar-actions:not(:has(:is(button, a):not([hidden]))) { display: none; }
.capture-toolbar { padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.play-settings { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0 0 10px; padding: 0; border: 0; }
.play-switch { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 47px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); font-size: .88rem; font-weight: 700; cursor: pointer; }
.play-switch:hover { border-color: var(--accent); }
.play-switch input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
.switch-track { position: relative; flex: 0 0 34px; height: 19px; border: 1px solid #806a55; border-radius: 99px; background: #2a2119; transition: background-color .18s var(--ease-out), border-color .18s var(--ease-out); }
.switch-track::after { content: ""; position: absolute; inset: 3px auto 3px 3px; width: 11px; border-radius: 50%; background: #c4ad90; transition: transform .15s ease; }
.play-switch input:checked + .switch-track { border-color: #f3c16a; background: #725024; }
.play-switch input:checked + .switch-track::after { transform: translateX(15px); background: #ffe8af; }
.play-switch:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.overlay-settings { align-items: center; margin-bottom: 16px; color: var(--muted); font-size: .85rem; }
.overlay-settings select { background: var(--surface); color: var(--text); border: 1px solid var(--gold-line); border-radius: 5px; padding: 4px 7px; font: inherit; }
.overlay-settings p { margin-left: 6px; }
.marker-settings { margin-bottom: 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--well); }
.marker-settings summary { color: #f4d99f; font-size: .85rem; font-weight: 700; cursor: pointer; }
.marker-setting-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 10px; font-size: .85rem; }
.marker-setting-row input { flex: 1 1 110px; max-width: 240px; min-width: 85px; accent-color: var(--accent); }
.marker-setting-row output { min-width: 3ch; color: var(--accent); font-variant-numeric: tabular-nums; }
#marker-shortcut { margin-top: 5px; }
.capture-status {
  display: flex;
  flex: 1 1 230px;
  align-items: baseline;
  gap: 10px;
  color: var(--muted);
  font-size: .85rem;
}
.capture-status::before {
  content: "";
  flex: 0 0 7px;
  height: 7px;
  align-self: center;
  background: currentColor;
  border-radius: 50%;
}
.capture-status[data-state="running"] { color: #b7ebc5; }
.capture-status[data-state="paused"], .capture-status[data-state="requesting"] { color: var(--accent); }
.capture-status[data-state="error"] { color: #ffb6a8; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, .67fr); gap: 20px; align-items: start; }
.side { display: grid; gap: 20px; min-width: 0; }
.workspace.map-disabled { grid-template-columns: minmax(0, 1fr); }
.workspace.map-disabled .side { grid-template-columns: minmax(220px, .68fr) minmax(0, 1fr); align-items: start; }

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: inset 0 1px #ffda8c0d, 0 6px 18px #0b060633;
}

.panel-heading {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
}

.panel-heading h2 { color: #ffdfa5; font: 800 1.4rem/1.05 var(--display); letter-spacing: .015em; }
.scope { color: var(--muted); font-size: .8rem; }
.storage-status { padding: 10px 16px; color: var(--accent); }

.player-stage {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  background: var(--well);
  border-top: 1px solid var(--line);
  overflow: hidden;
  border-radius: 0 0 11px 11px;
}

.player-placeholder { padding: 12px; text-align: center; color: var(--muted); font-size: .86rem; }
#game-video { display: block; width: 100%; height: 100%; min-width: 0; min-height: 0; background: #000; object-fit: contain; }
.chest-outline { position: absolute; pointer-events: none; border: 2px solid var(--accent); border-radius: 4px; box-shadow: 0 0 0 1px #18140b; }
.frame-observation { padding: 10px 16px; color: var(--accent); font-size: .82rem; font-weight: 650; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 7px 14px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: .875rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}

.primary { background: linear-gradient(135deg, #ffe4a1, #eeb456); color: #261506; border-color: #f8ce79; }
.primary:hover { background: linear-gradient(135deg, #fff0ba, #ffc76c); }
.secondary { background: #231912; color: var(--text); border-color: var(--gold-line); }
.secondary:hover { background: #3a2716; }
.stop { color: #ffddd5; background: #542e2b; border-color: #93524a; }
.stop:hover { background: #673733; }
.button:disabled { opacity: .48; cursor: default; }
.button, .profile-choice, .play-switch, .tabs button { transition: border-color .18s var(--ease-out), background-color .18s var(--ease-out), box-shadow .18s var(--ease-out), color .18s var(--ease-out), transform .18s var(--ease-out); }
.button:not(:disabled):hover, .profile-choice:hover, .tabs button:hover, .play-switch:hover { border-color: #ffda88; box-shadow: 0 0 0 1px #eeb35745; }
.button[aria-pressed="true"] { background: #3c2a15; color: #ffe4a6; border-color: #e5b85e; }
@media (hover: hover) {
  .button:not(:disabled):hover, .profile-choice:hover { transform: translateY(-1px); }
}
:is(button, a, select, input, summary):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.map-content { max-width: 520px; margin-inline: auto; }
.map-stage {
  display: grid;
  place-items: center;
  margin: 0 16px 12px;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--well);
}

#map-view { display: block; width: 100%; height: 100%; pointer-events: none; }
#map-placeholder { max-width: 26ch; padding: 8px; color: var(--muted); font-size: .85rem; text-align: center; }
.map-direction { padding: 0 16px 10px; color: var(--accent); font-size: .86rem; font-weight: 650; }
.route-controls { display: grid; gap: 10px; padding: 0 16px 14px; }
#route-status { color: var(--muted); font-size: .82rem; }
.route-actions:not(:has(button:not([hidden]))) { display: none; }
.route-actions .button { min-height: 32px; padding: 4px 8px; font-size: .75rem; }
.map-content > .scope { padding: 0 16px 16px; }
.spawn-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.map-content > .spawn-legend { padding: 0 16px 16px; }
.spawn-legend span { display: inline-flex; align-items: center; gap: 6px; }
.spawn-legend span::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #ffcb6e; }
.spawn-legend span + span::before { background: #83dcff; }
.route-run { display: flex; align-items: center; flex-wrap: wrap; justify-content: space-between; gap: 6px 14px;
  padding: 10px 14px; margin-bottom: 14px; color: #ffe0a2; font-size: .88rem; }
.route-run .button { min-height: 34px; padding-block: 4px; }
.route-library { display: grid; grid-template-columns: minmax(165px, .32fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.route-sidebar, .route-preview-header, .route-preview-footer { padding: 15px 17px; }
.route-sidebar h2, .route-preview h2 { color: #ffdfa5; font: 800 1.65rem/1.07 var(--display); }
.route-choices { display: grid; gap: 6px; margin-top: 12px; }
.route-choice { min-height: 40px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px;
  color: var(--text); background: var(--well); text-align: left; cursor: pointer; font-weight: 700; font-size: .89rem; }
.route-choice:hover, .route-choice[aria-pressed="true"] { border-color: #c99140; background: #3a2a18; color: #ffdf99; }
.route-preview { overflow: hidden; }
.route-preview-header .scope { margin-top: 4px; }
.route-facts { display: flex; flex-wrap: wrap; gap: 5px 14px; margin-top: 9px; color: var(--accent); font-size: .85rem; font-weight: 700; }
.route-preview canvas { display: block; width: 100%; height: auto; background: var(--well); }
.route-preview-footer { display: grid; gap: 9px; }
#route-plan-status:empty { display: none; }
.counter { min-width: 38px; padding: 1px 9px; color: var(--accent); text-align: center; border: 1px solid var(--gold-line); border-radius: 5px; background: #372616; font: 800 1.35rem/1.4 var(--display); }
.event-actions { display: grid; gap: 8px; justify-items: start; padding: 0 16px 12px; }
.record-details { border-top: 1px solid var(--line); }
.record-details summary { padding: 9px 16px; color: var(--muted); font-size: .82rem; cursor: pointer; }
.record-details summary:focus-visible { outline: 2px solid var(--focus); outline-offset: -3px; }
.event-list { margin: 0; padding: 0; list-style: none; max-height: 290px; overflow: auto; }
.event-list li { display: flex; align-items: stretch; border-top: 1px solid var(--line); }
.event-delete { border: 0; background: transparent; cursor: pointer; }
.event-content { flex: 1; min-width: 0; display: flex; gap: 10px; align-items: center; padding: 10px 12px 10px 16px; }
.event-delete:hover { background: #3a2716; }
.event-text { font-size: .85rem; overflow-wrap: anywhere; }
.event-source { display: block; color: var(--muted); font-size: .7rem; }
.event-delete { width: 40px; font-size: 1.1rem; color: var(--muted); }
.event-delete:focus-visible { outline-offset: -2px; }

.video-panel { overflow: hidden; }
.video-toolbar { flex-wrap: wrap; }
.video-toolbar p { flex: 1 1 14ch; min-width: 0; color: var(--muted); font-size: .875rem; overflow-wrap: anywhere; }
#clip-video { display: block; width: 100%; max-height: min(72vh, 570px); aspect-ratio: 16 / 9; border-top: 1px solid var(--line); background: var(--well); object-fit: contain; }
.art-credit { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 18px; color: var(--muted); font-size: .7rem; }
.art-credit p { max-width: 100ch; }
.art-credit a { color: #f3cb87; text-underline-offset: 3px; }
.profile-picker { padding: clamp(15px, 2.3vw, 25px); }
.profile-picker h2 { margin-bottom: 12px; color: #ffe0a4; font: 800 clamp(1.6rem, 3.5vw, 2.05rem)/1 var(--display); }
.profile-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(153px, 1fr)); gap: 8px; }
.profile-choice { display: flex; align-items: center; gap: 9px; min-height: 52px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--well); color: var(--text); text-align: left; cursor: pointer; font-weight: 700; }
.profile-choice:hover { background: #2e2114; color: var(--accent); }
.group-settings { margin-top: 12px; min-height: 34px; font-size: .78rem; }
.group-notice { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; padding: 9px 15px; background: #2b2015; }
.group-notice .button { min-height: 33px; padding: 5px 8px; font-size: .78rem; }
#avatar-sync { margin-top: 9px; border: 1px solid var(--line); border-radius: 8px; }
.group-dialog { width: min(460px, calc(100% - 32px)); padding: 22px; color: var(--text); }
.group-dialog::backdrop { background: #100d0bb8; }
.group-dialog h2 { color: #ffdfa5; font: 800 1.7rem/1 var(--display); }
.group-form { display: grid; gap: 9px; margin-top: 10px; }
.group-form input { min-width: 0; padding: 8px 9px; border: 1px solid var(--gold-line); border-radius: 5px; background: var(--well); color: var(--text); font: inherit; }
.group-form .route-actions { justify-content: end; }
.group-form input[aria-invalid="true"] { border-color: #f69c89; }
#name-status { color: #ffc1b3; }
.avatar { display: inline-grid; place-items: center; flex: 0 0 auto; width: 34px; height: 34px; object-fit: cover; border-radius: 50%; color: #fff; font-size: .7rem; font-weight: 780; }
.avatar-large { width: 70px; height: 70px; font-size: 1.25rem; outline: 1px solid var(--line); outline-offset: 3px; }
.profile-header { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; padding: 18px; }
.profile-header-copy { flex: 1 1 145px; min-width: 0; }
.profile-header h2 { color: #ffdfa5; font: 800 1.95rem/1.08 var(--display); overflow-wrap: anywhere; }
.profile-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.player-name { min-width: 0; overflow-wrap: anywhere; }
#change-profile { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.profile-tabs { width: fit-content; margin: 14px 0; }
.profile-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); gap: 10px; margin: 0; }
.stat { padding: 15px; }
.stat dt { color: var(--muted); font-size: .85rem; }
.stat dd { margin: 3px 0 0; color: var(--accent); font-size: 1.75rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.form-status, #more-matches { margin-top: 12px; }
.history-empty { padding: 16px; color: var(--muted); }
.match-history { display: grid; gap: 8px; }
.history-row summary { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; padding: 12px 15px; cursor: pointer; }
.history-row summary strong { color: var(--accent); }
.history-row summary > span:first-child { flex: 1 1 145px; }
.history-best { border-color: #8c672d; }
.history-record { color: var(--accent); font-size: 0.78rem; font-weight: 700; }
.history-breakdown { padding: 0 15px 12px; }
.ranking-heading { flex-wrap: wrap; }
.ranking-heading h2 { display: flex; align-items: center; gap: 9px; }
.ranking-heading img { object-fit: contain; }
.ranking-scroll { overflow-x: auto; }
.ranking-table { width: 100%; min-width: 530px; border-collapse: collapse; font-size: .86rem; font-variant-numeric: tabular-nums; }
.ranking-table th, .ranking-table td { padding: 10px 14px; border-top: 1px solid var(--line); text-align: right; white-space: nowrap; }
.ranking-table :is(th, td):nth-child(2) { width: 46%; text-align: left; }
.ranking-table th { color: var(--muted); font-size: .76rem; }
.ranking-table td:first-child { color: var(--accent); font-weight: 720; }
.ranking-person { display: flex; align-items: center; gap: 8px; white-space: normal; }
.ranking-table .current-player { background: #ffcf7410; }
#match-status { color: var(--accent); }

@keyframes panel-in {
  from { opacity: .55; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

#player-workspace > [role="tabpanel"]:not([hidden]),
#panel-profile > [role="tabpanel"]:not([hidden]),
.group-dialog[open] { animation: panel-in .19s var(--ease-out); }

@media (max-width: 830px) {
  .workspace { grid-template-columns: minmax(0, 1fr) minmax(220px, .74fr); gap: 12px; }
  .side { gap: 12px; }
  .welcome-hero { min-height: 315px; }
}

@media (max-width: 670px) {
  .workspace { grid-template-columns: 1fr; }
  .side { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .profile-layout { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .route-library { grid-template-columns: minmax(0, 1fr); }
  .route-choices { display: flex; flex-wrap: wrap; }
  .route-choice { flex: 1 1 105px; text-align: center; }
  .token-preview { min-height: clamp(170px, 38vw, 245px); }
  .play-settings { grid-template-columns: minmax(0, 1fr); gap: 5px; }
  .play-switch { min-height: 37px; padding-block: 5px; }
}

@media (max-width: 505px) {
  .site-bar { padding-block: 12px; }
  .site-brand { font-size: 1.39rem; }
  .welcome-hero { grid-template-columns: 1fr; min-height: 282px; }
  .welcome-hero::before { background: linear-gradient(90deg, #160e09 3%, #1a100af2 34%, #3520108f 100%); }
  .hero-token { position: absolute; top: 14px; right: -18px; width: min(51%, 224px); margin: 0; opacity: .73; }
  .welcome-copy h1 { font-size: clamp(3.35rem, 14vw, 4.65rem); }
  .welcome-description { max-width: 27ch; }
  .side, .workspace.map-disabled .side { grid-template-columns: 1fr; }
  #workspace-tabs { width: 100%; flex-wrap: wrap; }
  #workspace-tabs button { flex: 1 0 auto; padding-inline: clamp(6px, 2vw, 10px); font-size: .8rem; white-space: nowrap; }
  .profile-choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profile-choice { overflow-wrap: anywhere; }
}

@media (prefers-reduced-motion: reduce) {
  .button, .profile-choice, .play-switch, .tabs button, .switch-track, .switch-track::after { transition: none; }
  .button:not(:disabled):hover, .profile-choice:hover { transform: none; }
  #player-workspace > [role="tabpanel"], #panel-profile > [role="tabpanel"], .group-dialog[open] { animation: none !important; }
}
