:root {
  --accent: #86aebb;
  --ink: #171717;
  --cream: #f4efe4;
  --sand: #efe5d5;
  --wood: #8c6a4a;
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; font-family: Inter, "Segoe UI", Arial, sans-serif; background: #d8d1c7; }
button { font: inherit; }
.a-canvas { cursor: grab; }
.a-canvas:active { cursor: grabbing; }
body.modal-open .a-canvas, body.help-open .a-canvas { pointer-events: none; }

.topbar {
  position: fixed; z-index: 30; top: 0; left: 0; right: 0;
  min-height: 70px; padding: 10px 14px;
  display: grid; grid-template-columns: minmax(260px, 1fr) auto minmax(220px, 1fr);
  align-items: center; gap: 14px;
  color: #fff;
  background: linear-gradient(180deg, rgba(42,31,22,.88), rgba(54,43,32,.58), transparent);
  pointer-events: none;
}
.topbar button, .room-nav { pointer-events: auto; }
.brand { min-width: 0; display: flex; align-items: center; gap: 10px; }
.brand-mark { flex: 0 0 auto; width: 8px; height: 42px; border-radius: 20px; background: var(--accent); box-shadow: 0 0 20px color-mix(in srgb, var(--accent) 75%, transparent); }
.brand-text { min-width: 0; display: flex; flex-direction: column; }
.brand-text strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .98rem; }
.brand-text span { margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .79rem; opacity: .78; }
.room-nav { display: flex; align-items: center; gap: 5px; padding: 5px; border-radius: 999px; background: rgba(60,45,31,.46); backdrop-filter: blur(9px); }
.room-nav button { min-width: 36px; height: 36px; padding: 0 10px; border: 0; border-radius: 999px; color: #fff; background: rgba(255,255,255,.12); cursor: pointer; }
.room-nav button:hover, .room-nav button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; background: rgba(255,255,255,.26); }
.room-nav button.active { color: #111; background: var(--accent); font-weight: 800; }
.top-actions { justify-self: end; display: flex; gap: 7px; }
.tool-button { height: 38px; padding: 0 13px; border: 1px solid rgba(255,255,255,.35); border-radius: 999px; color: #fff; background: rgba(72,54,39,.4); cursor: pointer; backdrop-filter: blur(9px); }
.tool-button:hover, .tool-button:focus-visible { outline: 2px solid #fff; background: rgba(255,255,255,.18); }

.loading, .transition {
  position: fixed; z-index: 120; inset: 0; display: flex; align-items: center; justify-content: center; gap: 14px;
  color: #222; background: #efe7db; transition: opacity .35s;
}
.loading.hidden { opacity: 0; pointer-events: none; }
.loading > div:last-child { display: flex; flex-direction: column; gap: 4px; }
.loading span { font-size: .82rem; opacity: .65; }
.spinner { width: 30px; height: 30px; border: 3px solid #bbb; border-top-color: #222; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.transition { z-index: 115; color: #fff; background: rgba(15,15,15,.93); opacity: 0; pointer-events: none; font-weight: 750; letter-spacing: .04em; }
.transition.visible { opacity: 1; pointer-events: auto; }

.interaction-hint {
  position: fixed; z-index: 25; left: 50%; top: 84px; transform: translateX(-50%);
  max-width: calc(100vw - 30px); padding: 9px 14px; border: 1px solid rgba(255,255,255,.3); border-radius: 999px;
  color: #fff; background: rgba(59,45,33,.6); font-size: .82rem; text-align: center; backdrop-filter: blur(8px); transition: opacity .25s;
}
.interaction-hint.hidden { opacity: 0; pointer-events: none; }
.hover-card {
  position: fixed; z-index: 35; left: 50%; bottom: 54px; transform: translate(-50%, 8px);
  min-width: 250px; max-width: min(620px, 88vw); padding: 10px 15px; display: flex; flex-direction: column; gap: 3px;
  border-radius: 11px; color: #fff; background: rgba(54,41,30,.85); opacity: 0; pointer-events: none; text-align: center; backdrop-filter: blur(8px); transition: .18s;
}
.hover-card.visible { opacity: 1; transform: translate(-50%, 0); }
.hover-card span { font-size: .78rem; opacity: .72; }
.desktop-hint { position: fixed; z-index: 20; left: 50%; bottom: 10px; transform: translateX(-50%); padding: 7px 11px; border-radius: 8px; color: #fff; background: rgba(55,42,31,.58); font-size: .74rem; white-space: nowrap; backdrop-filter: blur(7px); }

.touch-controls { position: fixed; z-index: 45; left: max(16px, env(safe-area-inset-left)); bottom: max(16px, env(safe-area-inset-bottom)); width: 142px; height: 142px; display: none; grid-template: repeat(3, 44px) / repeat(3, 44px); gap: 4px; }
.touch-controls button { border: 1px solid rgba(255,255,255,.52); border-radius: 13px; color: #fff; background: rgba(0,0,0,.58); font-size: 1.15rem; touch-action: none; }
.touch-controls button[data-move="forward"] { grid-area: 1 / 2; }
.touch-controls button[data-move="left"] { grid-area: 2 / 1; }
.touch-controls button[data-move="backward"] { grid-area: 2 / 2; }
.touch-controls button[data-move="right"] { grid-area: 2 / 3; }

.help-modal { position: fixed; z-index: 130; inset: 0; display: grid; place-items: center; padding: 22px; background: rgba(0,0,0,.88); }
.help-modal[hidden] { display: none; }
.help-card { position: relative; width: min(650px, 100%); padding: 34px; border: 1px solid rgba(255,255,255,.24); border-radius: 20px; color: #fff; background: #251d18; box-shadow: 0 24px 90px rgba(0,0,0,.55); }
.help-card h1 { margin: 8px 0 16px; font-family: Georgia, serif; font-size: clamp(2rem, 5vw, 3.2rem); line-height: 1.05; }
.help-card p { line-height: 1.6; color: #ddd; }
.eyebrow { font-size: .76rem; letter-spacing: .17em; font-weight: 800; opacity: .65; }
.primary-button { width: 100%; margin-top: 12px; padding: 13px 18px; border: 0; border-radius: 12px; color: #111; background: var(--accent); font-weight: 800; cursor: pointer; }
.primary-button:focus-visible, .primary-button:hover { outline: 3px solid #fff; outline-offset: 3px; filter: brightness(1.05); }
.close-corner { position: absolute; top: 13px; right: 13px; width: 40px; height: 40px; border: 0; border-radius: 50%; color: #fff; background: rgba(255,255,255,.12); font-size: 1.6rem; cursor: pointer; }

.modal { position: fixed; z-index: 140; inset: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; color: #fff; background: rgba(17,12,9,.98); }
.modal[hidden] { display: none; }
.modal-toolbar { min-height: 65px; padding: 9px 14px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid rgba(255,255,255,.13); }
.modal-meta { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.modal-meta strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.modal-meta span { font-size: .78rem; opacity: .68; }
.modal-actions { flex: 0 0 auto; display: flex; gap: 6px; }
.modal-actions button, .modal-footer button { min-width: 42px; min-height: 40px; padding: 0 12px; border: 1px solid rgba(255,255,255,.22); border-radius: 9px; color: #fff; background: rgba(255,255,255,.08); cursor: pointer; }
.modal-actions button:hover, .modal-footer button:hover, .modal-actions button:focus-visible, .modal-footer button:focus-visible { outline: 2px solid #fff; background: rgba(255,255,255,.18); }
.close-button { font-size: 1.55rem; }
.modal-viewport { min-height: 0; overflow: auto; padding: 20px; display: block; text-align: center; cursor: grab; overscroll-behavior: contain; }
.modal-viewport.dragging { cursor: grabbing; }
.modal-image { display: inline-block; width: min(100%, 1500px); height: auto; box-shadow: 0 14px 60px rgba(0,0,0,.65); user-select: none; transform-origin: top center; }
.modal-footer { min-height: 62px; padding: 8px 14px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px; border-top: 1px solid rgba(255,255,255,.13); }
.modal-footer p { margin: 0; text-align: center; font-size: .82rem; opacity: .78; }

@media (pointer: coarse), (max-width: 760px) {
  .topbar { grid-template-columns: minmax(0, 1fr) auto; min-height: 64px; padding: 8px 10px; }
  .brand-text strong { font-size: .86rem; }
  .brand-text span { font-size: .7rem; }
  .room-nav { position: fixed; top: 69px; left: 50%; transform: translateX(-50%); max-width: calc(100vw - 18px); overflow-x: auto; }
  .top-actions .tool-button:first-child { display: none; }
  .tool-button { padding: 0 10px; font-size: .78rem; }
  .touch-controls { display: grid; }
  .desktop-hint { display: none; }
  .interaction-hint { top: 119px; }
  .hover-card { bottom: 14px; left: auto; right: 12px; transform: translateY(8px); min-width: 190px; max-width: 58vw; }
  .hover-card.visible { transform: translateY(0); }
  .modal-toolbar { align-items: flex-start; }
  .modal-actions button { min-width: 38px; padding: 0 8px; }
  .modal-footer { grid-template-columns: 1fr 1fr; }
  .modal-footer p { grid-column: 1 / -1; grid-row: 1; }
  .modal-footer button { grid-row: 2; }
  .help-card { padding: 28px 22px; }
}
