/* wii.css — client chrome (SPEC §6). Canvas fullscreen; WC2-authentic HUD +
   menus (HUD wave): the real WC2 UI art as CSS backgrounds (indexed PNGs
   decode fine for display; image-rendering: pixelated everywhere). The HUD
   left column + top bar render at native WC2 pixel sizes and scale via
   --wii-hud (1 or 2, set by ui_menus.js from screen height / options). */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root { --wii-hud: 2; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #000;
  color: #d8c890;
  font-family: 'Palatino Linotype', Palatino, Georgia, serif;
  user-select: none;
  -webkit-user-select: none;
}

canvas#gl {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  outline: none;
}

/* ---- HUD skeleton (ui_hud.js fills these once the world is up) ---- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud > * { pointer-events: auto; }
#hud > *:empty { display: none; }
#left > *:empty { display: none; }
#hud, #hud * { image-rendering: pixelated; }

/* top resource bar — WC2 resource strip art, full width, left column padded */
#resources {
  position: absolute; top: 0; left: 0;
  height: 16px;
  width: calc(100% / var(--wii-hud));
  transform: scale(var(--wii-hud));
  transform-origin: 0 0;
  background: url('/assets/graphics/ui/human/resource.png?v=1') repeat-x #000;
  display: flex; align-items: center; gap: 22px;
  padding-left: 184px;
  font: bold 10px/1 'Palatino Linotype', Georgia, serif;
  color: #fce088;
}
.hud-orc #resources { background-image: url('/assets/graphics/ui/orc/resource.png?v=1'); }
.res-item { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.res-v.res-over { color: #ff5040; }
.res-v.res-flash { animation: wii-redflash .28s 3; }
@keyframes wii-redflash { 50% { color: #ff2020; } }

.res-ico {
  display: inline-block; width: 14px; height: 14px;
  background: url('/assets/graphics/ui/gold,wood,oil,mana.png?v=1') no-repeat;
  vertical-align: middle;
}
.ri-gold  { background-position: 0 0; }
.ri-wood  { background-position: 0 -14px; }
.ri-oil   { background-position: 0 -28px; }
.ri-mana  { background-position: 0 -42px; }
.ri-food  { background: url('/assets/graphics/ui/food.png?v=1') no-repeat; }
.ri-score { background: url('/assets/graphics/ui/score.png?v=1') no-repeat; }

/* left column: menu button / minimap frame / info panel / command card */
#left {
  position: absolute; left: 0;
  top: calc(16px * var(--wii-hud));
  width: 176px;
  transform: scale(var(--wii-hud));
  transform-origin: 0 0;
}
#minimap { width: 176px; }
.mm-menubtn {
  display: block; width: 176px; height: 24px;
  background: url('/assets/graphics/ui/human/menubutton.png?v=1');
  border: 0; cursor: pointer;
  font: bold 11px 'Palatino Linotype', Georgia, serif;
  color: #ffd75e; text-shadow: 1px 1px #000;
  image-rendering: pixelated;
}
.hud-orc .mm-menubtn { background-image: url('/assets/graphics/ui/orc/menubutton.png?v=1'); }
.mm-menubtn:hover { color: #fff; }
.mm-f10 { font-weight: normal; color: #b09a60; font-size: 9px; }
.mm-frame {
  position: relative; width: 176px; height: 136px;
  background: url('/assets/graphics/ui/human/minimap.png?v=1');
}
.hud-orc .mm-frame { background-image: url('/assets/graphics/ui/orc/minimap.png?v=1'); }
.mm-frame canvas {
  position: absolute; left: 24px; top: 2px;
  width: 128px; height: 128px;
  image-rendering: pixelated;
  cursor: crosshair;
}

/* selection info panel (top 176px slice of infopanel.png) */
.sel-panel {
  position: relative; width: 176px; height: 176px;
  background: url('/assets/graphics/ui/human/infopanel.png?v=1') 0 0;
}
.hud-orc .sel-panel { background-image: url('/assets/graphics/ui/orc/infopanel.png?v=1'); }
.sel-body { position: absolute; inset: 6px 8px 6px 8px; overflow: hidden; }
.sel-one { display: flex; gap: 6px; }
.sel-porta { width: 50px; flex: none; }
.sel-porta.sel-flash .sel-portrait { animation: wii-flashgold .3s 4; }
@keyframes wii-flashgold { 50% { filter: brightness(1.9) sepia(.6); } }
.sel-portrait { width: 46px; height: 38px; border: 2px solid #3a2e18; box-shadow: 0 0 0 1px #000; background-repeat: no-repeat; }
.sel-hpbar { width: 50px; height: 5px; background: #000; margin-top: 3px; border: 1px solid #201808; }
.sel-hpbar > div { height: 100%; }
.sel-hptext { font: 9px monospace; color: #cfc090; text-align: center; }
.sel-name { font: bold 12px 'Palatino Linotype', Georgia, serif; color: #fce088; text-shadow: 1px 1px #000; padding-top: 4px; }
.sel-stats { margin-top: 6px; font: 10px/1.5 'Palatino Linotype', Georgia, serif; color: #d8c890; }
.sel-stat { display: flex; justify-content: space-between; padding: 0 4px; }
.sel-stat span:first-child { color: #a89464; }
.sel-manabar { width: 100%; height: 5px; background: #000; border: 1px solid #201808; margin-top: 3px; }
.sel-manabar > div { height: 100%; background: #3050e0; }
.sel-progress {
  position: absolute; left: 2px; right: 2px; bottom: 2px; height: 14px;
  background: #14100a; border: 1px solid #46381c; text-align: center;
}
.sel-progress span { position: relative; font: 9px monospace; color: #e8d8a0; line-height: 14px; }
.sel-progfill { position: absolute; inset: 0 auto 0 0; background: rgb(48, 100, 4); }
.sel-indet .sel-progfill { width: 30%; animation: wii-indet 1.6s linear infinite; }
@keyframes wii-indet { 0% { left: 0; } 100% { left: 70%; } }
.sel-cargo { display: flex; gap: 2px; margin-top: 4px; flex-wrap: wrap; }
.sel-multi { display: flex; flex-wrap: wrap; gap: 3px; }
.sel-chip { cursor: pointer; }
.sel-chip:hover .sel-chipicon { filter: brightness(1.3); }
.sel-chipicon { border: 1px solid #3a2e18; background-repeat: no-repeat; background-color: #1a140c; }
.sel-chiphp { height: 3px; background: #000; margin-top: 1px; }
.sel-chiphp > div { height: 100%; }
.sel-dense .sel-chip { width: 30px; }

/* command card 3x3 on the buttonpanel art */
.cmd-panel {
  position: relative; width: 176px; height: 144px;
  background: url('/assets/graphics/ui/human/buttonpanel.png?v=1');
}
.hud-orc .cmd-panel { background-image: url('/assets/graphics/ui/orc/buttonpanel.png?v=1'); }
.cmd-btn { position: absolute; width: 50px; height: 42px; cursor: pointer; }
.cmd-btn.p1 { left: 7px;  top: 2px; }  .cmd-btn.p2 { left: 63px;  top: 2px; }  .cmd-btn.p3 { left: 119px; top: 2px; }
.cmd-btn.p4 { left: 7px;  top: 49px; } .cmd-btn.p5 { left: 63px;  top: 49px; } .cmd-btn.p6 { left: 119px; top: 49px; }
.cmd-btn.p7 { left: 7px;  top: 96px; } .cmd-btn.p8 { left: 63px;  top: 96px; } .cmd-btn.p9 { left: 119px; top: 96px; }
.cmd-icon { width: 46px; height: 38px; margin: 2px; border: 1px solid #000; box-shadow: 0 0 0 1px #4a3a1c; background-repeat: no-repeat; background-color: #1a140c; }
.cmd-btn:hover .cmd-icon { filter: brightness(1.25); }
.cmd-btn:active .cmd-icon { transform: translate(1px, 1px); }
.cmd-btn.cmd-lack .cmd-icon { filter: grayscale(.65) brightness(.75); }
.cmd-btn.cmd-lack::after {
  content: ''; position: absolute; inset: 2px 2px 2px 2px;
  background: rgba(150, 10, 10, .35); pointer-events: none;
}
.cmd-btn.cmd-armed .cmd-icon { box-shadow: 0 0 0 2px #ffd75e; }
.cmd-key {
  position: absolute; right: 4px; bottom: 3px;
  font: bold 9px monospace; color: #ffe37a; text-shadow: 1px 1px #000;
  pointer-events: none;
}

/* bottom status line: tooltips + alerts on the WC2 statusline art */
#wii-status {
  position: fixed; bottom: 0; right: 0;
  left: calc(176px * var(--wii-hud));
  height: calc(16px * var(--wii-hud));
  background: url('/assets/graphics/ui/human/statusline.png?v=1') repeat-x #000;
  background-size: auto 100%;
  color: #e8d8a0;
  font: bold calc(7px * var(--wii-hud))/calc(16px * var(--wii-hud)) 'Palatino Linotype', Georgia, serif;
  padding: 0 12px;
  white-space: nowrap; overflow: hidden;
  pointer-events: none;
  z-index: 11;
}
.hud-orc #wii-status { background-image: url('/assets/graphics/ui/orc/statusline.png?v=1'); }
#wii-status.st-alert, .st-alert { color: #ff4838; }
#wii-status u { color: #fff; }
.st-costs { margin-left: 14px; }
.st-costs .res-ico { margin: 0 3px 0 8px; transform: scale(var(--wii-hud)); transform-origin: center; }

/* chat overlay (log + Enter input) */
#chat {
  position: absolute;
  left: calc(176px * var(--wii-hud) + 10px);
  bottom: calc(16px * var(--wii-hud) + 8px);
  width: 42%;
  pointer-events: none;
  font: calc(6px * var(--wii-hud))/1.5 'Palatino Linotype', Georgia, serif;
}
.chat-log div { text-shadow: 1px 1px 2px #000; color: #e8e0c0; }
.chat-in {
  display: none; width: 100%; margin-top: 4px; pointer-events: auto;
  background: rgba(10, 8, 4, .85); border: 1px solid #665c33; color: #ffe9a8;
  font: inherit; padding: 3px 6px; outline: none;
}
.chat-in.open { display: block; }

/* ---- menus (ui_menus.js) ---- */
#menus { position: fixed; inset: 0; z-index: 26; pointer-events: none; }
#menus > * { pointer-events: auto; }
#menus:empty { display: none; }
#menus, #menus * { image-rendering: pixelated; }

.mn-screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px;
}
.mn-title { background: url('/assets/graphics/ui/title.png?v=1') center / cover no-repeat #000; justify-content: flex-end; padding-bottom: 7vh; }
.mn-bg { background: url('/assets/graphics/ui/Menu_background_without_title.png?v=1') center / cover no-repeat #000; }
.mn-overlay { background: rgba(0, 0, 0, .55); }
.mn-over { background-color: #000; background-position: center; background-repeat: no-repeat; background-size: contain; justify-content: flex-end; padding-bottom: 4vh; }

.mn-panel {
  background: url('/assets/graphics/ui/human/panel_2.png?v=1');
  background-size: 100% 100%;
  padding: 26px 30px;
  min-width: 430px; max-width: 92vw; max-height: 92vh;
  overflow: auto;
  box-shadow: 0 8px 40px #000;
}
.mn-narrow { min-width: 300px; }
.mn-wide { min-width: 640px; }
.mn-room { min-width: min(960px, 94vw); }
.mn-h {
  font: bold 20px 'Palatino Linotype', Georgia, serif; letter-spacing: 3px;
  color: #ffd75e; text-shadow: 1px 2px 3px #000; text-align: center; margin-bottom: 12px;
}
.mn-sub { font: bold 13px Georgia, serif; color: #c8a850; margin: 10px 0 4px; letter-spacing: 1px; }
.mn-stack { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.mn-row { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.mn-cols { display: flex; gap: 22px; flex-wrap: wrap; }
.mn-col { flex: 1 1 380px; min-width: 320px; }
.mn-col-map { flex: 0 0 200px; }
.mn-dim { color: #9a8a60; font-size: 12px; }
.mn-credits {
  position: absolute; bottom: 6px; left: 0; right: 0; text-align: center;
  font: 11px Georgia, serif; color: #8a7a50; text-shadow: 1px 1px #000;
}

.mn-btn {
  width: 224px; height: 28px; border: 0; cursor: pointer;
  background: url('/assets/graphics/ui/human/widgets/button-medium-normal.png?v=1') center / 100% 100% no-repeat;
  font: bold 12px 'Palatino Linotype', Georgia, serif;
  color: #ffd75e; text-shadow: 1px 1px #000;
  image-rendering: pixelated;
  width: 164px;
}
.mn-btn.mn-large { width: 224px; background-image: url('/assets/graphics/ui/human/widgets/button-large-normal.png?v=1'); }
.mn-btn.mn-small { width: 106px; background-image: url('/assets/graphics/ui/human/widgets/button-small-normal.png?v=1'); }
.mn-btn:hover:not(:disabled) { color: #fff; }
.mn-btn:active:not(:disabled) { background-image: url('/assets/graphics/ui/human/widgets/button-medium-pressed.png?v=1'); }
.mn-btn.mn-large:active:not(:disabled) { background-image: url('/assets/graphics/ui/human/widgets/button-large-pressed.png?v=1'); }
.mn-btn.mn-small:active:not(:disabled) { background-image: url('/assets/graphics/ui/human/widgets/button-small-pressed.png?v=1'); }
.mn-btn:disabled, .mn-btn.mn-grayed {
  background-image: url('/assets/graphics/ui/human/widgets/button-medium-grayed.png?v=1');
  color: #786848; cursor: default;
}
.mn-btn.mn-large:disabled { background-image: url('/assets/graphics/ui/human/widgets/button-large-grayed.png?v=1'); }

.mn-input {
  background: #14100a; border: 1px solid #665c33; color: #ffe9a8;
  font: 13px 'Palatino Linotype', Georgia, serif; padding: 5px 8px; outline: none;
  min-width: 120px;
}
.mn-name { margin-top: 8px; font: 12px Georgia, serif; color: #c8b070; display: flex; gap: 8px; align-items: center; }

select, #menus select {
  background: #14100a; color: #e8d8a0; border: 1px solid #665c33;
  font: 12px Georgia, serif; padding: 2px 4px; max-width: 130px;
}
select:disabled { color: #786848; }
input[type=range] { accent-color: #c8a850; }
input[type=checkbox] { accent-color: #c8a850; width: 15px; height: 15px; }

.mn-roomlist { min-height: 120px; max-height: 40vh; overflow: auto; border: 1px solid #46381c; background: rgba(8, 6, 2, .5); padding: 6px; }
.mn-roomrow { display: grid; grid-template-columns: 70px 1fr 2fr 50px 110px; gap: 8px; align-items: center; padding: 4px 6px; border-bottom: 1px solid #2a2210; font-size: 13px; }
.mn-code { font: bold 13px monospace; color: #ffd75e; letter-spacing: 2px; }

.rm-slot { display: grid; grid-template-columns: 20px 1fr 106px 84px 80px 106px; gap: 5px; align-items: center; padding: 3px 0; font-size: 12px; }
.rm-num { color: #8a7a50; }
.rm-name { color: #e8d8a0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rm-name.rm-you { color: #ffd75e; font-weight: bold; }
.rm-opt { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 3px 0; font-size: 12px; color: #c8b070; }
.mn-chat { height: 110px; overflow: auto; border: 1px solid #46381c; background: rgba(8, 6, 2, .5); padding: 4px 8px; font-size: 12px; }
.mn-chatin { width: 100%; margin-top: 4px; }
.mn-preview { width: 176px; height: 176px; image-rendering: pixelated; border: 2px solid #46381c; background: #101008; }

.mn-picker { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); display: flex; align-items: center; justify-content: center; }
.mn-pickerbox { min-width: min(860px, 92vw); }
.pk-list { flex: 1; max-height: 52vh; overflow: auto; border: 1px solid #46381c; background: rgba(8, 6, 2, .5); }
.pk-row { padding: 4px 8px; cursor: pointer; font-size: 13px; border-bottom: 1px solid #201808; }
.pk-row:hover { background: #2a2210; }
.pk-row.sel { background: #3a3018; color: #ffd75e; }

.mn-toast {
  position: fixed; top: 12%; left: 50%; transform: translateX(-50%);
  background: rgba(60, 8, 4, .92); border: 1px solid #a03020; color: #ffb0a0;
  padding: 8px 22px; font: 14px Georgia, serif; opacity: 0; transition: opacity .25s;
  pointer-events: none; z-index: 40;
}
.mn-toast.on { opacity: 1; }

.mn-overpanel { min-width: min(680px, 92vw); }
.ov-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ov-table th { color: #c8a850; text-align: left; border-bottom: 1px solid #665c33; padding: 3px 8px; }
.ov-table td { padding: 3px 8px; border-bottom: 1px solid #2a2210; }
.ov-table tr.ov-me td { background: rgba(200, 168, 80, .12); }
.ov-win { color: #ffe37a; }
.ov-loss { color: #ff5040; }

/* ---- FPS / debug overlay (?dev=1 / ?fps=1) ---- */
#fps {
  display: none;
  position: fixed; top: 4px; right: 8px; z-index: 40;
  font: 12px/1.4 monospace;
  color: #7fff7f;
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
}
#fps.on { display: block; }

/* ---- loading screen ---- */
#loading {
  position: fixed; inset: 0; z-index: 30;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px;
  background: #000;
  transition: opacity .35s ease;
}
#loading.done { opacity: 0; pointer-events: none; }
#loading-title {
  font-size: 34px; letter-spacing: 8px; font-weight: bold;
  color: #c8a850;
  text-shadow: 0 2px 6px #402800, 0 0 24px #604010;
}
#loading-label { font-size: 14px; color: #907850; min-height: 18px; }
#loading-label.error { color: #ff6a5a; max-width: 70%; text-align: center; }
#loading-bar {
  width: 320px; height: 14px;
  border: 1px solid #705828;
  background: #181008;
  box-shadow: inset 0 1px 3px #000;
}
#loading-fill {
  width: 0%; height: 100%;
  background: linear-gradient(#b89040, #806020);
  transition: width .15s linear;
}
