/* atl.city — Caveman Tech look: stone paper, slate ink, clay accent, watercolor map.
   Quiet, practical, handcrafted. The map and type set the tone, not the UI. */
:root {
  --slate: #2e3a40;
  --stone: #e8e1d4;
  --clay: #c56a3a;
  --moss: #6b7f66;
  --sky: #8faec3;
  --bg: #e8e1d4;
  --paper: #f3eee4;
  --paper-2: #efe8db;
  --line: #d9cfbd;
  --line-2: #c9bca5;
  --ink: var(--slate);
  --ink-dim: #5d676a;
  --ink-faint: #8f938c;
  --ochre: #d49a3a;
  --shadow: 0 1px 2px rgba(46, 58, 64, .08), 0 4px 14px rgba(46, 58, 64, .06);
  --title: 'Merriweather', Georgia, serif;
  --ui: 'Inter', system-ui, sans-serif;
  --side: 300px;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .3 0 0 0 0 .22 0 0 0 .5 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 400 14px/1.4 var(--ui); overflow: hidden; }
body::before { content: ''; position: fixed; inset: 0; pointer-events: none; background: var(--grain); opacity: .35; mix-blend-mode: multiply; z-index: 30; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--clay); }
kbd { font: 500 10px/1 var(--ui); color: var(--ink-faint); border: 1px solid var(--line); border-radius: 3px; padding: 1px 4px; background: var(--paper); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

#game {
  height: 100dvh; display: grid; gap: 10px; padding: 10px;
  grid-template-columns: 1fr var(--side);
  grid-template-rows: 56px 1fr 108px;
  grid-template-areas: "top top" "field side" "cmd side";
}

/* Cards: plain paper, thin rule, barely-there shadow. */
.frame { position: relative; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }

/* ---------- top bar ---------- */
#topbar { grid-area: top; display: flex; align-items: center; gap: 16px; padding: 0 16px; }
.brand { font: 700 21px/1 var(--title); color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: 10px; letter-spacing: -.01em; }
.mark { height: 34px; width: auto; display: block; }
.res { display: flex; gap: 18px; list-style: none; margin: 0 0 0 8px; padding: 0 0 0 18px; border-left: 1px solid var(--line); }
.res li { display: flex; align-items: baseline; gap: 6px; }
.res b { font: 700 17px/1 var(--title); color: var(--ink); font-variant-numeric: tabular-nums; }
.res small { color: var(--ink-dim); font-size: 12px; }
.ico { width: 14px; height: 14px; align-self: center; background: var(--ink-faint); -webkit-mask: var(--m) center/contain no-repeat; mask: var(--m) center/contain no-repeat; }
.ico-hammer { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2 5l5-4 3 2-2 2 7 8-2 2-7-8-2 2z'/%3E%3C/svg%3E"); background: var(--clay); }
.ico-flag { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 1h1.5v14H3zM5 2h9l-2.5 3.5L14 9H5z'/%3E%3C/svg%3E"); background: var(--moss); }
.ico-shield { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1l6 2v5c0 4-3 6-6 7-3-1-6-3-6-7V3z'/%3E%3C/svg%3E"); background: var(--sky); }
.ico-eye { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 3C4 3 1 8 1 8s3 5 7 5 7-5 7-5-3-5-7-5zm0 8a3 3 0 110-6 3 3 0 010 6z'/%3E%3C/svg%3E"); }
.base { margin: 0 0 0 auto; color: var(--ink-dim); font-size: 13px; white-space: nowrap; }
.base button { background: none; border: 0; border-bottom: 1px solid var(--moss); padding: 0 1px 1px; font: 700 14px/1 var(--title); color: var(--moss); }
.base button:hover { color: var(--slate); border-color: var(--slate); }
.sys { display: flex; gap: 8px; }
.sys button, .stagecard button, .menu-grid > *, .x, #zoombar button {
  background: var(--stone); border: 1px solid transparent; border-radius: 8px;
  padding: 7px 14px; font-weight: 500; font-size: 13px; color: var(--ink); transition: background .15s;
}
.sys button:hover, .stagecard button:hover, .menu-grid > *:hover, .x:hover, #zoombar button:hover { background: #dfd6c5; }
.sys button[aria-expanded="true"] { background: var(--clay); color: #fff; }

/* ---------- field ---------- */
#field { grid-area: field; position: relative; overflow: hidden; border-radius: 14px; border: 1px solid var(--line); box-shadow: var(--shadow); background: #e2dac8; touch-action: none; }
#field canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#cv-fog, #cv-top { pointer-events: none; }
/* Paper grain + a soft deckled vignette over the map, like a watercolor on cold-press paper. */
#field::before { content: ''; position: absolute; inset: 0; z-index: 2; pointer-events: none; background: var(--grain); opacity: .55; mix-blend-mode: multiply; }
#field::after { content: ''; position: absolute; inset: 0; z-index: 2; pointer-events: none; box-shadow: inset 0 0 70px 10px rgba(243, 238, 228, .75); border-radius: 14px; }
#field.grab { cursor: grabbing; }
#field.hover { cursor: pointer; }
#loading { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; font: 400 18px var(--title); color: var(--ink-dim); }
#game:not(.loading) #loading { display: none; }
#banner {
  position: absolute; left: 50%; top: 18px; transform: translateX(-50%) translateY(-4px); z-index: 3; pointer-events: none;
  padding: 10px 22px 11px; background: rgba(243, 238, 228, .96); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
  font: 700 18px/1.2 var(--title); color: var(--ink); text-align: center; opacity: 0; transition: opacity .4s, transform .4s; max-width: 90%;
}
#banner.show { opacity: 1; transform: translateX(-50%); }
#banner small { display: block; font: 400 13px var(--ui); color: var(--ink-dim); margin-top: 3px; }
#tip { position: absolute; z-index: 4; pointer-events: none; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 13px; max-width: 240px; box-shadow: var(--shadow); }
#tip b { color: var(--ink); display: block; font: 700 13px var(--title); margin-bottom: 1px; }
#tip span { color: var(--ink-dim); }
#zoombar { position: absolute; z-index: 3; left: 12px; bottom: 12px; display: flex; align-items: center; gap: 4px; padding: 4px; border-radius: 10px; }
#zoombar button { width: 30px; height: 30px; padding: 0; font-size: 17px; line-height: 1; background: transparent; }
#z-level { font: 400 13px var(--title); color: var(--ink); min-width: 60px; text-align: center; }
.noscript { position: absolute; inset: 40% 10% auto; text-align: center; }

/* ---------- side ---------- */
#side { grid-area: side; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.panel { padding: 36px 14px 14px; min-height: 0; }
.panel h2 { position: absolute; top: 12px; left: 14px; right: 14px; margin: 0; font: 400 11px/16px var(--title); color: var(--ink); letter-spacing: .14em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel h2 small { font: 400 11px var(--ui); color: var(--ink-faint); letter-spacing: 0; text-transform: none; }
#mini-panel { flex: none; }
#cv-mini { display: block; width: 100%; aspect-ratio: 1 / 1; border: 1px solid var(--line); border-radius: 8px; cursor: crosshair; background: #e2dac8; touch-action: none; }
#unit { flex: none; }
.hint { margin: 2px 0 0; color: var(--ink-dim); font-size: 13px; }
.u-top { display: flex; gap: 12px; align-items: flex-start; }
.portrait { flex: none; width: 64px; height: 64px; border: 1px solid var(--line); border-radius: 8px; background: var(--stone); }
.u-name { font: 700 16px/1.25 var(--title); color: var(--ink); margin: 0 0 4px; overflow-wrap: anywhere; }
.u-sub { margin: 0; color: var(--ink-dim); font-size: 12.5px; }
.u-cat { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 0; }
.bar { position: relative; height: 6px; margin: 26px 0 10px; background: var(--stone); border-radius: 3px; }
.bar i { position: absolute; inset: 0 auto 0 0; border-radius: 3px; background: var(--moss); }
.bar.amber i { background: var(--clay); }
.bar span { position: absolute; left: 0; right: 0; bottom: 10px; display: flex; justify-content: space-between; font: 500 12px/1 var(--ui); color: var(--ink); }
.u-stats { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 13px; }
.u-stats dt { color: var(--ink-faint); }
.u-stats dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
.u-note { margin: 10px 0 0; font-size: 12px; color: var(--ink-faint); }
.u-acts { display: flex; gap: 8px; margin-top: 12px; }
.u-acts a, .u-acts button { flex: 1; text-align: center; text-decoration: none; color: var(--ink); background: var(--stone); border: 0; border-radius: 8px; padding: 8px 4px; font-weight: 500; font-size: 13px; }
.u-acts a:first-child { background: var(--clay); color: #fff; }
.u-acts a:hover, .u-acts button:hover { filter: brightness(.97); }
#queue-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
#queue { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; position: relative; z-index: 1; padding-bottom: 56px; }
.ridge { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: auto; opacity: .55; pointer-events: none; border-radius: 0 0 12px 12px; mask-image: linear-gradient(transparent, #000 60%); -webkit-mask-image: linear-gradient(transparent, #000 60%); }
#queue li button, #intel-list li button { width: 100%; display: grid; grid-template-columns: 1fr 52px; gap: 2px 10px; align-items: center; text-align: left; padding: 8px 2px; background: none; border: 0; border-bottom: 1px solid var(--line); }
#queue li:last-child button { border-bottom: 0; }
#queue li button:hover, #intel-list li button:hover { background: rgba(232, 225, 212, .6); }
.q-n { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-s { grid-column: 1; font-size: 12px; color: var(--ink-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-bar { grid-row: 1 / span 2; grid-column: 2; height: 4px; background: var(--stone); border-radius: 2px; position: relative; overflow: hidden; }
.q-bar i { position: absolute; inset: 0 auto 0 0; background: var(--moss); }
.q-bar.amber i { background: var(--clay); }
.empty { color: var(--ink-faint); font-size: 13px; padding: 6px 2px; }

/* ---------- command bar ---------- */
#cmd { grid-area: cmd; display: flex; align-items: stretch; gap: 14px; padding: 12px 14px; min-width: 0; }
.cmdcard { display: grid; grid-template-columns: repeat(7, 66px); gap: 4px; flex: none; }
.cmdcard button {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  background: transparent; border: 0; border-radius: 10px; font-size: 12px; font-weight: 500; color: var(--ink-dim); padding: 4px 2px; transition: background .15s;
}
.cmdcard button kbd { position: absolute; top: 4px; right: 5px; padding: 0 3px; font-size: 9px; border: 0; background: none; }
.cmdcard button:hover { color: var(--ink); background: rgba(232, 225, 212, .7); }
.cmdcard button.on { color: var(--clay); background: var(--stone); }
.glyph { width: 24px; height: 24px; background: currentColor; -webkit-mask: var(--m) center/contain no-repeat; mask: var(--m) center/contain no-repeat; }
.g-all { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.6' stroke-linejoin='round'%3E%3Cpath d='M3 21h18M5 21V10l4-2v13M10 21V5l5-2v18M16 21V9h3v12'/%3E%3C/svg%3E"); }
.g-food { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='M7 3v8M5 3v5a2 2 0 004 0V3M7 11v10M17 21V3c-2 1-3 4-3 8h3'/%3E%3C/svg%3E"); }
.g-drinks { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.6' stroke-linejoin='round' stroke-linecap='round'%3E%3Cpath d='M4 4h16l-8 9zM12 13v7M8 20h8'/%3E%3C/svg%3E"); }
.g-shops { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.6' stroke-linejoin='round'%3E%3Cpath d='M5 8h14l-1 13H6zM9 8a3 3 0 016 0'/%3E%3C/svg%3E"); }
.g-wellness { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='M2 12h2M20 12h2M6 7v10M18 7v10M4 9v6M20 9v6M6 12h12'/%3E%3C/svg%3E"); }
.g-services { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.6' stroke-linejoin='round'%3E%3Cpath d='M14.5 3.5a5 5 0 00-5.2 7.1L3.5 16.4 7.6 20.5l5.8-5.8a5 5 0 007.1-5.2l-3 3-3-1-1-3z'/%3E%3C/svg%3E"); }
.g-other { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.6' stroke-linejoin='round' stroke-linecap='round'%3E%3Cpath d='M6 21V3M6 4h12l-3 4 3 4H6'/%3E%3C/svg%3E"); }
.stagecard { display: flex; flex-direction: column; gap: 4px; flex: none; justify-content: center; padding-left: 14px; border-left: 1px solid var(--line); }
.stagecard button { padding: 4px 14px; font-size: 12px; background: transparent; text-align: left; }
.stagecard button.on { background: var(--stone); color: var(--clay); }
#log { -webkit-mask-image: linear-gradient(transparent, #000 22px); mask-image: linear-gradient(transparent, #000 22px); flex: 1; min-width: 0; list-style: none; margin: 0; padding: 4px 0 2px 14px; border-left: 1px solid var(--line); overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; font-size: 13px; }
#log li { flex: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-dim); line-height: 1.55; animation: logIn .5s ease-out; }
#log li b { color: var(--ink); font-weight: 600; }
#log li.good b { color: var(--moss); }
#log li time { color: var(--ink-faint); margin-right: 8px; font-variant-numeric: tabular-nums; }
@keyframes logIn { from { opacity: 0; transform: translateY(4px); } }

/* ---------- overlays ---------- */
.overlay { position: fixed; z-index: 20; top: 76px; right: calc(var(--side) + 20px); width: min(420px, calc(100vw - 24px)); max-height: calc(100dvh - 210px); display: flex; flex-direction: column; padding: 16px; gap: 12px; box-shadow: 0 10px 30px rgba(46, 58, 64, .14); }
.overlay[hidden], #tip[hidden] { display: none; }
.ov-h { display: flex; align-items: center; justify-content: space-between; }
.ov-h h2 { margin: 0; font: 700 19px var(--title); color: var(--ink); }
.x { padding: 4px 10px; font-size: 12px; }
#intel-q { width: 100%; padding: 10px 12px; background: #fbf9f4; color: var(--ink); border: 1px solid var(--line-2); border-radius: 8px; font: 400 15px var(--ui); }
#intel-q:focus { outline: 2px solid var(--clay); outline-offset: 0; }
#intel-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; min-height: 0; scrollbar-width: thin; }
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.menu-grid > * { text-align: center; text-decoration: none; color: var(--ink); }
.fine { margin: 0; font-size: 12px; color: var(--ink-faint); }
.keys kbd { margin: 0 1px; }

:focus-visible { outline: 2px solid var(--clay); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }

/* ---------- small screens ---------- */
@media (max-width: 1100px) {
  :root { --side: 250px; }
  .res li.explored, .sys kbd { display: none; }
  .res { gap: 12px; }
  .cmdcard { grid-template-columns: repeat(7, 54px); }
}
@media (max-width: 820px) {
  #game { grid-template-columns: 1fr; grid-template-rows: 52px 1fr auto; grid-template-areas: "top" "field" "cmd"; padding: 0; gap: 0; }
  #topbar { gap: 10px; padding: 0 10px; border-radius: 0; border-width: 0 0 1px; box-shadow: none; }
  .brand { font-size: 17px; gap: 6px; }
  .mark { height: 28px; }
  .res { margin: 0; padding-left: 10px; gap: 10px; }
  .res li:nth-child(n+3) { display: none; }
  .res small { display: none; }
  .base { font-size: 0; }
  .base button { font-size: 13px; }
  .sys button { padding: 6px 10px; font-size: 12px; }
  #field { border-radius: 0; border-width: 0; box-shadow: none; }
  #field::after { border-radius: 0; }
  #side { position: absolute; inset: 62px 10px auto auto; width: 124px; z-index: 5; pointer-events: none; }
  #side > * { pointer-events: auto; }
  #mini-panel { padding: 4px; border-radius: 10px; }
  #mini-panel h2, #queue-panel { display: none; }
  #cv-mini { border-radius: 7px; }
  #unit { position: fixed; left: 8px; right: 8px; bottom: calc(var(--cmd-h, 120px) + 8px); width: auto; display: none; max-height: 48dvh; overflow-y: auto; }
  #unit.has { display: block; }
  #cmd { flex-direction: column; gap: 6px; padding: 8px; border-radius: 0; border-width: 1px 0 0; box-shadow: none; }
  .cmdcard { display: flex; overflow-x: auto; gap: 2px; scrollbar-width: none; }
  .cmdcard button { flex: none; width: 58px; height: 50px; }
  .cmdcard kbd { display: none; }
  .glyph { width: 20px; height: 20px; }
  .stagecard { flex-direction: row; border: 0; padding: 0; }
  .stagecard button { flex: 1; text-align: center; }
  #log { display: none; }
  .overlay { top: 60px; right: 8px; left: 8px; width: auto; max-height: calc(100dvh - 200px); }
  #zoombar { left: 8px; bottom: 8px; }
  #banner { font-size: 15px; top: 10px; }
}
@media (max-width: 430px) {
  .res li:nth-child(n+2) { display: none; }
  .res { padding-left: 8px; }
  #topbar { gap: 8px; }
}
