/* Bastion Road Defense UI. Colours are variables: change them here to re-skin the whole interface. */
:root {
  --ink: #241a12;          /* outlines, dark panels */
  --panel: rgba(36, 26, 18, .9);
  --paper: #f6eedd;        /* text on dark */
  --muted: #cdbf9f;
  --btn: #e9d8b4;          /* light buttons */
  --accent: #f2c76b;       /* selected / primary */
  --good: #7bd66f;
  --bad: #ff7a66;
  --magic: #b9a2ff;
  --radius: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #24331f; color: var(--paper);
  font: 14px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
#game { position: fixed; inset: 0; touch-action: none; }
#game canvas { display: block; touch-action: none; }
[hidden] { display: none !important; }
button { font: inherit; color: var(--ink); background: var(--btn); border: 0; border-radius: 9px; padding: 6px 12px; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); font-weight: 700; }
button.danger { background: var(--bad); color: #fff; font-weight: 700; }
button.link { background: none; color: var(--muted); text-decoration: underline; padding: 4px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
svg .f { fill: currentColor; stroke: none; }
code { background: rgba(255,255,255,.1); padding: 0 4px; border-radius: 4px; font-size: 12px; }
.icon { width: 40px; height: 40px; padding: 0; display: inline-grid; place-items: center; }
.icon.small { width: 28px; height: 28px; font-size: 18px; }
.chip { display: inline-flex; align-items: center; gap: 2px; background: rgba(255,255,255,.1); border-radius: 8px; padding: 1px 7px 1px 2px; font-weight: 700; white-space: nowrap; }
.chip img { width: 26px; height: 26px; object-fit: contain; }
.row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 4px 0; }

/* loading */
#loading { position: fixed; inset: 0; display: grid; place-content: center; text-align: center; background: #24331f; z-index: 30; }
#loading h1 { margin: 0 0 14px; font-size: 28px; }
#loading .bar { width: min(320px, 70vw); height: 10px; background: rgba(0,0,0,.3); border-radius: 6px; overflow: hidden; margin: auto; }
#loading .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* level select */
#menu { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; z-index: 10; background: linear-gradient(180deg, rgba(20,14,10,.15), rgba(20,14,10,.55)); overflow-y: auto; }
.menu-card { width: min(900px, 100%); background: var(--panel); border-radius: 18px; padding: 18px 18px 12px; box-shadow: 0 12px 40px rgba(0,0,0,.35); }
.logo { font-weight: 900; font-size: 34px; line-height: 1; letter-spacing: .5px; text-shadow: 0 3px 0 var(--ink); }
.logo span { color: var(--accent); margin-right: 8px; }
.sub { color: var(--muted); margin: 6px 0 14px; }
.note { color: var(--muted); font-size: 12px; margin: 12px 0 0; }
#levels { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 10px; }
.lvl { text-align: left; padding: 10px; border-radius: var(--radius); background: #f3e6c8; display: grid; gap: 4px; min-height: 112px; align-content: start; }
.lvl.done { background: #e4f0cf; }
.lvl.locked { background: #8d7f68; color: #4a3f31; }
.lvl.locked img { filter: grayscale(1) opacity(.5); }
.lvl .num { font-weight: 900; font-size: 20px; }
.lvl .nm { font-weight: 700; }
.lvl .gl { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; font-size: 12px; }
.lvl .gl img { width: 22px; height: 22px; object-fit: contain; }
.lvl .gl span { margin-left: 4px; opacity: .75; }
.lvl .st i svg, .bigstars i svg { color: rgba(0,0,0,.18); }
.lvl .st i.on svg, .bigstars i.on svg { color: #f2a93b; }
.lvl .st svg { width: 16px; height: 16px; }
.menu-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; color: var(--muted); flex-wrap: wrap; gap: 8px; }

/* top bar */
#top { position: fixed; left: 8px; right: 8px; top: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; pointer-events: none; z-index: 5; }
#top > * { pointer-events: auto; }
#lvl-name, .stat { background: var(--panel); padding: 6px 12px; border-radius: var(--radius); font-weight: 700; white-space: nowrap; }
.stat { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; font-size: 16px; padding: 4px 12px 4px 6px; }
.stat img { width: 28px; height: 28px; }
#gold b { color: var(--accent); }
#lives.low { animation: blink 1s infinite; }
@keyframes blink { 50% { background: rgba(160, 40, 30, .9); } }
.grow { flex: 1; pointer-events: none !important; }
#speed { display: flex; background: var(--panel); border-radius: var(--radius); padding: 4px; gap: 4px; }
#speed .sp { padding: 4px 8px; background: transparent; color: var(--paper); display: inline-flex; align-items: center; gap: 2px; }
#speed .sp svg { width: 16px; height: 16px; }
#speed .sp.on { background: var(--accent); color: var(--ink); }

/* wave bar */
#wavebar { position: fixed; left: 50%; bottom: calc(8px + var(--safe-b)); transform: translateX(-50%); display: flex; align-items: center; gap: 10px; background: var(--panel); padding: 6px 6px 6px 12px; border-radius: 16px; max-width: calc(100vw - 16px); z-index: 5; }
#wave-next { display: grid; gap: 2px; min-width: 0; }
#wave-next small { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
#wave-chips { display: flex; gap: 4px; flex-wrap: wrap; }
#btn-wave { padding: 10px 16px; font-size: 15px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
#btn-wave em { font-style: normal; color: #7a4a00; }
#btn-wave small { opacity: .7; font-weight: 600; }
#btn-wave.pulse { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(242, 199, 107, .35); } }
.gtag { position: fixed; display: flex; gap: 3px; background: var(--panel); border: 2px solid var(--accent); border-radius: 10px; padding: 3px 4px; z-index: 4; pointer-events: none; }
.gtag .chip { background: none; padding: 0 3px 0 0; font-size: 12px; }
.gtag .chip img { width: 22px; height: 22px; }

#toast { position: fixed; left: 50%; top: 64px; transform: translateX(-50%); background: var(--bad); color: #fff; padding: 6px 14px; border-radius: 10px; font-weight: 700; z-index: 8; pointer-events: none; }
#banner { position: fixed; left: 50%; top: 22%; transform: translateX(-50%); font-size: 30px; font-weight: 900; color: var(--paper); text-shadow: 0 3px 0 var(--ink), 0 0 18px rgba(0,0,0,.5); z-index: 7; pointer-events: none; white-space: nowrap; }
#banner em { font-style: normal; color: var(--accent); font-size: 20px; }
#banner.show { animation: drop 1.9s ease-out forwards; }
@keyframes drop { 0% { opacity: 0; transform: translate(-50%, -20px); } 15% { opacity: 1; transform: translate(-50%, 0); } 80% { opacity: 1; } 100% { opacity: 0; } }

/* build menu (follows its pad) */
#build { position: fixed; display: grid; grid-template-columns: repeat(4, auto); gap: 6px; background: var(--panel); padding: 8px; border-radius: 14px; z-index: 6; box-shadow: 0 6px 20px rgba(0,0,0,.35); max-width: calc(100vw - 16px); }
#build .bt { width: 80px; padding: 4px 2px 5px; display: grid; justify-items: center; gap: 1px; background: #f3e6c8; }
#build .bt > img { height: 54px; width: 70px; object-fit: contain; object-position: bottom; }
#build .bt b { font-size: 11px; line-height: 1.1; }
#build .bt small { display: inline-flex; align-items: center; gap: 2px; font-weight: 800; }
#build .bt small img { width: 16px; height: 16px; }
#build .bt.poor { opacity: .55; }
#build .bt.poor small { color: #b5402c; }
#build .binfo { grid-column: 1 / -1; color: var(--muted); font-size: 12px; max-width: 340px; text-align: center; }

/* tower panel */
#panel { position: fixed; right: 8px; top: 64px; width: 280px; max-width: calc(100vw - 16px); background: var(--panel); border-radius: 14px; padding: 10px 12px; z-index: 6; }
.ph { display: flex; justify-content: space-between; align-items: center; font-size: 16px; }
.ph b { display: inline-flex; align-items: center; gap: 6px; }
.ph b img { width: 28px; height: 28px; }
.ph .lv { color: var(--accent); font-size: 14px; letter-spacing: 1px; }
#panel-body p { margin: 4px 0 6px; color: var(--muted); font-size: 13px; }
.kv { display: flex; gap: 6px; align-items: baseline; font-size: 13px; padding: 2px 0; border-bottom: 1px solid rgba(255,255,255,.06); }
.kv span { flex: 1; color: var(--muted); }
.kv em { color: var(--good); font-style: normal; font-weight: 700; font-size: 12px; }
.kv.muted b { color: var(--muted); }
#panel-modes { display: flex; align-items: center; gap: 4px; margin-top: 8px; flex-wrap: wrap; }
#panel-modes label { color: var(--muted); font-size: 12px; margin-right: 2px; }
#panel-modes button { font-size: 12px; padding: 3px 8px; }
#panel-modes button.on { background: var(--accent); box-shadow: inset 0 0 0 2px var(--ink); font-weight: 700; }
#panel-acts { display: flex; gap: 6px; margin-top: 10px; }
#panel-acts .act { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 4px; font-size: 13px; padding: 8px 6px; }
#panel-acts .act img { width: 20px; height: 20px; }
#panel-acts .act small { display: inline-flex; align-items: center; gap: 1px; font-weight: 800; }
#panel-acts .act small img { width: 15px; height: 15px; }
#panel-acts .act.poor { opacity: .6; }

/* modal */
#modal { position: fixed; inset: 0; background: rgba(15,10,7,.55); display: grid; place-items: center; padding: 16px; z-index: 20; }
#modal .card { background: var(--panel); border-radius: 18px; padding: 18px 20px; width: min(460px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; box-shadow: 0 12px 40px rgba(0,0,0,.4); }
#modal h2 { margin: 0 0 6px; font-size: 24px; }
#modal h3 { margin: 12px 0 6px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
#modal p { color: var(--muted); margin: 6px 0; }
#modal .small { font-size: 12px; }
.kicker { color: var(--accent); font-weight: 700; text-transform: uppercase; letter-spacing: 1px; font-size: 12px; }
.foes { display: grid; gap: 4px; }
.foes div { display: grid; grid-template-columns: 40px auto; column-gap: 8px; align-items: center; background: rgba(255,255,255,.06); border-radius: 10px; padding: 3px 8px 3px 4px; }
.foes img { width: 40px; height: 40px; object-fit: contain; grid-row: span 2; }
.foes small { color: var(--muted); font-size: 12px; }
.tips { margin: 10px 0 0; padding-left: 20px; color: var(--paper); }
.tips li { margin: 4px 0; }
details { margin-top: 10px; color: var(--muted); }
.btns { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.btns button { padding: 9px 16px; }
.bigstars { display: flex; gap: 6px; justify-content: center; margin: 10px 0; }
.bigstars svg { width: 54px; height: 54px; }
.card.lose h2 { color: var(--bad); }

/* phones */
@media (max-width: 700px) {
  #lvl-name { display: none; }
  #top { gap: 5px; }
  .stat { font-size: 14px; padding: 3px 9px 3px 4px; gap: 4px; }
  .stat img { width: 22px; height: 22px; }
  #speed .sp svg { display: none; }
  #speed .sp[data-s="0"] svg { display: inline; }
  #speed .sp { padding: 4px 7px; font-size: 13px; }
  #wavebar { left: 8px; right: 8px; transform: none; max-width: none; justify-content: space-between; }
  #btn-wave { padding: 9px 12px; font-size: 14px; }
  .chip img { width: 22px; height: 22px; }
  #build { grid-template-columns: repeat(4, 1fr); }
  #build .bt { width: auto; min-width: 66px; }
  #build .bt > img { height: 44px; width: 58px; }
  #panel { left: 8px; right: 8px; width: auto; top: auto; bottom: calc(76px + var(--safe-b)); }
  #panel-body p { display: none; }
  #banner { font-size: 24px; }
  .logo { font-size: 28px; }
  #levels { grid-template-columns: repeat(2, 1fr); }
}
@media (max-height: 480px) and (orientation: landscape) {
  #panel { top: 56px; bottom: auto; max-height: calc(100vh - 120px); overflow-y: auto; }
  #panel-body p { display: none; }
}
