/* PlopQuest - retro UI: tan parchment panels, dark wood frames, yellow chat text. */

:root {
  --ink: #2a1d12;
  --ink-soft: #5a4630;
  --tan: #d9bf8f;
  --tan-light: #ead6aa;
  --tan-dark: #b8986a;
  --wood: #3b2714;
  --wood-light: #5a3d22;
  --frame: #0e0905;
  --bg: #17110c;
  --chat-bg: #120d09;
  --yellow: #ffe45c;
  --good: #7ee070;
  --bad: #ff6a4a;
  --warn: #ffa040;
  --quest: #6ef0ff;
  --rare: #d89aff;
  --font: "Trebuchet MS", "Segoe UI", Verdana, Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 13px/1.35 var(--font); overflow: hidden; user-select: none; -webkit-user-select: none; }
[hidden] { display: none !important; }
canvas { image-rendering: crisp-edges; image-rendering: pixelated; }
h2, h3 { margin: 0; font-size: 15px; }
p { margin: 0 0 6px; }
.small { font-size: 12px; color: var(--ink-soft); }
.error { color: #a8281c; }
a { color: #c86a1e; }

button {
  font: bold 13px var(--font);
  color: var(--ink);
  background: linear-gradient(#f2dfb4, #c9a978);
  border: 2px solid var(--wood);
  border-radius: 2px;
  padding: 5px 12px;
  cursor: pointer;
  box-shadow: inset 1px 1px 0 #fff4d6, inset -1px -1px 0 #9a7a4c;
}
button:hover:not(:disabled) { filter: brightness(1.07); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: linear-gradient(#ffd479, #d8902a); }
button.danger { background: linear-gradient(#eba38f, #b8503a); color: #fff; text-shadow: 1px 1px 0 #5a1610; }
input { font: 13px var(--font); }

.panel {
  background: var(--tan);
  border: 2px solid var(--wood);
  border-radius: 3px;
  box-shadow: inset 0 0 0 2px var(--tan-light), inset 0 0 0 3px var(--tan-dark);
  padding: 9px;
}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.rotate { display: flex; justify-content: center; gap: 4px; margin: 2px 0 6px; }
.rotate button { padding: 1px 8px; font-size: 11px; }

.boot { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #f3e6c8; text-align: center; padding: 16px; }
.boot .small { color: #b8a27a; max-width: 460px; }

/* ------------------------------------------------ start screen */
#screen-start {
  position: fixed; inset: 0; overflow: auto; user-select: auto;
  background: radial-gradient(ellipse at 50% 30%, rgba(40, 26, 12, 0.55), rgba(10, 6, 3, 0.94) 75%), var(--grass, none);
  background-size: auto, 96px 96px;
  image-rendering: pixelated;
}
.start-wrap { max-width: 1000px; margin: 0 auto; padding: 22px 16px 16px; display: flex; flex-direction: column; align-items: center; }
#logo { max-width: 100%; height: auto; }
.tagline { color: #f0dcae; font-style: italic; margin: 6px 0 16px; text-shadow: 1px 1px 0 #000; }
#start-list, #start-create { width: 100%; }
.offline-ribbon { background: #8a1e14; color: #fff3df; border: 2px solid #3b0d08; padding: 5px 12px; margin: -6px 0 12px; font-weight: bold; text-align: center; }
/* online: boosted rates from the owner's dashboard */
.boost-ribbon {
  background: linear-gradient(#ffe08a, #e09a2a); color: #3b1a06; border: 2px solid var(--wood); padding: 6px 18px; margin: -6px 0 12px;
  font-weight: bold; font-size: 15px; text-align: center; box-shadow: inset 1px 1px 0 #fff4d6, inset -1px -1px 0 #9a6a2c, 0 0 14px rgba(255, 201, 74, 0.45);
}
/* the house rules, shown once before a first hero enters the world (no way around them but the two buttons) */
.rules-modal { position: fixed; inset: 0; z-index: 50; background: rgba(8, 5, 2, 0.82); display: flex; align-items: center; justify-content: center; padding: 16px; }
.rules-panel { max-width: 560px; width: 100%; }
.rules-panel h2 { font-size: 18px; margin-bottom: 8px; }
.rules-panel ul { margin: 0 0 6px; padding-left: 20px; }
.rules-panel li { margin: 0 0 7px; font-size: 14px; line-height: 1.4; }
.rules-news { background: #fff1c8; border: 2px solid #b8862a; padding: 6px 10px 2px; margin: 0 0 10px; }
.rules-news b { color: #7a4a08; }
/* online mode: sign-in page and account bar */
#start-login { width: 100%; max-width: 780px; }
.login-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.login-left label { display: flex; flex-direction: column; gap: 3px; margin: 6px 0; font-weight: bold; }
.login-left input, .account-delete input { padding: 6px 8px; border: 2px solid var(--wood); background: #fff8e6; color: var(--ink); font-size: 14px; }
.google-btn { width: 100%; padding: 8px 12px; font-weight: bold; background: linear-gradient(#fffdf6, #e8dcc0); }
.login-or { text-align: center; margin: 8px 0 2px; }
.login-right { border-left: 2px dashed var(--tan-dark); padding-left: 14px; }
.login-right p { margin: 0 0 8px; }
/* a button that reads like a link (Ask the Plop Master) */
.link-btn { background: none; border: 0; box-shadow: none; padding: 0; font: inherit; font-weight: bold; color: #a8501a; text-decoration: underline; cursor: pointer; }
/* asking the Plop Master for a new password */
.help-box h3 { margin-bottom: 6px; }
.help-box label { display: flex; flex-direction: column; gap: 3px; margin: 6px 0; font-weight: bold; max-width: 460px; }
.help-box input, .help-box textarea, .support textarea { padding: 6px 8px; border: 2px solid var(--wood); background: #fff8e6; color: var(--ink); font: 14px var(--font); resize: vertical; }
#help-status { font-size: 14px; }
.star-badge { display: inline-block; margin-left: 6px; padding: 0 6px; border: 1px solid #a8741a; background: #fff1c0; color: #8a5a10; font-weight: bold; border-radius: 2px; }
.account-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 8px; }
.account-actions { display: flex; gap: 5px; }
.account-actions button { padding: 3px 9px; font-size: 12px; }
.account-delete { border: 2px solid #8a1e14; background: #f3d6c4; padding: 8px 10px; margin-bottom: 8px; }
.account-delete label { display: flex; align-items: center; gap: 8px; font-weight: bold; }
@media (max-width: 640px) { .login-grid { grid-template-columns: 1fr; } .login-right { border-left: 0; padding-left: 0; } }
#hero-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; }
.hero-card {
  display: grid; grid-template-columns: 80px 1fr; grid-template-rows: auto auto; gap: 2px 10px; align-items: center;
  background: var(--tan-light); border: 2px solid #8a6a42; padding: 6px 8px;
}
.hero-card canvas { grid-row: 1 / 3; width: 88px; height: 88px; background: radial-gradient(#9cbf6a 0%, #5a8a3a 70%); border: 2px solid var(--wood); }
.hero-card .info { display: flex; flex-direction: column; }
.hero-card .info b { font-size: 16px; }
.hero-card .info small { color: var(--ink-soft); }
.hero-card .actions { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }
.hero-card .actions button { padding: 3px 9px; font-size: 12px; }
.hero-card .confirm { font-weight: bold; color: #8a1e14; margin-right: 4px; }
/* online: support the game (the donation links come from the owner's dashboard) and ideas for the Plop Master */
.support { width: 100%; max-width: 780px; margin-top: 12px; }
#start-list:not([hidden]) ~ .support { max-width: none; } /* as wide as the hero list */
.support-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; font-size: 13px; }
.support-ideas { border-left: 2px dashed var(--tan-dark); padding-left: 14px; }
.support textarea { width: 100%; margin-top: 4px; }
.support .row { margin-top: 6px; }
.donate-btn {
  display: inline-block; padding: 6px 18px; font-weight: bold; font-size: 14px; color: #3b1a06; text-decoration: none;
  background: linear-gradient(#ffe08a, #e09a2a); border: 2px solid var(--wood); border-radius: 2px; box-shadow: inset 1px 1px 0 #fff4d6, inset -1px -1px 0 #9a6a2c;
}
.donate-btn:hover { filter: brightness(1.07); }
.donate-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.star-text { color: #9a6410; }
@media (max-width: 640px) { .support-grid { grid-template-columns: 1fr; } .support-ideas { border-left: 0; padding-left: 0; } }
.start-foot { color: #b8a27a; font-size: 12px; margin-top: 14px; text-align: center; }
.start-foot a { color: #ffc94a; }

.create-grid { display: grid; grid-template-columns: 1fr 230px; gap: 14px; }
.name-row { display: flex; align-items: center; gap: 8px; font-weight: bold; margin-bottom: 8px; }
.name-row input { flex: 1; max-width: 260px; padding: 5px 8px; border: 2px solid var(--wood); background: #fff8e6; color: var(--ink); font-size: 15px; font-weight: bold; }
#class-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.class-card {
  display: grid; grid-template-columns: 80px 1fr; gap: 8px; text-align: left; align-items: start;
  background: linear-gradient(#efdcb2, #d6ba88); font-weight: normal; padding: 6px;
}
.class-card canvas { width: 88px; height: 88px; background: radial-gradient(#9cbf6a 0%, #5a8a3a 70%); border: 2px solid var(--wood); }
.class-card.on { outline: 3px solid #d8702a; outline-offset: -1px; background: linear-gradient(#fff1c8, #e9cd96); }
.class-text b { font-size: 15px; display: block; }
.class-text .role { font-size: 11px; color: #8a4a1a; text-transform: uppercase; letter-spacing: 0.5px; }
.class-text p { font-size: 12px; margin: 3px 0 4px; }
.class-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1px 8px; }
.cs { display: flex; align-items: center; gap: 3px; font-size: 10px; }
.cs i { font-style: normal; width: 22px; color: var(--ink-soft); }
.cs em { display: block; height: 6px; background: #c86a1e; border: 1px solid var(--wood); }
.cs small { font-size: 10px; }
.create-right { display: flex; flex-direction: column; align-items: center; background: rgba(255, 248, 230, 0.4); border: 2px solid #8a6a42; padding: 8px; }
#create-preview { width: 128px; height: 128px; background: radial-gradient(#9cbf6a 0%, #5a8a3a 70%); border: 2px solid var(--wood); }
.swatch-group { width: 100%; margin-bottom: 6px; }
.swatch-group span { font-weight: bold; font-size: 12px; }
.swatches { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
.swatch { width: 26px; height: 26px; padding: 0; border: 2px solid var(--wood); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3); }
.swatch.on { outline: 3px solid #fff; outline-offset: 1px; }

/* ------------------------------------------------ game screen layout */
/* The game screen is laid out for at least 1280x720 'design pixels' and scaled to fit the window
   (see fitScreen() in game.js), so everything stays visible from a 10" laptop to a 23" monitor. */
#screen-game { position: fixed; left: 0; top: 0; width: 100vw; height: 100vh; transform-origin: 0 0; display: grid; grid-template-rows: 42px minmax(0, 1fr); overflow: hidden; }
#hud {
  display: flex; align-items: center; gap: 12px; padding: 0 10px; color: #f3e6c8;
  background: linear-gradient(#4a3320, #24180f); border-bottom: 2px solid var(--frame);
}
.hud-hero { display: flex; flex-direction: column; min-width: 130px; line-height: 1.15; }
.hud-hero b { font-size: 15px; color: #fff3cf; }
.hud-hero span { font-size: 11px; color: #d8c49a; }
.hud-bars { display: flex; gap: 8px; flex: 1; min-width: 0; }
.bar { position: relative; flex: 1; max-width: 200px; height: 18px; background: #1a0f08; border: 2px solid var(--frame); box-shadow: 0 0 0 1px #6a4a2a; }
.bar .fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; transition: width 0.15s; }
.bar.hp .fill { background: linear-gradient(#ff7a62, #b02a1e 60%, #8a1e14); }
.bar.focus .fill { background: linear-gradient(#8ab8ff, #2f62c8 60%, #1e3e8a); }
.bar.xp .fill { background: linear-gradient(#ffe48a, #d8a02a 60%, #9a6a14); }
.bar .txt { position: absolute; inset: 0; text-align: center; font: bold 11px/14px var(--font); color: #fff; text-shadow: 1px 1px 0 #000, -1px -1px 0 #000; white-space: nowrap; }
.bar.hp.low { animation: lowhp 0.7s infinite alternate; }
@keyframes lowhp { from { box-shadow: 0 0 0 1px #6a4a2a; } to { box-shadow: 0 0 0 2px #ff3a2a; } }
.hud-marks { display: flex; align-items: center; gap: 5px; font-weight: bold; color: #ffd75e; text-shadow: 1px 1px 0 #000; min-width: 70px; }
.hud-boosts { color: #eaffd8; font-weight: bold; text-shadow: 1px 1px 0 #000; background: #14321c; border: 1px solid #4a8a3a; border-radius: 3px; padding: 1px 6px; white-space: nowrap; }
.hud-oath { color: #ff7a6a; font-weight: bold; text-shadow: 1px 1px 0 #000; background: #2a0c08; border: 1px solid #8a2418; border-radius: 3px; padding: 1px 6px; white-space: nowrap; animation: oath-pulse 1.4s ease-in-out infinite; }
@keyframes oath-pulse { 50% { border-color: #ff5a3a; box-shadow: 0 0 6px rgba(255, 70, 40, 0.5); } }
.coin { width: 14px; height: 14px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff4c0, #e8c15a 45%, #9a6a14); border: 1px solid #3a2408; }
.hud-btn { padding: 3px 9px; font-size: 12px; }
.hud-btn.off { background: linear-gradient(#b8a888, #8a7a5a); }

#play {
  display: grid; min-height: 0;
  grid-template-columns: minmax(0, 1fr) 300px; grid-template-rows: minmax(0, 1fr) 146px;
  grid-template-areas: 'view side' 'bottom side';
}
#viewport { grid-area: view; position: relative; overflow: hidden; background: #000; }
#world { position: absolute; left: 0; top: 0; display: block; }
#hover-tip {
  position: absolute; z-index: 5; pointer-events: none; white-space: nowrap;
  background: rgba(14, 9, 5, 0.86); color: #fff; border: 1px solid #000; padding: 2px 7px; font-size: 12px;
}
#hover-tip i { color: #b8a27a; font-style: normal; font-size: 11px; }

#sidebar { grid-area: side; display: flex; flex-direction: column; gap: 6px; padding: 6px; background: #2b1d12; border-left: 2px solid var(--frame); overflow: hidden; min-height: 0; }
/* the handle on the view's right edge folds the side panel away (P) for a bigger view, handy on phones */
.panel-fold {
  position: absolute; right: 0; top: 50%; z-index: 4; width: 34px; height: 84px; margin-top: -42px; padding: 0;
  border-right: 0; border-radius: 8px 0 0 8px; font-size: 26px; line-height: 1; opacity: 0.88;
}
.panel-fold:hover:not(:disabled) { opacity: 1; }
#screen-game.folded #play { grid-template-columns: minmax(0, 1fr) 0; }
#screen-game.folded #sidebar { display: none; }
.map-panel { padding: 6px; }
.map-head { display: flex; justify-content: space-between; align-items: baseline; font-weight: bold; margin-bottom: 4px; }
#minimap { display: block; width: 100%; aspect-ratio: 4 / 3; height: auto; border: 2px solid var(--wood); background: #000; cursor: crosshair; }
#tabs { display: flex; gap: 3px; }
#tabs button { flex: 1; padding: 4px 0; font-size: 12px; background: linear-gradient(#b8986a, #8a6a42); color: #2a1d12; }
#tabs button.active { background: linear-gradient(#f2dfb4, #d9bf8f); border-bottom-color: #d9bf8f; }
.tab-panel { flex: 1; overflow-y: auto; min-height: 0; }

/* ------------------------------------------------ item slots */
#pack-equip { display: flex; align-items: center; justify-content: center; gap: 1px; margin: -2px 0 7px; }
.slot.equip.mini { width: 21px; height: 21px; }
.slot.equip.mini .icon { left: 1px; top: 1px; width: 18px; height: 18px; }
#pack-grid { display: grid; grid-template-columns: repeat(7, 36px); gap: 3px; justify-content: center; }
.slot {
  position: relative; width: 36px; height: 36px; background: #a88a5c; border: 1px solid #4a321c;
  box-shadow: inset 1px 1px 0 #6f5332, inset -1px -1px 0 #c8a878; cursor: pointer; touch-action: none;
}
.slot.empty { cursor: default; background: #b2946a; }
.slot .icon { position: absolute; left: 1px; top: 1px; width: 32px; height: 32px; image-rendering: pixelated; pointer-events: none; }
.slot .qty { position: absolute; left: 2px; top: 0; font: bold 11px/13px var(--font); color: var(--yellow); text-shadow: 1px 1px 0 #000, -1px 0 0 #000, 0 -1px 0 #000; pointer-events: none; }
.slot.unusable .icon { filter: grayscale(0.6) brightness(0.75); }
.slot.unusable::after { content: ''; position: absolute; right: 2px; bottom: 2px; width: 6px; height: 6px; background: #c8352a; border: 1px solid #3a0a06; }
.slot.tier2 { box-shadow: inset 0 0 0 1px #e8ecef, inset 1px 1px 0 #6f5332; }
.slot.tier3 { box-shadow: inset 0 0 0 2px #ff9a4a; }
.slot.tier4 { box-shadow: inset 0 0 0 2px #c09aff; }
.slot.tier5 { box-shadow: inset 0 0 0 2px #6ee0ff, 0 0 4px #6ee0ff; }
.slot.tier6 { box-shadow: inset 0 0 0 2px #ff6a4a, 0 0 4px #ff6a4a; }
.slot.tier7 { box-shadow: inset 0 0 0 2px #ffe27a, 0 0 6px #ffe27a; }
.slot.tier8 { box-shadow: inset 0 0 0 2px #4a8cff, 0 0 6px #4a8cff; }
.slot.tier9 { box-shadow: inset 0 0 0 2px #a596cc, 0 0 6px #6a5a8a; }
.slot.tier10 { box-shadow: inset 0 0 0 2px #3ee08a, 0 0 6px #3ee08a; }
.slot.tier11 { box-shadow: inset 0 0 0 2px #ff3a5a, 0 0 7px #ff3a5a; }
.slot.tier12 { box-shadow: inset 0 0 0 2px #8fd8ff, 0 0 7px #8fd8ff; }
.slot.tier13 { box-shadow: inset 0 0 0 2px #fff2c0, 0 0 8px #fff2c0, 0 0 2px #9fe8ff; }
body.dragging, body.dragging * { cursor: grabbing !important; }
#drag-ghost { position: fixed; z-index: 60; width: 32px; height: 32px; pointer-events: none; image-rendering: pixelated; opacity: 0.85; }

/* gear */
.gear-top { display: flex; gap: 6px; align-items: flex-start; justify-content: center; }
.gear-col { display: flex; flex-direction: column; gap: 6px; }
.doll-wrap { background: radial-gradient(#9cbf6a 0%, #5a8a3a 75%); border: 2px solid var(--wood); padding: 2px; }
#gear-doll { width: 128px; height: 128px; display: block; }
.doll-wrap .rotate { margin: 0 0 2px; align-items: center; }
.doll-wrap .ring-row { display: flex; justify-content: center; gap: 10px; padding: 3px 0 2px; }
.tip-jewel-kind { color: #9ae8ff; font-size: 12px; margin: 1px 0 3px; }
#gear-build { color: #f3e6c8; text-shadow: 1px 1px 0 #000; font-size: 10px; min-width: 70px; text-align: center; }
.slot.equip { width: 38px; height: 38px; }
.slot.equip .icon { left: 2px; top: 2px; }
.slot.equip .lbl { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 9px; font-weight: bold; color: #7a6040; pointer-events: none; }
.slot.equip:not(.empty) .lbl { display: none; }
#gear-stats { margin-top: 8px; border-top: 1px solid var(--tan-dark); padding-top: 6px; }
.stat-row { display: flex; justify-content: space-between; padding: 1px 2px; }
.stat-row .k { color: var(--ink-soft); }
.stat-row .v { font-weight: bold; }

/* skills */
.hero-level .big { font-weight: bold; font-size: 15px; margin-bottom: 3px; }
.minibar { position: relative; height: 13px; background: #6f5332; border: 1px solid var(--wood); margin: 2px 0; flex: 1; }
.minibar .fill { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(#ffe48a, #d8a02a); }
.minibar.skill .fill { background: linear-gradient(#9ae8ff, #3a8ac8); }
.minibar.quest .fill { background: linear-gradient(#a8f08a, #4a9a3a); }
.minibar .txt { position: absolute; inset: 0; text-align: center; font: bold 10px/11px var(--font); color: #fff; text-shadow: 1px 1px 0 #000; }
.points { margin: 8px 0 3px; font-weight: bold; }
.points.glow { color: #8a2a00; animation: glow 0.8s infinite alternate; }
@keyframes glow { to { color: #e86a00; } }
.stat-line { display: grid; grid-template-columns: 64px 54px 24px 1fr; align-items: center; gap: 4px; padding: 1px 0; }
.stat-line .name { font-weight: bold; }
.stat-line .val { font-weight: bold; color: #5a2a00; }
.stat-line .plus { padding: 0; width: 22px; height: 20px; font-size: 14px; line-height: 14px; }
.stat-line .desc { font-size: 11px; color: var(--ink-soft); line-height: 1.1; }
.group { margin: 9px 0 2px; font-weight: bold; color: #6a3a10; border-bottom: 1px solid var(--tan-dark); }
.skill-line { display: grid; grid-template-columns: 26px 78px 22px 1fr; align-items: center; gap: 4px; }
.icon.small { width: 24px; height: 24px; image-rendering: pixelated; }
.skill-line .lvl { font-weight: bold; text-align: right; }
.total { margin-top: 8px; font-weight: bold; text-align: right; }

/* quests */
.quest-card { border: 1px solid var(--tan-dark); background: rgba(255, 248, 230, 0.35); padding: 6px; margin-bottom: 6px; }
.quest-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.quest-name { font-weight: bold; font-size: 14px; }
.chip { font-size: 10px; font-weight: bold; padding: 1px 6px; border: 1px solid var(--wood); background: #c8a878; }
.quest-card.active .chip { background: #ffd479; }
.quest-card.ready .chip { background: #a8f08a; }
.quest-card.done { opacity: 0.7; }
.quest-card.done .chip { background: #8ac878; }

/* options */
.opt-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 0; font-weight: bold; }
.opt-row input[type='range'] { width: 120px; }
.opt-buttons { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.help { font-size: 12px; }
.help ul { margin: 4px 0 0; padding-left: 16px; }
.help li { margin-bottom: 2px; }

/* ------------------------------------------------ chat & abilities */
#bottom { grid-area: bottom; display: grid; grid-template-columns: minmax(0, 1fr) 292px; background: #1a120b; border-top: 2px solid var(--frame); min-height: 0; }
#chat { display: flex; flex-direction: column; min-height: 0; background: var(--chat-bg); }
#chat-log { flex: 1; overflow-y: auto; padding: 6px 10px; color: var(--yellow); text-shadow: 1px 1px 0 #000; font-size: 13px; user-select: text; -webkit-user-select: text; }
.msg { margin: 0 0 1px; }
.msg.muted { color: #d2bf96; }
.msg.warn { color: var(--warn); }
.msg.bad { color: var(--bad); }
.msg.good { color: var(--good); }
.msg.loot { color: #ffd98a; }
.msg.rare { color: var(--rare); font-weight: bold; }
.msg.luxury { color: #ff4a4a; font-weight: bold; text-shadow: 0 0 4px rgba(255, 60, 60, 0.6); }
.msg.quest { color: var(--quest); }
.msg.examine { color: #f3efe2; font-style: italic; }
.msg.speech { color: var(--yellow); }
.msg.master { color: #ffb347; font-weight: bold; text-shadow: 1px 1px 0 #000, 0 0 6px rgba(255, 160, 40, 0.45); }
#chat-input { border: 0; border-top: 1px solid var(--wood); background: #0c0805; color: var(--yellow); padding: 6px 10px; outline: none; }
#chat-input::placeholder { color: #6a5a3a; }
#abilities { display: grid; grid-template-columns: 1fr 1fr 1fr 0.75fr; gap: 5px; padding: 7px; border-left: 2px solid var(--frame); background: #2b1d12; }
.ability .aicon { width: 28px; height: 28px; image-rendering: pixelated; flex: none; }
.ability-pair { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ability-pair .ability { flex: 1; padding: 1px 2px; min-height: 0; }
.ability-pair .aicon { width: 20px; height: 20px; }
.ability-pair .key { top: 1px; }
.ability.ult { box-shadow: inset 1px 1px 0 #c9962e, 0 0 0 1px #c9962e; }
.ability.ult:not(.locked) .aicon { filter: drop-shadow(0 0 3px #ffd06a); }
.ability {
  position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: linear-gradient(#6a4a2a, #3b2714); color: #f3e6c8; border: 2px solid var(--frame); padding: 4px; box-shadow: inset 1px 1px 0 #8a6a42;
}
.ability .key { position: absolute; left: 4px; top: 2px; font-size: 11px; color: var(--yellow); }
.ability .aname { font-size: 11px; text-align: center; line-height: 1.05; overflow-wrap: anywhere; max-width: 100%; }
.ability .cost { font-size: 11px; color: #9ac8ff; font-weight: normal; }
.ability .cd { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: rgba(0, 0, 0, 0.62); pointer-events: none; }
.ability.locked { opacity: 0.45; }
.ability.locked .cost { color: #ffa040; }
.ability.nofocus .cost { color: #ff6a4a; }
.ability.eat .cost { color: #a8f08a; }

/* ------------------------------------------------ windows, menus, tooltips */
.window { background: var(--tan); border: 3px solid var(--wood); box-shadow: 0 6px 0 rgba(0, 0, 0, 0.4), inset 0 0 0 2px var(--tan-light); padding: 10px; z-index: 10; }
.window-title { font-weight: bold; font-size: 15px; color: #5a2a00; margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center; }
.window-title .close { padding: 0 7px; font-size: 16px; line-height: 18px; }
#dialog { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); width: min(600px, calc(100% - 24px)); display: flex; gap: 12px; }
#dialog-portrait { width: 96px; height: 78px; flex: none; background: radial-gradient(#e8c68a, #a8804a); border: 2px solid var(--wood); }
.dialog-body { flex: 1; min-width: 0; }
#dialog-text p { font-size: 14px; margin-bottom: 6px; }
#dialog-options { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.dialog-opt { text-align: left; font-weight: bold; padding: 4px 10px; background: linear-gradient(#f6e6c0, #dcc090); }
#shop { position: absolute; right: 12px; top: 12px; width: 292px; }
#shop-grid { display: grid; grid-template-columns: repeat(6, 38px); gap: 6px 4px; margin: 4px 0 8px; max-height: 240px; overflow-y: auto; padding-right: 2px; }
.shop-slot { width: 38px; height: 38px; }
.shop-slot .icon { left: 2px; top: 1px; }
.shop-slot .price { position: absolute; right: 1px; bottom: -1px; font: bold 10px/12px var(--font); color: var(--yellow); text-shadow: 1px 1px 0 #000, -1px 0 0 #000; pointer-events: none; }
.shop-slot.poor .price { color: #ff8a6a; }

#ctx-menu { position: fixed; z-index: 50; min-width: 170px; background: #1d140c; border: 2px solid #000; box-shadow: 0 0 0 1px #8a6a42, 0 6px 0 rgba(0, 0, 0, 0.4); padding-bottom: 2px; }
.menu-title { background: var(--tan); color: var(--ink); padding: 3px 9px; font-weight: bold; border-bottom: 1px solid #000; }
.menu-item { display: block; width: 100%; text-align: left; background: none; border: 0; box-shadow: none; border-radius: 0; padding: 3px 10px; font: 13px var(--font); color: #f3e6c8; }
.menu-item:hover { background: var(--wood-light); filter: none; }
.menu-item .target { font-weight: bold; }

#item-tip { position: fixed; z-index: 55; max-width: 250px; pointer-events: none; background: rgba(20, 13, 8, 0.95); border: 1px solid #000; box-shadow: 0 0 0 1px #8a6a42; color: #f3e6c8; padding: 6px 8px; font-size: 12px; }
.tip-name { font-weight: bold; font-size: 14px; }
.tip-sub { color: #b8a27a; margin-bottom: 3px; }
.tip-stat { color: #fff; }
.tip-req { color: #a8f08a; }
.tip-req.bad { color: var(--bad); }
.tip-examine { font-style: italic; color: #d8c8a8; margin-top: 4px; }
.tip-price { color: #ffd75e; margin-top: 3px; }

/* ------------------------------------------------ smaller windows (start screen only; the game screen scales) */
@media (max-width: 980px) {
  .create-grid { grid-template-columns: 1fr; }
  #class-cards { grid-template-columns: 1fr; }
}

/* fighting style choice on the create screen */
.style-row { margin-top: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#style-pick { display: flex; gap: 6px; flex-wrap: wrap; }
.style-btn { font-weight: bold; }
.style-btn.on { outline: 3px solid #d8702a; outline-offset: -1px; background: linear-gradient(#fff1c8, #e9cd96); }
.style-btn small { display: block; font-weight: normal; font-size: 11px; color: var(--ink-soft); }

/* abilities list in the Skills tab */
.ab-line { display: grid; grid-template-columns: 30px 1fr; gap: 6px; align-items: center; padding: 3px 0; border-bottom: 1px dotted var(--tan-dark); }
.ab-line .aicon { width: 28px; height: 28px; image-rendering: pixelated; }
.ab-line b { font-size: 13px; }
.ab-line .meta { font-size: 11px; color: var(--ink-soft); }
.ab-line.locked { opacity: 0.55; }
.tip-tier { font-size: 11px; margin-bottom: 2px; }
.tip-cmp.up { color: #7ee070; }
.tip-cmp.down { color: #ff7a5a; }

/* ------------------------------------------------ upgraded items (+1 to +5) and special options */
.slot.g1 { background-image: radial-gradient(circle at 50% 110%, rgba(114, 224, 122, 0.75), rgba(114, 224, 122, 0) 70%); }
.slot.g2 { background-image: radial-gradient(circle at 50% 110%, rgba(90, 170, 255, 0.8), rgba(90, 170, 255, 0) 72%); }
.slot.g3 { background-image: radial-gradient(circle at 50% 110%, rgba(194, 122, 255, 0.85), rgba(194, 122, 255, 0) 75%); }
.slot.g4 { background-image: radial-gradient(circle at 50% 110%, rgba(255, 154, 42, 0.95), rgba(255, 154, 42, 0) 80%); }
.tip-grade { font-weight: bold; font-size: 11px; letter-spacing: 0.5px; }
.tip-bonus { color: #8ef08a; }
.tip-set { margin-top: 4px; font-weight: bold; }
.tip-setline { color: #8a8070; font-size: 11px; }
.tip-setline.on { color: #8ef08a; }
.stat-row.set-row .v { font-size: 10px; text-align: right; }
.slot .plus { position: absolute; right: 1px; bottom: 0; font: bold 10px/12px var(--font); color: #fff; text-shadow: 1px 1px 0 #000, -1px 0 0 #000, 0 -1px 0 #000; pointer-events: none; }
.slot .gem { position: absolute; right: 2px; top: 2px; width: 6px; height: 6px; border: 1px solid #000; pointer-events: none; display: none; }
.slot.opt-blue .gem { display: block; background: #6ab8ff; box-shadow: 0 0 3px #6ab8ff; }
.slot.opt-gold .gem { display: block; background: #ffd84a; box-shadow: 0 0 4px #ffd84a; }
.slot.amb::after { content: ''; position: absolute; left: 3px; top: 3px; width: 5px; height: 5px; background: #ffa630; border: 1px solid #3a1c00; transform: rotate(45deg); box-shadow: 0 0 4px #ffb340; pointer-events: none; }
.tip-plus { color: #fff; font-weight: bold; }
.tip-amber { color: #ffb340; font-weight: bold; }
.tip-lux { color: #ff4040; font-weight: bold; }
.tip-art { color: #c99a2a; font-weight: bold; }
.tip-opt { font-weight: bold; }
.tip-opt.excellent { color: #6ab8ff; }
.tip-opt.lucky { color: #ff5a4a; }
.tip-opt.total { color: #ffd84a; }
.tip-jewel { color: #ffd84a; }
body.using, body.using * { cursor: crosshair !important; }
.slot.use-src { outline: 2px solid #ffd84a; outline-offset: -2px; }

/* ------------------------------------------------ storage chest, forge and lantern gate windows */
#vault { position: absolute; right: 12px; top: 12px; width: 410px; }
#vault-grid { display: grid; grid-template-columns: repeat(10, 36px); gap: 3px; margin: 4px 0 8px; justify-content: center; }
#forge { position: absolute; right: 12px; top: 12px; width: 432px; }
#forge-tabs { display: flex; flex-wrap: wrap; gap: 3px; margin-bottom: 6px; }
#forge-tabs button { padding: 2px 7px; font-size: 11px; }
#forge-tabs button.on { background: linear-gradient(#fff1c8, #e9cd96); outline: 2px solid #d8702a; outline-offset: -1px; }
#forge-tabs label { font-size: 11px; display: flex; align-items: center; gap: 3px; margin-left: auto; font-weight: bold; }
#forge-list { display: grid; grid-template-columns: repeat(10, 38px); gap: 3px; max-height: 128px; overflow-y: auto; margin-bottom: 6px; }
.forge-slot.sel { outline: 2px solid #fff; outline-offset: -1px; }
.forge-slot.locked .icon { filter: grayscale(0.7) brightness(0.7); }
#forge-detail { border-top: 1px solid var(--tan-dark); padding-top: 6px; min-height: 96px; }
.recipe-name { font-weight: bold; font-size: 14px; }
.needs { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 4px 0; }
.need { display: flex; align-items: center; gap: 4px; font-weight: bold; }
.need .icon { width: 24px; height: 24px; image-rendering: pixelated; }
.need.missing { color: #a8281c; }
.forge-buttons { display: flex; gap: 6px; margin-top: 4px; }
#travel { position: absolute; left: 50%; top: 24px; transform: translateX(-50%); width: 360px; }
#worldmap { position: absolute; left: 50%; top: 8px; transform: translateX(-50%); width: calc(100% - 16px); max-width: 900px; max-height: calc(100% - 16px); display: flex; flex-direction: column; }
#worldmap-layers { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; margin: 0 0 4px; }
#worldmap-layers label { display: flex; align-items: center; gap: 3px; cursor: pointer; }
#worldmap-canvas { display: block; margin: 0 auto; image-rendering: pixelated; background: #1a2a3a; border: 2px solid #3a2a1a; min-height: 0; max-width: 100%; }
#worldmap-info { min-height: 16px; margin-top: 3px; }
#guide { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); width: min(640px, calc(100% - 24px)); max-height: calc(100% - 24px); display: flex; flex-direction: column; }
#guide-body { overflow-y: auto; min-height: 0; padding-right: 4px; }
.forge-odds { color: #2e6a14; font-weight: bold; margin: 2px 0 4px; }
.forge-odds.hard { color: #a8281c; }
/* the Shiny Swirl (Starplops) */
#starshop { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); width: min(580px, calc(100% - 24px)); max-height: calc(100% - 24px); display: flex; flex-direction: column; }
#star-body { overflow-y: auto; min-height: 0; padding-right: 4px; font-size: 13px; }
#star-body p { margin: 2px 0 6px; }
.star-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin: 2px 0 6px; }
.star-balance { display: inline-flex; align-items: center; gap: 5px; font-size: 15px; color: #7a4a08; }
.star-balance .icon { width: 16px; height: 16px; }
.star-tabs, .star-pick { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; margin: 0 0 6px; }
.star-tabs button.on, .star-pick button.on { outline: 3px solid #d8702a; outline-offset: -1px; background: linear-gradient(#fff1c8, #e9cd96); }
.star-pick label { display: inline-flex; gap: 4px; align-items: center; margin-left: 6px; }
.star-list { display: flex; flex-direction: column; }
.star-row { display: grid; grid-template-columns: 34px 1fr auto 92px; gap: 8px; align-items: center; padding: 2px 2px; border-bottom: 1px dotted var(--tan-dark); }
.star-row .icon { width: 32px; height: 32px; }
.star-row .star-name { font-weight: bold; text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.55); }
.star-price { font-weight: bold; color: #7a4a08; white-space: nowrap; }
.star-row button { padding: 3px 6px; font-size: 12px; }
.star-rates { border-collapse: collapse; margin: 4px 0 6px; }
.star-rates th, .star-rates td { padding: 2px 12px 2px 0; text-align: left; }
.star-order { margin-top: 8px; padding: 6px 8px; background: #fff8e6; border: 2px solid var(--wood); }
#guide-body h4 { margin: 8px 0 4px; font-size: 13px; }
#guide-body p { margin: 2px 0 6px; font-size: 12px; }
/* the welcome guide, shown in the same window when a hero enters the world */
.welcome-places { margin: 2px 0 6px; padding-left: 18px; font-size: 12px; }
.welcome-places li { margin: 3px 0; }
.welcome-places li.later { color: var(--ink-soft); }
.welcome-ways { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin: 4px 0 6px; }
.welcome-way { display: flex; gap: 6px; align-items: flex-start; font-size: 12px; }
.welcome-way .gicon { display: inline-block; width: 24px; height: 24px; image-rendering: pixelated; flex: none; }
.welcome-way b { display: block; }
#guide-body p.welcome-keys { font-size: 11px; color: var(--ink-soft); }
.welcome-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; font-size: 12px; }
@media (max-width: 560px) { .welcome-ways { grid-template-columns: 1fr; } }
.guide-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-bottom: 6px; }
.guide-table th { text-align: left; font-size: 11px; color: #6a4a2a; border-bottom: 1px solid #b2946a; padding: 2px 4px; }
.guide-table td { padding: 2px 4px; border-bottom: 1px solid rgba(120, 90, 50, 0.25); vertical-align: middle; }
.guide-table tr.locked td { opacity: 0.55; }
.guide-table .gitem { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.guide-table .gicon { display: inline-block; width: 24px; height: 24px; image-rendering: pixelated; flex: none; }
.guide-table .num { white-space: nowrap; font-weight: bold; }
.guide-table .gcombine { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; }
.guide-table .gplus { font-weight: bold; color: #6a4a2a; }
.guide-table .gqty { font-weight: bold; }
.guide-table .heal { color: #2f7a2a; font-weight: bold; white-space: nowrap; }
.guide-table .focus { color: #2a5aa8; font-weight: bold; white-space: nowrap; }
#travel-list { display: flex; flex-direction: column; gap: 4px; max-height: 380px; overflow-y: auto; }
.travel-opt { display: flex; justify-content: space-between; gap: 8px; text-align: left; }
.travel-opt small { font-weight: normal; color: var(--ink-soft); }
.travel-opt.here { opacity: 0.55; }
.travel-opt.dark { opacity: 0.4; cursor: default; }
#zoom-tip { position: absolute; right: 10px; top: 10px; z-index: 6; pointer-events: none; background: rgba(14, 9, 5, 0.8); color: #fff; border: 1px solid #000; padding: 2px 8px; font-size: 12px; }
