@font-face {
  font-family: "Maplestory";
  src: url("./fonts/Maplestory-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --background: #1e1930;
  --surface: #332b47;
  --text: #f0eafa;
  --muted: #bcaed1;
  --line: #58486d;
  --accent: #c49afb;
  --accent-soft: #53406d;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--background);
}

* { box-sizing: border-box; }
body { display: flow-root; margin: 0; min-height: 100vh; background: radial-gradient(ellipse at 50% 0, #3a294b 0, transparent 65%); }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button { color: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: .4; cursor: default; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button, a { transition: background .15s, border-color .15s, color .15s; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }
.shell { width: min(960px, calc(100% - 48px)); margin: 36px auto; }
.site-header, .page-heading, .toolbar, .history-actions, .section-heading { display: flex; align-items: center; }
.site-header { justify-content: space-between; gap: 12px; margin-bottom: 24px; }
.page-heading { gap: 14px; min-width: 0; }
h1 { font: 700 32px/1.3 "Maplestory", sans-serif; letter-spacing: -.5px; margin: 0; color: #e7ceff; text-shadow: 0 2px 0 #49305f, 0 4px 12px #110d2366; }
.npc { width: 72px; height: 72px; object-fit: contain; image-rendering: pixelated; flex-shrink: 0; }
main { padding: 20px; border: 1px solid #68517f; border-radius: 16px; background: #282137; box-shadow: inset 0 1px 0 #bca1d522, 0 12px 32px #100b2033; }
.home-link { display: grid; place-items: center; width: 34px; height: 34px; font-size: 20px; border-radius: 8px; color: var(--muted); }
.home-link:hover { background: var(--line); color: var(--text); }
.text-button { border: 1px solid #705889; border-radius: 7px; background: linear-gradient(#50415f, #3c304d); box-shadow: inset 0 1px 0 #bc9ed433, 0 2px 0 #171121; font-family: "Maplestory", sans-serif; font-weight: 700; min-height: 36px; padding: 8px 11px; font-size: 12px; color: #e4d5f5; white-space: nowrap; }
.text-button:not(:disabled):hover { color: var(--text); background: #453554; }
.text-button[aria-pressed=true] { color: var(--accent); background: var(--accent-soft); }
.toolbar { justify-content: space-between; gap: 12px; padding-bottom: 22px; }
.history-actions { gap: 8px; }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(240px, 1fr); gap: 24px; align-items: start; }
.section-heading { justify-content: space-between; gap: 8px; min-height: 24px; margin-bottom: 12px; }
.section-heading h2 { font-family: "Maplestory", sans-serif; color: #d7b4ff; font-size: 14px; font-weight: 700; margin: 0; }
.section-heading>span { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.room-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.furniture-grid { display: grid; grid-template-columns: 1fr; gap: 5px; }
.room-grid {
  --passage: 22px;
  gap: var(--passage);
  padding: 17px;
  border: 2px solid #735888;
  outline: 1px solid #3c2e4f;
  outline-offset: 4px;
  border-radius: 16px;
  background-color: #1c1629;
  background-image: none;
  box-shadow: inset 0 0 0 5px #251c34;
}
.room, .furniture { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 0; border: 1px solid var(--line); background: linear-gradient(#3d3250, #30283f); border-radius: 9px; box-shadow: inset 0 1px 0 #a186c41a; }
.room {
  height: 142px;
  padding: 26px 5px 8px;
  border: 3px solid #79638c;
  border-radius: 12px;
  background-color: #362a46;
  background-image: none;
  box-shadow: inset 0 0 0 3px #21192f, 0 3px 0 #0f0b1c;
}
.room::before, .room::after { content: ""; position: absolute; pointer-events: none; background: #564263; box-sizing: border-box; }
.room:not(:nth-child(3n))::after { width: calc(var(--passage) + 6px); height: 14px; right: calc(-1 * var(--passage) - 3px); top: calc(50% - 7px); border-block: 2px solid #887097; }
.room:nth-child(-n+6)::before { height: calc(var(--passage) + 6px); width: 14px; bottom: calc(-1 * var(--passage) - 3px); left: calc(50% - 7px); border-inline: 2px solid #887097; }
.room-selected { position: absolute; right: 7px; top: 7px; padding: 2px 5px; border-radius: 5px; background: #d4b1ff; color: #36244b; font-size: 9px; font-weight: 700; }
.room:hover { border-color: #ac87d0; }
.room.is-selected { border-color: #dfbcff; background-color: #58426f; box-shadow: inset 0 0 0 3px #352343, 0 0 12px #c49afb33; }
.furniture-key { position: absolute; top: 9px; right: 10px; font: 10px/1.2 Consolas, monospace; color: var(--muted); opacity: 0; }
.furniture:hover .furniture-key, .furniture:focus-visible .furniture-key { opacity: 1; }
.room img { max-width: 100%; width: 82px; height: 68px; object-fit: contain; pointer-events: none; }
.room .unknown { width: 82px; height: 68px; object-fit: contain; }
.room-name { font-size: 11px; line-height: 18px; margin-top: 4px; }
.room.is-empty .room-name { display: none; }
.room.is-empty { padding-bottom: 24px; }
.map-bottom { display: flex; justify-content: flex-end; padding-top: 12px; min-height: 44px; }
.map-bottom .text-button { font-size: 11px; padding-inline: 4px; }
.furniture-panel { padding-left: 20px; border-left: 1px solid var(--line); }
.furniture-panel .section-heading { flex-wrap: wrap; }
.furniture-panel .section-heading>span { font-size: 10px; color: #d8bbfa; }
.furniture { height: 49px; padding: 4px 10px; flex-direction: row; justify-content: flex-start; gap: 12px; border-color: transparent; border-bottom-color: #59436b; border-radius: 8px; background: #342a44; box-shadow: none; }
.furniture:hover { background: #443458; border-color: #ac87d0; }
.furniture.is-active { border-color: var(--accent); background: var(--accent-soft); }
.furniture-key { left: 2px; right: auto; top: 3px; font-size: 8px; }
.furniture img { height: 40px; width: 49px; flex-shrink: 0; object-fit: contain; pointer-events: none; }
.furniture-name { margin-top: 0; font-size: 11px; }
.primary-button { min-height: 36px; padding: 8px 14px; border: 1px solid #d6b1ff; border-radius: 7px; background: linear-gradient(#b78be7, #8b5fb9); color: #fff7ff; font: 700 12px "Maplestory", sans-serif; text-shadow: 0 1px 1px #402255; box-shadow: inset 0 1px 0 #f2ddff88, 0 2px 0 #3c244f; }
.primary-button:not(:disabled):hover { background: linear-gradient(#c39af0, #9b6bca); }
.save-error { color: #ffbb9f; font-size: 12px; margin-top: 16px; }
footer a { text-decoration: underline; text-underline-offset: 3px; }
footer { text-align: right; color: #a090b3; font-size: 10px; margin-top: 28px; }
.sr-only, .skip-link:not(:focus) { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link:focus { position: fixed; top: 8px; left: 8px; z-index: 10; padding: 12px; background: var(--accent); color: #241931; }
dialog { background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 16px; padding: 26px; max-width: calc(100% - 32px); box-shadow: 0 20px 80px #18253d22; }
dialog::backdrop { background: #100b22aa; }
dialog h2 { font-size: 19px; margin: 0 0 12px; letter-spacing: -.4px; }
dialog p { color: var(--muted); font-size: 13px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 25px; }
body.compact .shell { width: min(760px, calc(100% - 28px)); margin-block: 16px; }
body.compact .site-header { margin-bottom: 18px; }
body.compact h1 { font-size: 25px; }
body.compact .npc { width: 54px; height: 54px; }
body.compact main { padding: 14px; }
body.compact .toolbar { padding-bottom: 16px; }
body.compact .workspace-grid { gap: 20px; }
body.compact .room { height: 119px; }
body.compact .furniture { height: 42px; }
body.compact .room img, body.compact .room .unknown { height: 56px; width: 70px; }
body.compact .furniture img { height: 34px; width: 42px; }
body.compact .room-grid { --passage: 17px; padding: 12px; }
body.compact .furniture-panel { padding-left: 12px; }
body.compact footer { display: none; }

@media (max-width: 760px) {
  .shell { width: calc(100% - 32px); margin-top: 22px; }
  .site-header { margin-bottom: 24px; }
  h1 { font-size: 27px; }
  .workspace-grid { grid-template-columns: minmax(0, 1.65fr) minmax(195px, 1fr); gap: 20px; }
  .room { height: 124px; }
  .furniture { height: 43px; gap: 7px; padding-inline: 6px; }
  .furniture-panel { padding-left: 12px; }
  .room img, .room .unknown { width: 65px; height: 58px; }
  .furniture img { width: 42px; height: 35px; }
  .room-grid { --passage: 16px; padding: 12px; }

}

@media (max-width: 560px) {
  .shell, body.compact .shell { width: calc(100% - 24px); margin-block: 16px; }
  .site-header { margin-bottom: 18px; }
  .page-heading { gap: 4px; }
  h1, body.compact h1 { font-size: clamp(18px, 5vw, 25px); }
  .npc, body.compact .npc { width: 48px; height: 48px; }
  main, body.compact main { padding: 12px; border-radius: 12px; }
  .home-link { width: 28px; }
  .text-button { font-size: 11px; padding-inline: 8px; }
  .toolbar { padding-bottom: 18px; gap: 6px; }
  .primary-button { padding-inline: 10px; font-size: 11px; }
  .history-actions { gap: 6px; }
  .workspace-grid, body.compact .workspace-grid { grid-template-columns: 1fr; gap: 20px; }
  .furniture-panel, body.compact .furniture-panel { border-left: 0; padding-left: 0; padding-top: 16px; border-top: 1px solid var(--line); }
  .room { height: 102px; padding-top: 23px; }
  .room img, .room .unknown { height: 51px; width: 70px; }
  .room-grid, body.compact .room-grid { --passage: 16px; padding: 10px; }
  .section-heading { margin-bottom: 8px; }
  .map-bottom { min-height: 34px; padding-top: 2px; }
  .map-bottom .text-button { min-height: 30px; }
  .furniture { height: 45px; padding: 4px 12px; gap: 16px; }
  .furniture img { height: 37px; width: 48px; }

  body.compact .room { height: 83px; }
  body.compact .furniture { height: 40px; }
  body.compact .room img, body.compact .room .unknown { height: 36px; }
  body.compact .furniture img { height: 32px; }
  footer { margin-top: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
