/* Highground Tactics UI. Colours are variables: change them here to re-skin the whole interface. */
:root {
  --ink: #15121c;          /* outlines, darkest */
  --panel: rgba(26, 24, 38, .9);
  --paper: #f4ecdc;        /* text on dark */
  --muted: #b9b0c8;
  --btn: #e8dcc0;          /* light buttons */
  --accent: #f2c76b;       /* selected / primary */
  --blue: #4f8fe8;
  --red: #e0574a;
  --good: #6fdc84;
  --bad: #ff7a66;
  --radius: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1d2130; 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; }
.icon { width: 40px; height: 40px; padding: 0; display: inline-grid; place-items: center; }

/* loading */
#loading { position: fixed; inset: 0; display: grid; place-content: center; text-align: center; background: #1d2130; z-index: 30; }
#loading h1 { margin: 0 0 14px; font-size: 28px; }
#loading .bar { width: min(320px, 70vw); height: 10px; background: rgba(255,255,255,.12); 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(12,10,20,.1), rgba(12,10,20,.6)); overflow-y: auto; }
.menu-card { width: min(920px, 100%); background: var(--panel); border-radius: 18px; padding: 18px 18px 12px; box-shadow: 0 12px 40px rgba(0,0,0,.4); }
.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; }
#levels { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.lvl { text-align: left; padding: 10px; border-radius: var(--radius); background: #efe4cb; display: grid; gap: 4px; min-height: 124px; align-content: start; }
.lvl.done { background: #dcebd0; }
.lvl.locked { background: #6f6a7c; color: #3a3546; }
.lvl .num { font-weight: 900; font-size: 20px; }
.lvl .nm { font-weight: 700; }
.lvl .gl { font-size: 12px; color: #5b5266; }
.lvl.locked .gl { color: #3a3546; }
.lvl .team { display: flex; gap: 2px; }
.lvl .team img { width: 22px; height: 22px; }
.lvl .st { display: flex; align-items: center; gap: 1px; }
.lvl .st em { font-size: 11px; color: #6b6276; margin-left: 6px; font-style: normal; }
.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: 12px; color: var(--muted); flex-wrap: wrap; gap: 8px; }
.menu-foot .note { font-size: 12px; opacity: .8; }

/* 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, #goal, #round { background: var(--panel); padding: 8px 12px; border-radius: var(--radius); font-weight: 700; white-space: nowrap; }
#goal { color: var(--accent); display: inline-flex; align-items: center; gap: 6px; }
#goal svg { width: 18px; height: 18px; }
#round { font-variant-numeric: tabular-nums; color: var(--muted); }
.grow { flex: 1; pointer-events: none !important; }
.chip-btn { background: var(--panel); color: var(--paper); padding: 8px 12px; border-radius: var(--radius); font-weight: 700; display: inline-flex; align-items: center; gap: 4px; }
.chip-btn svg { width: 14px; height: 14px; }
.chip-btn.on { background: var(--accent); color: var(--ink); }

/* turn order */
#order { position: fixed; left: 50%; top: 60px; transform: translateX(-50%); display: flex; align-items: center; gap: 5px; z-index: 5; max-width: calc(100vw - 16px); overflow-x: auto; padding: 4px 6px; background: rgba(26,24,38,.65); border-radius: 30px; }
.tok { position: relative; width: 36px; height: 36px; flex: 0 0 auto; padding: 0; border-radius: 50%; background: #2c2940; border: 3px solid var(--blue); display: grid; place-items: center; overflow: hidden; }
.tok.enemy { border-color: var(--red); }
.tok.boss { border-color: #ffcf3a; box-shadow: 0 0 0 2px var(--red); }
.tok.vip { border-color: #ffd34a; }
.tok img { width: 24px; height: 24px; }
.tok i { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--good); }
.tok.enemy i { background: var(--bad); }
.tok.now { width: 46px; height: 46px; box-shadow: 0 0 0 3px var(--accent); }
.tok.now img { width: 30px; height: 30px; }
.tok.later { opacity: .55; }
#order .rd { font-weight: 900; color: var(--accent); padding: 0 4px 0 2px; font-variant-numeric: tabular-nums; }
#order .next { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; padding: 0 2px; }

/* unit card, tile info, hint */
#unit { position: fixed; left: 8px; bottom: calc(8px + var(--safe-b)); width: 250px; background: var(--panel); border-radius: 14px; padding: 9px 11px; z-index: 6; border-left: 5px solid var(--blue); }
#unit.enemy { border-left-color: var(--red); }
.uh { display: flex; gap: 8px; align-items: center; }
.uh img { width: 36px; height: 36px; }
.uh b { font-size: 15px; } .uh svg { width: 15px; height: 15px; color: #ffcf3a; }
.uh small { display: block; color: var(--muted); }
.hp { position: relative; height: 16px; background: rgba(255,255,255,.12); border-radius: 6px; overflow: hidden; margin: 7px 0 5px; }
.hp i { position: absolute; inset: 0 auto 0 0; background: var(--good); }
#unit.enemy .hp i { background: var(--bad); }
.hp span { position: relative; display: block; text-align: center; font-size: 11px; font-weight: 700; line-height: 16px; text-shadow: 0 1px 2px #000; }
.stats { display: flex; flex-wrap: wrap; gap: 3px 9px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.chip { display: inline-flex; align-items: center; gap: 2px; background: rgba(255,255,255,.1); border-radius: 8px; padding: 1px 7px 1px 2px; font-size: 12px; font-weight: 700; }
.chip img { width: 20px; height: 20px; }
#tile { position: fixed; right: 8px; bottom: calc(8px + var(--safe-b)); background: var(--panel); padding: 6px 10px; border-radius: 10px; color: var(--muted); font-size: 12px; z-index: 4; pointer-events: none; text-transform: capitalize; }
#hint { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(92px + var(--safe-b)); background: var(--panel); padding: 6px 12px; border-radius: 10px; max-width: min(640px, calc(100vw - 32px)); color: var(--paper); font-size: 13px; text-align: center; z-index: 4; pointer-events: none; }

/* skill bar */
#actions { position: fixed; left: 50%; bottom: calc(8px + var(--safe-b)); transform: translateX(-50%); display: flex; align-items: center; gap: 6px; background: var(--panel); padding: 6px; border-radius: 16px; z-index: 5; max-width: calc(100vw - 16px); }
#skills { display: flex; gap: 6px; }
.skill, .act { position: relative; width: 64px; height: 68px; padding: 3px 2px 2px; display: grid; grid-template-rows: 1fr auto; place-items: center; background: #ede2c8; }
.skill img { width: 38px; height: 38px; pointer-events: none; }
.skill small, .act small { font-weight: 700; font-size: 10.5px; white-space: nowrap; overflow: hidden; max-width: 60px; text-overflow: ellipsis; }
.skill.on { background: var(--accent); box-shadow: inset 0 0 0 2px var(--ink); }
.skill.off { opacity: .45; }
.skill .cd, .skill .key { position: absolute; top: 2px; right: 3px; font-size: 10px; min-width: 16px; height: 16px; line-height: 16px; border-radius: 8px; text-align: center; }
.skill .cd { background: var(--ink); color: var(--accent); }
.skill .key { color: rgba(0,0,0,.35); }
.act svg { width: 28px; height: 28px; }
.act.primary { background: var(--accent); }
.sep { width: 2px; align-self: stretch; background: rgba(255,255,255,.15); }

/* banner + toast */
#banner { position: fixed; left: 50%; top: 32%; transform: translate(-50%, -50%); font-size: 44px; font-weight: 900; color: var(--accent); text-shadow: 0 4px 0 var(--ink), 0 0 20px rgba(0,0,0,.6); z-index: 7; pointer-events: none; animation: ban 1.3s ease forwards; white-space: nowrap; }
#banner.bad { color: var(--bad); }
@keyframes ban { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.6); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); } 25% { transform: translate(-50%, -50%) scale(1); } 75% { opacity: 1; } 100% { opacity: 0; } }
#toast { position: fixed; left: 50%; top: 116px; transform: translateX(-50%); background: var(--bad); color: #fff; padding: 6px 14px; border-radius: 10px; font-weight: 700; z-index: 8; pointer-events: none; }

/* modal */
#modal { position: fixed; inset: 0; background: rgba(10,8,16,.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,.45); }
#modal h2 { margin: 0 0 6px; font-size: 24px; }
#modal h3 { margin: 12px 0 6px; font-size: 12px; 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; }
.kicker.bad { color: var(--bad); }
.goalbox { background: rgba(242,199,107,.15); color: var(--accent); border-radius: 10px; padding: 7px 10px; font-weight: 700; margin: 8px 0; }
.squad { display: flex; flex-wrap: wrap; gap: 6px; }
.sq { display: flex; align-items: center; gap: 4px; background: rgba(255,255,255,.07); border-radius: 10px; padding: 3px 9px 3px 3px; border-left: 4px solid var(--blue); font-size: 13px; }
.sq.enemy { border-left-color: var(--red); }
.sq.boss, .sq.vip { border-left-color: #ffcf3a; }
.sq img { width: 26px; height: 26px; }
.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; }
.checks { list-style: none; padding: 0; margin: 6px 0; }
.checks li { color: var(--muted); padding-left: 22px; position: relative; margin: 3px 0; }
.checks li::before { content: "○"; position: absolute; left: 2px; }
.checks li.ok { color: var(--paper); }
.checks li.ok::before { content: "✓"; color: var(--good); font-weight: 900; }

/* phones */
@media (max-width: 760px) {
  #lvl-name, #round { display: none; }
  #top { gap: 5px; flex-wrap: nowrap; }
  #goal { min-width: 0; overflow: hidden; } #goal span { overflow: hidden; text-overflow: ellipsis; }
  #goal, #round, .chip-btn { padding: 6px 9px; font-size: 12px; }
  #order { top: 54px; }
  .tok { width: 30px; height: 30px; } .tok img { width: 20px; height: 20px; }
  .tok.now { width: 38px; height: 38px; } .tok.now img { width: 26px; height: 26px; }
  #actions { left: 8px; right: 8px; transform: none; max-width: none; justify-content: center; }
  #skills { gap: 4px; }
  .skill, .act { width: 54px; height: 60px; } .skill img { width: 32px; height: 32px; }
  .skill small, .act small { font-size: 9.5px; max-width: 52px; }
  #unit { bottom: calc(84px + var(--safe-b)); width: 210px; padding: 7px 9px; }
  #unit .stats { display: none; }
  #tile { display: none; }
  #hint { bottom: auto; top: 112px; font-size: 12px; }
  .logo { font-size: 28px; }
  #levels { grid-template-columns: repeat(2, 1fr); }
}
@media (max-height: 520px) and (orientation: landscape) {
  .skill, .act { width: 50px; height: 52px; } .skill img { width: 28px; height: 28px; }
  #unit { bottom: calc(8px + var(--safe-b)); }
  #hint { display: none; }
}
