/* Moat & Mortar, the tin toy fort (game-hub-D67, Direction A; the owner's pick 2026-11-02, "moat and mortar A").
   Both screens are a lithographed tin box: a blue-striped lid, steel chips with an ink edge and a hard drop, cream
   panels with a red offset print. The board itself is js/td/tin.js. Mock-ups: design/moat/round2.html. */

@font-face { font-family: "Bungee"; src: url("../fonts/bungee-latin.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Archivo"; src: url("../fonts/archivo-latin.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

.tin {
  --ink: #1f1d2b; --cream: #f4e7c6; --cream2: #e8d6a8; --red: #d8402f;
  --steel: linear-gradient(#f5f6f7, #d5dade 55%, #a9b0b8);
  --gold: linear-gradient(#ffe08a, #e8b22e);
  --edge: inset 0 0 0 1.5px var(--ink);
  color: var(--ink);
  font: 700 15px/1.3 "Archivo", system-ui, sans-serif;
  font-variant-numeric: lining-nums tabular-nums;
}
body[data-screen="tmenu"], body[data-screen="td"] {
  background: repeating-linear-gradient(90deg, #2a5aa8 0 18px, #2f62b3 18px 36px) fixed;
  color-scheme: light;
}
body[data-screen="tmenu"] main, body[data-screen="td"] main {
  width: min(100%, 1100px); height: 100dvh; margin: 0 auto; padding: 0; box-sizing: border-box;
  display: flex; flex-direction: column;
}
body[data-screen="tmenu"] main { height: auto; min-height: 100dvh; width: min(100%, 560px); }
#screen-tmenu.tin, #screen-td.tin { flex: 1; min-height: 0; gap: 0; text-align: left; }

/* ---------- the frame: steel chips, the stats on a cream plate ---------- */
.tin .topbar {
  display: flex; align-items: center; gap: 8px; padding: calc(12px + env(safe-area-inset-top)) 12px 0; flex: none;
}
.tin .topbar > :last-child { margin-left: auto; }
/* the maps screen: the Tacs and the settings gear stand together on the right (mock-up A, game-hub-D121) */
#screen-tmenu .topbar > .coins { margin-left: auto; }
#screen-tmenu .topbar > #td-gear { margin-left: 0; }
.tin :is(.back, .coins, .hud-btn, .tin-chip) {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 44px; min-width: 44px; box-sizing: border-box; padding: 0 12px; border: 0; border-radius: 10px;
  background: var(--steel); color: var(--ink); box-shadow: var(--edge), 0 3px 0 var(--ink);
  font: 800 15px/1 "Archivo", system-ui, sans-serif; font-variant-numeric: lining-nums tabular-nums;
  white-space: nowrap; text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: transform 0.06s, box-shadow 0.06s;
}
/* the hub's chunky lift (ui.css) is a soft drop and an accent ledge; tin keeps its ink drop and sinks onto it */
.tin :is(.back, .hud-btn, .tin-chip):hover:not(:disabled) { filter: brightness(1.04); transform: none; box-shadow: var(--edge), 0 3px 0 var(--ink); }
.tin :is(.back, .hud-btn, .tin-chip):active:not(:disabled) { transform: translateY(3px); box-shadow: var(--edge), 0 0 0 var(--ink); filter: none; }
.tin :is(button, .tin-map):focus-visible { outline: 3px solid var(--cream); outline-offset: 3px; }
.tin .hud-btn { padding: 0; }
.tin .hud-btn svg { width: 22px; height: 22px; }
.tin .coins { cursor: default; }
.tin-stats {
  display: flex; gap: 10px; align-items: center; height: 40px; padding: 0 10px; margin-left: auto; box-sizing: border-box;
  background: var(--cream); border-radius: 10px; box-shadow: var(--edge), 2px 2px 0 var(--red);
  white-space: nowrap; font: 800 14px/1 "Archivo", system-ui, sans-serif; font-variant-numeric: lining-nums tabular-nums;
}
.tin-stats + .hud-btn { margin-left: 0; }
.tin-stats i { font: 400 12px/1 "Bungee", system-ui, sans-serif; font-style: normal; color: var(--red); }
.tin-stats b { font-weight: 800; }
.tin-stats b.bump { animation: bump 0.45s ease-out; display: inline-block; }

/* ---------- the board and what stands on it ---------- */
#screen-td .stage { flex: 1 1 0; min-height: 0; margin: 8px 12px 0; overflow: hidden; position: relative; }
#screen-td .stage canvas {
  width: 100%; height: 100%; border-radius: 0; background: transparent; box-shadow: none; touch-action: none;
}
#screen-td .overlay {
  border-radius: 10px; background: rgb(31 29 43 / 0.45); backdrop-filter: none; padding: 16px;
}
.tin-card {
  display: grid; justify-items: center; gap: 10px; padding: 18px 20px 16px; max-width: 320px; box-sizing: border-box;
  background: var(--cream); border-radius: 8px; text-align: center;
  box-shadow: inset 0 0 0 2px var(--ink), 4px 4px 0 var(--red), 5px 5px 0 var(--ink);
}
#screen-td .overlay-title { margin: 0; font: 400 30px/1.05 "Bungee", system-ui, sans-serif; color: var(--red); }
#screen-td .overlay-text { margin: 0; color: var(--ink); font: 800 15px/1.35 "Archivo", system-ui, sans-serif; font-variant-numeric: lining-nums tabular-nums; }
#screen-td .overlay-text b { color: var(--ink); }
.tin-card-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.tin-card-row .tin-chip { font-size: 13px; }
.tin-card-row .tin-chip svg { width: 16px; height: 16px; flex: none; } /* the pause's Settings gear (game-hub-D123) */

/* The wave held: a cream ribbon stamped onto the board, the bolts it paid under the words. */
.tin-ribbon {
  position: absolute; left: 50%; top: 42%; z-index: 2; pointer-events: none;
  padding: 10px 22px 12px; border-radius: 6px; background: var(--cream); text-align: center; white-space: nowrap;
  box-shadow: inset 0 0 0 2px var(--ink), 4px 4px 0 var(--red), 5px 5px 0 var(--ink);
  transform: translate(-50%, -50%) rotate(-3deg);
}
.tin-ribbon b { display: block; font: 400 30px/1.05 "Bungee", system-ui, sans-serif; color: var(--red); }
.tin-ribbon span { font: 800 15px/1 "Archivo", system-ui, sans-serif; font-variant-numeric: lining-nums tabular-nums; }
.tin-ribbon.stamp { animation: tin-stamp 0.32s cubic-bezier(0.3, 1.5, 0.6, 1) both; }
.tin-ribbon.lift { animation: tin-lift 0.35s ease-in both; }
@keyframes tin-stamp {
  0% { opacity: 0; transform: translate(-50%, -50%) rotate(-9deg) scale(1.5); }
  60% { opacity: 1; transform: translate(-50%, -50%) rotate(-2deg) scale(0.96); }
  100% { opacity: 1; transform: translate(-50%, -50%) rotate(-3deg) scale(1); }
}
@keyframes tin-lift {
  0% { opacity: 1; transform: translate(-50%, -50%) rotate(-3deg) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -70%) rotate(-3deg) scale(1); }
}

/* ---------- the tray, and the chosen tower's panel in its place (game-hub-D64) ---------- */
#screen-td .td-dock { flex: none; height: 72px; padding: 8px 12px 0; box-sizing: border-box; }
#screen-td .td-toolbar { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; height: 100%; padding: 0; }
#screen-td:has(#td-selected:not([hidden])) .td-toolbar { display: none; }
.tin-tower {
  display: grid; justify-items: center; align-content: center; gap: 2px; height: 100%; min-width: 0; padding: 0; border: 0;
  border-radius: 10px; background: linear-gradient(var(--cream), var(--cream2)); color: var(--ink); cursor: pointer;
  box-shadow: var(--edge), 0 3px 0 var(--ink); font: 800 12px/1 "Archivo", system-ui, sans-serif;
  font-variant-numeric: lining-nums tabular-nums; -webkit-tap-highlight-color: transparent;
  transition: transform 0.06s, box-shadow 0.06s;
}
.tin-tower canvas { width: 30px; height: 30px; }
.tin-tower .nm { font: 700 10px/1 "Archivo", system-ui, sans-serif; letter-spacing: -0.2px; white-space: nowrap; max-width: 100%; overflow: hidden; }
.tin-tower[aria-pressed="true"] { background: var(--gold); transform: translateY(2px); box-shadow: var(--edge), 0 1px 0 var(--ink); }
.tin-tower:active { transform: translateY(3px); box-shadow: var(--edge), 0 0 0 var(--ink); }
.tin-tower[data-poor] { filter: saturate(0.25); color: rgb(31 29 43 / 0.55); }
#screen-td .td-selected {
  display: grid; grid-template-columns: auto auto minmax(0, 1fr) 44px; grid-template-rows: auto 44px; align-items: center;
  gap: 4px 6px; height: 100%; padding: 0; background: none; outline: 0; animation: none;
}
#screen-td .td-selected[hidden] { display: none; }
#td-sel-name {
  grid-column: 1 / -1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--cream);
  font: 400 12px/1 "Bungee", system-ui, sans-serif; text-shadow: 1px 1px 0 var(--ink);
}
#td-sel-name small { font: 800 12px/1 "Archivo", system-ui, sans-serif; text-shadow: none; opacity: 0.92; }
#screen-td .td-selected .tin-chip { padding: 0 10px; font-size: 14px; min-width: 0; }
#screen-td .td-selected .tin-chip.up { background: var(--gold); }
#screen-td .td-selected .tin-chip[aria-disabled="true"] { filter: saturate(0.25); color: rgb(31 29 43 / 0.6); }
#td-target { justify-self: start; text-transform: capitalize; }

/* ---------- Next wave, the speed ---------- */
#screen-td .td-controls { display: flex; gap: 8px; padding: 8px 12px calc(12px + env(safe-area-inset-bottom)); flex: none; }
.tin-go {
  height: 54px; padding: 0 16px; border: 0; border-radius: 12px; background: var(--red); color: var(--cream); cursor: pointer;
  box-shadow: var(--edge), 0 4px 0 var(--ink); font: 400 18px/1 "Bungee", system-ui, sans-serif; white-space: nowrap;
  font-variant-numeric: lining-nums tabular-nums; -webkit-tap-highlight-color: transparent;
  transition: transform 0.06s, box-shadow 0.06s;
}
.tin-go:active { transform: translateY(4px); box-shadow: var(--edge), 0 0 0 var(--ink); }
.tin-go[aria-disabled="true"] { filter: saturate(0.3) brightness(0.92); }
#screen-td .td-controls .tin-go { flex: 1; min-width: 0; }
#td-speed { width: 64px; height: 54px; border-radius: 12px; font: 400 16px/1 "Bungee", system-ui, sans-serif; box-shadow: var(--edge), 0 4px 0 var(--ink); }
#screen-td .keys-hint { display: none; }
@media (hover: hover) and (pointer: fine) and (min-width: 700px) {
  #screen-td .keys-hint { display: block; margin: 0 0 10px; text-align: center; color: var(--cream); font: 600 12px/1.3 "Archivo", system-ui, sans-serif; }
}

/* ---------- the map list ---------- */
#screen-tmenu .tin-title { padding: 18px 16px 12px; }
#screen-tmenu h1 { margin: 0; font: 400 34px/1 "Bungee", system-ui, sans-serif; color: var(--cream); text-shadow: 3px 3px 0 var(--red), 4px 4px 0 var(--ink); }
#screen-tmenu .tin-title p { margin: 8px 0 0; color: var(--cream); font: 700 14px/1.3 "Archivo", system-ui, sans-serif; }
.tin-maps { display: grid; gap: 10px; padding: 0 12px; }
.tin-map {
  display: flex; gap: 12px; align-items: center; padding: 8px; border: 0; border-radius: 12px; text-align: left; color: var(--ink);
  background: linear-gradient(#f5f6f7, #c8ced4); box-shadow: var(--edge), 0 4px 0 var(--ink); cursor: pointer;
  -webkit-tap-highlight-color: transparent; transition: transform 0.06s, box-shadow 0.06s;
}
.tin-map:active { transform: translateY(4px); box-shadow: var(--edge), 0 0 0 var(--ink); }
.tin-map[aria-pressed="true"] { background: var(--gold); }
.tin-map canvas { display: block; flex: none; width: 196px; height: 127px; border-radius: 4px; box-shadow: 0 0 0 1.5px var(--ink); }
.tin-map > span { min-width: 0; }
.tin-map b { display: block; margin-bottom: 4px; font: 400 17px/1.15 "Bungee", system-ui, sans-serif; }
.tin-map small { display: block; white-space: nowrap; font: 700 13px/1.3 "Archivo", system-ui, sans-serif; font-variant-numeric: lining-nums tabular-nums; }
.tin-map .stars { display: block; margin-top: 4px; color: var(--red); font-size: 20px; letter-spacing: 2px; line-height: 1; }
.tin-map .stars .o { color: rgb(31 29 43 / 0.25); }
/* Defend stays at the thumbs while the rows scroll under it (at 320 x 568 the list is taller than the screen) */
#td-play { position: sticky; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 2; margin: 14px 12px calc(12px + env(safe-area-inset-bottom)); height: 60px; font-size: 21px; border-radius: 14px; box-shadow: var(--edge), 0 5px 0 var(--ink); flex: none; }

/* ---------- the smallest phones: the rows give up padding before the board gives up room ---------- */
@media (max-width: 340px), (max-height: 640px) {
  .tin .topbar { gap: 6px; padding: calc(8px + env(safe-area-inset-top)) 8px 0; }
  .tin :is(.back, .coins, .tin-chip) { padding: 0 9px; }
  .tin-stats { gap: 7px; padding: 0 8px; font-size: 13px; }
  .tin-stats i.w { display: none; }
  #screen-td .stage { margin: 6px 8px 0; }
  #screen-td .td-dock { height: 64px; padding: 6px 8px 0; }
  #screen-td .td-toolbar { gap: 5px; }
  .tin-tower canvas { width: 26px; height: 26px; }
  #screen-td .td-controls { padding: 6px 8px calc(8px + env(safe-area-inset-bottom)); }
  #screen-td .td-controls .tin-go, #td-speed { height: 48px; }
  #screen-td .td-selected .tin-chip { padding: 0 8px; font-size: 13px; }
  .tin-maps { gap: 8px; padding: 0 8px; }
  .tin-map canvas { width: 128px; height: 83px; }
  #screen-tmenu .tin-title { padding: 12px 12px 10px; }
  #screen-tmenu h1 { font-size: 30px; }
  #td-play { margin: 12px 8px calc(8px + env(safe-area-inset-bottom)); bottom: calc(8px + env(safe-area-inset-bottom)); height: 54px; }
}

/* ---------- a tablet or a desktop: bigger tray, the rows two by two ---------- */
@media (min-width: 700px) and (min-height: 600px) {
  .tin .topbar { padding: calc(16px + env(safe-area-inset-top)) 20px 0; }
  #screen-td .stage { margin: 12px 20px 0; }
  #screen-td .td-dock { height: 92px; padding: 12px 20px 0; width: min(100%, 820px); align-self: center; }
  .tin-tower { font-size: 14px; gap: 4px; }
  .tin-tower .nm { font-size: 12px; letter-spacing: 0; }
  .tin-tower canvas { width: 40px; height: 40px; }
  #screen-td .td-controls { padding: 12px 20px calc(16px + env(safe-area-inset-bottom)); width: min(100%, 820px); align-self: center; box-sizing: border-box; }
  #screen-td .td-dock { box-sizing: border-box; }
  #td-sel-name { font-size: 14px; }
  body[data-screen="tmenu"] main { width: min(100%, 860px); }
  .tin-maps { grid-template-columns: 1fr 1fr; gap: 14px; padding: 0 20px; }
  .tin-map canvas { width: 176px; height: 114px; }
  #screen-tmenu .tin-title { padding: 28px 20px 18px; }
  #screen-tmenu h1 { font-size: 44px; }
  #td-play { margin: 22px 20px 28px; justify-self: center; align-self: center; width: min(100% - 40px, 420px); }
}
/* an upright tablet: one row a map, the sheets big, so the list fills the height instead of leaving it bare */
@media (min-width: 700px) and (min-height: 600px) and (orientation: portrait) {
  body[data-screen="tmenu"] main { width: min(100%, 680px); }
  .tin-maps { grid-template-columns: 1fr; }
  .tin-map canvas { width: 272px; height: 177px; }
  .tin-map b { font-size: 22px; }
  .tin-map small { font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) {
  .tin-ribbon.stamp, .tin-ribbon.lift { animation-duration: 0.01s; }
}
