@font-face { font-family: 'Future'; src: url('assets/kenney/fonts/Kenney Future.ttf'); }
@font-face { font-family: 'Future Narrow'; src: url('assets/kenney/fonts/Kenney Future Narrow.ttf'); }

:root {
  --paper: #fdfaf2;
  --accent: #ff6b4a;
  --gold: #ffd166;
  --good: #7ee081;
  --muted: #8a93a6;
  --glass: rgba(20, 25, 38, 0.74);
}

* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; overflow: hidden; background: #232a3b; }
body { font-family: 'Future Narrow', system-ui, sans-serif; color: var(--paper); user-select: none; }
#stage { position: fixed; inset: 0; }
#stage canvas { display: block; width: 100%; height: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* --- HUD ------------------------------------------------------------------- */
.hud {
  position: fixed; inset: 0; pointer-events: none;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 18px 22px;
}
.hud button, .hud .intel { pointer-events: auto; }
.hud-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.pill {
  background: var(--glass);
  backdrop-filter: blur(6px);
  border-radius: 14px;
  padding: 10px 16px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  display: flex; align-items: center; gap: 16px;
}
.label { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.value { font-family: 'Future', sans-serif; font-size: 20px; font-variant-numeric: tabular-nums; }
.gold { color: var(--gold); }
.stat { display: flex; flex-direction: column; gap: 2px; min-width: 64px; }
.hpbar { height: 4px; border-radius: 2px; background: rgba(255,255,255,.12); overflow: hidden; }
.hpbar i { display: block; height: 100%; background: var(--good); transition: width .3s; }

.clock { flex-direction: column; align-items: center; gap: 2px; padding: 10px 26px; min-width: 260px; }
.clock .value { font-size: 30px; letter-spacing: 0.04em; }
.clock .bar { width: 100%; height: 4px; border-radius: 2px; background: rgba(255,255,255,0.12); overflow: hidden; margin-top: 6px; }
.clock .bar i { display: block; height: 100%; background: var(--accent); }
.clock-actions { display: flex; gap: 6px; margin-top: 8px; }

.btn {
  border: 0; border-radius: 10px; padding: 7px 14px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
  background: rgba(255,255,255,.12); transition: transform .12s, background .12s;
}
.btn:hover:not(:disabled) { background: rgba(255,255,255,.2); transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: #ff8467; }
.btn.ghost { background: transparent; outline: 1px solid rgba(255,255,255,.2); }
.chip { border: 0; background: transparent; padding: 4px 8px; border-radius: 8px; font-size: 12px; color: var(--muted); }
.chip.on { background: rgba(255,255,255,.14); color: var(--paper); }
.chip.sound { align-self: flex-start; padding: 4px; margin: -4px -8px 0 -6px; line-height: 0; }
.chip.sound:hover { color: var(--paper); }

.intel {
  position: fixed; left: 22px; bottom: 18px; width: 250px;
  flex-direction: column; align-items: stretch; gap: 8px;
  transition: opacity .4s, transform .4s;
}
.intel.collapsed { opacity: 0; transform: translateX(-20px); pointer-events: none; }
.intel p { font-family: 'Future', sans-serif; font-size: 15px; }
.intel-row { display: grid; grid-template-columns: 34px 1fr; column-gap: 8px; align-items: center; }
.intel-row img { grid-row: span 2; width: 34px; height: 34px; object-fit: contain; }
.intel-row b { font-weight: normal; font-size: 14px; }
.intel-row small, .muted { color: var(--muted); font-size: 11px; }

/* Radial menu on the clicked tile */
.radial { position: fixed; left: 0; top: 0; pointer-events: none; }
.radial.in .radial-item { animation: radial-in .26s cubic-bezier(.3,1.5,.5,1) both; }
.radial-item {
  position: absolute; left: 0; top: 0; width: 54px; height: 54px; border: 0; border-radius: 50%;
  pointer-events: auto; background: var(--glass); backdrop-filter: blur(6px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .3); outline: 1px solid rgba(255, 255, 255, .12);
  display: grid; place-items: center;
  transform: translate(-50%, -50%) rotate(var(--a)) translate(66px) rotate(calc(-1 * var(--a)));
  transition: background .12s, outline-color .12s;
}
.radial-item:hover:not(:disabled) { background: rgba(40, 48, 68, .9); outline: 2px solid var(--accent); }
.radial-item:disabled { opacity: .45; cursor: default; }
.radial-item .face { font-size: 20px; line-height: 1; margin-top: -8px; }
.radial-item img { width: 34px; height: 34px; object-fit: contain; }
.radial-item .cost {
  position: absolute; bottom: -7px; left: 50%; translate: -50% 0; padding: 1px 6px; border-radius: 7px;
  font: 11px 'Future', sans-serif; color: var(--gold); background: rgba(16, 20, 32, .92); white-space: nowrap;
}
.radial-item.plan .cost { color: var(--muted); outline: 1px dashed rgba(255, 209, 102, .6); }
.radial-item kbd { position: absolute; top: 3px; right: 6px; font: 9px 'Future', sans-serif; color: var(--muted); }
@keyframes radial-in { from { opacity: 0; transform: translate(-50%, -50%) scale(.4); } }
.radial-caption {
  position: absolute; left: 0; top: 30px; translate: -50% 0;
  display: flex; flex-direction: column; align-items: center; gap: 1px; white-space: nowrap;
  background: var(--glass); backdrop-filter: blur(6px); border-radius: 10px; padding: 5px 10px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
}
.radial-caption b { font-weight: normal; font-size: 13px; }
.radial-caption small { color: var(--muted); font-size: 11px; }

/* Banner, toast, floating numbers */
.banner {
  position: fixed; left: 50%; top: 30%; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none;
  text-shadow: 0 4px 24px rgba(0,0,0,.5);
}
.banner b { font: 44px 'Future', sans-serif; font-weight: normal; }
.banner span { font-size: 15px; letter-spacing: .12em; text-transform: uppercase; color: #dfe6f5; }
.banner.in { animation: banner 2.6s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes banner {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.7); }
  12% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(.98); }
}
.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  background: rgba(255, 107, 74, .9); padding: 8px 16px; border-radius: 10px; font-size: 13px; pointer-events: none;
}
.toast.in { animation: toast 1.6s ease both; }
@keyframes toast { 0% { opacity: 0; translate: 0 10px; } 10%, 80% { opacity: 1; translate: 0 0; } 100% { opacity: 0; } }
.float {
  position: fixed; pointer-events: none; font: 18px 'Future', sans-serif;
  text-shadow: 0 2px 8px rgba(0,0,0,.6); animation: float 1s ease-out forwards;
}
@keyframes float {
  0% { opacity: 0; transform: translate(-50%, 0) scale(.6); }
  15% { opacity: 1; transform: translate(-50%, -12px) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -52px) scale(1); }
}

/* Outcome */
.outcome {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: radial-gradient(ellipse at center, rgba(20,25,38,.35), rgba(20,25,38,.8));
  animation: fade .6s ease both;
}
.outcome-card {
  background: var(--glass); backdrop-filter: blur(10px); border-radius: 22px; padding: 28px 36px;
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.4); animation: pop .6s cubic-bezier(.2,1.5,.4,1) both;
}
.outcome h1 { font: 46px 'Future', sans-serif; }
.outcome.won h1 { color: var(--good); }
.outcome.lost h1 { color: var(--accent); }
.outcome p { color: #cfd6e6; font-size: 14px; }
.outcome p b { color: var(--paper); }
.outcome .grid { font-size: 24px; letter-spacing: 3px; line-height: 1; }
.outcome-actions { display: flex; gap: 8px; margin-top: 8px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.85); } }

/* --- Dev panel --------------------------------------------------------------- */
.dev {
  position: fixed; right: 12px; top: 12px; bottom: 12px; width: 300px; z-index: 50;
  background: rgba(12, 15, 24, .92); border-radius: 12px; font: 12px system-ui, sans-serif; color: #d6dbea;
  display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 10px 40px rgba(0,0,0,.5);
}
.dev header { display: flex; align-items: center; gap: 6px; padding: 8px; border-bottom: 1px solid #ffffff14; flex-wrap: wrap; }
.dev.min { bottom: auto; width: auto; }
.dev.min nav, .dev.min main, .dev.min [data-reset] { display: none; }
.dev.min header { border-bottom: 0; }
.dev header b { font: 11px 'Future', sans-serif; color: var(--accent); margin-right: 4px; }
.dev nav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
.dev button { border: 0; background: #ffffff12; border-radius: 6px; padding: 4px 8px; font-size: 11px; }
.dev button:hover { background: #ffffff22; }
.dev nav button.on { background: var(--accent); color: #fff; }
.dev main { overflow-y: auto; padding: 8px 10px; }
.dev section { display: flex; flex-direction: column; gap: 6px; }
.dev section > button { align-self: stretch; text-align: left; padding: 6px 8px; }
.dev label { display: grid; grid-template-columns: 1fr 110px 44px; align-items: center; gap: 6px; }
.dev label:has(input[type=checkbox]) { grid-template-columns: 1fr auto; }
.dev input[type=range] { width: 100%; accent-color: var(--accent); }
.dev output { text-align: right; font-variant-numeric: tabular-nums; color: #fff; }
.dev pre { background: #ffffff0a; border-radius: 6px; padding: 8px; white-space: pre-wrap; word-break: break-all; font: 11px ui-monospace, monospace; }

/* Social sieges: your plan list and pins for planned builds */
.plans {
  position: fixed; right: 22px; top: 96px; max-height: calc(100% - 114px); min-width: 170px; max-width: 280px;
  flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 6px; pointer-events: auto;
  padding: 8px 12px;
}
.plans ol:empty { display: none; }
.plans ol { flex: 0 1 auto; min-height: 0; }
/* The hint wraps to the list's width instead of widening it. */
.plans [data-plan-hint] { width: 0; min-width: 100%; }
.plans li { padding: 3px 4px; border-radius: 6px; cursor: default; }
.plans li:hover { background: rgba(255, 255, 255, .08); }
.plans ol { margin: 0; padding: 0; list-style: none; overflow: auto; display: flex; flex-direction: column; gap: 3px; counter-reset: plan; }
.plans li { display: grid; grid-template-columns: 18px 1fr auto auto; align-items: center; gap: 6px; font-size: 12px; counter-increment: plan; }
.plans li::before { content: counter(plan); color: var(--muted); font: 11px 'Future', sans-serif; }
.plans li b { font: 12px 'Future', sans-serif; color: var(--gold); font-weight: normal; }
.plans li.done { opacity: .45; }
.plans li.placed b { color: var(--paper); }
.plans header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.plans li.next b { color: var(--paper); }
.plans .plan-tools { display: flex; gap: 2px; }
.plans .chip:disabled { opacity: .3; }
.plans li i { color: var(--good); font-style: normal; }
/* Drag to reorder: the dragged row fades, a gold line marks where it lands. */
.plans li[draggable="true"] { cursor: grab; }
.plans li.dragging { opacity: .35; }
.plans li.drop-before { box-shadow: inset 0 2px 0 var(--gold); }
.plans li.drop-after { box-shadow: inset 0 -2px 0 var(--gold); }
.plans .chip { padding: 0 6px; }
.plan-pin {
  position: fixed; left: 0; top: 0; pointer-events: none; white-space: nowrap;
  font: 11px 'Future', sans-serif; color: var(--gold); padding: 2px 7px; border-radius: 8px;
  background: rgba(16, 20, 32, .78); outline: 1px dashed rgba(255, 209, 102, .7);
}
/* Chess-style moves: the tower's piece letter (G, or G+ for an upgrade) as a tag before the square. */
.plans .move { font: 12px 'Future', sans-serif; }
.plans .piece { display: inline-block; min-width: 2.2em; margin-right: 4px; padding: 0 3px; border-radius: 4px; background: rgba(255, 255, 255, .14); color: var(--gold); font-style: normal; text-align: center; }
