/* ══════════════════════════════════════════════════════
   ROGAL  —  PixelUI design system
   Pixel-notched corners · dark chrome · Silkscreen font
   ══════════════════════════════════════════════════════ */

/* ── Reset & Base ──────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 100%; height: 100%;
  background: #0a0a0a;
  color: #ccc;
  font-family: 'Silkscreen', monospace;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

/* ── Sim Background ────────────────────────────────── */
.sim-bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 1;
}

/* ── Pixel-notch clip-path helper ──────────────────── */
/* Reused via --notch custom prop on each element      */

/* ══════════════════════════════════════════════════════
   LOBBY  —  shared lobby system overrides
   ══════════════════════════════════════════════════════ */
#lobby {
  display: flex;
  width: 100%; height: 100%;
  position: relative;
  z-index: 1;
}

/* ── Shared button system (PixelUI) ────────────────── */
.btn {
  --notch: 4px;
  display: block;
  width: 100%;
  font-family: 'Silkscreen', monospace;
  font-size: 11px;
  padding: 9px 16px;
  cursor: pointer;
  border: none;
  text-align: center;
  letter-spacing: 1px;
  text-transform: uppercase;
  clip-path: polygon(
    0% var(--notch), var(--notch) var(--notch), var(--notch) 0%,
    calc(100% - var(--notch)) 0%, calc(100% - var(--notch)) var(--notch), 100% var(--notch),
    100% calc(100% - var(--notch)), calc(100% - var(--notch)) calc(100% - var(--notch)), calc(100% - var(--notch)) 100%,
    var(--notch) 100%, var(--notch) calc(100% - var(--notch)), 0% calc(100% - var(--notch))
  );
  transition: filter 0.1s, background 0.1s;
}
.btn-primary { background: #2a1e00; color: #ff6; }
.btn-primary:hover { background: #3a2800; }
.btn-primary:active { filter: brightness(0.8); }
.btn-secondary { background: #001a1a; color: #6ff; }
.btn-secondary:hover { background: #002828; }
.btn-secondary:active { filter: brightness(0.8); }
.btn-danger { background: #1a0000; color: #f66; }
.btn-danger:hover { background: #2a0a0a; }
.btn-danger:active { filter: brightness(0.8); }
.btn-large { padding: 10px 20px; font-size: 12px; --notch: 5px; }
.btn:disabled { opacity: 0.35; cursor: default; }

/* ── Close button (PixelUI) ────────────────────────── */
.btn-close {
  --notch: 3px;
  background: #1a1a1a;
  border: none;
  color: #555;
  font-family: 'Silkscreen', monospace;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  clip-path: polygon(
    0% var(--notch), var(--notch) var(--notch), var(--notch) 0%,
    calc(100% - var(--notch)) 0%, calc(100% - var(--notch)) var(--notch), 100% var(--notch),
    100% calc(100% - var(--notch)), calc(100% - var(--notch)) calc(100% - var(--notch)), calc(100% - var(--notch)) 100%,
    var(--notch) 100%, var(--notch) calc(100% - var(--notch)), 0% calc(100% - var(--notch))
  );
  transition: background 0.1s, color 0.1s;
}
.btn-close:hover { color: #f66; background: #2a1010; }

/* ── Labels & inputs (PixelUI) ─────────────────────── */
.field-label {
  display: block;
  color: #444;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}
.hint { color: #2a2a2a; text-transform: none; letter-spacing: 0; }

input[type="text"], input[type="number"] {
  --notch: 4px;
  display: block;
  width: 100%;
  background: #0a0a0a;
  border: none;
  color: #ff6;
  font-family: 'Silkscreen', monospace;
  font-size: 13px;
  padding: 8px 10px;
  outline: none;
  clip-path: polygon(
    0% var(--notch), var(--notch) var(--notch), var(--notch) 0%,
    calc(100% - var(--notch)) 0%, calc(100% - var(--notch)) var(--notch), 100% var(--notch),
    100% calc(100% - var(--notch)), calc(100% - var(--notch)) calc(100% - var(--notch)), calc(100% - var(--notch)) 100%,
    var(--notch) 100%, var(--notch) calc(100% - var(--notch)), 0% calc(100% - var(--notch))
  );
  transition: background 0.1s;
}
input[type="text"]:focus, input[type="number"]:focus { background: #0f0f0f; }
input[type="text"]::placeholder, input[type="number"]::placeholder { color: #2a2a2a; }

/* ── Error message ─────────────────────────────────── */
.error-msg { color: #c44; font-size: 11px; min-height: 1.2em; text-align: center; }

/* ══════════════════════════════════════════════════════
   GAME LAYOUT
   ══════════════════════════════════════════════════════ */
#game {
  display: flex;
  flex-direction: column;
  width: 100%; height: 100%;
  position: relative;
  z-index: 1;
}

/* ── Game Header ───────────────────────────────────── */
#gameHeader {
  background: #111;
  border-bottom: 2px solid #1e1e1e;
  padding: 5px 12px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
  image-rendering: pixelated;
}
#roomLabel { color: #ff6; font-weight: bold; }
#floorLabel { color: #6ff; }
#playerCount { color: #555; margin-left: auto; }

.header-btn {
  --notch: 3px;
  background: #1a1a1a;
  border: none;
  color: #666;
  font-family: 'Silkscreen', monospace;
  font-size: 10px;
  letter-spacing: 1px;
  padding: 3px 10px;
  cursor: pointer;
  text-transform: uppercase;
  clip-path: polygon(
    0% var(--notch), var(--notch) var(--notch), var(--notch) 0%,
    calc(100% - var(--notch)) 0%, calc(100% - var(--notch)) var(--notch), 100% var(--notch),
    100% calc(100% - var(--notch)), calc(100% - var(--notch)) calc(100% - var(--notch)), calc(100% - var(--notch)) 100%,
    var(--notch) 100%, var(--notch) calc(100% - var(--notch)), 0% calc(100% - var(--notch))
  );
  transition: background 0.1s, color 0.1s;
}
.header-btn:hover { background: #2a1e00; color: #ff6; }

#gfxIndicator {
  --notch: 2px;
  background: #111;
  border: none;
  color: #669;
  font-size: 9px;
  letter-spacing: 1px;
  padding: 2px 8px;
  cursor: default;
  user-select: none;
  clip-path: polygon(
    0% var(--notch), var(--notch) var(--notch), var(--notch) 0%,
    calc(100% - var(--notch)) 0%, calc(100% - var(--notch)) var(--notch), 100% var(--notch),
    100% calc(100% - var(--notch)), calc(100% - var(--notch)) calc(100% - var(--notch)), calc(100% - var(--notch)) 100%,
    var(--notch) 100%, var(--notch) calc(100% - var(--notch)), 0% calc(100% - var(--notch))
  );
}

/* ── Badges (PixelUI) ──────────────────────────────── */
.badge {
  --notch: 2px;
  font-size: 9px;
  letter-spacing: 1px;
  padding: 2px 7px;
  border: none;
  clip-path: polygon(
    0% var(--notch), var(--notch) var(--notch), var(--notch) 0%,
    calc(100% - var(--notch)) 0%, calc(100% - var(--notch)) var(--notch), 100% var(--notch),
    100% calc(100% - var(--notch)), calc(100% - var(--notch)) calc(100% - var(--notch)), calc(100% - var(--notch)) 100%,
    var(--notch) 100%, var(--notch) calc(100% - var(--notch)), 0% calc(100% - var(--notch))
  );
}
.badge-host { background: #2a1e00; color: #fa0; }
.badge-private { background: #1a0e2a; color: #a6f; }

/* ── Game Area & Canvas ────────────────────────────── */
#gameArea {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #080808;
  position: relative;
}
#gameCanvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ── Stats Bar ─────────────────────────────────────── */
#statsBar {
  background: #111;
  border-top: 2px solid #1e1e1e;
  padding: 4px 12px;
  font-size: 11px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  flex-shrink: 0;
}
#statsBar span { white-space: nowrap; }
#statHp { color: #0f0; }
#statStr { color: #f80; }
#statLvl { color: #ff6; }
#statGold { color: #ff0; }
#statHunger { color: #a60; }
#statWeapon { color: #aaf; }
#statArmor { color: #aaf; }
#statStatus { font-size: 11px; letter-spacing: 0.5px; }

/* ── Message Log ───────────────────────────────────── */
#messageLog {
  background: #0a0a0a;
  border-top: 2px solid #1a1a1a;
  padding: 4px 12px;
  font-size: 11px;
  max-height: 80px;
  overflow-y: auto;
  flex-shrink: 0;
  scrollbar-width: thin;
  scrollbar-color: #222 transparent;
}
#messageLog::-webkit-scrollbar { width: 3px; }
#messageLog::-webkit-scrollbar-thumb { background: #2a2a2a; }
.msg-line { margin: 1px 0; }

/* ══════════════════════════════════════════════════════
   INVENTORY PANEL (PixelUI)
   ══════════════════════════════════════════════════════ */
#inventoryPanel {
  --notch: 5px;
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: #111;
  border: none;
  z-index: 100;
  min-width: 300px;
  max-width: 92vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  clip-path: polygon(
    0% var(--notch), var(--notch) var(--notch), var(--notch) 0%,
    calc(100% - var(--notch)) 0%, calc(100% - var(--notch)) var(--notch), 100% var(--notch),
    100% calc(100% - var(--notch)), calc(100% - var(--notch)) calc(100% - var(--notch)), calc(100% - var(--notch)) 100%,
    var(--notch) 100%, var(--notch) calc(100% - var(--notch)), 0% calc(100% - var(--notch))
  );
  box-shadow: 6px 6px 0 rgba(0,0,0,0.5);
}
.inv-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #ff6;
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  border-bottom: 2px solid #2a2a2a;
  padding: 11px 16px;
  flex-shrink: 0;
}
#invList {
  overflow-y: auto;
  padding: 0 16px 12px;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: #222 transparent;
}
#invList::-webkit-scrollbar { width: 3px; }
#invList::-webkit-scrollbar-thumb { background: #2a2a2a; }

.inv-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 4px;
  border-bottom: 1px solid #1a1a1a;
  font-size: 12px;
}
.inv-item:hover { background: rgba(255,255,255,0.03); }
.inv-item-name { flex: 1; color: #ccc; }
.inv-item-ch { color: #aaf; margin-right: 8px; min-width: 14px; text-align: center; }
.inv-sprite { width: 32px; height: 32px; image-rendering: pixelated; margin-right: 6px; flex-shrink: 0; }
.inv-btn {
  --notch: 3px;
  background: #0e1a2a;
  border: none;
  color: #6ff;
  font-family: 'Silkscreen', monospace;
  font-size: 10px;
  padding: 4px 10px;
  cursor: pointer;
  margin-left: 4px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  clip-path: polygon(
    0% var(--notch), var(--notch) var(--notch), var(--notch) 0%,
    calc(100% - var(--notch)) 0%, calc(100% - var(--notch)) var(--notch), 100% var(--notch),
    100% calc(100% - var(--notch)), calc(100% - var(--notch)) calc(100% - var(--notch)), calc(100% - var(--notch)) 100%,
    var(--notch) 100%, var(--notch) calc(100% - var(--notch)), 0% calc(100% - var(--notch))
  );
  transition: background 0.1s, filter 0.1s;
}
.inv-btn:hover { background: #153a50; }
.inv-btn:active { filter: brightness(0.8); }
.inv-btn.drop { color: #f88; background: #2a0e0e; }
.inv-btn.drop:hover { background: #401818; }
.inv-empty { color: #444; font-size: 12px; padding: 10px; }
.inv-stat { font-size: 11px; font-family: inherit; margin: 0 4px; min-width: 52px; text-align: right; flex-shrink: 0; }
.inv-best-badge {
  --notch: 2px;
  font-size: 10px; font-weight: bold; color: #111; background: #ffd700;
  padding: 1px 5px; margin-right: 2px; flex-shrink: 0; letter-spacing: 0.5px;
  clip-path: polygon(
    0% var(--notch), var(--notch) var(--notch), var(--notch) 0%,
    calc(100% - var(--notch)) 0%, calc(100% - var(--notch)) var(--notch), 100% var(--notch),
    100% calc(100% - var(--notch)), calc(100% - var(--notch)) calc(100% - var(--notch)), calc(100% - var(--notch)) 100%,
    var(--notch) 100%, var(--notch) calc(100% - var(--notch)), 0% calc(100% - var(--notch))
  );
}

/* ══════════════════════════════════════════════════════
   ROOM MANAGEMENT PANEL (PixelUI)
   ══════════════════════════════════════════════════════ */
#roomPanel {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.88);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.roompanel-box {
  --notch: 5px;
  background: #111;
  border: none;
  padding: 20px 24px;
  width: 90%; max-width: 340px;
  max-height: 90vh; overflow-y: auto;
  clip-path: polygon(
    0% var(--notch), var(--notch) var(--notch), var(--notch) 0%,
    calc(100% - var(--notch)) 0%, calc(100% - var(--notch)) var(--notch), 100% var(--notch),
    100% calc(100% - var(--notch)), calc(100% - var(--notch)) calc(100% - var(--notch)), calc(100% - var(--notch)) 100%,
    var(--notch) 100%, var(--notch) calc(100% - var(--notch)), 0% calc(100% - var(--notch))
  );
  box-shadow: 6px 6px 0 rgba(0,0,0,0.5);
  scrollbar-width: thin;
  scrollbar-color: #222 transparent;
}
.roompanel-box::-webkit-scrollbar { width: 3px; }
.roompanel-box::-webkit-scrollbar-thumb { background: #2a2a2a; }

.roompanel-header {
  display: flex; justify-content: space-between; align-items: center;
  color: #ff6; font-size: 10px; letter-spacing: 2px; text-transform: uppercase;
  border-bottom: 2px solid #2a2a2a;
  padding-bottom: 10px; margin-bottom: 14px;
}
.roompanel-name {
  color: #fff; font-size: 15px; font-weight: bold;
  margin-bottom: 14px; letter-spacing: 1px;
}
.roompanel-section {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 2px dashed #1a1a1a;
}
.roompanel-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.roompanel-label {
  color: #555; font-size: 9px; text-transform: uppercase;
  letter-spacing: 2px; margin-bottom: 8px;
}

/* Invite code */
.invite-row {
  display: flex; align-items: center; gap: 8px;
}
.invite-code {
  --notch: 3px;
  flex: 1;
  color: #6ff;
  font-size: 13px;
  background: #0a0a0a;
  border: none;
  padding: 6px 10px;
  letter-spacing: 0.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  clip-path: polygon(
    0% var(--notch), var(--notch) var(--notch), var(--notch) 0%,
    calc(100% - var(--notch)) 0%, calc(100% - var(--notch)) var(--notch), 100% var(--notch),
    100% calc(100% - var(--notch)), calc(100% - var(--notch)) calc(100% - var(--notch)), calc(100% - var(--notch)) 100%,
    var(--notch) 100%, var(--notch) calc(100% - var(--notch)), 0% calc(100% - var(--notch))
  );
}
.invite-copy-btn {
  --notch: 3px;
  background: #1a1a1a; border: none; color: #888;
  font-family: 'Silkscreen', monospace; font-size: 10px; letter-spacing: 1px;
  padding: 6px 12px; cursor: pointer; text-transform: uppercase;
  white-space: nowrap;
  clip-path: polygon(
    0% var(--notch), var(--notch) var(--notch), var(--notch) 0%,
    calc(100% - var(--notch)) 0%, calc(100% - var(--notch)) var(--notch), 100% var(--notch),
    100% calc(100% - var(--notch)), calc(100% - var(--notch)) calc(100% - var(--notch)), calc(100% - var(--notch)) 100%,
    var(--notch) 100%, var(--notch) calc(100% - var(--notch)), 0% calc(100% - var(--notch))
  );
  transition: background 0.1s, color 0.1s;
}
.invite-copy-btn:hover { background: #0e2a2a; color: #6ff; }
.invite-copied {
  color: #6f6; font-size: 10px; margin-top: 4px;
}

/* Room player list */
.rp-player {
  --notch: 3px;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px;
  background: #0d0d0d;
  font-size: 12px;
  margin-bottom: 2px;
  clip-path: polygon(
    0% var(--notch), var(--notch) var(--notch), var(--notch) 0%,
    calc(100% - var(--notch)) 0%, calc(100% - var(--notch)) var(--notch), 100% var(--notch),
    100% calc(100% - var(--notch)), calc(100% - var(--notch)) calc(100% - var(--notch)), calc(100% - var(--notch)) 100%,
    var(--notch) 100%, var(--notch) calc(100% - var(--notch)), 0% calc(100% - var(--notch))
  );
}
.rp-swatch {
  width: 10px; height: 10px; flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.1);
}
.rp-name { flex: 1; color: #ccc; }
.rp-status { color: #555; font-size: 10px; }
.rp-actions { display: flex; gap: 4px; }
.rp-btn {
  --notch: 2px;
  background: #1a1a1a;
  border: none; color: #555;
  font-family: 'Silkscreen', monospace; font-size: 10px;
  letter-spacing: 1px; padding: 3px 8px; cursor: pointer;
  text-transform: uppercase;
  clip-path: polygon(
    0% var(--notch), var(--notch) var(--notch), var(--notch) 0%,
    calc(100% - var(--notch)) 0%, calc(100% - var(--notch)) var(--notch), 100% var(--notch),
    100% calc(100% - var(--notch)), calc(100% - var(--notch)) calc(100% - var(--notch)), calc(100% - var(--notch)) 100%,
    var(--notch) 100%, var(--notch) calc(100% - var(--notch)), 0% calc(100% - var(--notch))
  );
  transition: background 0.1s, color 0.1s;
}
.rp-btn:hover { background: #2a2a2a; color: #ccc; }
.rp-btn.danger { background: #1a0808; color: #844; }
.rp-btn.danger:hover { background: #2a1010; color: #f44; }

/* ══════════════════════════════════════════════════════
   FAB QUICK-USE (game-specific)
   ══════════════════════════════════════════════════════ */
#mcFabQuick { display: flex; flex-direction: row; gap: 8px; }
.fab-quick-btn {
  width: 50px; height: 50px;
  background: rgba(16, 14, 6, 0.93);
  border: 2px solid rgba(255, 100, 200, 0.3);
  border-radius: 0;
  font-family: 'Courier New', monospace;
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  flex-shrink: 0;
  line-height: 1;
}
.fab-quick-btn:active { filter: brightness(1.5); }
.fab-quick-btn.potion { border-color: rgba(255, 80, 220, 0.55); color: #f4f; }
.fab-quick-btn.food   { border-color: rgba(200, 110, 20, 0.55); color: #f80; }
.fab-quick-sprite { width: 32px; height: 32px; image-rendering: pixelated; pointer-events: none; }
.fab-quick-count {
  position: absolute;
  bottom: 2px; right: 3px;
  font-size: 9px;
  font-family: inherit;
  color: #ff6;
  line-height: 1;
  pointer-events: none;
}

/* ══════════════════════════════════════════════════════
   MOBILE HUD
   ══════════════════════════════════════════════════════ */
#mobileHud {
  display: none;
  position: absolute;
  top: 4px; left: 4px; right: 4px;
  z-index: 10;
  pointer-events: none;
}
#hudHp { height: 4px; border-radius: 2px; background: #300; overflow: hidden; }
#hudHp::after { content: ''; display: block; height: 100%; background: #0f0; transition: width 0.2s; }
#hudInfo {
  display: flex; justify-content: space-between;
  font-size: 10px; margin-top: 2px; color: #aaa;
  text-shadow: 0 0 4px #000;
}
#hudStats {
  display: flex; justify-content: space-between;
  font-size: 9px; margin-top: 1px; color: #888;
  text-shadow: 0 0 4px #000;
  gap: 4px;
}
#mobileMsg {
  display: none;
  position: fixed;
  bottom: calc(165px + 10px); left: 4px; right: 4px;
  z-index: 10;
  font-size: 10px; color: #ddd;
  text-shadow: 0 0 4px #000;
  pointer-events: none; text-align: center;
  max-height: 28px; overflow: hidden;
}

/* ── Mobile Log ────────────────────────────────────── */
#mobileLog {
  position: fixed; inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.94);
  display: flex; flex-direction: column;
}
.log-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px;
  color: #ff6; font-size: 12px; letter-spacing: 2px; text-transform: uppercase;
  border-bottom: 2px solid #2a2a2a;
  flex-shrink: 0;
}
#logContent {
  flex: 1; overflow-y: auto;
  padding: 8px 12px; font-size: 11px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #222 transparent;
}
#logContent::-webkit-scrollbar { width: 3px; }
#logContent::-webkit-scrollbar-thumb { background: #2a2a2a; }
#logContent .msg-line { margin: 3px 0; line-height: 1.4; }

/* ── Desktop inventory button ──────────────────────── */
#btnInventory {
  --notch: 4px;
  display: none;
  position: fixed; bottom: 10px; right: 10px;
  z-index: 50;
  background: #2a1e00;
  border: none;
  color: #ff6;
  font-family: 'Silkscreen', monospace;
  font-size: 11px;
  padding: 8px 16px;
  cursor: pointer;
  letter-spacing: 1px;
  text-transform: uppercase;
  clip-path: polygon(
    0% var(--notch), var(--notch) var(--notch), var(--notch) 0%,
    calc(100% - var(--notch)) 0%, calc(100% - var(--notch)) var(--notch), 100% var(--notch),
    100% calc(100% - var(--notch)), calc(100% - var(--notch)) calc(100% - var(--notch)), calc(100% - var(--notch)) 100%,
    var(--notch) 100%, var(--notch) calc(100% - var(--notch)), 0% calc(100% - var(--notch))
  );
  transition: background 0.1s, filter 0.1s;
}
#btnInventory:hover { background: #3a2800; }
#btnInventory:active { filter: brightness(0.8); }

/* ══════════════════════════════════════════════════════
   SETTINGS PANEL (PixelUI)
   ══════════════════════════════════════════════════════ */
#settingsPanel {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.88);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.settings-box {
  --notch: 5px;
  background: #111;
  border: none;
  padding: 20px 24px;
  max-width: 300px; width: 90%;
  clip-path: polygon(
    0% var(--notch), var(--notch) var(--notch), var(--notch) 0%,
    calc(100% - var(--notch)) 0%, calc(100% - var(--notch)) var(--notch), 100% var(--notch),
    100% calc(100% - var(--notch)), calc(100% - var(--notch)) calc(100% - var(--notch)), calc(100% - var(--notch)) 100%,
    var(--notch) 100%, var(--notch) calc(100% - var(--notch)), 0% calc(100% - var(--notch))
  );
  box-shadow: 6px 6px 0 rgba(0,0,0,0.5);
}
.settings-header {
  display: flex; justify-content: space-between; align-items: center;
  color: #6ff; font-size: 10px; letter-spacing: 2px; text-transform: uppercase;
  margin-bottom: 16px;
  border-bottom: 2px solid #2a2a2a;
  padding-bottom: 8px;
}
.settings-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px; font-size: 12px; color: #888;
}
.settings-row label { flex: 1; }
.zoom-controls { display: flex; align-items: center; gap: 10px; }
.zoom-btn {
  --notch: 3px;
  width: 30px; height: 30px;
  background: #1a1a1a; border: none; color: #888;
  font-size: 16px; font-family: 'Silkscreen', monospace; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  clip-path: polygon(
    0% var(--notch), var(--notch) var(--notch), var(--notch) 0%,
    calc(100% - var(--notch)) 0%, calc(100% - var(--notch)) var(--notch), 100% var(--notch),
    100% calc(100% - var(--notch)), calc(100% - var(--notch)) calc(100% - var(--notch)), calc(100% - var(--notch)) 100%,
    var(--notch) 100%, var(--notch) calc(100% - var(--notch)), 0% calc(100% - var(--notch))
  );
  transition: background 0.1s, color 0.1s;
}
.zoom-btn:hover { background: #0e2a2a; color: #6ff; }
#zoomLevel { color: #888; font-size: 12px; min-width: 38px; text-align: center; }
.settings-toggle {
  --notch: 3px;
  background: #1a1a1a; border: none; color: #888;
  font-family: 'Silkscreen', monospace; font-size: 11px; padding: 5px 12px; cursor: pointer;
  letter-spacing: 1px;
  clip-path: polygon(
    0% var(--notch), var(--notch) var(--notch), var(--notch) 0%,
    calc(100% - var(--notch)) 0%, calc(100% - var(--notch)) var(--notch), 100% var(--notch),
    100% calc(100% - var(--notch)), calc(100% - var(--notch)) calc(100% - var(--notch)), calc(100% - var(--notch)) 100%,
    var(--notch) 100%, var(--notch) calc(100% - var(--notch)), 0% calc(100% - var(--notch))
  );
  transition: background 0.1s, color 0.1s;
}
.settings-toggle:hover { background: #0e2a2a; color: #6ff; }
.settings-section { margin-top: 10px; padding-top: 10px; border-top: 2px dashed #1a1a1a; }
.settings-section-label { color: #555; font-size: 9px; text-transform: uppercase; letter-spacing: 2px; margin-bottom: 10px; display: block; }
.legend-item {
  --notch: 3px;
  display: flex; align-items: center; gap: 8px; margin-bottom: 3px; font-size: 12px;
  padding: 4px 6px;
  background: #0d0d0d;
  clip-path: polygon(
    0% var(--notch), var(--notch) var(--notch), var(--notch) 0%,
    calc(100% - var(--notch)) 0%, calc(100% - var(--notch)) var(--notch), 100% var(--notch),
    100% calc(100% - var(--notch)), calc(100% - var(--notch)) calc(100% - var(--notch)), calc(100% - var(--notch)) 100%,
    var(--notch) 100%, var(--notch) calc(100% - var(--notch)), 0% calc(100% - var(--notch))
  );
}
.legend-swatch { width: 12px; height: 12px; flex-shrink: 0; border: 1px solid rgba(255,255,255,0.1); }
.legend-name { color: #aaa; flex: 1; }

/* Kick button */
.kick-btn {
  --notch: 2px;
  background: #1a0808;
  border: none;
  color: #844;
  font-family: 'Silkscreen', monospace;
  font-size: 10px;
  padding: 2px 8px;
  cursor: pointer;
  letter-spacing: 1px;
  clip-path: polygon(
    0% var(--notch), var(--notch) var(--notch), var(--notch) 0%,
    calc(100% - var(--notch)) 0%, calc(100% - var(--notch)) var(--notch), 100% var(--notch),
    100% calc(100% - var(--notch)), calc(100% - var(--notch)) calc(100% - var(--notch)), calc(100% - var(--notch)) 100%,
    var(--notch) 100%, var(--notch) calc(100% - var(--notch)), 0% calc(100% - var(--notch))
  );
  transition: background 0.1s, color 0.1s;
}
.kick-btn:hover { background: #2a1010; color: #f44; }

/* ══════════════════════════════════════════════════════
   DEATH OVERLAY (PixelUI)
   ══════════════════════════════════════════════════════ */
#deathOverlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
}
.death-box {
  --notch: 6px;
  text-align: center;
  background: #111;
  padding: 32px 40px;
  clip-path: polygon(
    0% var(--notch), var(--notch) var(--notch), var(--notch) 0%,
    calc(100% - var(--notch)) 0%, calc(100% - var(--notch)) var(--notch), 100% var(--notch),
    100% calc(100% - var(--notch)), calc(100% - var(--notch)) calc(100% - var(--notch)), calc(100% - var(--notch)) 100%,
    var(--notch) 100%, var(--notch) calc(100% - var(--notch)), 0% calc(100% - var(--notch))
  );
  box-shadow: 6px 6px 0 rgba(0,0,0,0.5);
}
.death-title {
  color: #c00; font-size: 36px; margin-bottom: 10px;
  animation: pulse 1.5s ease-in-out infinite;
}
.death-msg { color: #555; font-size: 13px; margin-bottom: 20px; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ══════════════════════════════════════════════════════
   TOOLTIP (PixelUI)
   ══════════════════════════════════════════════════════ */
.tooltip {
  --notch: 3px;
  position: fixed;
  background: #111; border: none;
  padding: 5px 10px; font-size: 11px;
  color: #aaa; z-index: 300;
  pointer-events: none; white-space: nowrap; max-width: 300px;
  clip-path: polygon(
    0% var(--notch), var(--notch) var(--notch), var(--notch) 0%,
    calc(100% - var(--notch)) 0%, calc(100% - var(--notch)) var(--notch), 100% var(--notch),
    100% calc(100% - var(--notch)), calc(100% - var(--notch)) calc(100% - var(--notch)), calc(100% - var(--notch)) 100%,
    var(--notch) 100%, var(--notch) calc(100% - var(--notch)), 0% calc(100% - var(--notch))
  );
  box-shadow: 3px 3px 0 rgba(0,0,0,0.4);
}

/* ── Floor Event Banner ────────────────────────────── */
#eventBanner {
  --notch: 4px;
  position: fixed;
  top: 18%; left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: rgba(8, 6, 2, 0.92);
  border: none;
  padding: 10px 28px;
  font-size: 14px; letter-spacing: 1px;
  z-index: 200; pointer-events: none;
  opacity: 0; transition: opacity 0.35s, transform 0.35s;
  white-space: nowrap;
  box-shadow: 0 0 24px rgba(255,200,0,0.15);
  clip-path: polygon(
    0% var(--notch), var(--notch) var(--notch), var(--notch) 0%,
    calc(100% - var(--notch)) 0%, calc(100% - var(--notch)) var(--notch), 100% var(--notch),
    100% calc(100% - var(--notch)), calc(100% - var(--notch)) calc(100% - var(--notch)), calc(100% - var(--notch)) 100%,
    var(--notch) 100%, var(--notch) calc(100% - var(--notch)), 0% calc(100% - var(--notch))
  );
}
#eventBanner.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Damage Flash ──────────────────────────────────── */
.damage-flash {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 150;
  opacity: 0; transition: opacity 0.08s;
}
.damage-flash.hit { background: rgba(255,0,0,0.18); opacity: 1; }
.damage-flash.kill { background: rgba(255,255,100,0.12); opacity: 1; }

/* ══════════════════════════════════════════════════════
   HELP OVERLAY (PixelUI)
   ══════════════════════════════════════════════════════ */
#helpOverlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 250;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.help-box {
  --notch: 5px;
  background: #111; border: none;
  padding: 24px 32px; max-width: 680px; width: 95%;
  max-height: 90vh; overflow-y: auto;
  clip-path: polygon(
    0% var(--notch), var(--notch) var(--notch), var(--notch) 0%,
    calc(100% - var(--notch)) 0%, calc(100% - var(--notch)) var(--notch), 100% var(--notch),
    100% calc(100% - var(--notch)), calc(100% - var(--notch)) calc(100% - var(--notch)), calc(100% - var(--notch)) 100%,
    var(--notch) 100%, var(--notch) calc(100% - var(--notch)), 0% calc(100% - var(--notch))
  );
  box-shadow: 6px 6px 0 rgba(0,0,0,0.5);
  scrollbar-width: thin;
  scrollbar-color: #222 transparent;
}
.help-box::-webkit-scrollbar { width: 3px; }
.help-box::-webkit-scrollbar-thumb { background: #2a2a2a; }

.help-title {
  color: #ff6; font-size: 12px; letter-spacing: 2px; text-transform: uppercase;
  margin-bottom: 16px;
  border-bottom: 2px solid #2a2a2a; padding-bottom: 8px;
}
.help-close { color: #444; font-size: 10px; float: right; margin-top: 2px; }
.help-cols { display: flex; gap: 32px; }
.help-col { flex: 1; }
.help-col h3 {
  color: #6ff; font-size: 10px; text-transform: uppercase; letter-spacing: 2px;
  margin: 12px 0 6px 0; border-bottom: 2px dashed #1a1a1a; padding-bottom: 3px;
}
.help-col h3:first-child { margin-top: 0; }
.help-row { font-size: 11px; color: #888; margin: 4px 0; }
.help-row em { color: #ff6; font-style: normal; }
.hk {
  --notch: 2px;
  display: inline-block; background: #1a1a1a; border: none;
  color: #ff6; padding: 2px 6px; font-size: 10px; min-width: 20px; text-align: center;
  clip-path: polygon(
    0% var(--notch), var(--notch) var(--notch), var(--notch) 0%,
    calc(100% - var(--notch)) 0%, calc(100% - var(--notch)) var(--notch), 100% var(--notch),
    100% calc(100% - var(--notch)), calc(100% - var(--notch)) calc(100% - var(--notch)), calc(100% - var(--notch)) 100%,
    var(--notch) 100%, var(--notch) calc(100% - var(--notch)), 0% calc(100% - var(--notch))
  );
}
.hs { font-size: 13px; font-weight: bold; margin-right: 2px; }

/* ══════════════════════════════════════════════════════
   SHOP PANEL (PixelUI)
   ══════════════════════════════════════════════════════ */
#shopPanel {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.88);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.shop-box {
  --notch: 5px;
  background: #111; border: none;
  padding: 16px 20px; max-width: 380px; width: 90%;
  max-height: 80vh; overflow-y: auto;
  clip-path: polygon(
    0% var(--notch), var(--notch) var(--notch), var(--notch) 0%,
    calc(100% - var(--notch)) 0%, calc(100% - var(--notch)) var(--notch), 100% var(--notch),
    100% calc(100% - var(--notch)), calc(100% - var(--notch)) calc(100% - var(--notch)), calc(100% - var(--notch)) 100%,
    var(--notch) 100%, var(--notch) calc(100% - var(--notch)), 0% calc(100% - var(--notch))
  );
  box-shadow: 6px 6px 0 rgba(0,0,0,0.5);
  scrollbar-width: thin;
  scrollbar-color: #222 transparent;
}
.shop-box::-webkit-scrollbar { width: 3px; }
.shop-box::-webkit-scrollbar-thumb { background: #2a2a2a; }

.shop-header {
  display: flex; justify-content: space-between; align-items: center;
  color: #0d0; font-size: 10px; letter-spacing: 2px; text-transform: uppercase;
  margin-bottom: 12px;
  border-bottom: 2px solid #1e3a1e; padding-bottom: 8px; gap: 12px;
}
.shop-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 4px; border-bottom: 1px solid #1a1a1a; font-size: 12px;
}
.shop-item:hover { background: rgba(255,255,255,0.03); }
.shop-item-name { flex: 1; color: #ccc; }
.shop-item-cost { color: #ff0; margin: 0 8px; white-space: nowrap; }
.shop-buy { color: #0f0 !important; background: #0e2a0e; }
.shop-buy:hover { background: #154015; }

/* ── Game Length Selector (PixelUI) ────────────────── */
.game-length-row {
  display: flex; align-items: center; gap: 10px; margin: 8px 0;
}
.game-length-btns {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.len-btn {
  --notch: 3px;
  background: #1e1e1e; border: none; color: #888;
  padding: 6px 12px; font-family: 'Silkscreen', monospace; font-size: 11px;
  cursor: pointer; display: flex; flex-direction: column; align-items: center;
  clip-path: polygon(
    0% var(--notch), var(--notch) var(--notch), var(--notch) 0%,
    calc(100% - var(--notch)) 0%, calc(100% - var(--notch)) var(--notch), 100% var(--notch),
    100% calc(100% - var(--notch)), calc(100% - var(--notch)) calc(100% - var(--notch)), calc(100% - var(--notch)) 100%,
    var(--notch) 100%, var(--notch) calc(100% - var(--notch)), 0% calc(100% - var(--notch))
  );
  transition: background 0.1s, color 0.1s;
}
.len-btn:hover { background: #2a2a2a; color: #ccc; }
.len-btn.active { background: #2a1e00; color: #f80; }
.len-hint { font-size: 9px; color: #555; margin-top: 2px; }
.len-btn.active .len-hint { color: #a60; }

/* ══════════════════════════════════════════════════════
   VICTORY OVERLAY (PixelUI)
   ══════════════════════════════════════════════════════ */
#victoryOverlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 300;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.victory-box {
  --notch: 6px;
  background: #0a0d0a; border: none;
  padding: 32px 40px; max-width: 480px; width: 90%;
  text-align: center;
  clip-path: polygon(
    0% var(--notch), var(--notch) var(--notch), var(--notch) 0%,
    calc(100% - var(--notch)) 0%, calc(100% - var(--notch)) var(--notch), 100% var(--notch),
    100% calc(100% - var(--notch)), calc(100% - var(--notch)) calc(100% - var(--notch)), calc(100% - var(--notch)) 100%,
    var(--notch) 100%, var(--notch) calc(100% - var(--notch)), 0% calc(100% - var(--notch))
  );
  box-shadow: 6px 6px 0 rgba(0,0,0,0.5);
}
.victory-art {
  color: #ffd700; font-size: 11px; line-height: 1.3;
  margin: 0 0 12px 0; white-space: pre;
}
.victory-subtitle { color: #8f8; font-size: 13px; margin-bottom: 16px; }
.victory-stats {
  color: #aaa; font-size: 12px; margin-bottom: 20px; line-height: 1.8;
}
.victory-stats strong { color: #ffd700; }

/* ══════════════════════════════════════════════════════
   VILLAGE OVERLAY (PixelUI)
   ══════════════════════════════════════════════════════ */
#villageOverlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.88);
  z-index: 250;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.village-box {
  --notch: 5px;
  background: #0f0e0c; border: none;
  width: min(520px, 96vw); max-height: 88vh;
  display: flex; flex-direction: column;
  box-shadow: 0 0 40px rgba(200,120,0,0.15), 6px 6px 0 rgba(0,0,0,0.5);
  clip-path: polygon(
    0% var(--notch), var(--notch) var(--notch), var(--notch) 0%,
    calc(100% - var(--notch)) 0%, calc(100% - var(--notch)) var(--notch), 100% var(--notch),
    100% calc(100% - var(--notch)), calc(100% - var(--notch)) calc(100% - var(--notch)), calc(100% - var(--notch)) 100%,
    var(--notch) 100%, var(--notch) calc(100% - var(--notch)), 0% calc(100% - var(--notch))
  );
}
.village-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 2px solid #3a2a14;
  background: #161210;
}
.village-title { color: #d4a060; font-size: 12px; letter-spacing: 2px; text-transform: uppercase; }
.village-gold { color: #ffd700; font-size: 13px; }
.village-content {
  flex: 1; overflow-y: auto; padding: 12px 16px;
  scrollbar-width: thin; scrollbar-color: #3a2a14 #0f0e0c;
}
.village-content::-webkit-scrollbar { width: 3px; }
.village-content::-webkit-scrollbar-thumb { background: #3a2a14; }

.village-footer {
  padding: 10px 16px; border-top: 2px solid #3a2a14;
  display: flex; align-items: center; gap: 12px;
  background: #161210;
}
.village-note { font-size: 11px; color: #f80; flex: 1; }

/* Village sections */
.vl-section {
  --notch: 3px;
  border: none; background: #131109;
  margin-bottom: 10px; padding: 10px 12px;
  clip-path: polygon(
    0% var(--notch), var(--notch) var(--notch), var(--notch) 0%,
    calc(100% - var(--notch)) 0%, calc(100% - var(--notch)) var(--notch), 100% var(--notch),
    100% calc(100% - var(--notch)), calc(100% - var(--notch)) calc(100% - var(--notch)), calc(100% - var(--notch)) 100%,
    var(--notch) 100%, var(--notch) calc(100% - var(--notch)), 0% calc(100% - var(--notch))
  );
}
.vl-npc-row {
  display: flex; align-items: center; gap: 12px; margin-bottom: 8px;
}
.vl-npc-sprite {
  image-rendering: pixelated; flex-shrink: 0;
  border: 1px solid #2a1e0e;
}
.vl-npc-name { color: #d4a060; font-size: 12px; font-weight: bold; margin-bottom: 2px; }
.vl-npc-desc { color: #666; font-size: 11px; }
.vl-service-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 0; border-top: 1px solid #1e1608;
}
.vl-service-label { color: #aaa; font-size: 11px; }
.vl-cost { color: #ffd700; }
.vl-sell-price { color: #4f4; }
.vl-full-tag { color: #555; font-size: 11px; font-style: italic; }
.vl-section-title { color: #888; font-size: 9px; text-transform: uppercase;
  letter-spacing: 2px; margin-bottom: 6px; }
.vl-others { color: #556; font-size: 10px; margin-top: 6px; text-align: center; }
.vl-opener-note { color: #864; }

/* Village buttons */
.vl-btn {
  --notch: 3px;
  background: #1a1206; border: none; color: #c8901c;
  padding: 5px 14px; font-family: 'Silkscreen', monospace; font-size: 11px;
  cursor: pointer; white-space: nowrap;
  clip-path: polygon(
    0% var(--notch), var(--notch) var(--notch), var(--notch) 0%,
    calc(100% - var(--notch)) 0%, calc(100% - var(--notch)) var(--notch), 100% var(--notch),
    100% calc(100% - var(--notch)), calc(100% - var(--notch)) calc(100% - var(--notch)), calc(100% - var(--notch)) 100%,
    var(--notch) 100%, var(--notch) calc(100% - var(--notch)), 0% calc(100% - var(--notch))
  );
  transition: background 0.1s, color 0.1s;
}
.vl-btn:hover { background: #2a1e0e; color: #ffd700; }
.vl-btn-heal:hover { background: #0e2a1e; color: #0f8; }
.vl-btn-feed:hover { background: #2a1e00; color: #fa0; }
.vl-btn-smith:hover { background: #0e1e2a; color: #8af; }
.vl-btn-sell:hover { background: #0e2a0e; color: #4f4; }

/* ══════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  #gameHeader { display: none; }
  #statsBar { display: none; }
  #messageLog { display: none; }
  #btnInventory { display: none !important; }
  #mobileHud { display: block; }
  #mobileMsg { display: block; }
  .help-cols { flex-direction: column; gap: 8px; }
  .help-box { padding: 16px; }

  /* Inventory: bottom-sheet on mobile */
  #inventoryPanel {
    --notch: 0px;
    top: auto; bottom: 0; left: 0; right: 0;
    transform: none;
    max-width: 100vw;
    max-height: 55vh;
    clip-path: none;
    border-top: 2px solid #ff6;
  }
}
@media (min-width: 769px) {
  #btnInventory { display: block; }
}
