/* tibia-js: minimal dark Tibia-ish UI */
* { box-sizing: border-box; }

body {
  background: #0c0c10;
  color: #d8d8d8;
  font-family: Verdana, Geneva, sans-serif;
  font-size: 13px;
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

body.entry-screen {
  background-color: #080b0d;
  background-image:
    linear-gradient(rgba(5, 7, 8, 0.16), rgba(5, 7, 8, 0.42)),
    url("assets/login-background-76-heroine.webp");
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  background-attachment: fixed;
}

body.entry-screen .panel {
  background: rgba(19, 19, 23, 0.94);
  border-color: #5b5140;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.78), inset 0 0 0 1px rgba(215, 184, 102, 0.08);
  backdrop-filter: blur(2px);
}

body.entry-screen #login-screen { width: min(390px, calc(100vw - 24px)); }
body.entry-screen #character-list-screen { width: min(390px, calc(100vw - 24px)); }

.panel {
  background: #16161d;
  border: 1px solid #33333f;
  border-radius: 6px;
  padding: 28px 32px;
  width: 340px;
}

@media (prefers-reduced-transparency: reduce) {
  body.entry-screen .panel { backdrop-filter: none; }
}

@media (prefers-reduced-motion: reduce) {
  #asset-loader-fill, #asset-loader-fill::after, .asset-loader-runes i { animation: none; transition: none; }
}

h1 {
  font-size: 20px;
  margin: 0 0 4px;
  color: #e8c860;
  letter-spacing: 1px;
}

.subtitle { color: #777; margin: 0 0 18px; }
.entry-benefits { display: flex; gap: 5px; flex-wrap: wrap; margin: -6px 0 12px; }
.entry-benefits span {
  padding: 3px 6px; color: #e5cf8b; background: #29251b; border: 1px solid #5b513a;
  font-size: 10px; font-weight: bold; text-transform: uppercase;
}
.entry-copy { margin: 0 0 14px; color: #bbb4a4; font-size: 11px; line-height: 1.45; }

label {
  display: block;
  margin-bottom: 10px;
  color: #999;
}

input[type=text], input[type=password], input[type=number] {
  display: block;
  width: 100%;
  margin-top: 3px;
  background: #0c0c10;
  border: 1px solid #3a3a46;
  border-radius: 4px;
  color: #e8e8e8;
  padding: 7px 9px;
  font-size: 13px;
}

input:focus { outline: none; border-color: #e8c860; }

button {
  width: 100%;
  margin-top: 8px;
  padding: 9px;
  background: #e8c860;
  border: none;
  border-radius: 4px;
  color: #1a1a10;
  font-weight: bold;
  font-size: 14px;
  cursor: pointer;
}
button:hover { background: #f4d878; }
.secondary-button { background: #39372f; color: #d8d2c2; border: 1px solid #615b4b; }
.secondary-button:hover { background: #4a463b; }
.character-list { display: grid; gap: 6px; margin: 10px 0; }
.character-entry {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; margin: 0; padding: 8px 10px; text-align: left;
  background: #25241f; border: 1px solid #514b3c; color: #e6ddc7;
}
.character-entry:hover { background: #343126; }
.character-entry small { color: #a69d89; font-size: 10px; font-weight: normal; }

.status { color: #999; margin: 14px 0 0; min-height: 16px; line-height: 1.4; }
.entry-links { margin: 12px 0 0; text-align: center; }
.entry-links a { color: #e8c860; }
.entry-links a:hover { color: #fff0a7; }

.asset-loader {
  margin-top: 14px;
  color: #b8ad94;
  font-size: 10px;
  letter-spacing: .2px;
  transition: opacity .25s ease;
}
.asset-loader-line { display: flex; justify-content: space-between; gap: 10px; }
#asset-loader-percent { color: #d7bf76; font-variant-numeric: tabular-nums; }
.asset-loader-track {
  height: 8px;
  margin-top: 5px;
  overflow: hidden;
  background: #070707;
  border: 1px solid #554b38;
  box-shadow: inset 0 1px 2px #000;
}
#asset-loader-fill {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #796329, #d4b85f 70%, #f0d985);
  box-shadow: 0 0 7px rgba(218, 183, 82, .55);
  transition: width .16s ease-out;
  position: relative;
}
#asset-loader-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 34%;
  background: linear-gradient(90deg, transparent, rgba(255,255,220,.5), transparent);
  animation: asset-shimmer 1.3s linear infinite;
}
.asset-loader-runes { display: flex; justify-content: center; gap: 5px; height: 8px; margin-top: 5px; }
.asset-loader-runes i {
  width: 4px;
  height: 4px;
  transform: rotate(45deg);
  background: #8d7740;
  box-shadow: 0 0 4px rgba(222, 187, 90, .55);
  animation: rune-pulse 1.05s ease-in-out infinite;
}
.asset-loader-runes i:nth-child(2) { animation-delay: .16s; }
.asset-loader-runes i:nth-child(3) { animation-delay: .32s; }
.asset-loader.is-complete #asset-loader-fill { background: #7e963d; box-shadow: 0 0 6px rgba(126,150,61,.55); }
.asset-loader.is-complete #asset-loader-fill::after,
.asset-loader.is-complete .asset-loader-runes { display: none; }
.asset-loader.is-error #asset-loader-fill { background: #8f3530; box-shadow: none; }
.asset-loader.is-error #asset-loader-fill::after,
.asset-loader.is-error .asset-loader-runes { display: none; }

@keyframes asset-shimmer { from { transform: translateX(-120%); } to { transform: translateX(350%); } }
@keyframes rune-pulse { 0%, 100% { opacity: .25; transform: rotate(45deg) scale(.75); } 50% { opacity: 1; transform: rotate(45deg) scale(1.15); } }

.outfit-row { display: flex; gap: 14px; align-items: center; margin-bottom: 8px; }
#outfit-preview {
  background: #0c0c10;
  border: 1px solid #3a3a46;
  border-radius: 4px;
  image-rendering: pixelated;
}
.outfit-cols { flex: 1; }
.outfit-cols label { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.outfit-cols select { width: 105px; margin-top: 0; }
.outfit-part-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }
.outfit-part-tabs button {
  position: relative; min-width: 0; margin: 0; padding: 3px 3px 3px 17px;
  color: #111; background: #aaa; border: 2px outset #ccc; border-radius: 0;
  font: 10px Verdana, sans-serif; text-align: left;
}
.outfit-part-tabs button::before {
  content: ""; position: absolute; left: 3px; top: 3px; width: 9px; height: 9px;
  background: var(--part-color, #000); border: 1px inset #aaa;
}
.outfit-part-tabs button.active { color: #fff; background: #404080; border-style: inset; }
.outfit-palette {
  display: grid; grid-template-columns: repeat(19, 11px); grid-auto-rows: 11px;
  justify-content: center; gap: 1px; padding: 5px; background: #777; border: 2px inset #aaa;
}
.outfit-palette button {
  width: 11px; height: 11px; min-width: 0; margin: 0; padding: 0;
  border: 1px solid rgba(0,0,0,.6); border-radius: 0;
}
.outfit-palette button:hover { outline: 1px solid #fff; z-index: 1; }
.outfit-palette button.selected { outline: 2px solid #fff; z-index: 2; }

/* ---- game screen ---- */
#game-screen { flex-direction: column; align-items: center; }

.game-main { display: flex; align-items: flex-start; gap: 6px; }

.canvas-col {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
}
#zoom-btn {
  position: absolute;
  top: 4px; right: 4px;
  width: auto; margin: 0; padding: 2px 10px;
  background: rgba(22,22,29,0.85);
  border: 1px solid #444450; border-radius: 3px;
  color: #e8c860; font-size: 12px; z-index: 5;
}

#game-canvas {
  display: block;
  background: #000;
  border: 1px solid #33333f;
  image-rendering: pixelated;
  cursor: crosshair;
}
#game-canvas:focus { outline: none; border-color: #e8c860; }

#death-overlay {
  position: absolute;
  inset: 0 0 auto 0;
  height: var(--game-viewport-height, 704px);
  z-index: 7;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(25, 0, 0, 0.68);
  color: #ddd;
  font-size: 16px;
  text-shadow: 1px 1px #000;
  pointer-events: all;
}
#death-overlay strong { color: #c8c8c8; font-size: 28px; font-weight: normal; }

.side { width: 260px; display: flex; flex-direction: column; gap: 8px; }

.hud-box {
  background: #16161d;
  border: 1px solid #33333f;
  border-radius: 4px;
  padding: 8px 10px;
}

.bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.bar-row > span { width: 44px; color: #999; }

.bar {
  position: relative;
  flex: 1;
  height: 14px;
  background: #0c0c10;
  border: 1px solid #3a3a46;
  border-radius: 3px;
  overflow: hidden;
}

.bar-fill { height: 100%; transition: width 0.15s; }
.bar-fill.hp { background: #c02828; }
.bar-fill.mana { background: #2850c8; }
.bar-fill.exp { background: #68a030; }

.bar-text {
  position: absolute;
  inset: 0;
  text-align: center;
  font-size: 10px;
  line-height: 14px;
  color: #fff;
  text-shadow: 0 1px 1px #000;
}

.exp-text { color: #888; font-size: 11px; margin-top: 3px; }

#chat-console {
  width: 100%;
  margin-top: 3px;
  padding: 3px;
  background: #777;
  border: 2px outset #aaa;
}
#chat-log {
  height: 118px;
  min-height: 118px;
  max-height: 118px;
  overflow-y: auto;
  font-size: 12px;
  line-height: 1.5;
  word-wrap: break-word;
}
#chat-log .chat-info { color: #e8c860; }
#chat-log .chat-loot { color: #68d868; }
#chat-log .chat-whisper { color: #ddd; font-style: italic; }
#chat-log .chat-yell { color: #f0d050; font-weight: bold; }
#chat-log .chat-private { color: #9fc5ff; }
#chat-log .chat-channel { color: #f0d050; }

#chat-toolbar { display: flex; align-items: stretch; gap: 2px; }
#chat-tabs {
  display: flex; flex: 1 1 auto; min-width: 0; gap: 1px;
  overflow-x: auto; overflow-y: hidden; scrollbar-width: thin;
}
#chat-tabs button {
  flex: 0 0 auto; width: auto; min-width: 62px; margin: 0; padding: 2px 5px;
  color: #111; background: #aaa; border: 2px outset #ccc; border-radius: 0;
  font: 9px Verdana, sans-serif; white-space: nowrap;
}
#chat-tabs button.active { border-style: inset; background: #ddd; }
#chat-tabs button.unread { color: #700; font-weight: bold; }
.console-control {
  flex: 0 0 27px; width: 27px; margin: 0; padding: 0; color: #111;
  background: #aaa; border: 2px outset #ccc; border-radius: 0;
  font: bold 12px/18px Verdana, sans-serif;
}
.console-control:active, .console-control.active { border-style: inset; background: #ddd; }
.console-control:disabled { color: #666; border-style: inset; background: #999; }
#ignore-list-btn { font-size: 16px; }
#ignore-list-btn.filtered { color: #c00000; background: #e0b0b0; }

#chat-input { width: 100%; }

.hint { color: #666; margin-top: 8px; }

/* minimap */
#minimap-box { padding: 6px; }
#minimap {
  cursor: crosshair;
  display: block;
  width: 100%;
  background: #000;
  border: 1px solid #3a3a46;
  border-radius: 3px;
  image-rendering: pixelated;
}

.mlvl { color: #b48cff; margin-left: auto; }
.gold-text { color: #ffd24a; margin-top: 4px; font-size: 12px; }

/* equipment slots */
#equipment { padding: 6px; }
.equip-grid {
  display: grid;
  grid-template-columns: repeat(3, 40px);
  gap: 4px;
  justify-content: center;
}
.slot {
  width: 40px; height: 40px;
  background: #0c0c10;
  border: 1px solid #3a3a46;
  border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  position: relative;
}
.slot:hover { border-color: #e8c860; }
.slot canvas { image-rendering: pixelated; }
.slot .slot-count {
  position: absolute; right: 2px; bottom: 0;
  font-size: 10px; color: #fff; text-shadow: 0 1px 1px #000;
}

/* backpack */
#backpack { max-height: 150px; overflow-y: auto; padding: 6px; }
.bp-items { display: flex; flex-wrap: wrap; gap: 4px; }
.bp-item {
  width: 40px; height: 40px;
  background: #0c0c10;
  border: 1px solid #3a3a46;
  border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; position: relative;
}
.bp-item:hover { border-color: #e8c860; }
.bp-item canvas { image-rendering: pixelated; }
.bp-item .slot-count {
  position: absolute; right: 2px; bottom: 0;
  font-size: 10px; color: #fff; text-shadow: 0 1px 1px #000;
}

/* floating panels (loot / trade) */
.float-panel {
  position: absolute;
  top: 60px; left: 520px;
  min-width: 260px;
  background: #16161d;
  border: 1px solid #444450;
  border-radius: 6px;
  padding: 10px;
  z-index: 10;
  box-shadow: 0 6px 24px rgba(0,0,0,0.6);
}
.panel-title {
  display: flex; justify-content: space-between; align-items: center;
  color: #e8c860; font-weight: bold; margin-bottom: 8px;
}
.close-btn {
  width: auto; margin: 0; padding: 0 8px;
  background: #333; color: #ccc; font-size: 12px;
}
.item-rows { display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow-y: auto; }
.item-row {
  display: flex; align-items: center; gap: 8px;
  background: #0c0c10; border: 1px solid #2c2c36; border-radius: 3px;
  padding: 3px 6px; cursor: pointer;
}
.item-row:hover { border-color: #e8c860; }
.item-row canvas { image-rendering: pixelated; }
.item-row .item-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.item-row .item-name { font-size: 12px; }
.item-row .item-details { color: #92929d; font-size: 10px; white-space: nowrap; }
.item-row .item-count { color: #aaa; font-size: 11px; }
.item-row .item-price { color: #ffd24a; font-size: 11px; }
.trade-tools { display: flex; gap: 5px; margin-bottom: 7px; }
.trade-tools input, .trade-tools select {
  min-width: 0; height: 24px; padding: 2px 5px; border: 1px solid #444450;
  background: #0c0c10; color: #d8d8dc; font: 11px Arial, sans-serif;
}
.trade-tools input { flex: 1; }
.trade-tools select { width: 125px; }
.trade-cols { display: flex; gap: 10px; }
.trade-col { flex: 1; min-width: 230px; }
.trade-col h3 { margin: 0 0 6px; font-size: 12px; color: #999; }
#loot-take-all { margin-top: 8px; }

.player-trade-dialog { width: 330px; }
.player-trade-offers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.player-trade-offers h3 { margin: 0 0 5px; color: #aaa; font-size: 11px; }
.secure-trade-item {
  min-height: 70px; padding: 6px; border: 1px solid #4b4b55; background: #101015;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; text-align: center; font-size: 11px;
}
.secure-trade-item canvas { image-rendering: pixelated; }
.secure-trade-item.accepted { border-color: #5f9e55; box-shadow: inset 0 0 0 1px #2e5f29; }
.player-trade-status { min-height: 16px; margin: 8px 0 3px; color: #bdbdbd; font-size: 11px; }

/* Tibia-style container windows, docked in the right panel */
#containers {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 46vh;
  overflow-y: auto;
}
#containers:empty { display: none; }
.container-window {
  background: #16161d;
  border: 1px solid #33333f;
  border-radius: 4px;
  padding: 8px;
  user-select: none;
}
.container-window .panel-title { margin-bottom: 6px; }
.cw-grid {
  display: grid;
  grid-template-columns: repeat(4, 40px);
  gap: 4px;
}
.cw-pager {
  display: none;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
}
.cw-pager button {
  width: auto; margin: 0; padding: 2px 10px;
  background: #333; color: #ccc; font-size: 12px;
}
.cw-page { color: #888; font-size: 11px; }
.drag-ghost {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  opacity: 0.85;
}
.drag-ghost canvas { display: block; image-rendering: pixelated; }

/* ---- Tibia 7.6-style right sidebar ---- */
.side {
  width: 190px;
  gap: 3px;
  padding: 3px;
  background: #777;
  border: 2px outset #aaa;
  color: #111;
  height: var(--game-viewport-height, 704px);
  max-height: calc(100vh - 20px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: #aaa #666;
  scrollbar-width: thin;
}
.side > * { flex-shrink: 0; }
.side::-webkit-scrollbar { width: 14px; }
.side::-webkit-scrollbar-track { background: #666; border: 2px inset #999; }
.side::-webkit-scrollbar-thumb { background: #aaa; border: 2px outset #ccc; }
.side .hud-box, .container-window {
  background: #888;
  border: 2px inset #bbb;
  border-radius: 0;
  padding: 4px;
}
#minimap-box { padding: 3px; }
#minimap { width: 100%; height: 112px; border: 2px inset #aaa; border-radius: 0; }
.minimap-controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin-top: 2px; }
.minimap-controls button, .sidebar-tabs button {
  width: auto; min-width: 0; margin: 0; padding: 2px;
  color: #111; background: #aaa; border: 2px outset #ccc; border-radius: 0;
  font: bold 10px Verdana, sans-serif;
}
.minimap-controls button:active, .sidebar-tabs button:active { border-style: inset; }
#status-box { font-size: 10px; }
#status-box .bar-row { margin-bottom: 2px; gap: 3px; }
#status-box .bar-row > span { width: 30px; color: #111; }
#status-box .bar { height: 12px; border-radius: 0; border-color: #444; }
#status-box .bar-text { font-size: 9px; line-height: 11px; }
#condition-bar { display: flex; flex-wrap: wrap; gap: 2px; min-height: 0; margin-top: 3px; }
.condition-icon {
  position: relative; width: 22px; height: 22px; border: 2px inset #aaa;
  background: #666; color: #fff; text-align: center; line-height: 18px;
  font: bold 10px Verdana, sans-serif; cursor: help;
}
.condition-icon.harmful { color: #ffe0b0; background: #713b32; }
.condition-icon .condition-time {
  position: absolute; right: 1px; bottom: -1px; font-size: 7px; line-height: 8px;
  color: #fff; text-shadow: 1px 1px #000;
}
#equipment { padding: 4px; }
.doll-grid { position: relative; width: 154px; height: 170px; margin: 0 auto; }
#doll-preview { position: absolute; left: 45px; top: 53px; width: 64px; height: 64px; image-rendering: pixelated; opacity: .42; }
.doll-grid .slot { position: absolute; width: 32px; height: 32px; border: 2px inset #aaa; border-radius: 0; background: #555; }
.doll-head { left: 61px; top: 0; }
.doll-neck { left: 20px; top: 35px; }
.doll-pack { right: 20px; top: 35px; }
.doll-left { left: 0; top: 70px; }
.doll-armor { left: 61px; top: 70px; }
.doll-right { right: 0; top: 70px; }
.doll-ring { left: 20px; top: 105px; }
.doll-legs { left: 61px; top: 105px; }
.doll-ammo { right: 20px; top: 105px; }
.doll-boots { left: 61px; top: 138px; }
.doll-grid .slot:not([data-from])::after {
  content: var(--slot-label, "");
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #bcbcbc;
  font: bold 6px/1 Verdana, sans-serif;
  letter-spacing: -.2px;
  text-align: center;
  text-shadow: 1px 1px #333;
  opacity: .72;
  pointer-events: none;
}
.doll-head { --slot-label: "HEAD"; }
.doll-neck { --slot-label: "NECK"; }
.doll-pack { --slot-label: "BAG"; }
.doll-left { --slot-label: "L HAND"; }
.doll-armor { --slot-label: "ARMOR"; }
.doll-right { --slot-label: "R HAND"; }
.doll-ring { --slot-label: "RING"; }
.doll-legs { --slot-label: "LEGS"; }
.doll-ammo { --slot-label: "AMMO"; }
.doll-boots { --slot-label: "BOOTS"; }
.soul-cap { display: flex; justify-content: space-between; padding: 2px 5px; font-size: 10px; }
.soul-cap b { font-weight: normal; }
#fight-controls { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; margin-top: 2px; }
#fight-controls button {
  width: auto; min-width: 0; margin: 0; padding: 2px 1px; color: #111;
  background: #aaa; border: 2px outset #ccc; border-radius: 0;
  font: bold 9px Verdana, sans-serif;
}
#fight-controls button.active { border-style: inset; background: #d0c080; }
#chase-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin-top: 2px; }
#chase-controls button {
  width: auto; min-width: 0; margin: 0; padding: 2px 1px; color: #111;
  background: #aaa; border: 2px outset #ccc; border-radius: 0;
  font: bold 9px Verdana, sans-serif;
}
#chase-controls button.active { border-style: inset; background: #d0c080; }
.control-option {
  display: flex; align-items: center; gap: 4px; margin-top: 2px; padding: 2px 3px;
  border: 1px inset #aaa; background: #888; color: #111;
  font: 9px Verdana, sans-serif; cursor: pointer; user-select: none;
}
.control-option input { width: 12px; height: 12px; margin: 0; accent-color: #7b641f; }
.classic-option-button {
  width: 100%; margin: 2px 0 0; padding: 2px 3px; color: #111; background: #aaa;
  border: 2px outset #ccc; border-radius: 0; font: bold 9px Verdana, sans-serif;
}
#report-bug-btn { display: block; text-align: center; text-decoration: none; }
.classic-option-button:active { border-style: inset; }
.sidebar-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.side-panel { max-height: 180px; overflow-y: auto; font-size: 10px; }
.classic-title { padding: 1px 3px; margin: -2px -2px 3px; background: #555; color: #fff; font-weight: bold; }
.skill-line, .battle-line { display: flex; justify-content: space-between; padding: 2px 3px; border-bottom: 1px solid #777; }
.battle-line.attacking { box-shadow: inset 2px 0 #d02020; background: #8c7777; }
.battle-line.following { box-shadow: inset 2px 0 #20b020; background: #778c77; }
.skill-vocation { text-align: center; font-weight: bold; padding: 2px; border-bottom: 1px solid #666; }
.skill-entry { padding-bottom: 1px; }
.skill-entry .skill-line { border-bottom: 0; padding-bottom: 0; }
.skill-meter { height: 4px; margin: 0 3px 1px; background: #555; border: 1px inset #999; }
.skill-meter span { display: block; height: 100%; background: #d4b83f; }
.battle-line { cursor: pointer; }
.battle-line:hover { background: #aaa; }
.vip-line {
  display: flex; align-items: center; min-height: 17px; padding: 2px 3px;
  border-bottom: 1px solid #777; cursor: default;
}
.vip-line:hover { background: #aaa; }
.vip-line.online { color: #206020; }
.vip-line.offline { color: #555; }
.vip-mark { flex: 0 0 15px; width: 15px; color: #202050; text-align: center; font-weight: bold; }
.vip-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#containers { max-height: none; overflow: visible; gap: 3px; }

#thing-tooltip {
  position: fixed; z-index: 200; max-width: 330px; pointer-events: none;
  padding: 4px 6px; background: rgba(20,20,20,.94); border: 1px solid #d8d8b0;
  color: #f2f2d6; font: 11px Verdana, sans-serif; line-height: 1.35;
  box-shadow: 1px 2px 5px rgba(0,0,0,.7); white-space: normal;
}
#classic-context-menu {
  position: fixed; z-index: 350; min-width: 138px; padding: 2px;
  color: #111; background: #aaa; border: 2px outset #ddd;
  box-shadow: 2px 3px 7px rgba(0,0,0,.65); font: 11px Verdana, sans-serif;
}
#classic-context-menu button {
  display: block; width: 100%; margin: 0; padding: 3px 18px 3px 6px;
  color: #111; background: transparent; border: 0; border-radius: 0;
  text-align: left; font: 11px Verdana, sans-serif;
}
#classic-context-menu button:hover { color: #fff; background: #404080; }
.classic-dialog {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 292px; z-index: 300; padding: 2px; color: #111; background: #888;
  border: 2px outset #ccc; box-shadow: 3px 4px 10px rgba(0,0,0,.65);
  font: 11px Verdana, sans-serif;
}
.classic-dialog-title {
  padding: 2px 4px; color: #fff; background: #404080; font-weight: bold;
}
.move-amount-body { padding: 10px 8px 7px; }
.move-amount-body label { color: #111; margin: 0 0 8px; }
.move-amount-controls { display: flex; align-items: center; gap: 8px; }
.move-amount-controls input[type=range] { flex: 1; }
.move-amount-controls input[type=number] {
  width: 54px; margin: 0; padding: 2px 3px; color: #111; background: #fff;
  border: 2px inset #aaa; border-radius: 0; text-align: right;
}
.classic-dialog-buttons { display: flex; justify-content: center; gap: 8px; margin-top: 10px; }
.classic-dialog-buttons button {
  width: 72px; margin: 0; padding: 3px; color: #111; background: #aaa;
  border: 2px outset #ccc; border-radius: 0; font: 11px Verdana, sans-serif;
}
.classic-dialog-buttons button:active { border-style: inset; }
.map-mark-dialog { width: 260px; }
.map-mark-dialog select, .map-mark-dialog input { width: 100%; box-sizing: border-box; }
.channel-dialog { width: 260px; }
.channel-dialog-body { padding: 8px; }
.channel-dialog-body > label { margin: 0 0 3px; color: #111; }
#channel-list {
  width: 100%; height: 78px; margin-bottom: 6px; padding: 2px; color: #111;
  background: #fff; border: 2px inset #aaa; font: 11px Verdana, sans-serif;
}
#channel-private-name {
  box-sizing: border-box; width: 100%; margin: 0; padding: 3px 4px;
  color: #111; background: #fff; border: 2px inset #aaa; border-radius: 0;
  font: 11px Verdana, sans-serif;
}
.ignore-dialog { width: 520px; max-width: calc(100vw - 24px); }
.ignore-dialog-body {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 8px;
}
.ignore-dialog-body section { min-width: 0; }
.ignore-dialog-body section > label:first-child {
  display: block; margin: 0 0 3px; color: #111; font-weight: bold;
}
#ignore-list, #white-list {
  box-sizing: border-box; width: 100%; height: 106px; padding: 2px;
  color: #111; background: #fff; border: 2px inset #aaa;
  font: 11px Verdana, sans-serif;
}
#ignore-list option.permanent, #white-list option.permanent { color: #a00000; }
.ignore-entry-controls {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 3px; margin-top: 4px;
}
.ignore-entry-controls input {
  min-width: 0; padding: 2px 3px; color: #111; background: #fff;
  border: 2px inset #aaa; border-radius: 0; font: 11px Verdana, sans-serif;
}
.ignore-entry-controls button {
  margin: 0; padding: 2px 5px; color: #111; background: #aaa;
  border: 2px outset #ccc; border-radius: 0; font: 10px Verdana, sans-serif;
}
.ignore-option {
  display: flex; align-items: center; gap: 4px; margin: 5px 0 0;
  color: #111; font: 10px Verdana, sans-serif; user-select: none;
}
.ignore-option input { width: 13px; height: 13px; margin: 0; accent-color: #7b641f; }
.ignore-global-options {
  grid-column: 1 / -1; display: flex; justify-content: center; gap: 18px;
  padding-top: 2px; border-top: 1px solid #666;
}
.ignore-dialog .classic-dialog-buttons { grid-column: 1 / -1; margin-top: 0; }
.vip-edit-dialog { width: 330px; }
.vip-add-dialog { width: 275px; }
.vip-dialog-body { padding: 8px; }
.vip-dialog-body > strong { display: block; margin-bottom: 7px; }
.vip-dialog-body > label:not(.ignore-option) { display: block; margin: 5px 0 2px; color: #111; }
.vip-dialog-body select, .vip-dialog-body textarea, .vip-dialog-body > input {
  box-sizing: border-box; width: 100%; padding: 3px 4px; color: #111;
  background: #fff; border: 2px inset #aaa; border-radius: 0;
  font: 11px Verdana, sans-serif;
}
.vip-dialog-body textarea { resize: none; }
.hotkeys-dialog { width: 330px; }
.hotkeys-dialog-body { padding: 8px; }
.hotkeys-dialog-body > label { margin: 0 0 3px; color: #111; }
#hotkeys-list {
  width: 100%; height: 142px; margin-bottom: 8px; padding: 2px; color: #111;
  background: #fff; border: 2px inset #aaa; font: 11px Verdana, sans-serif;
}
#hotkey-text {
  width: 100%; margin: 0 0 7px; padding: 3px 4px; color: #111; background: #fff;
  border: 2px inset #aaa; border-radius: 0; font: 11px Verdana, sans-serif;
}
.hotkey-auto-option {
  display: flex; align-items: center; gap: 5px; margin: 0; color: #111;
  font: 11px Verdana, sans-serif; user-select: none;
}
.hotkey-auto-option input { width: 13px; height: 13px; margin: 0; accent-color: #7b641f; }
.outfit-dialog-body { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px; }
#outfit-dialog-preview {
  width: 64px; height: 64px; background: #555; border: 2px inset #aaa;
  image-rendering: pixelated;
}
.outfit-dialog-fields { flex: 1; min-width: 185px; }
.outfit-dialog-fields label { color: #111; margin: 0 0 5px; }
.outfit-dialog-fields select {
  display: block; width: 100%; margin-top: 2px; padding: 2px; background: #fff;
  border: 2px inset #aaa; font: 11px Verdana, sans-serif;
}
.outfit-color-grid { display: block; }
.outfit-color-grid .outfit-part-tabs { margin-top: 7px; }
#outfit-dialog-palette { flex-basis: 100%; }
.outfit-dialog-buttons { flex-basis: 100%; margin-top: 2px; }
.text-dialog { width: 420px; max-width: calc(100vw - 24px); }
#text-window-content, #text-window-editor, #house-edit-content {
  box-sizing: border-box; width: calc(100% - 12px); min-height: 190px; max-height: 55vh;
  margin: 6px; padding: 5px; overflow: auto; color: #111; background: #fff;
  border: 2px inset #aaa; white-space: pre-wrap; font: 11px Verdana, sans-serif;
}
#text-window-editor, #house-edit-content { display: block; resize: vertical; }
#text-window-byline { min-height: 14px; margin: 0 7px; color: #333; font-size: 10px; }
.text-dialog-buttons { margin: 6px; }
.container-window { color: #111; }
.container-window .panel-title { color: #111; margin-bottom: 3px; }
.container-window .cw-title { flex: 1; padding-left: 3px; text-align: left; }
.container-window .close-btn, .container-window .cw-back {
  width: 22px; height: 20px; margin: 0; padding: 0;
  background: #aaa; color: #111; border: 2px outset #ccc; border-radius: 0;
  font: bold 11px Verdana, sans-serif;
}
.container-window .cw-back:active { border-style: inset; }
.cw-grid { grid-template-columns: repeat(4, 32px); gap: 2px; justify-content: center; }
.bp-item { width: 32px; height: 32px; border: 2px inset #aaa; border-radius: 0; background: #555; }
#chat-log {
  min-height: 118px; max-height: 118px; padding: 4px 6px;
  background: #222; color: #ddd; border: 2px inset #aaa; border-radius: 0;
}
#chat-input {
  height: 25px; margin: 2px 0 0; padding: 3px 5px; color: #111;
  background: #fff; border: 2px inset #aaa; border-radius: 0;
}

/* Touch controls are opt-in through the mobile/coarse-pointer media query. */
#mobile-controls, #mobile-items-dock, #mobile-orientation-gate { display: none; }

html:fullscreen, html:-webkit-full-screen { width: 100%; height: 100%; background: #111; }
html:fullscreen body, html:-webkit-full-screen body { width: 100%; min-height: 100%; }

@media (max-width: 900px), (pointer: coarse) {
  #game-screen, #game-screen button {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
  }
  #chat-log, #chat-input {
    user-select: text;
    -webkit-user-select: text;
    -webkit-touch-callout: default;
  }
  html, body { width: 100%; min-width: 0; }
  body:not(.entry-screen) {
    display: block;
    min-height: 100dvh;
    padding: env(safe-area-inset-top) env(safe-area-inset-right)
      env(safe-area-inset-bottom) env(safe-area-inset-left);
    overflow-x: hidden;
    overscroll-behavior: none;
    background: #111;
  }
  body.entry-screen { padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)); }
  body.entry-screen .panel, .panel { max-width: calc(100vw - 24px); padding: 20px 18px; }

  #game-screen { width: 100%; min-width: 0; align-items: stretch; }
  .game-main { width: 100%; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
  .canvas-col { width: 100%; min-width: 0; }
  #game-canvas {
    width: 100%;
    max-width: 100vw;
    height: auto;
    aspect-ratio: 496 / 368;
    border-width: 0 0 1px;
    touch-action: none;
  }
  #zoom-btn { display: none; }
  #death-overlay { height: var(--game-viewport-css-height, auto); }

  #mobile-items-dock {
    position: sticky;
    top: env(safe-area-inset-top);
    z-index: 20;
    display: block;
    width: 100%;
    padding: 3px;
    color: #111;
    background: #777;
    border: 2px outset #aaa;
  }
  .mobile-items-title {
    display: flex;
    align-items: center;
    gap: 5px;
    min-height: 23px;
    padding: 0 2px 2px;
    font: 9px Verdana, sans-serif;
  }
  .mobile-items-title strong { font-size: 10px; }
  .mobile-items-title span { flex: 1; color: #292929; }
  .mobile-items-landscape-tip { display: none; }
  #mobile-gear-toggle {
    width: auto;
    min-height: 22px;
    margin: 0;
    padding: 1px 8px;
    color: #111;
    background: #aaa;
    border: 2px outset #ccc;
    border-radius: 0;
    font: bold 9px Verdana, sans-serif;
  }
  #mobile-gear-toggle:active { border-style: inset; }
  #mobile-item-host {
    display: flex;
    align-items: flex-start;
    gap: 3px;
    max-height: 126px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }
  #mobile-item-host #equipment {
    flex: 0 0 178px;
    min-width: 178px;
    padding: 3px;
  }
  #mobile-item-host .doll-grid {
    position: static;
    display: grid;
    grid-template-columns: repeat(5, 32px);
    grid-template-rows: repeat(2, 32px);
    gap: 2px;
    width: auto;
    height: auto;
    margin: 0;
  }
  #mobile-item-host #doll-preview { display: none; }
  #mobile-item-host .doll-grid .slot {
    position: relative;
    inset: auto;
    width: 32px;
    height: 32px;
  }
  #mobile-item-host .soul-cap { padding: 2px 3px 0; font-size: 9px; }
  #mobile-item-host #equipment > :not(.doll-grid):not(.soul-cap) { display: none; }
  #mobile-item-host #containers {
    display: flex;
    flex: 0 0 auto;
    flex-direction: row;
    align-items: flex-start;
    gap: 3px;
    max-height: none;
    overflow: visible;
  }
  #mobile-item-host #containers:empty { display: none; }
  #mobile-item-host .container-window { flex: 0 0 148px; width: 148px; padding: 3px; }
  #mobile-item-host .container-window .panel-title { margin-bottom: 2px; }
  #mobile-item-host .container-window .cw-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  #mobile-item-host .cw-grid { grid-template-columns: repeat(4, 32px); gap: 2px; }
  #mobile-item-host .bp-item { width: 32px; height: 32px; }
  #mobile-item-host .cw-pager { margin-top: 2px; }
  #mobile-item-host .cw-pager button { min-height: 20px; padding: 0 8px; }
  #mobile-items-dock.mobile-gear-open #mobile-item-host {
    max-height: min(52dvh, 350px);
    overflow-y: auto;
  }
  #mobile-items-dock.mobile-gear-open #equipment { flex-basis: 214px; min-width: 214px; }
  #mobile-items-dock.mobile-gear-open #equipment > #fight-controls,
  #mobile-items-dock.mobile-gear-open #equipment > #chase-controls { display: grid; }
  #mobile-items-dock.mobile-gear-open #equipment > .control-option { display: flex; }
  #mobile-items-dock.mobile-gear-open #equipment > .classic-option-button { display: block; }
  #mobile-items-dock.mobile-gear-open #fight-controls button,
  #mobile-items-dock.mobile-gear-open #chase-controls button,
  #mobile-items-dock.mobile-gear-open .classic-option-button { min-height: 30px; }

  #mobile-controls {
    display: block;
    width: 100%;
    padding: 4px;
    color: #111;
    background: #777;
    border: 2px outset #aaa;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
  }
  .mobile-vitals {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
    font: 9px Verdana, sans-serif;
  }
  #mobile-level { min-width: 38px; padding-left: 2px; }
  .mobile-vital {
    position: relative;
    height: 14px;
    overflow: hidden;
    background: #333;
    border: 2px inset #aaa;
  }
  .mobile-vital i { display: block; width: 0; height: 100%; transition: width .12s linear; }
  .mobile-vital i.mobile-hp { background: #c02828; }
  .mobile-vital i.mobile-mana { background: #2850c8; }
  .mobile-vital b {
    position: absolute; inset: 0; color: #fff; text-align: center;
    font: normal 8px/10px Verdana, sans-serif; text-shadow: 1px 1px #000;
  }
  .mobile-control-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .mobile-dpad {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: repeat(3, 44px);
    grid-template-rows: repeat(3, 38px);
    gap: 2px;
  }
  .mobile-dpad button, .mobile-actions button {
    width: auto; min-width: 0; min-height: 38px; margin: 0; padding: 0;
    color: #111; background: #aaa; border: 2px outset #ccc; border-radius: 2px;
    font: bold 17px Verdana, sans-serif;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
  }
  .mobile-dpad button:active, .mobile-dpad button.pressed,
  .mobile-actions button:active, .mobile-actions button.active {
    border-style: inset; background: #d0c080;
  }
  #mobile-walk-stop { color: #7b2020; font-size: 12px; }
  .mobile-actions {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: repeat(3, minmax(52px, 1fr));
    gap: 3px;
  }
  .mobile-actions button { padding: 3px 4px; font-size: 11px; }
  #mobile-action-help { margin: 3px 1px 0; color: #222; font: 8px Verdana, sans-serif; text-align: center; }
  #mobile-items-dock button, #mobile-orientation-gate button {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: manipulation;
  }

  #chat-console { width: 100%; margin: 2px 0 0; }
  #chat-log { min-height: 76px; height: 76px; max-height: 76px; font-size: 10px; line-height: 1.35; }
  #chat-input { min-height: 34px; font-size: 16px; }
  #chat-tabs button { min-height: 28px; }
  .console-control { flex-basis: 34px; width: 34px; min-height: 28px; }

  .side {
    display: none;
    width: 100%;
    height: auto;
    max-height: none;
    overflow: visible;
    gap: 4px;
  }
  .side.mobile-open { display: flex; }
  .side .hud-box, .container-window { padding: 6px; }
  #minimap { height: 132px; }
  .minimap-controls button, .sidebar-tabs button,
  #fight-controls button, #chase-controls button, .classic-option-button {
    min-height: 36px; font-size: 11px;
  }
  .control-option { min-height: 34px; font-size: 11px; }
  .control-option input { width: 18px; height: 18px; }
  .side .cw-grid { grid-template-columns: repeat(auto-fit, 42px); gap: 4px; }
  .bp-item, .doll-grid .slot { touch-action: none; }
  .side .bp-item { width: 42px; height: 42px; }
  .side-panel { max-height: 42dvh; font-size: 11px; }
  .battle-line, .vip-line, .skill-line { min-height: 34px; align-items: center; }

  .float-panel, .classic-dialog {
    position: fixed;
    left: max(6px, env(safe-area-inset-left));
    right: max(6px, env(safe-area-inset-right));
    top: max(8px, env(safe-area-inset-top));
    width: auto;
    min-width: 0;
    max-width: none;
    max-height: calc(100dvh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    overflow: auto;
    transform: none;
  }
  .trade-cols { flex-direction: column; }
  .trade-col { min-width: 0; }
  .ignore-dialog-body { grid-template-columns: 1fr; }
  .ignore-global-options, .ignore-dialog .classic-dialog-buttons { grid-column: 1; }
  .hint { display: none; }
}

@media (orientation: portrait) and (max-width: 900px),
       (orientation: portrait) and (pointer: coarse) {
  body:not(.entry-screen) { overflow: hidden; }
  #mobile-orientation-gate {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right))
      max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
    color: #eee;
    background: #111;
    text-align: center;
  }
  #mobile-orientation-gate > div {
    width: min(330px, 100%);
    padding: 22px 18px;
    background: #777;
    border: 2px outset #aaa;
    color: #111;
  }
  .mobile-rotate-icon { display: block; font: bold 54px/1 Verdana, sans-serif; }
  #mobile-rotate-title { display: block; margin-top: 8px; font: bold 18px Verdana, sans-serif; }
  #mobile-orientation-gate p { margin: 8px 0 14px; font: 12px Verdana, sans-serif; }
  #mobile-gate-fullscreen {
    width: 100%;
    min-height: 44px;
    margin: 0;
    color: #111;
    background: #d0c080;
    border: 2px outset #eee0aa;
    border-radius: 0;
    font: bold 12px Verdana, sans-serif;
  }
  #mobile-fullscreen-note { display: block; margin-top: 10px; font: 9px/1.4 Verdana, sans-serif; }
}

@media (max-width: 390px) {
  .mobile-dpad { grid-template-columns: repeat(3, 40px); grid-template-rows: repeat(3, 36px); }
  .mobile-dpad button, .mobile-actions button { min-height: 36px; }
  .mobile-actions { grid-template-columns: repeat(2, minmax(50px, 1fr)); }
}

@media (orientation: landscape) and (max-height: 520px) and (max-width: 900px),
       (orientation: landscape) and (max-height: 520px) and (pointer: coarse) {
  .canvas-col {
    display: grid;
    grid-template-columns: auto minmax(300px, 1fr);
    grid-template-rows: auto auto auto;
    align-items: start;
    gap: 3px;
  }
  #game-canvas {
    grid-column: 1;
    grid-row: 1 / 4;
    width: auto;
    max-width: 56vw;
    height: min(calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom)), 368px);
    align-self: start;
  }
  #death-overlay {
    right: auto;
    width: var(--game-viewport-css-width, 56vw);
  }
  #mobile-items-dock {
    grid-column: 2;
    grid-row: 1;
    position: static;
    padding: 2px;
  }
  .mobile-items-title { min-height: 19px; padding-bottom: 1px; }
  .mobile-items-title strong { font-size: 9px; }
  .mobile-items-portrait-tip { display: none; }
  .mobile-items-landscape-tip { display: inline; }
  #mobile-item-host { max-height: 98px; gap: 2px; }
  #mobile-item-host #equipment {
    flex-basis: 68px;
    min-width: 68px;
    padding: 2px;
  }
  #mobile-item-host .doll-grid {
    grid-template-columns: repeat(3, 20px);
    grid-template-rows: repeat(4, 20px);
    gap: 1px;
  }
  #mobile-item-host .doll-grid .slot {
    width: 20px;
    height: 20px;
  }
  #mobile-item-host .doll-grid .slot:not([data-from])::after {
    font-size: 5px;
  }
  #mobile-item-host .doll-head { grid-column: 2; grid-row: 1; }
  #mobile-item-host .doll-neck { grid-column: 1; grid-row: 2; }
  #mobile-item-host .doll-armor { grid-column: 2; grid-row: 2; }
  #mobile-item-host .doll-pack { grid-column: 3; grid-row: 2; }
  #mobile-item-host .doll-left { grid-column: 1; grid-row: 3; }
  #mobile-item-host .doll-legs { grid-column: 2; grid-row: 3; }
  #mobile-item-host .doll-right { grid-column: 3; grid-row: 3; }
  #mobile-item-host .doll-ring { grid-column: 1; grid-row: 4; }
  #mobile-item-host .doll-boots { grid-column: 2; grid-row: 4; }
  #mobile-item-host .doll-ammo { grid-column: 3; grid-row: 4; }
  #mobile-item-host .doll-grid .slot canvas,
  #mobile-item-host .bp-item canvas {
    width: 18px;
    height: 18px;
  }
  #mobile-item-host .soul-cap { padding: 1px 2px 0; font-size: 8px; }
  #mobile-item-host .container-window {
    flex-basis: 213px;
    width: 213px;
    padding: 2px;
  }
  #mobile-item-host .container-window .panel-title { margin-bottom: 1px; font-size: 8px; }
  #mobile-item-host .container-window .close-btn,
  #mobile-item-host .container-window .cw-back { width: 18px; min-height: 18px; padding: 0; }
  #mobile-item-host .cw-grid { grid-template-columns: repeat(8, 25px); gap: 1px; }
  #mobile-item-host .bp-item { width: 25px; height: 25px; }
  #mobile-item-host .cw-pager { margin-top: 1px; font-size: 8px; }
  #mobile-item-host .cw-pager button { min-height: 18px; padding: 0 6px; }
  #mobile-controls { grid-column: 2; grid-row: 2; }
  #chat-console { grid-column: 2; grid-row: 3; }
  .mobile-vitals { margin-bottom: 2px; }
  .mobile-control-row { justify-content: center; }
  .mobile-dpad { grid-template-columns: repeat(3, 38px); grid-template-rows: repeat(3, 32px); }
  .mobile-dpad button, .mobile-actions button { min-height: 32px; }
  .mobile-actions { flex: 0 1 290px; }
  #mobile-action-help { display: none; }
  #chat-log { min-height: 58px; height: 58px; max-height: 58px; }
}
