/* Lords Online recreation — Slice 1 client styles.
   Original artwork: all icons are canvas-drawn at runtime. No IGG assets. */

:root {
  --gold: #c9a227;
  --gold-hi: #f0d060;
  --gold-dk: #7a5f14;
  --bg: #14100b;
  --bg2: #1e1811;
  --panel: #241c12;
  --red: #8c1f1f;
  --red-hi: #b33232;
  --ink: #e8dcc0;
  --ink-dim: #a8977a;
  --parchment: #e9d9ae;
  --parchment-dk: #cdb884;
  --blue: #4a7fc4;
  --green: #6a9a4a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--ink);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 20% 10%, rgba(201,162,39,0.06), transparent 60%),
    radial-gradient(ellipse at 80% 90%, rgba(140,31,31,0.08), transparent 60%),
    repeating-linear-gradient(45deg, rgba(255,255,255,0.012) 0 2px, transparent 2px 6px);
}

#app { min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- generic ---------- */
.hidden { display: none !important; }
button {
  font-family: inherit; cursor: pointer;
  background: linear-gradient(#5a3f1c, #3a2a12);
  color: var(--gold-hi); border: 1px solid var(--gold-dk);
  border-radius: 4px; padding: 6px 14px; font-size: 14px;
  text-shadow: 1px 1px 2px #000;
}
button:hover:not(:disabled) { background: linear-gradient(#6d4f24, #4a3517); color: #ffe9a8; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.danger { background: linear-gradient(#6d2323, #471515); border-color: #8c3a3a; color: #f0b0b0; }
input, select, textarea {
  font-family: inherit; background: #0f0c08; color: var(--ink);
  border: 1px solid var(--gold-dk); border-radius: 3px; padding: 6px 8px; font-size: 14px;
}
input:focus, select:focus { outline: 1px solid var(--gold); }
.err { color: #ff8a8a; font-size: 13px; margin-top: 6px; min-height: 18px; }

.gold-rule { border: none; border-top: 1px solid var(--gold-dk); margin: 8px 0; }

/* ---------- login / create ---------- */
.center-wrap {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.auth-box {
  width: 380px; max-width: 94vw;
  background: linear-gradient(#2b2114, #1c150c);
  border: 2px solid var(--gold-dk); border-radius: 8px;
  box-shadow: 0 0 40px rgba(0,0,0,0.7), inset 0 0 30px rgba(201,162,39,0.05);
  padding: 28px 30px;
}
.auth-box h1 {
  margin: 0 0 4px; text-align: center; letter-spacing: 3px;
  color: var(--gold-hi); text-shadow: 0 0 12px rgba(201,162,39,0.4), 2px 2px 3px #000;
  font-size: 28px;
}
.auth-box .sub { text-align: center; color: var(--ink-dim); font-size: 13px; margin-bottom: 18px; font-style: italic; }
.auth-box label { display: block; font-size: 13px; color: var(--ink-dim); margin: 10px 0 4px; }
.auth-box input { width: 100%; }
.auth-row { display: flex; gap: 10px; margin-top: 16px; }
.auth-row button { flex: 1; padding: 9px; font-size: 15px; }

.create-box { width: 640px; max-width: 96vw; }
.race-cards { display: flex; gap: 12px; margin: 8px 0 4px; }
.race-card {
  flex: 1; border: 2px solid #4a3d22; border-radius: 6px; padding: 10px;
  background: #181208; cursor: pointer; text-align: center;
}
.race-card h3 { margin: 6px 0 4px; color: var(--gold-hi); font-size: 17px; }
.race-card p { font-size: 12px; color: var(--ink-dim); margin: 0; font-style: italic; }
.race-card canvas { display: block; margin: 0 auto; }
.race-card.selected { border-color: var(--gold); box-shadow: 0 0 14px rgba(201,162,39,0.35); background: #221a0d; }
.region-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.region-row button { flex: 1 1 28%; }
.region-row button.selected { border-color: var(--gold); box-shadow: 0 0 10px rgba(201,162,39,0.5); color: #ffe9a8; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }

/* ---------- top bar ---------- */
#topbar {
  display: flex; align-items: center; gap: 14px;
  background: linear-gradient(#2c2113, #1a140b);
  border-bottom: 2px solid var(--gold-dk);
  padding: 6px 14px; flex-wrap: wrap;
}
#topbar .lord { font-size: 17px; color: var(--gold-hi); text-shadow: 1px 1px 2px #000; white-space: nowrap; }
#topbar .lord small { color: var(--ink-dim); font-size: 12px; }
#resbar { display: flex; gap: 10px; flex-wrap: wrap; flex: 1; }
.res { display: flex; align-items: center; gap: 5px; font-size: 13px; white-space: nowrap; }
.res canvas { display: block; }
.res .amt { color: #ffe9a8; }
.res .rate { color: var(--ink-dim); font-size: 11px; }
.res .pop { color: #ffe9a8; }
#topbar .spacer { flex: 1; }
#topbar .coins { color: var(--gold-hi); font-size: 13px; white-space: nowrap; }
.topbtns { display: flex; gap: 6px; }
.topbtns button { padding: 5px 10px; font-size: 13px; position: relative; }
#reports-btn .dot {
  position: absolute; top: -4px; right: -4px; width: 12px; height: 12px;
  background: #e33; border-radius: 50%; border: 1px solid #fff;
}

/* ---------- tabs ---------- */
#tabs { display: flex; gap: 4px; padding: 8px 14px 0; background: #100c07; }
#tabs button {
  border: none; border-radius: 8px 8px 0 0; padding: 9px 34px;
  font-size: 16px; letter-spacing: 1px;
  background: linear-gradient(#6e2424, #471717); color: #f5c9c9;
  border-top: 1px solid #a05252; border-left: 1px solid #a05252; border-right: 1px solid #a05252;
  text-shadow: 1px 1px 2px #000;
}
#tabs button.active { background: linear-gradient(#b33232, #7c2020); color: #fff; box-shadow: 0 -2px 12px rgba(179,50,50,0.5); }

/* ---------- main layout ---------- */
#game-main { display: flex; flex: 1; min-height: 0; }
#view-pane {
  flex: 1; min-width: 0; padding: 14px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(201,162,39,0.05), transparent 70%),
    #151009;
  border-top: 2px solid var(--gold-dk);
  overflow: auto;
}
#sidebar {
  width: 300px; flex-shrink: 0; display: flex; flex-direction: column;
  border-left: 2px solid var(--gold-dk); border-top: 2px solid var(--gold-dk);
  background: #181209; min-height: 0;
}
.castle-switch { padding: 8px 12px; border-bottom: 1px solid #3a2f1a; font-size: 13px; }
.castle-switch select { width: 100%; margin-top: 4px; }

/* ---------- town fields ---------- */
.fields-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; max-width: 760px; }
.field {
  aspect-ratio: 1; border: 2px solid #4a3d22; border-radius: 6px;
  background: #1c150b; cursor: pointer; position: relative;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .15s;
}
.field:hover { border-color: var(--gold); }
.field.selected { border-color: var(--gold); box-shadow: 0 0 12px rgba(201,162,39,0.5); }
.field .lvl {
  position: absolute; bottom: 3px; right: 5px; font-size: 12px; font-weight: bold;
  color: #ffe9a8; text-shadow: 1px 1px 2px #000; background: rgba(0,0,0,0.55);
  padding: 0 5px; border-radius: 8px; border: 1px solid var(--gold-dk);
}
.field .qdot { position: absolute; top: 4px; left: 4px; width: 10px; height: 10px; border-radius: 50%; background: #ffb020; box-shadow: 0 0 6px #ffb020; }
.field .fname { position: absolute; top: 3px; right: 5px; font-size: 10px; color: var(--ink-dim); text-transform: capitalize; }
.detail-panel {
  margin-top: 14px; max-width: 760px; padding: 14px 16px;
  background: linear-gradient(#efe0b4, #dcc794); color: #2b2113;
  border: 2px solid var(--gold-dk); border-radius: 6px;
  box-shadow: inset 0 0 24px rgba(122,95,20,0.25);
}
.detail-panel h3 { margin: 0 0 6px; color: #5a3f10; }
.detail-panel .row { display: flex; justify-content: space-between; font-size: 14px; margin: 3px 0; }
.detail-panel button { margin-top: 8px; }
.detail-panel .costs { font-size: 13px; color: #4a3a1a; margin-top: 6px; }

/* ---------- city plots ---------- */
.plots-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; max-width: 760px; }
.plot {
  aspect-ratio: 1; border: 2px dashed #5a4a2a; border-radius: 6px;
  background: rgba(0,0,0,0.25); cursor: pointer; position: relative;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .15s;
}
.plot:hover { border-color: var(--gold); }
.plot.built { border-style: solid; border-color: #4a3d22; background: #20180d; }
.plot.selected { border-color: var(--gold); box-shadow: 0 0 12px rgba(201,162,39,0.5); }
.plot .lvl { position: absolute; bottom: 3px; right: 5px; font-size: 12px; font-weight: bold; color: #ffe9a8; text-shadow: 1px 1px 2px #000; background: rgba(0,0,0,0.55); padding: 0 5px; border-radius: 8px; border: 1px solid var(--gold-dk); }
.plot .bname { position: absolute; bottom: 3px; left: 5px; font-size: 10px; color: var(--ink-dim); max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plot .qdot { position: absolute; top: 4px; left: 4px; width: 10px; height: 10px; border-radius: 50%; background: #ffb020; box-shadow: 0 0 6px #ffb020; }
.plot .empty-label { color: #6a5a3a; font-size: 24px; }

/* ---------- map ---------- */
#map-wrap { position: relative; width: 100%; height: calc(100vh - 260px); min-height: 420px; border: 2px solid var(--gold-dk); border-radius: 6px; overflow: hidden; background: #0d1a0d; }
#map-canvas { display: block; cursor: grab; }
#map-canvas:active { cursor: grabbing; }
#map-controls { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
#map-controls input { width: 70px; }
#tooltip {
  position: fixed; z-index: 200; pointer-events: none;
  background: rgba(10,8,5,0.94); border: 1px solid var(--gold);
  border-radius: 4px; padding: 6px 10px; font-size: 12px; color: var(--ink);
  max-width: 260px; box-shadow: 0 2px 10px rgba(0,0,0,0.7);
}
#tooltip .tt-name { color: var(--gold-hi); font-weight: bold; font-size: 13px; }

/* ---------- heroes panel ---------- */
#heroes-panel { border-bottom: 2px solid var(--gold-dk); padding: 10px 12px; max-height: 46%; overflow-y: auto; }
#heroes-panel h3, #chat-panel h3 { margin: 0 0 8px; color: var(--gold-hi); font-size: 15px; letter-spacing: 1px; }
.hero-card { border: 1px solid #4a3d22; border-radius: 5px; padding: 8px; margin-bottom: 8px; background: #1c150b; font-size: 13px; }
.hero-card .hname { color: #ffe9a8; font-weight: bold; }
.hero-card .hstate { color: var(--ink-dim); font-size: 11px; font-style: italic; }
.expbar { height: 8px; background: #0a0805; border: 1px solid #4a3d22; border-radius: 4px; margin: 4px 0; overflow: hidden; }
.expbar > div { height: 100%; background: linear-gradient(90deg, #4a7fc4, #7fb0e8); }
.hero-card .stats { font-size: 12px; color: var(--ink-dim); }
.hero-card .btnrow { display: flex; gap: 6px; margin-top: 6px; }
.hero-card .btnrow button { font-size: 11px; padding: 3px 8px; }
#tavern-btn { width: 100%; margin-top: 4px; }

/* ---------- chat ---------- */
#chat-panel { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 10px 12px; }
#chat-log { flex: 1; overflow-y: auto; font-size: 13px; background: #0d0a06; border: 1px solid #3a2f1a; border-radius: 4px; padding: 8px; min-height: 120px; }
#chat-log .msg { margin: 3px 0; word-wrap: break-word; }
#chat-log .msg .from { color: #9fc4ff; }
#chat-log .msg.sys { color: var(--gold-hi); font-style: italic; }
#chat-log .msg .ts { color: #5a5344; font-size: 11px; }
#chat-form { display: flex; gap: 6px; margin-top: 8px; }
#chat-form input { flex: 1; }
#chat-err { font-size: 12px; color: #ff8a8a; min-height: 16px; margin-top: 2px; }

/* ---------- modals ---------- */
#modal-root .overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.65); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: linear-gradient(#efe0b4, #d9c48e); color: #2b2113;
  border: 3px solid var(--gold-dk); border-radius: 8px;
  box-shadow: 0 0 50px rgba(0,0,0,0.8), inset 0 0 30px rgba(122,95,20,0.2);
  padding: 20px 24px; max-width: 560px; width: 100%; max-height: 86vh; overflow-y: auto;
  position: relative;
}
.modal.dark { background: linear-gradient(#2b2114, #191209); color: var(--ink); }
.modal h2 { margin: 0 0 10px; color: #5a3f10; border-bottom: 1px solid #a8894a; padding-bottom: 6px; }
.modal.dark h2 { color: var(--gold-hi); border-bottom-color: #4a3d22; }
.modal .x {
  position: absolute; top: 10px; right: 12px; background: none; border: none;
  font-size: 20px; color: #7a5f14; padding: 2px 8px; text-shadow: none;
}
.modal.dark .x { color: var(--ink-dim); }
.modal .row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 14px; border-bottom: 1px dotted #b49b5e; }
.modal.dark .row { border-bottom-color: #3a2f1a; }
.modal .row .k { color: #6a5326; font-weight: bold; }
.modal.dark .row .k { color: var(--ink-dim); }
.modal .btnrow { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

.build-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.build-item { display: flex; align-items: center; gap: 10px; border: 1px solid #a8894a; border-radius: 5px; padding: 6px 10px; background: rgba(255,255,255,0.25); }
.build-item canvas { flex-shrink: 0; }
.build-item .bi-name { font-weight: bold; color: #4a3510; }
.build-item .bi-desc { font-size: 12px; color: #5a4a2a; }
.build-item .bi-cost { font-size: 12px; color: #6a5326; margin-left: auto; text-align: right; white-space: nowrap; }
.build-item button { margin-left: 8px; }

.queue-list { margin-top: 10px; }
.qitem { display: flex; align-items: center; gap: 8px; border: 1px solid #a8894a; border-radius: 5px; padding: 6px 10px; margin-bottom: 6px; background: rgba(255,255,255,0.2); font-size: 13px; }
.qitem .qname { font-weight: bold; color: #4a3510; }
.qitem .qtime { color: #7a5f14; font-variant-numeric: tabular-nums; }
.qitem .qarrow { background: none; border: none; color: #7a5f14; font-size: 16px; padding: 0 4px; }
.speedups { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; align-items: center; }
.speedups button { font-size: 12px; padding: 4px 8px; }
.speedups .inv { font-size: 12px; color: #6a5326; }

.unit-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 13px; border-bottom: 1px dotted #b49b5e; }
.unit-row input { width: 70px; }
.unit-row .have { color: #6a5326; font-size: 12px; margin-left: auto; }

/* toasts */
#toast-root { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: rgba(20,14,6,0.95); border: 1px solid var(--gold); color: #ffe9a8;
  padding: 8px 18px; border-radius: 20px; font-size: 14px; box-shadow: 0 2px 12px rgba(0,0,0,0.6);
}
.toast.err { border-color: #c44; color: #ffb0b0; }

.report-item { border-bottom: 1px dotted #b49b5e; padding: 8px 0; cursor: pointer; font-size: 14px; }
.report-item:hover { background: rgba(201,162,39,0.12); }
.report-item .rt { color: #7a5f14; font-size: 12px; }
.report-body { white-space: pre-wrap; font-size: 14px; line-height: 1.5; background: rgba(255,255,255,0.3); border: 1px solid #a8894a; border-radius: 4px; padding: 10px; margin-top: 10px; }

.inv-item { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px dotted #b49b5e; font-size: 14px; }
.inv-item .qty { margin-left: auto; font-weight: bold; color: #5a3f10; }

.alloc-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dotted #b49b5e; }
.alloc-row .aname { width: 90px; font-weight: bold; color: #4a3510; }
.alloc-row .aval { width: 40px; text-align: center; font-size: 16px; font-weight: bold; }
.alloc-row button { font-size: 14px; padding: 2px 10px; }

@media (max-width: 900px) {
  #game-main { flex-direction: column; }
  #sidebar { width: 100%; border-left: none; border-top: 2px solid var(--gold-dk); }
  .fields-grid, .plots-grid { grid-template-columns: repeat(4, 1fr); }
}
