:root {
  --bg: #17120c; --panel: rgba(24, 18, 11, 0.94); --edge: #6b5330; --gold: #e3c98a; --text: #d9cdb4; --dim: #9a8c70;
  --red: #a3241c; --blue: #2b4f9e; --green: #5c8a3a;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #000; color: var(--text); font: 15px/1.4 Georgia, 'Times New Roman', serif; }
/* The game picture and its interface live on the "stage" (see js/layout.js): the whole
   window on a computer, the part the touch controls leave free on a phone. */
:root { --sx: 0px; --sy: 0px; --sw: 100vw; --sh: 100vh; --pad: 0px; --ts: 1; }
html, body { overscroll-behavior: none; -webkit-text-size-adjust: 100%; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
canvas#view { position: fixed; left: var(--sx); top: var(--sy); width: var(--sw); height: var(--sh); display: block; touch-action: none; }
[hidden] { display: none !important; }

.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: #120d07; z-index: 30; overflow: hidden; isolation: isolate; padding: 12px; }
/* The picture behind the menus: slightly out of focus, covering any screen shape. It is
   drawn larger than the screen so the blur never shows a soft edge. */
.screen::before {
  content: ''; position: absolute; inset: -28px; z-index: -2;
  background: #1c150c url(/img/tlo.jpg) center 45% / cover no-repeat;
  filter: blur(5px) saturate(0.92);
}
/* Darkened towards the edges so the panel and its text stay readable on any part of it. */
.screen::after { content: ''; position: absolute; inset: 0; z-index: -1; background: radial-gradient(ellipse at center, rgba(18, 12, 6, 0.38), rgba(0, 0, 0, 0.8)); }
/* Upright phones see a narrow slice: keep the figure on the cliff in it. */
@media (orientation: portrait) {
  .screen::before { background-position: 27% 50%; filter: blur(3px) saturate(0.95); }
  .screen::after { background: radial-gradient(ellipse at center, rgba(18, 12, 6, 0.22), rgba(0, 0, 0, 0.62)); }
}
/* Very wide and low windows: keep the horizon, not the foreground. */
@media (min-aspect-ratio: 21/9) { .screen::before { background-position: center 38%; } }
.menu-panel { max-height: calc(100% - 4px); overflow-y: auto; scrollbar-width: thin; }
.phase { margin: -6px 0 10px; font-size: 11.5px; letter-spacing: 3px; text-transform: uppercase; color: #c9a55b; display: flex; align-items: center; justify-content: center; gap: 10px; }
.phase::before, .phase::after { content: ''; flex: 1; max-width: 46px; height: 1px; background: linear-gradient(90deg, transparent, rgba(201, 165, 91, 0.7)); }
.phase::after { transform: scaleX(-1); }
.panel { background: var(--panel); border: 1px solid var(--edge); box-shadow: 0 0 0 1px #000, 0 12px 40px rgba(0, 0, 0, 0.7); padding: 18px 22px; border-radius: 3px; }
.menu-panel { width: min(380px, 92vw); text-align: center; }
h1, h2, h3 { color: var(--gold); font-weight: normal; margin: 0 0 10px; letter-spacing: 1px; }
h1 { font-size: 30px; }
h2 { font-size: 19px; }
h3 { font-size: 15px; margin-top: 12px; }
.sub { color: var(--dim); margin: 0 0 14px; font-size: 13px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.error { color: #e0705f; min-height: 1.4em; margin: 10px 0 0; }

input, select, textarea, button { font: inherit; color: var(--text); background: #0d0a06; border: 1px solid var(--edge); padding: 7px 9px; border-radius: 2px; }
textarea { resize: vertical; min-height: 54px; font-family: Consolas, monospace; font-size: 12px; }
input:focus, select:focus, textarea:focus { outline: 1px solid var(--gold); }
button { cursor: pointer; color: var(--gold); background: linear-gradient(#3a2b16, #20170b); }
button:hover { background: linear-gradient(#4d3a1e, #2b1f0f); }
button:disabled { opacity: 0.45; cursor: default; }
button.link { background: none; border: none; color: var(--dim); text-decoration: underline; padding: 2px; }
button.small { padding: 2px 8px; font-size: 13px; }
button.danger { color: #e58b7c; }
label { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--dim); font-size: 13px; }
label.check { justify-content: flex-start; text-align: left; }
label.check input { flex: none; }
label > input, label > select { flex: 1; min-width: 0; }

/* ---------- character screen ---------- */
#characters { gap: 12px; }
#characters h2 { margin-bottom: 2px; }
#character-list { gap: 8px; }
#character-list:empty::after { content: 'Nie masz jeszcze żadnej postaci.'; color: var(--dim); font-size: 13px; padding: 6px 0; }
.char-row { display: flex; align-items: center; gap: 10px; border: 1px solid var(--edge); background: rgba(0, 0, 0, 0.28); padding: 8px 8px 8px 12px; text-align: left; }
.char-row b { color: var(--gold); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; }
.char-row .muted { white-space: nowrap; font-size: 13px; }
.char-row button { padding: 7px 16px; }
.char-row button.small { padding: 7px 10px; }
#new-character { padding: 9px 16px; }
.menu-links { display: flex; justify-content: center; gap: 22px; padding-top: 10px; border-top: 1px solid rgba(107, 83, 48, 0.45); }
.menu-links button.link { padding: 4px 2px; font-size: 14px; }
.menu-links button.link:hover { color: var(--gold); }

/* ---------- HUD ---------- */
#hud { position: fixed; left: var(--sx); top: var(--sy); width: var(--sw); height: var(--sh); pointer-events: none; z-index: 10; user-select: none; -webkit-user-select: none; overflow: hidden; }
#hud > * { pointer-events: auto; }
#labels, #toasts, #crosshair, #focus, #bars, #info, #hint { pointer-events: none !important; }
#crosshair { position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px; border-radius: 50%; background: rgba(255, 255, 255, 0.55); }
#focus { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); width: 260px; text-align: center; text-shadow: 0 1px 3px #000; }
#focus-name { color: var(--gold); font-size: 17px; }
.bar { position: relative; height: 19px; background: rgba(0, 0, 0, 0.65); border: 1px solid #000; outline: 1px solid var(--edge); overflow: hidden; }
.bar > div { height: 100%; width: 0; transition: width 0.15s; }
.bar > span { position: absolute; inset: 0; text-align: center; font-size: 12px; line-height: 17px; color: #fff; text-shadow: 0 0 3px #000; }
#focus .bar { height: 8px; margin-top: 3px; }
#focus-hp, #hp-fill { background: linear-gradient(#d1382c, var(--red)); }
#mana-fill { background: linear-gradient(#4f7fe0, var(--blue)); }
#xp-fill { background: linear-gradient(#c7a955, #7d6427); }
#bars { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); display: grid; grid-template-columns: 210px 260px 210px; gap: 14px; align-items: center; }
#bars .xp { height: 15px; }
#bars .xp span { font-size: 10.5px; line-height: 13px; }

#chat { position: absolute; left: 10px; bottom: 52px; width: min(430px, 44vw); }
#chat-log { max-height: 190px; overflow-y: auto; padding: 4px 6px; font-size: 13.5px; text-shadow: 0 1px 2px #000, 0 0 4px #000; scrollbar-width: thin; user-select: text; }
#chat-log div { overflow-wrap: anywhere; white-space: pre-wrap; }
#chat-log .who { color: var(--gold); }
#chat-log .ch-s { color: #c9b26b; font-style: italic; }
#chat-log .ch-w { color: #c78fd6; }
#chat-log .ch-l { color: #a9c9a0; }
#chat-log .t-warn { color: #e58b7c; }
#chat-log .t-ok { color: #9fd08a; }
#chat-log .t-quest { color: #f0d575; }
#chat-input { width: 100%; background: rgba(0, 0, 0, 0.5); border-color: rgba(107, 83, 48, 0.6); font-size: 13px; }
#info { position: absolute; top: 8px; right: 12px; font-size: 12px; color: var(--dim); text-shadow: 0 1px 2px #000; }
canvas { outline: none; user-select: none; -webkit-user-select: none; }
#hint { position: absolute; top: 8px; left: 12px; font-size: 12px; color: var(--dim); text-shadow: 0 1px 2px #000; }

.label { position: absolute; transform: translate(-50%, -100%); white-space: nowrap; font-size: 13px; text-shadow: 0 1px 2px #000, 0 0 5px #000; color: #e8e2d2; text-align: center; }
.label.player { color: #9fd0ff; }
.label.hostile { color: #f0a090; }
#tool-flags { color: #7fd0ff; font-weight: bold; }
#combat-flag { color: #ffb347; font-weight: bold; }
.tool-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
.tool-row small { display: block; color: var(--dim); font-size: 12px; }
.tool-row button { min-width: 96px; }
.tool-row button.on { background: #35602a; color: #fff; }
.label .pvp, #focus-name .pvp, #pvp-flag { color: #ff3b30; font-style: normal; font-weight: bold; }
.label.talk { color: #f0d575; }
.label i { display: block; height: 4px; width: 60px; margin: 1px auto 0; background: rgba(0, 0, 0, 0.7); border: 1px solid #000; }
.label i b { display: block; height: 100%; background: #c93a2e; }
.float { position: absolute; transform: translate(-50%, -50%); font-weight: bold; font-size: 17px; color: #ffd27a; text-shadow: 0 1px 3px #000; animation: rise 0.9s ease-out forwards; }
.float.me { color: #ff6a5a; }
@keyframes rise { to { margin-top: -46px; opacity: 0; } }
#toasts { position: absolute; top: 76px; left: 50%; transform: translateX(-50%); text-align: center; }
.toast { font-size: 18px; color: var(--gold); text-shadow: 0 2px 4px #000; animation: fade 3.2s forwards; }
@keyframes fade { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- windows ---------- */
#windows { position: absolute; inset: 0; pointer-events: none !important; }
.window { position: absolute; pointer-events: auto; max-height: 86vh; display: flex; flex-direction: column; min-width: 280px; }
.window > header { display: flex; align-items: center; justify-content: space-between; margin: -6px -8px 10px; padding-bottom: 6px; border-bottom: 1px solid var(--edge); }
.window > header h2 { margin: 0; }
.window .body { overflow-y: auto; scrollbar-width: thin; }
.grid { display: grid; grid-template-columns: repeat(6, 58px); gap: 4px; }
.slot { position: relative; width: 58px; height: 58px; background: #0b0805 center/contain no-repeat; border: 1px solid #3e301b; cursor: pointer; }
.slot:hover { border-color: var(--gold); }
.slot.eq { border-color: #c9a646; box-shadow: inset 0 0 8px rgba(227, 201, 138, 0.5); }
.slot span { position: absolute; right: 3px; bottom: 1px; font-size: 12px; color: #fff; text-shadow: 0 0 3px #000, 0 0 3px #000; }
.rows { display: grid; grid-template-columns: 1fr auto auto; gap: 4px 12px; align-items: center; }
.rows .v { color: var(--gold); text-align: right; }
.muted { color: var(--dim); font-size: 13px; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
td, th { padding: 3px 8px; text-align: left; border-bottom: 1px solid rgba(107, 83, 48, 0.35); }
th { color: var(--gold); font-weight: normal; }
tr.on td:first-child::before { content: '● '; color: #8fd07a; }
#tooltip { position: fixed; z-index: 60; pointer-events: none; max-width: 300px; font-size: 13px; }
#tooltip b { color: var(--gold); }
.quest { border: 1px solid rgba(107, 83, 48, 0.5); padding: 7px 9px; margin-bottom: 8px; }
.quest h3 { margin: 0 0 4px; }
.quest ul { margin: 4px 0; padding-left: 18px; }
.quest li.done { color: #9fd08a; }
.shop { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.shop .list { max-height: 54vh; overflow-y: auto; scrollbar-width: thin; }
.shop .item { display: flex; align-items: center; gap: 6px; padding: 3px 2px; border-bottom: 1px solid rgba(107, 83, 48, 0.3); font-size: 13.5px; }
.shop .item .n { flex: 1; }
.shop .item .p { color: var(--gold); }
#death { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(60, 0, 0, 0.45); }
kbd { background: #0d0a06; border: 1px solid var(--edge); padding: 0 5px; border-radius: 2px; color: var(--gold); font: 12px Consolas, monospace; }

/* ---------- admin ---------- */
.admin { width: min(760px, 96vw); }
.tabs { display: flex; flex-wrap: wrap; gap: 3px; margin-bottom: 10px; }
.tabs button { padding: 4px 10px; font-size: 13px; }
.tabs button.active { background: #5a4420; color: #fff; }
/* Wraps into two rows instead of stretching the window past the item grid. */
.inv-tabs { margin-bottom: 8px; max-width: 380px; }
.inv-tabs button { padding: 3px 7px; font-size: 12px; }
.inv-tabs button.empty:not(.active) { opacity: 0.45; }
.window .actions input[type=search] { flex: 1; min-width: 160px; }
table.orig td { padding-top: 5px; padding-bottom: 5px; }
.verdict { padding: 7px 10px; border: 1px solid var(--edge); background: rgba(0, 0, 0, 0.35); }
.verdict.ok { color: #9fd08a; }
.verdict.warn { color: #e6c460; }
.verdict.bad { color: #f08a7a; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin-bottom: 8px; }
.form .wide { grid-column: 1 / -1; }
.form label { flex-direction: column; align-items: stretch; gap: 2px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }

/* ---------- message boxes ---------- */
.modal-screen { position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at center, rgba(20, 13, 6, 0.55), rgba(0, 0, 0, 0.82)); animation: modal-in 0.18s ease-out; }
.modal-screen.closing { opacity: 0; transition: opacity 0.15s; }
.modal { width: min(430px, 90vw); text-align: center; padding: 22px 26px 20px; border-color: #8a6c3c; box-shadow: 0 0 0 1px #000, inset 0 0 0 1px rgba(227, 201, 138, 0.12), 0 18px 60px rgba(0, 0, 0, 0.85); animation: modal-pop 0.2s ease-out; }
.modal h2 { font-size: 22px; padding-bottom: 10px; margin-bottom: 14px; border-bottom: 1px solid var(--edge); }
.modal p { margin: 0 0 18px; font-size: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.modal-actions { display: flex; justify-content: center; gap: 12px; }
.modal-actions button { min-width: 120px; padding: 8px 16px; }
@keyframes modal-in { from { opacity: 0; } }
@keyframes modal-pop { from { transform: scale(0.94); opacity: 0; } }
.modal-actions button:focus { outline: 1px solid var(--gold); outline-offset: 1px; }

/* ---------- Escape menu ---------- */
.window.game-menu { min-width: 240px; padding: 14px 20px 16px; border-color: #8a6c3c; box-shadow: 0 0 0 1px #000, inset 0 0 0 1px rgba(227, 201, 138, 0.12), 0 18px 60px rgba(0, 0, 0, 0.85), 0 0 0 100vmax rgba(0, 0, 0, 0.45); }
.window.game-menu > header { justify-content: center; margin: 0 0 10px; padding-bottom: 7px; }
.window.game-menu > header h2 { font-size: 20px; letter-spacing: 2px; }
.window.game-menu > header button { display: none; }
.menu-items { display: flex; flex-direction: column; gap: 5px; }
.menu-items button { padding: 4px 12px; font-size: 14px; letter-spacing: 0.5px; }
.menu-items .slider { display: grid; grid-template-columns: 1fr; gap: 4px; color: var(--text); font-size: 15px; position: relative; }
.menu-items .switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--text); font-size: 15px; cursor: pointer; }
.menu-items .switch > span { flex: 1; min-width: 0; }
.menu-items .switch > input { flex: none; width: 18px; height: 18px; padding: 0; margin: 0; accent-color: var(--gold); cursor: pointer; }
.menu-items .switch small { display: block; color: var(--dim); font-size: 12px; }
.menu-items .slider .v { position: absolute; right: 0; top: 0; color: var(--gold); }
input[type=range] { -webkit-appearance: none; appearance: none; height: 8px; padding: 0; background: #0d0a06; border: 1px solid var(--edge); border-radius: 4px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--gold); border: 1px solid #000; cursor: pointer; }
input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--gold); border: 1px solid #000; cursor: pointer; }

/* ---------- reports ---------- */
.ticket-thread { max-height: 38vh; overflow-y: auto; scrollbar-width: thin; display: flex; flex-direction: column; gap: 7px; padding-right: 4px; }
.ticket-msg { border: 1px solid rgba(107, 83, 48, 0.5); background: rgba(0, 0, 0, 0.25); padding: 6px 9px; border-radius: 2px; }
.ticket-msg.admin { border-color: #8a6c3c; background: rgba(90, 68, 32, 0.28); }
.ticket-text { white-space: pre-wrap; overflow-wrap: anywhere; user-select: text; }
.ticket-row { cursor: pointer; }
.ticket-row:hover td { background: rgba(227, 201, 138, 0.08); }
.ticket-open { color: #9fd08a; }
.window textarea { width: 100%; font-family: inherit; font-size: 14px; }

/* ---------- character preview ---------- */
.char-preview { display: block; margin: 0 auto; cursor: grab; background: radial-gradient(ellipse at 50% 70%, rgba(227, 201, 138, 0.14), transparent 68%); }
#create-preview { min-height: 300px; }
.inv-top { display: grid; grid-template-columns: 96px 1fr; gap: 10px; align-items: center; margin-bottom: 6px; max-width: 380px; font-size: 13px; }
.inv-top .muted > div { margin-bottom: 2px; overflow-wrap: anywhere; }


/* ---------- choosing how the game is controlled ---------- */
.control-pick { display: grid; grid-template-columns: 1fr; gap: 4px; margin-top: 4px; text-align: left; font-size: 12px; color: var(--dim); letter-spacing: 0.5px; }
.control-pick select { width: 100%; min-width: 0; font-size: 14px; padding: 7px 8px; }
/* ---------- changelog ---------- */
.changelog { width: min(620px, 84vw); display: flex; flex-direction: column; gap: 10px; }
.log-stamp { text-align: center; color: var(--dim); font-size: 13px; letter-spacing: 0.5px; padding-bottom: 8px; border-bottom: 1px solid rgba(107, 83, 48, 0.55); }
/* The page scrolls inside the window once it is longer than the window allows. */
.log-page { max-height: min(56vh, 520px); overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--edge) transparent; padding: 4px 12px 4px 4px; text-align: left; font-size: 15px; line-height: 1.5; user-select: text; -webkit-user-select: text; overscroll-behavior: contain; }
.log-page p { margin: 0 0 4px; overflow-wrap: anywhere; white-space: pre-wrap; }
.log-page h3 { margin: 14px 0 6px; font-size: 18px; color: var(--gold); border-bottom: 1px solid rgba(107, 83, 48, 0.4); padding-bottom: 3px; }
.log-page h3:first-child { margin-top: 2px; }
.log-point { position: relative; padding-left: 18px; margin: 0 0 3px; overflow-wrap: anywhere; }
.log-point::before { content: '◆'; position: absolute; left: 3px; top: 3px; font-size: 9px; color: #c9a55b; }
.log-gap { height: 10px; }
.log-edit { width: 100%; height: min(56vh, 520px); resize: none; font: 14px/1.5 Georgia, 'Times New Roman', serif; color: var(--text); padding: 10px; user-select: text; -webkit-user-select: text; }
.menu-items.row { flex-direction: row; justify-content: center; }
.menu-items.row button { flex: 1; max-width: 220px; }
body.touch.playing .changelog { width: auto; }
/* On a phone the page does not scroll on its own: the whole window does, and the
   buttons stay in sight at its bottom edge whatever the length of the text. */
body.touch.playing .log-page { max-height: none; height: auto; min-height: 0; overflow: visible; padding-right: 4px; }
body.touch.playing .log-edit { height: calc(100vh - 240px); height: calc(100dvh - 240px); min-height: 120px; }
body.touch.playing .changelog > .menu-items.row { position: sticky; bottom: -1px; margin: 0 -2px; padding: 8px 2px 2px; background: var(--panel); box-shadow: 0 -10px 12px -6px rgba(0, 0, 0, 0.75); }
.menu-items .choice { display: grid; grid-template-columns: 1fr; gap: 4px; color: var(--text); font-size: 15px; }
.menu-items .choice small { display: block; color: var(--dim); font-size: 12px; }
.menu-items .choice select { width: 100%; }

/* ---------- touch controls: an area of their own, never on the picture ---------- */
#touch { display: none; }
body.touch.playing #touch { display: block; position: fixed; inset: 0; z-index: 20; pointer-events: none; }
/* A window takes the whole screen on a phone; the controls step aside while it is open. */
body.has-window #touch { visibility: hidden; }
.tpanel {
  position: absolute; pointer-events: auto; display: flex; flex-direction: column; align-items: center; justify-content: space-between; gap: calc(6px * var(--ts));
  padding: 8px; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  /* dark, worn wood with a brass edge towards the picture */
  background:
    repeating-linear-gradient(92deg, rgba(255, 220, 160, 0.022) 0 2px, transparent 2px 9px),
    radial-gradient(ellipse at 50% 0%, rgba(120, 84, 40, 0.28), transparent 70%),
    linear-gradient(180deg, #23190d, #0c0805);
  box-shadow: inset 0 0 26px rgba(0, 0, 0, 0.75);
}
/* upright: both panels share the strip under the picture */
body.portrait .tpanel { top: var(--sh); height: var(--pad); width: 50%; border-top: 2px solid #6b5330; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
body.portrait .tleft { left: 0; border-right: 1px solid rgba(107, 83, 48, 0.45); padding-left: max(8px, env(safe-area-inset-left)); }
body.portrait .tright { right: 0; padding-right: max(8px, env(safe-area-inset-right)); }
body.portrait .tpanel::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 1px; background: linear-gradient(90deg, transparent, rgba(227, 201, 138, 0.55), transparent); }
/* sideways: one panel at each side of the picture */
body.landscape .tpanel { top: 0; height: 100%; width: var(--pad); padding-top: max(8px, env(safe-area-inset-top)); padding-bottom: max(8px, env(safe-area-inset-bottom)); }
body.landscape .tleft { left: 0; border-right: 2px solid #6b5330; padding-left: max(8px, env(safe-area-inset-left)); }
body.landscape .tright { right: 0; border-left: 2px solid #6b5330; padding-right: max(8px, env(safe-area-inset-right)); }
body.landscape .tleft::before, body.landscape .tright::before { content: ''; position: absolute; top: 0; bottom: 0; width: 1px; background: linear-gradient(180deg, transparent, rgba(227, 201, 138, 0.55), transparent); }
body.landscape .tleft::before { right: 0; }
body.landscape .tright::before { left: 0; }

/* Labels shrink with the panel so that none is ever cut off on a narrow phone. */
.tgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: calc(5px * var(--ts)); width: 100%; flex: 0 1 auto; container-type: inline-size; --tf: 8.4cqw; }
body.portrait .tgrid { grid-template-columns: repeat(3, 1fr); --tf: 5.6cqw; }
.tbtn {
  min-width: 0; height: calc(31px * var(--ts)); padding: 0 2px; border-radius: 4px; cursor: pointer; touch-action: none;
  font: bold calc(10px * var(--ts)) Georgia, 'Times New Roman', serif; font-size: min(calc(10.5px * var(--ts)), var(--tf)); letter-spacing: 0.2px; white-space: nowrap; overflow: hidden; text-overflow: clip;
  color: var(--gold); text-shadow: 0 1px 0 #000;
  background: linear-gradient(180deg, #4b381d, #2a1e0e 55%, #1c1409);
  border: 1px solid #8a6c3c;
  box-shadow: inset 0 1px 0 rgba(255, 224, 160, 0.22), inset 0 -2px 3px rgba(0, 0, 0, 0.45), 0 2px 0 #000;
}
.tbtn.on { background: linear-gradient(180deg, #7a5c2c, #46331a); transform: translateY(1px); box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.6), 0 1px 0 #000; color: #fff3d0; }
.tbtn.lit { border-color: #f0d575; color: #fff3d0; box-shadow: inset 0 0 9px rgba(240, 213, 117, 0.45), 0 0 7px rgba(240, 213, 117, 0.35), 0 2px 0 #000; }
.tbtn.taction {
  grid-column: 1 / -1; height: calc(46px * var(--ts)); font-size: min(calc(14px * var(--ts)), 12cqw); letter-spacing: 3px; color: #ffe2c2;
  background: linear-gradient(180deg, #8a3122, #521a10 60%, #36100a); border-color: #c9824a;
  box-shadow: inset 0 1px 0 rgba(255, 200, 170, 0.3), inset 0 -3px 5px rgba(0, 0, 0, 0.5), 0 2px 0 #000;
}
.tbtn.taction.on { background: linear-gradient(180deg, #b84a32, #6e2415); }

.tslot { flex: 1 1 0; min-height: 0; width: 100%; display: flex; align-items: flex-end; justify-content: center; container-type: size; padding-bottom: calc(13px * var(--ts)); }
.tstick {
  position: relative; flex: none; border-radius: 50%; touch-action: none;
  /* as large as the slot allows, up to a comfortable thumb size */
  width: calc(118px * var(--ts)); height: calc(118px * var(--ts));
  width: min(100cqw - 6px, 100cqh - 4px, calc(132px * var(--ts))); height: min(100cqw - 6px, 100cqh - 4px, calc(132px * var(--ts)));
  background: radial-gradient(circle at 50% 42%, #3b2b16 0%, #1d150a 58%, #0b0704 100%);
  border: 2px solid #8a6c3c;
  box-shadow: inset 0 0 0 5px rgba(0, 0, 0, 0.45), inset 0 0 0 6px rgba(227, 201, 138, 0.16), inset 0 6px 16px rgba(0, 0, 0, 0.8), 0 2px 0 #000;
}
.tstick.on { border-color: #e3c98a; }
.tknob {
  position: absolute; left: 50%; top: 50%; width: 42%; height: 42%; margin: -21% 0 0 -21%; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 38% 30%, #c9a55b 0%, #7a5a26 45%, #33240f 100%);
  border: 1px solid #e3c98a; box-shadow: 0 3px 6px rgba(0, 0, 0, 0.75), inset 0 -3px 5px rgba(0, 0, 0, 0.45);
}
.tstick > span { position: absolute; color: rgba(227, 201, 138, 0.42); font-size: calc(9px * var(--ts)); pointer-events: none; line-height: 1; }
.tstick-n { left: 50%; top: 7%; transform: translateX(-50%); }
.tstick-s { left: 50%; bottom: 7%; transform: translateX(-50%); }
.tstick-w { left: 7%; top: 50%; transform: translateY(-50%); }
.tstick-e { right: 7%; top: 50%; transform: translateY(-50%); }
.tstick > .tstick-label { left: 0; right: 0; top: 100%; margin-top: 2px; text-align: center; font: bold calc(8.5px * var(--ts)) Georgia, serif; letter-spacing: 2px; color: rgba(227, 201, 138, 0.6); }

/* ---------- the interface on a small stage ---------- */
body.touch.playing #hint { display: none; }
body.touch.playing #bars { left: 6px; right: 6px; bottom: 5px; transform: none; grid-template-columns: 1fr 1.15fr 1fr; gap: 6px; }
body.touch.playing .bar { height: 15px; }
body.touch.playing .bar > span { font-size: 10.5px; line-height: 13px; }
body.touch.playing #bars .xp { height: 13px; }
body.touch.playing #bars .xp span { font-size: 9.5px; line-height: 11px; }
body.touch.playing #chat { left: 6px; bottom: 26px; width: min(64%, 330px); }
body.touch.playing #chat-log { max-height: calc(var(--sh) * 0.2); font-size: 11.5px; padding: 2px 4px; }
/* 16px: phones zoom into smaller fields. Hidden until the chat button is used. */
body.touch.playing #chat-input { font-size: 16px; padding: 3px 6px; height: 28px; }
body.touch.playing #chat-input:not(:focus) { opacity: 0; height: 0; padding: 0; border: 0; pointer-events: none; }
body.touch.playing #info { top: 4px; right: 6px; font-size: 10.5px; }
body.touch.playing #focus { top: 4px; width: min(220px, 60%); }
body.touch.playing #focus-name { font-size: 14px; }
body.touch.playing #toasts { top: 44px; }
body.touch.playing .toast { font-size: 15px; }
body.touch.playing .label { font-size: 11.5px; }
/* Windows need room and fingers: they take the whole screen, over the controls. */
body.touch.playing #windows .window {
  position: fixed !important; left: max(6px, env(safe-area-inset-left)) !important; right: max(6px, env(safe-area-inset-right)) !important;
  top: max(6px, env(safe-area-inset-top)) !important; bottom: auto !important; transform: none !important;
  width: auto; min-width: 0; max-height: calc(100% - 12px - env(safe-area-inset-bottom)); z-index: 60; padding: 12px 12px 14px;
  /* (the part of the screen really in view: not what the browser's own bars cover) */
  max-height: calc(100dvh - 12px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}
body.touch.playing #windows .window .body { overflow: auto; -webkit-overflow-scrolling: touch; }
body.touch.playing #windows .window > header button { min-width: 38px; min-height: 34px; font-size: 17px; }
body.touch.playing #windows .window.game-menu { top: 50% !important; transform: translateY(-50%) !important; margin: 0 auto; max-width: 420px; }
body.touch.playing .grid { grid-template-columns: repeat(auto-fill, 58px); justify-content: center; }
body.touch.playing .inv-top, body.touch.playing .inv-tabs { max-width: none; }
body.touch.playing .inv-tabs button, body.touch.playing .tabs button { padding: 7px 9px; font-size: 13px; }
body.touch.playing .menu-items button { padding: 6px 12px; }
body.touch.playing #tooltip { display: none; }
body.touch.playing select, body.touch.playing input, body.touch.playing textarea { font-size: 16px; }
@media (max-width: 620px) {
  .form { grid-template-columns: 1fr; }
  .menu-panel { padding: 14px 14px; }
}
@media (max-height: 520px) {
  .menu-panel { max-height: 96vh; overflow-y: auto; }
  .modal { padding: 14px 16px 12px; }
}
/* Behind a full-screen window on a phone: the same dark wood as the panels, not bare black. */
body.touch.playing { background: linear-gradient(180deg, #17100a, #0a0705); }

/* ---------- item card (touch): description and actions of an item held under a finger ---------- */
#item-card { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; padding: 14px; background: rgba(0, 0, 0, 0.6); pointer-events: auto; }
#item-card[hidden] { display: none; }
#item-card .panel { width: 100%; max-width: 340px; max-height: calc(100vh - 28px); max-height: calc(100dvh - 28px); overflow-y: auto; font-size: 15px; line-height: 1.45; padding: 14px 16px; }
#item-card .panel > b { display: block; color: var(--gold); font-size: 17px; margin-bottom: 2px; }
#item-card .card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
#item-card .card-actions button { flex: 1 1 96px; min-height: 42px; font-size: 15px; }
.touch-hint { margin-top: 8px; font-size: 12px; text-align: center; }

/* ---------- chat: a send button for on-screen keyboards ---------- */
#chat-send { display: none; }
body.touch.playing #chat { position: absolute; }
body.touch.playing #chat-input:focus { padding-right: 50px; }
body.touch.playing #chat-input:focus + #chat-send { display: block; position: absolute; right: 0; bottom: 0; width: 46px; height: 28px; padding: 0; font-size: 15px; line-height: 1; }

/* ---------- "how many?" (buying and selling several at once) ---------- */
#item-card .amount-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
#item-card .amount-row input[type=range] { flex: 1; min-width: 0; }
#item-card .amount-row input[type=number] { width: 84px; font-size: 16px; text-align: center; user-select: text; -webkit-user-select: text; }
#item-card .amount-quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
#item-card .amount-quick button { flex: 1 1 60px; min-height: 34px; }
#item-card .amount-total { margin-top: 12px; font-size: 16px; }
#item-card .amount-total b { display: inline; color: var(--gold); font-size: 17px; }
.shop .item button[disabled] { opacity: 0.35; }

/* ---------- scrollbars: thin, dark and gold like everything else (never the system's white ones) ---------- */
* { scrollbar-width: thin; scrollbar-color: rgba(138, 108, 60, 0.75) transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(138, 108, 60, 0.7); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(201, 165, 91, 0.9); }
::-webkit-scrollbar-corner { background: transparent; }
#chat-log { scrollbar-color: rgba(138, 108, 60, 0.55) transparent; }
#chat-log::-webkit-scrollbar { width: 4px; }
#chat-log::-webkit-scrollbar-thumb { background: rgba(138, 108, 60, 0.5); }

/* ---------- what a chest held ---------- */
#loot-box { position: absolute; left: 50%; top: 27%; transform: translate(-50%, -50%); z-index: 20; min-width: 230px; max-width: min(360px, 86%); padding: 12px 16px 12px; pointer-events: none !important; animation: loot-in 0.25s ease-out; transition: opacity 0.4s; }
#loot-box.out { opacity: 0; }
#loot-box h3 { margin: 0 0 8px; text-align: center; font-size: 16px; letter-spacing: 1px; color: var(--gold); border-bottom: 1px solid rgba(107, 83, 48, 0.5); padding-bottom: 6px; }
.loot-row { display: flex; align-items: center; gap: 10px; padding: 2px 0; font-size: 14px; }
.loot-icon { flex: none; width: 38px; height: 38px; background: rgba(0, 0, 0, 0.35) center / contain no-repeat; border: 1px solid rgba(107, 83, 48, 0.6); border-radius: 2px; }
.loot-name { flex: 1; overflow-wrap: anywhere; }
.loot-count { color: var(--gold); font-weight: bold; }
@keyframes loot-in { from { opacity: 0; transform: translate(-50%, -40%); } to { opacity: 1; transform: translate(-50%, -50%); } }
body.touch.playing #loot-box { top: 30%; min-width: 200px; padding: 9px 12px; }
body.touch.playing .loot-icon { width: 32px; height: 32px; }

/* ---------- options: the ends of a slider named, and a way back to the usual value ---------- */
.menu-items .slider .slider-ends { display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; color: var(--dim); }
.menu-items .slider .slider-ends button { padding: 1px 8px; font-size: 11.5px; min-height: 0; }

/* ---------- diving: the air left, and the view under water ---------- */
#breath { position: absolute; left: 50%; top: 14%; transform: translateX(-50%); width: min(220px, 46%); height: 9px; background: rgba(0, 0, 0, 0.55); border: 1px solid rgba(120, 170, 200, 0.7); border-radius: 2px; z-index: 6; pointer-events: none !important; }
#breath > div { height: 100%; background: linear-gradient(#9fd8f5, #3f8fc0); transition: width 0.15s linear; }
#breath.low { border-color: #e07a6a; }
#breath.low > div { background: linear-gradient(#f0b0a0, #c0503f); }
#underwater { position: absolute; inset: 0; z-index: 1; pointer-events: none !important; background: radial-gradient(ellipse at center, rgba(20, 70, 90, 0.34), rgba(6, 34, 52, 0.62)); }
#breath[hidden], #underwater[hidden] { display: none; }

/* ---------- chat emoji ---------- */
/* Every line keeps the same height with or without pictures: the lines have a fixed
   height of their own, and a picture - a fixed square box - takes up less room in the
   line than it shows (the negative margins), so it never pushes the lines apart. */
#chat-log div { line-height: 1.45; }
#chat-log img.emoji { display: inline-block; width: 1.7em; height: 1.7em; margin: -0.5em 1px; vertical-align: middle; object-fit: contain; user-select: none; -webkit-user-drag: none; }
#chat-suggest { position: absolute; left: 0; bottom: 34px; min-width: 200px; max-width: 100%; z-index: 30; padding: 4px; background: rgba(20, 15, 10, 0.96); border: 1px solid var(--edge); border-radius: 3px; box-shadow: 0 6px 22px rgba(0, 0, 0, 0.7); pointer-events: auto; }
#chat-suggest[hidden] { display: none; }
#chat-suggest .row { display: flex; align-items: center; gap: 8px; padding: 3px 8px; border-radius: 2px; font-size: 13.5px; cursor: pointer; white-space: nowrap; }
#chat-suggest .row.on { background: rgba(201, 165, 91, 0.22); color: var(--gold); }
#chat-suggest .row:hover { background: rgba(201, 165, 91, 0.14); }
#chat-suggest img.emoji { width: 24px; height: 24px; object-fit: contain; flex: none; }
#chat-suggest .hint { margin-top: 3px; padding: 3px 8px 1px; border-top: 1px solid rgba(107, 83, 48, 0.4); font-size: 11px; color: var(--dim); white-space: nowrap; }
body.touch.playing #chat-suggest .row { padding: 7px 8px; font-size: 14px; }
body.touch.playing #chat-suggest .hint { display: none; }

/* ---------- panel: daily routines ---------- */
.rt-rows { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.rt-row { padding: 6px 8px; border: 1px solid rgba(107, 83, 48, 0.45); border-radius: 3px; background: rgba(0, 0, 0, 0.18); }
.rt-row.now { border-color: var(--gold); background: rgba(201, 165, 91, 0.1); }
.rt-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 3px 0; }
.rt-line label { display: flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--dim); white-space: nowrap; }
.rt-line label.grow { flex: 1 1 220px; }
.rt-line label.grow > input, .rt-line label.grow > select { flex: 1; min-width: 0; }
.rt-line label.check { color: var(--text); }
.rt-line input[type=time] { width: 96px; }
.rt-line input[type=number] { width: 70px; }
.rt-pos { font-size: 12px; color: var(--gold); }

/* ---------- through a passage into another level: a moment of black with the level's name ---------- */
#level-fade { position: absolute; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; background: #000; color: var(--gold); font-size: 30px; letter-spacing: 3px; text-shadow: 0 2px 6px #000; opacity: 0; pointer-events: none !important; transition: opacity 0.9s ease-in; }
#level-fade.on { opacity: 1; transition: opacity 0.05s; }
body.touch.playing #level-fade { font-size: 20px; }

/* ---------- the belt of runes and scrolls (keys 4 to 0) ---------- */
#spellbar { position: absolute; bottom: 44px; right: 14px; display: flex; gap: 4px; }
#spellbar[hidden] { display: none; }
#spellbar button { position: relative; width: 78px; height: 34px; padding: 2px 4px 2px 16px; background: rgba(12, 10, 8, 0.72); border: 1px solid #4a3b22; color: #d8cfb8; font: inherit; font-size: 10.5px; line-height: 1.15; text-align: left; overflow: hidden; cursor: pointer; }
#spellbar button.empty { opacity: 0.35; cursor: default; }
#spellbar button.active { border-color: var(--gold); box-shadow: 0 0 8px rgba(230, 190, 90, 0.55) inset; color: #fff; }
#spellbar button b { position: absolute; left: 4px; top: 2px; color: var(--gold); font-size: 11px; }
#spellbar button i { position: absolute; right: 3px; bottom: 1px; font-style: normal; font-size: 10px; color: #9fd0ff; }
#spellbar button span { display: block; max-height: 100%; overflow: hidden; }
body.touch.playing #spellbar { bottom: auto; top: 30px; right: auto; left: 50%; transform: translateX(-50%); gap: 2px; }
body.touch.playing #spellbar button { width: 52px; height: 30px; font-size: 9px; padding-left: 12px; }

/* ---------- the map (M) ---------- */
.map-wrap { position: relative; width: 100%; max-width: min(100%, calc(100vh - 230px)); margin: 0 auto; aspect-ratio: 1; overflow: hidden; border: 1px solid #4a3b22; background: #16120c; }
.map-canvas { display: block; width: 100%; touch-action: none; cursor: grab; }
.map-canvas:active { cursor: grabbing; }
.map-tip { position: absolute; padding: 3px 7px; background: rgba(10, 8, 5, 0.9); border: 1px solid #6b5631; color: #f0e2bd; font-size: 12px; white-space: nowrap; pointer-events: none; }
.map-info { position: absolute; left: 8px; top: 6px; color: #f0e2bd; font-size: 13px; text-shadow: 0 1px 3px #000; pointer-events: none; }
.map-bar { display: flex; gap: 6px; margin-top: 6px; }
.map-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; font-size: 11.5px; color: #cdbf9e; }
.map-legend span { display: inline-flex; align-items: center; gap: 5px; line-height: 16px; }
.map-legend b { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 16px; height: 16px; border-radius: 50%; color: #1b140a; font: bold 10px/1 sans-serif; }

/* ---------- the "Ruchome elementy" tab ---------- */
.movers-list { display: flex; flex-direction: column; gap: 6px; }
.movers-row { padding: 6px 8px; border: 1px solid #3c3020; background: rgba(0, 0, 0, 0.2); }
.movers-row.locked { border-color: #8a4a2a; background: rgba(120, 40, 20, 0.15); }
.movers-what { overflow-wrap: anywhere; }
.movers-edit { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; align-items: center; }
.movers-edit select { flex: 0 0 auto; }
.movers-edit input { flex: 1 1 160px; min-width: 0; }

/* ---------- the options, in sections ---------- */
.menu-items.options .options-section { margin: 10px 0 -2px; padding-bottom: 3px; border-bottom: 1px solid rgba(201, 163, 107, 0.35); color: var(--gold); font-size: 13px; letter-spacing: 2px; text-transform: uppercase; }
.menu-items.options .options-section:first-child { margin-top: 0; }
.menu-items .slider .slider-reset { position: absolute; right: 52px; top: -2px; padding: 1px 8px; font-size: 11.5px; min-height: 0; }


/* ---- titles and "(Mobile)" by players' names, achievements */
.label small.title { display: block; font-size: 11.5px; color: var(--gold); margin-bottom: -1px; }
.label small.mobile { display: block; font-size: 10.5px; color: #b8b2a4; margin-top: -1px; }
#chat-log .mobile, .title-preview .mobile { color: #a9a294; }
#chat-log .title { font-weight: bold; }
.ach { display: flex; flex-direction: column; gap: 10px; }
.ach-sum { color: var(--gold); text-align: center; font-size: 15px; }
.ach-list { display: flex; flex-direction: column; gap: 6px; }
.ach-row, .title-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid rgba(107, 83, 48, 0.6); background: rgba(0, 0, 0, 0.25); }
.title-row { align-items: center; }
.title-row.on { border-color: var(--gold); }
.ach-row.done { border-color: #8a6c3c; background: rgba(227, 201, 138, 0.07); }
.ach-row.secret { opacity: 0.75; }
.ach-icon { flex: none; width: 26px; height: 26px; display: grid; place-items: center; border: 1px solid var(--edge); color: var(--gold); font-weight: bold; }
.ach-row.secret .ach-icon { color: var(--dim); }
.ach-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: 14px; overflow-wrap: anywhere; }
.ach-text b { color: var(--text); font-size: 15px; }
.ach-row.done .ach-text b { color: var(--gold); }
.ach-badge { margin-left: 8px; padding: 0 5px; border: 1px solid var(--edge); color: var(--dim); font-size: 11px; font-weight: normal; vertical-align: middle; }
.ach-bar { position: relative; height: 16px; margin-top: 3px; background: rgba(0, 0, 0, 0.6); border: 1px solid #000; }
.ach-bar i { position: absolute; left: 0; top: 0; bottom: 0; background: #6b5330; }
.ach-bar span { position: relative; display: block; text-align: center; font-size: 11.5px; line-height: 16px; color: var(--text); }
.ach-when { color: var(--green); font-size: 12.5px; filter: brightness(1.5); }
.ach-reward { font-size: 13px; color: var(--dim); }
.title-now { text-align: center; font-size: 15px; }
.title-preview .who { color: #9fd0ff; }
#ach-box { position: absolute; top: 120px; left: 50%; transform: translateX(-50%); z-index: 30; pointer-events: none; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 12px 26px; min-width: 260px; max-width: 92vw; text-align: center; border-color: #8a6c3c; animation: ach-in 0.35s ease-out; transition: opacity 0.5s; }
#ach-box small { color: var(--dim); letter-spacing: 2px; text-transform: uppercase; font-size: 12px; }
#ach-box b { color: var(--gold); font-size: 20px; }
#ach-box.out { opacity: 0; }
@keyframes ach-in { from { opacity: 0; transform: translate(-50%, -12px); } to { opacity: 1; transform: translate(-50%, 0); } }
body.touch.playing #ach-box { top: 70px; padding: 9px 16px; }
body.touch.playing #ach-box b { font-size: 17px; }
.title-sample { padding: 4px 0; font-weight: bold; }
.form label.check { flex-direction: row; align-items: center; justify-content: flex-start; gap: 6px; }
#chat-log .sys-who { color: #b0213a; font-weight: bold; }

/* ---- the animations window (K) */
.emote-head { margin: 10px 0 6px; }
.emote-head:first-child { margin-top: 0; }
.emote-head small { color: var(--dim); font-size: 12px; letter-spacing: 0; }
.emote-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 5px; }
.emote-grid.small { grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); }
.emote-grid button { padding: 6px 8px; font-size: 13.5px; text-align: center; }
.emote-grid button.on { border-color: var(--gold); color: var(--gold); }
.emote-tip { margin: 10px 0 0; font-size: 12.5px; }
body.touch.playing .emote-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
body.touch.playing .emote-grid button { padding: 9px 6px; font-size: 14px; }

/* ---- cooking at a pan */
.cook { display: flex; flex-direction: column; gap: 8px; }
.cook-list { display: flex; flex-direction: column; gap: 5px; max-height: min(52vh, 460px); overflow-y: auto; padding-right: 2px; }
.cook-row { display: flex; gap: 10px; align-items: center; padding: 7px 9px; border: 1px solid rgba(107, 83, 48, 0.6); background: rgba(0, 0, 0, 0.25); cursor: pointer; }
.cook-row:hover { border-color: var(--edge); background: rgba(227, 201, 138, 0.05); }
.cook-row.on { border-color: var(--gold); background: rgba(227, 201, 138, 0.1); box-shadow: inset 0 0 0 1px rgba(227, 201, 138, 0.15); }
.cook-row.short { opacity: 0.72; }
.cook-icon { flex: none; width: 44px; height: 44px; border: 1px solid var(--edge); background: #0d0a06 center / contain no-repeat; }
.cook-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.cook-text b { color: var(--gold); font-weight: normal; font-size: 15px; }
.cook-makes { font-size: 13px; color: var(--text); }
.cook-needs { display: flex; flex-wrap: wrap; gap: 3px 10px; font-size: 12.5px; }
.cook-needs .ok { color: #9fd08a; }
.cook-needs .miss { color: #f08a7a; }
.cook-hint { margin: 0; text-align: center; font-size: 13px; min-height: 1.3em; }

/* ---- the staff's recipe form */
.rc-box { border: 1px solid rgba(107, 83, 48, 0.6); background: rgba(0, 0, 0, 0.2); padding: 8px 10px; margin-bottom: 8px; }
.rc-head { margin-bottom: 6px; }
.rc-line { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.rc-n { color: var(--dim); width: 20px; }
.rc-item { flex: 1 1 220px; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.rc-qty { display: flex; align-items: center; gap: 5px; color: var(--dim); font-size: 13px; }
.rc-count { width: 70px; }

/* ---- the quest form: lists to choose from */
.q-line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 7px; padding-bottom: 7px; border-bottom: 1px dashed rgba(107, 83, 48, 0.45); }
.q-line:last-of-type { border-bottom: 0; }
.q-type { flex: none; }
.pick { flex: 1 1 260px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.pick-filter { font-size: 12.5px; padding: 4px 7px; }
.pick-select { width: 100%; min-width: 0; }
.q-inline { display: flex; align-items: center; gap: 5px; color: var(--dim); font-size: 13px; }
.q-inline.grow { flex: 1 1 180px; }
.q-inline.grow input { flex: 1; min-width: 0; }
.q-num { width: 70px; }
.q-num.wide { width: 110px; }
.q-reach { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; }
.q-requires { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 3px 10px; max-height: 160px; overflow-y: auto; }
.stock-field, .pick-field { display: flex; flex-direction: column; gap: 3px; color: var(--dim); font-size: 13px; }
.stock-field .rc-box { margin: 2px 0 0; color: var(--text); }
/* (in the panel forms a field keeps its own height: a taller neighbour in the same row -
   a list with its search field - no longer stretches it, nor a checkbox) */
.form { align-items: start; }
.form label > input, .form label > select { flex: none; }
.form label > input[type=checkbox] { align-self: flex-start; width: 18px; height: 18px; margin: 4px 0 0; }
.pick-field .pick { flex: none; }

/* ---- bosses */
.label.boss { color: #ff8a5a; font-weight: bold; font-size: 14px; }
.label.boss i { width: 110px; height: 6px; }
#boss-box { position: absolute; left: 50%; top: 24%; transform: translate(-50%, -50%); z-index: 22; width: min(420px, 92%); padding: 12px 16px 10px; border-color: #8a6c3c; pointer-events: auto; animation: ach-in 0.35s ease-out; transition: opacity 0.5s; }
#boss-box.out { opacity: 0; }
#boss-box h3 { margin: 0; text-align: center; font-size: 13px; letter-spacing: 3px; text-transform: uppercase; color: var(--dim); }
.boss-name { text-align: center; color: #ff9a6a; font-size: 20px; margin: 2px 0 8px; padding-bottom: 6px; border-bottom: 1px solid rgba(107, 83, 48, 0.5); }
.boss-close { position: absolute; right: 8px; top: 8px; }
.boss-list { display: flex; flex-direction: column; gap: 4px; max-height: 42vh; overflow-y: auto; }
.boss-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 6px; border: 1px solid transparent; }
.boss-row.me { border-color: rgba(227, 201, 138, 0.45); background: rgba(227, 201, 138, 0.06); }
.boss-who { display: flex; flex-direction: column; min-width: 0; }
.boss-who b { color: var(--text); font-weight: normal; font-size: 15px; }
.boss-who small { color: var(--dim); font-size: 12px; }
.boss-got { display: flex; align-items: center; gap: 6px; color: var(--gold); font-size: 13.5px; text-align: right; }
.boss-got .loot-icon { width: 32px; height: 32px; }
.boss-got.none { color: #6f6450; }
.boss-note { margin: 6px 0 0; font-size: 11.5px; text-align: center; }
body.touch.playing #boss-box { top: 32%; }
.map-legend b.skull { background: none; border-radius: 0; }
.map-legend b.skull canvas { width: 16px; height: 16px; }
#haste-flag { color: #8fe0ff; font-weight: bold; }

/* ---- the owner's cinema tab */
.cine-link { flex: 1 1 320px; min-width: 0; }
.cine-controls { align-items: center; }
.cine-time { color: var(--gold); font-family: Consolas, monospace; margin: 0 6px; }
.cine-bar { width: 100%; margin: 4px 0 8px; }
.cine-ranges { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; margin: 6px 0; }
.cine-range { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; color: var(--dim); font-size: 13px; }
.cine-range input { grid-column: 1 / -1; width: 100%; }
@media (max-width: 700px) { .cine-ranges { grid-template-columns: 1fr; } }

/* ---- the owner watching a player (only the owner sees it) */
#spectate-bar { position: fixed; top: 8px; left: 50%; transform: translateX(-50%); z-index: 40; display: flex; align-items: center; gap: 10px;
  padding: 6px 10px 6px 14px; background: rgba(20, 14, 8, 0.82); border: 1px solid var(--gold-dim, #6a5232); color: var(--dim, #c9b88f); font-size: 14px; border-radius: 3px; }
#spectate-bar span { color: var(--gold, #c9a35a); font-weight: bold; }
#spectate-bar button { font-size: 13px; padding: 3px 10px; }

/* ---- the first-person view: a small dot in the middle of the picture to aim by */
#crosshair { position: fixed; left: calc(var(--sx, 0px) + var(--sw, 100vw) / 2); top: calc(var(--sy, 0px) + var(--sh, 100vh) / 2); width: 4px; height: 4px; margin: -2px 0 0 -2px;
  border-radius: 50%; background: rgba(255, 244, 220, 0.85); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55); pointer-events: none; z-index: 5; }
#crosshair[hidden] { display: none; }

/* ---- the arena: the strip over the fight, its window, the reward */
#arena-hud { position: fixed; left: calc(var(--sx, 0px) + var(--sw, 100vw) / 2); top: calc(var(--sy, 0px) + 54px); transform: translateX(-50%); z-index: 21; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 18px 7px; background: rgba(18, 12, 6, 0.78); border: 1px solid #8a6c3c; color: var(--dim); text-align: center; }
#arena-hud[hidden] { display: none; }
#arena-hud b { color: var(--gold); font-size: 20px; font-weight: normal; letter-spacing: 1px; }
#arena-hud span { font-size: 13px; }
#arena-hud.pulse { animation: ach-in 0.4s ease-out; }
.arena-status { display: grid; gap: 3px; margin: 10px 0; padding: 8px 12px; border: 1px solid var(--edge); background: rgba(0, 0, 0, 0.3); }
.arena-go { font-size: 16px; padding: 8px 22px; }
.window .actions:has(.arena-go) { justify-content: center; margin: 12px 0 6px; }
.arena-top { width: 100%; border-collapse: collapse; }
.arena-top td { padding: 3px 8px; border-bottom: 1px solid rgba(107, 83, 48, 0.3); }
.arena-top td:first-child { width: 2.5em; color: var(--dim); }
.arena-top td:last-child { text-align: right; white-space: nowrap; }
.arena-top tr.on td { color: var(--gold); }
#arena-reward { position: absolute; left: 50%; top: 30%; transform: translate(-50%, -50%); z-index: 23; min-width: 260px; max-width: min(400px, 90%); padding: 12px 16px 12px; border-color: #8a6c3c; pointer-events: auto; animation: ach-in 0.35s ease-out; }
#arena-reward h3 { margin: 0; text-align: center; font-size: 13px; letter-spacing: 3px; text-transform: uppercase; color: var(--dim); }
#arena-reward .arena-xp .loot-name { color: #9fd08a; }
