/* mobile-shell.css — phones and tablets (2026-11-14); see mobile.js for the three screen kinds and their media queries:
   compact @media (max-width: 1099px) · phone @media (max-width: 699px), (max-height: 500px) · touch @media (pointer: coarse).
   Every rule here sits inside one of those, so a desktop with a mouse at 1100 px or wider is unchanged — but for the first
   block: the few things mobile.js adds to the frame, which a desktop never shows.
   This file is the game's frame once logged in (the shell): the top bar, the lord and city column, the round buttons, the
   chat, the buff row, the jobs panel, the toast. Windows (.win, .pop) are mobile-win.css's; the views' touch is
   mobile-touch.css's; the login and account pages mobile-gate.css's.
   Layers on a small screen: the frame's bars ≤ 46, the dim backdrop 45, the chat sheet 48, the drawer 50, a window 60
   (mobile-win.css), the toast 70. */

/* ---- what mobile.js adds: hidden on a desktop */
.m-res, .m-drawer-btn, .m-drawer-x, .m-backdrop, #m-chat-btn, .m-chat-x, .jobtabs .m-ico, .jobtabs .m-short { display: none; }

/* ======== compact or phone: the frame fits the screen ======== */
@media (max-width: 1099px), (max-height: 500px) {
  body { min-width: 0; }
  body:has(> main#game:not([hidden])) { overflow: hidden; overscroll-behavior: none; }
  #game .frame { min-width: 0; height: 100vh; height: 100dvh;
    padding: 0 max(6px, env(safe-area-inset-right)) 0 max(6px, env(safe-area-inset-left)); }
  #game .topbar { padding-top: env(safe-area-inset-top); height: calc(46px + env(safe-area-inset-top)); background-position: 0 100%; }
  #game .bottom { padding-bottom: max(8px, env(safe-area-inset-bottom)); height: calc(196px + env(safe-area-inset-bottom)); }
  .m-backdrop:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 45; background: rgba(12, 7, 3, .55); }
}

/* ======== the drawer: the lord and city column slides in from the right (under 1000 px wide, or a phone on its side) ======== */
@media (max-width: 999px), (max-height: 500px) {
  #game .frame { grid-template-columns: minmax(0, 1fr); }
  #game .left { border-right: 0; }
  #game aside.right { position: fixed; z-index: 50; top: 0; right: 0; bottom: 0; width: min(350px, 86vw);
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) 0;
    overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
    background: #2a180a var(--sk-wood) 0 0 / 420px; border-left: 3px solid #1a0e05; box-shadow: -10px 0 28px rgba(0, 0, 0, .65), inset 1px 0 0 #c9953e;
    transform: translateX(calc(100% + 32px)); visibility: hidden; transition: transform .22s ease-out, visibility 0s linear .22s; }
  html.m-drawer-open #game aside.right { transform: none; visibility: visible; transition: transform .22s ease-out; }
  #game aside.right .brand { flex: none; }
  #game aside.right .lord { flex: none; }
  #game aside.right .citybox { flex: 1 0 auto; min-height: 470px; }
  #game .m-drawer-x { display: grid; position: absolute; z-index: 3; top: calc(env(safe-area-inset-top) + 2px); right: calc(env(safe-area-inset-right) + 8px);
    width: 36px; height: 36px; margin: 0; font-size: 16px; }
  /* the button that opens it: the lord's face on the top bar's right */
  #game .m-drawer-btn { display: flex; align-items: center; gap: 2px; flex: none; order: 5; width: auto; height: 38px; padding: 0 4px 0 3px; }
  #game .m-drawer-btn img, #game .m-drawer-btn svg:not(.ic) { display: block; width: 30px; height: 30px; border-radius: 3px; border: 1px solid #c9953e; }
  #game .m-drawer-btn .m-caret { color: var(--sk-gilt); font-size: 12px; }
  html.m-drawer-open #game .m-drawer-btn { border-color: #f2d58a; box-shadow: 0 0 6px rgba(242, 213, 138, .7); }
}

/* ======== the resource strip: on any small screen; a row of its own under the top bar (a phone on its side: in the bar) ======== */
@media (max-width: 1099px) {
  #game .topbar { flex-wrap: wrap; height: auto; row-gap: 0; padding-bottom: 0; background: #2a180a url(img/ui/skin/topbar.webp) 0 0 / auto calc(46px + env(safe-area-inset-top)) repeat-x; }
  #game .topbar > :not(.m-res) { height: 46px; }
  #game .topbar > .topicons, #game .topbar > .tabs.big, #game .topbar > .m-drawer-btn { height: auto; }
  #game .m-res { order: 10; flex: 1 0 100%; margin: 0 -8px; }
}
@media (max-width: 1099px), (max-height: 500px) {
  #game .m-res { display: flex; align-items: center; justify-content: space-around; gap: 4px; min-height: 32px; padding: 2px 8px; cursor: pointer;
    background: linear-gradient(#3a2412, #22150a); border-top: 1px solid #5a3a18; border-bottom: 2px solid #1a0e05; box-shadow: inset 0 1px 0 rgba(201, 149, 62, .35); }
  #game .m-res .m-r { display: inline-flex; align-items: center; gap: 4px; min-width: 0; white-space: nowrap; }
  #game .m-res .m-r i { display: inline-flex; flex: none; }
  #game .m-res .m-r i > * { display: block; width: 18px; height: 18px; }
  #game .m-res b { font: 700 13px Georgia, serif; color: #f6e7c2; text-shadow: 0 1px 1px #000; font-variant-numeric: tabular-nums; }
  #game .m-res b.bad { color: #ff9a8a; }
}

/* ======== touch: every tap target big enough for a finger, on any screen ======== */
@media (pointer: coarse) {
  /* a tablet on its side keeps the desktop's layout but fits its screen: no 1280 px floor, no scrolling */
  body { min-width: 0; }
  #game .frame { min-width: 0; height: 100vh; height: 100dvh; min-height: 0; }
  body:has(> main#game:not([hidden])) { overflow: hidden; overscroll-behavior: none; }
  #game #logout { width: 38px; height: 38px; }
  #game .m-drawer-btn { min-height: 40px; }
  /* the small + buttons keep their look; a finger's reach round them */
  #game .plus { position: relative; width: 24px; height: 24px; font-size: 16px; }
  #game .plus::after { content: ''; position: absolute; inset: -8px -6px; }
  #game .taxpct { display: inline-block; padding: 6px 2px; margin: -6px 0; }
  #game .lordbtn { min-height: 32px; font-size: 13px; }
  #game .ctabs button { min-height: 38px; }
  #game .jobtabs button { min-height: 36px; }
  #game #more-res { min-height: 36px; }
  #game .chan { width: 38px; height: 38px; }
  #game .chatrow > button, #game #chat-text { min-height: 36px; }
  #game #chat-grow { width: 32px; height: 32px; }
  #game .scene-zoom { gap: 6px; }
  #game .scene-zoom button { min-width: 42px; min-height: 42px; font-size: 18px; }
  #game .peacechip { height: 40px; }
  #game .peacechip .pc-t small, #game .peacechip .pc-caret { font-size: 11px; }
  #game .peacemenu .win-close { width: 40px; height: 40px; }
  #game .jobs button { min-height: 32px; min-width: 32px; }
  #game .toast-x { width: 32px; height: 32px; top: -18px; right: -20px; }
  #game .herorow { min-height: 42px; }
  #game .facehint { font-size: 11px; white-space: normal; }
  /* the hover lift the round buttons have does nothing for a finger: a press shows instead */
  #game .round:active .disc, #game .jobtabs button:active .m-ico { filter: brightness(.9); transform: translateY(1px); }
}
/* the bottom a little taller for the taller Construction and Troops tabs (not on a phone, where it is one bar) */
@media (pointer: coarse) and (min-width: 700px) and (min-height: 501px) {
  #game .bottom { height: calc(206px + env(safe-area-inset-bottom)); }
}

/* ======== tablets upright (compact, not a phone): the desktop's bottom, a little narrower ======== */
@media (max-width: 1099px) {
  #game .bottom { grid-template-columns: 300px minmax(0, 1fr); }
  #game .chatbox.tall { left: 316px; }
  #game .jobs { width: min(410px, calc(100% - 20px)); }
  #game .jobs:not([hidden]) ~ .charm-btn { left: auto; right: 10px; }
  #game .peacemenu { width: min(380px, calc(100% - 16px)); }
  #game .sysmsg { max-width: 80%; }
}

/* ======== phones: thin bars, the view first, the round buttons as one bar, the chat as a sheet ======== */
@media (max-width: 699px), (max-height: 500px) {
  /* the top bar: the three tabs share the width; the news line only when an attack is coming */
  #game .topbar { gap: 4px; padding-left: 2px; padding-right: 2px; }
  #game .topbar > :not(.m-res) { height: 42px; }
  #game .topbar > .topicons, #game .topbar > .tabs.big, #game .topbar > .m-drawer-btn { height: auto; }
  #game .ticker #status { display: none; }
  #game .ticker:has(#incoming:empty) { display: none; }
  #game .ticker { flex: 0 1 auto; font-size: 12px; }
  #game .tabs.big { flex: 1 1 auto; min-width: 0; gap: 2px; justify-content: center; }
  #game .tabs.big button { flex: 1 1 0; min-width: 0; max-width: 130px; height: 36px; justify-content: center; gap: 3px; padding: 0 4px 0 0;
    font-size: 13px; letter-spacing: 0; border-width: 6px 10px; border-image-width: 6px 10px; }
  #game .tabs.big button.on { border-width: 6px 10px; border-image-width: 6px 10px; }
  #game .tabs.big button .ic, #game .tabs.big button img, #game .tabs.big button svg { width: 22px; height: 22px; flex: none; }
  #game #logout { width: 36px; height: 36px; }
  #game .m-res b { font-size: 12px; }

  /* the bottom: one bar of round buttons, Chat first, sliding sideways when they do not all fit */
  #game .bottom { --m-nav: calc(66px + env(safe-area-inset-bottom)); display: block; position: relative; z-index: 46; height: var(--m-nav); padding: 0 0 env(safe-area-inset-bottom);
    background: #2a180a var(--sk-wood) 0 0 / 420px; }
  #game .btncol { flex-direction: row; gap: 0; height: 66px; padding-right: 16px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; overscroll-behavior-x: contain;
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 18px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 18px), transparent); }
  #game .btncol::-webkit-scrollbar { display: none; }
  #game .btncol > .jobtabs, #game .btncol > .buttons { display: contents; }
  #game .btncol .round, #game .btncol .jobtabs button { flex: 0 0 auto; position: relative; width: auto; min-width: 68px; height: 66px; margin: 0; padding: 4px 0 2px;
    display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 0; }
  #game .btncol .round .disc { width: 38px; height: 38px; }
  #game .btncol .round .disc svg, #game .btncol .round .disc img { max-width: 100%; max-height: 100%; }
  #game .btncol .round .lbl, #game .jobtabs .m-short { margin-top: -3px; max-width: 92px; border-width: 4px 5px; padding: 0 1px; overflow: hidden; text-overflow: ellipsis; font: 700 11px Georgia, serif; }
  #game .btncol .round .count { top: 0; right: 6px; }
  #m-chat-btn { order: 0; }   #quests-btn { order: 1; }   #mail-btn { order: 2; }   #reports-btn { order: 3; }   #alliance-btn { order: 4; }
  #shop-btn { order: 5; }   #jobs-build { order: 6; }   #jobs-troops { order: 7; }   #stats-btn { order: 8; }   #forum-btn { order: 9; }   #contact-btn { order: 10; }
  /* Construction and Troops: a picture and a short name, like the round ones; lit while they filter the jobs panel */
  #game .jobtabs button { color: var(--sk-gilt); text-shadow: 0 1px 1px #000; background: none; border: 0; border-image: none; box-shadow: none; }
  #game .jobtabs .m-long { display: none; }
  #game .jobtabs .m-ico { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
    background: radial-gradient(circle at 40% 35%, #fff6dc, #e2c17e 65%, #a87a34); border: 2px solid #8a6a2a; box-shadow: 0 2px 3px rgba(0, 0, 0, .45); }
  #game .jobtabs .m-short { display: block; padding: 0 3px; color: var(--sk-gilt); border-style: solid; border-color: transparent; border-width: 4px 7px;
    border-image: url(img/ui/skin/tooltip.webp) 24 26 fill / 4px 7px stretch; }
  #game .jobtabs button.on .m-ico { border-color: #f2d58a; box-shadow: 0 0 0 2px #e0782e, 0 0 8px rgba(242, 213, 138, .8); }
  #game .jobtabs button.on .m-short { color: #fff; }
  /* the chat's button: a count of what came in while it was shut, red when a whisper did */
  #game #m-chat-btn { display: flex; }
  #game #m-chat-btn .disc { display: grid; place-items: center; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #fff6dc, #e2c17e 65%, #a87a34);
    border: 2px solid #8a6a2a; box-shadow: 0 2px 3px rgba(0, 0, 0, .45); overflow: hidden; }
  #game #m-chat-btn.whisper .count { background: #b3261e; }
  html.m-chat-open #game #m-chat-btn .disc { border-color: #f2d58a; box-shadow: 0 0 0 2px #e0782e; }

  /* the chat: a sheet over the view, above the bar, opened by its button */
  #game .chatbox, #game .chatbox.tall { display: none; position: fixed; z-index: 48; left: max(4px, env(safe-area-inset-left)); right: max(4px, env(safe-area-inset-right));
    bottom: calc(66px + env(safe-area-inset-bottom)); top: auto; height: min(62vh, 520px); box-shadow: 0 -8px 24px rgba(0, 0, 0, .6); }
  html.m-chat-open #game .chatbox { display: flex; }
  html.m-chat-open #game .m-chat-x { display: grid; position: fixed; z-index: 49; right: max(10px, calc(env(safe-area-inset-right) + 6px));
    bottom: calc(66px + env(safe-area-inset-bottom) + min(62vh, 520px) - 22px); width: 40px; height: 40px; margin: 0; font-size: 17px; }
  #game #chat-grow { display: none; }
  #game .chatside { gap: 6px; }
  #game .chan { width: 40px; height: 40px; }
  #game .chatrow { gap: 6px; align-items: stretch; }
  #game .chatrow > button { min-height: 40px; }
  #game .chatrow .chanbtn { min-width: 64px; }
  #game #chat-go { min-width: 46px; }
  #game #chat-text { min-width: 0; min-height: 40px; font-size: 16px; }   /* 16 px: iOS does not zoom into it */
  #game .chatmain .chat-lines { font-size: 14px; }

  /* over the view: the buff row, the status menu, the jobs panel, the Lucky Charm, the notices */
  #game .buffbar { left: 6px; top: 6px; max-width: calc(100% - 150px); flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  #game .buffbar::-webkit-scrollbar { display: none; }
  #game .buffbar > * { flex: none; }
  #game .peacemenu { left: 6px; right: 6px; top: 46px; width: auto; max-height: calc(100% - 54px); }
  #game .peacemenu input, #game .peacemenu select { font-size: 16px; }
  #game .peacemenu button { min-height: 36px; }
  #game .sysmsg { top: 46px; max-width: calc(100% - 16px); width: max-content; }
  #game .jobs, #game .jobs:not([hidden]) { left: 6px; right: 76px; bottom: 6px; width: auto; max-height: 40%; }
  #game .jobs .jobrow button, #game .jobs button { min-height: 34px; min-width: 34px; }
  #game .charm-btn, #game .jobs:not([hidden]) ~ .charm-btn { left: auto; right: 6px; bottom: 6px; }
  #game .charm-btn .disc { width: 44px; height: 44px; }
  #game .charm-btn .lbl { font-size: 11px; }
  #game .toast { position: fixed; z-index: 70; bottom: calc(76px + env(safe-area-inset-bottom)); max-width: calc(100vw - 24px); }
  #game .scene-zoom { top: 6px; right: 6px; }
  /* the map's bar (its buttons are mobile-touch.css's) under the buff row, which it covered at the top */
  #game .map-bar { top: 52px; left: auto; right: 6px; max-width: calc(100% - 12px); flex-wrap: wrap; justify-content: flex-end; }
  #game .view:has(> #map:not([hidden])) .buffbar { max-width: calc(100% - 12px); }
}

/* ======== a phone on its side: one thin bar along the top (the strip in it), the round buttons down the left ======== */
@media (max-height: 500px) and (orientation: landscape) {
  #game .topbar { flex-wrap: nowrap; height: calc(42px + env(safe-area-inset-top)); background: #2a180a url(img/ui/skin/topbar.webp) 0 100% / auto 42px repeat-x; }
  #game .topbar > .topicons { order: 0; }
  #game .topbar > .ticker { order: 1; }
  #game .topbar > .tabs.big { order: 2; flex: 0 1 auto; }
  #game .tabs.big button { width: 96px; flex: none; }
  #game .m-res { order: 3; flex: 1 1 auto; min-width: 0; margin: 0; min-height: 34px; padding: 0 6px; border: 1px solid #5a3a18; border-radius: 3px; gap: 2px; }
  #game .m-res .m-r { gap: 2px; }
  #game .m-drawer-btn { order: 4; }
  #game .left { display: grid; grid-template-columns: 84px minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  #game .left > .topbar { grid-column: 1 / -1; grid-row: 1; }
  #game .left > .view { grid-column: 2; grid-row: 2; }
  #game .left > .bottom { grid-column: 1; grid-row: 2; height: auto; min-height: 0; padding: 0; border-top: 0; box-shadow: inset -1px 0 0 #c9953e; border-right: 3px solid #1a0e05; }
  #game .btncol { flex-direction: column; height: 100%; padding: 0 0 14px; overflow-x: hidden; overflow-y: auto; overscroll-behavior-y: contain;
    -webkit-mask-image: linear-gradient(180deg, #000 calc(100% - 16px), transparent); mask-image: linear-gradient(180deg, #000 calc(100% - 16px), transparent); }
  #game .btncol .round, #game .btncol .jobtabs button { width: 81px; min-width: 0; height: 62px; flex: 0 0 62px; }
  #game .btncol .round .lbl, #game .jobtabs .m-short { max-width: 79px; }
  #game .chatbox, #game .chatbox.tall { left: calc(88px + env(safe-area-inset-left)); right: auto; width: min(520px, calc(100vw - 108px)); top: calc(46px + env(safe-area-inset-top)); bottom: max(4px, env(safe-area-inset-bottom)); height: auto; }
  html.m-chat-open #game .m-chat-x { right: auto; left: calc(88px + env(safe-area-inset-left) + min(520px, calc(100vw - 108px)) - 28px); top: calc(36px + env(safe-area-inset-top)); bottom: auto; }
  #game .toast { bottom: max(10px, env(safe-area-inset-bottom)); }
  /* the drawer in two columns, the lord's beside the city's: the screen is wide but short */
  #game aside.right { width: min(700px, calc(100vw - 92px)); display: grid; grid-template-columns: 300px minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); overflow-y: auto; }
  #game aside.right .brand { grid-column: 1; grid-row: 1; }
  #game aside.right .lord { grid-column: 1; grid-row: 2; align-self: start; }
  #game aside.right .citybox { grid-column: 2; grid-row: 1 / span 2; min-height: 360px; padding-top: 8px; }
  #game .jobs, #game .jobs:not([hidden]) { max-height: 55%; }
}

/* ======== a small phone upright (iPhone SE, mini): the tabs' names go, their pictures stay ======== */
@media (max-width: 360px) {
  #game .tabs.big button { font-size: 12px; }
}

/* in the drawer (and on a phone) there is room for the + buttons themselves to grow */
@media (pointer: coarse) and (max-width: 999px), (pointer: coarse) and (max-height: 500px) {
  #game aside.right .plus { width: 28px; height: 28px; font-size: 17px; }
  #game aside.right .plus::after { inset: -6px -4px; }
  #game aside.right .lordbtn { min-height: 36px; }
  #game aside.right .facecol { gap: 5px; }
  #game aside.right .stat { min-height: 38px; }
}
