/* ============ BASTION — The Last Unit · field-guide UI ============ */
@font-face {
  font-family: 'Patrick Hand';
  src: url('fonts/patrick-hand.woff2') format('woff2');
  font-display: swap;
}

:root {
  --forest: #2d4a22;
  --forest-deep: #16240f;
  --moss: #7ba05b;
  --gunmetal: #4a4f55;
  --sun: #f0c86e;
  --sun-hot: #ffd98a;
  --bark: #5b4632;
  --paper: #f2ead8;
  --danger: #d96a4a;
}

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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--forest-deep);
  font-family: 'Patrick Hand', 'Segoe Print', 'Comic Sans MS', cursive;
  color: var(--paper);
  -webkit-user-select: none; user-select: none;
  touch-action: none;
}

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.hidden { display: none !important; }

#loading-note {
  position: fixed; inset: auto 0 12vh 0; text-align: center;
  color: var(--moss); font-size: 20px; letter-spacing: 2px;
  animation: pulse 1.6s ease-in-out infinite;
  pointer-events: none; z-index: 5;
}
@keyframes pulse { 0%,100% { opacity: .35; } 50% { opacity: 1; } }

/* ==================== HUD ==================== */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }

#topbar {
  position: absolute; top: 14px; left: 18px; right: 18px;
  display: flex; justify-content: space-between; align-items: flex-start;
}
#wave-label { font-size: 22px; color: var(--sun); text-shadow: 0 2px 8px rgba(0,0,0,.7); }
#objective { font-size: 15px; color: rgba(242,234,216,.85); text-shadow: 0 1px 4px rgba(0,0,0,.8); }
#scorebox { text-align: right; }
#score { font-size: 30px; color: var(--paper); text-shadow: 0 2px 8px rgba(0,0,0,.8); line-height: 1; }
#streak {
  font-size: 17px; color: var(--sun-hot); margin-top: 2px;
  text-shadow: 0 0 12px rgba(255,217,138,.6), 0 2px 4px rgba(0,0,0,.8);
  animation: streakpop .25s ease;
}
@keyframes streakpop { 0% { transform: scale(1.5); } 100% { transform: scale(1); } }

#vitals { position: absolute; left: 18px; bottom: 16px; }
#healthbar {
  width: 240px; height: 22px; border: 2px solid rgba(242,234,216,.5);
  border-radius: 11px; background: rgba(10,16,6,.65); overflow: hidden; position: relative;
  margin-bottom: 8px;
}
#healthfill {
  height: 100%; width: 100%; border-radius: 9px;
  background: linear-gradient(90deg, #6f9c52, #a8c47a);
  transition: width .18s ease, background .3s ease;
}
#healthfill.low { background: linear-gradient(90deg, #b4502e, #d96a4a); }
#healthtext {
  position: absolute; inset: 0; text-align: center; font-size: 14px; line-height: 19px;
  color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.9);
}
#configs { display: flex; gap: 8px; }
.config {
  min-width: 74px; padding: 5px 9px 4px; text-align: center;
  border: 2px solid rgba(242,234,216,.28); border-radius: 9px;
  background: rgba(10,16,6,.6); position: relative; overflow: hidden;
  opacity: .75; transition: all .2s ease;
}
.config.active { border-color: var(--sun); opacity: 1; box-shadow: 0 0 14px rgba(240,200,110,.35); }
.config.transforming { border-color: var(--danger); animation: shake .12s linear infinite; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-2px); } 75% { transform: translateX(2px); } }
.cfg-key {
  display: inline-block; font-size: 12px; color: var(--forest-deep);
  background: rgba(242,234,216,.75); border-radius: 4px; padding: 0 5px; margin-right: 4px;
}
.cfg-name { font-size: 15px; }
.cfg-cd {
  position: absolute; left: 0; bottom: 0; width: 100%; height: 0%;
  background: rgba(217,106,74,.4); pointer-events: none;
}

#ganymede-line {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  max-width: 74vw; text-align: center;
  font-size: 18px; color: #ffe9b0; font-style: italic;
  text-shadow: 0 2px 6px rgba(0,0,0,.85);
  background: rgba(10,16,6,.45); border-radius: 12px; padding: 4px 16px;
  transition: opacity .5s ease;
}
#center-note {
  position: absolute; top: 22%; left: 50%; transform: translateX(-50%);
  font-size: 30px; color: var(--sun-hot); text-align: center; white-space: nowrap;
  text-shadow: 0 0 20px rgba(240,200,110,.4), 0 3px 8px rgba(0,0,0,.9);
  animation: notedrift 2.4s ease forwards;
}
@keyframes notedrift {
  0% { opacity: 0; transform: translateX(-50%) translateY(14px) scale(.9); }
  15% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-12px); }
}
#interact-prompt {
  position: absolute; bottom: 24%; left: 50%; transform: translateX(-50%);
  font-size: 19px; color: var(--paper);
  background: rgba(45,74,34,.8); border: 1.5px solid rgba(240,200,110,.55);
  border-radius: 10px; padding: 5px 16px;
  text-shadow: 0 1px 3px rgba(0,0,0,.7);
}
#interact-prompt b { color: var(--sun); }
#artillery-banner {
  position: absolute; top: 60px; left: 50%; transform: translateX(-50%);
  font-size: 20px; color: #ffb89a; letter-spacing: 1px;
  background: rgba(60,20,8,.6); border: 1.5px solid rgba(217,106,74,.6);
  border-radius: 10px; padding: 4px 18px;
  text-shadow: 0 1px 4px rgba(0,0,0,.8);
}

/* reticle */
#reticle { position: absolute; width: 34px; height: 34px; margin: -17px 0 0 -17px; pointer-events: none; }
.ret-dot { position: absolute; left: 15px; top: 15px; width: 4px; height: 4px; border-radius: 50%; background: var(--sun-hot); box-shadow: 0 0 6px rgba(255,217,138,.9); }
.ret-ring {
  position: absolute; inset: 0; border: 1.5px solid rgba(255,217,138,.85); border-radius: 50%;
  animation: retbreath 1.8s ease-in-out infinite;
}
@keyframes retbreath { 0%,100% { transform: scale(1); opacity: .9; } 50% { transform: scale(1.18); opacity: .5; } }

/* ==================== TOUCH UI ==================== */
#touch-ui { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
#joystick {
  position: absolute; left: 26px; bottom: 90px; width: 128px; height: 128px;
  border: 2px solid rgba(242,234,216,.35); border-radius: 50%;
  background: rgba(10,16,6,.35); pointer-events: auto;
}
#joy-knob {
  position: absolute; left: 39px; top: 39px; width: 50px; height: 50px;
  border-radius: 50%; background: rgba(240,200,110,.55);
  border: 2px solid rgba(242,234,216,.6);
}
#touch-buttons {
  position: absolute; right: 18px; bottom: 80px;
  display: flex; flex-direction: column; gap: 10px; align-items: flex-end;
  pointer-events: auto;
}
.tbtn {
  font-family: inherit; font-size: 16px; color: var(--paper);
  min-width: 88px; padding: 10px 14px; border-radius: 12px;
  border: 2px solid rgba(242,234,216,.4); background: rgba(10,16,6,.55);
}
.tbtn:active { background: rgba(240,200,110,.4); }
.tbtn.big { min-width: 104px; min-height: 64px; font-size: 20px; border-color: var(--sun); }

/* ==================== SCREENS ==================== */
#title-screen, .overlay-screen {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse at 50% 115%, rgba(240,200,110,.14), transparent 55%),
    linear-gradient(180deg, rgba(13,22,8,.88) 0%, rgba(22,36,15,.82) 55%, rgba(11,18,7,.92) 100%);
  backdrop-filter: blur(2px);
  overflow-y: auto;
}
.title-inner, .overlay-inner { text-align: center; max-width: 640px; padding: 6vh 24px; }
.field-tag {
  display: inline-block; font-size: 14px; letter-spacing: 3px; color: var(--moss);
  border: 1px solid rgba(123,160,91,.5); border-radius: 20px; padding: 3px 16px; margin-bottom: 18px;
}
h1 {
  font-size: clamp(54px, 11vw, 96px); letter-spacing: 14px; color: var(--sun);
  text-shadow: 0 0 34px rgba(240,200,110,.35), 0 4px 0 rgba(60,45,15,.9);
  font-weight: 400; margin-left: 14px;
}
h2 { font-size: clamp(34px, 6vw, 54px); color: var(--sun); font-weight: 400; margin-bottom: 14px; text-shadow: 0 3px 0 rgba(60,45,15,.9); }
.subtitle { font-size: clamp(19px, 3vw, 26px); color: var(--paper); letter-spacing: 6px; margin-bottom: 22px; }
.lore { font-size: clamp(15px, 2.2vw, 18px); line-height: 1.55; color: rgba(242,234,216,.9); margin-bottom: 26px; }
button {
  font-family: inherit; font-size: 22px; cursor: pointer;
  color: var(--forest-deep); background: linear-gradient(180deg, var(--sun-hot), var(--sun));
  border: none; border-radius: 14px; padding: 13px 38px;
  box-shadow: 0 4px 0 #8a6a2c, 0 8px 22px rgba(0,0,0,.5);
  transition: transform .12s ease, box-shadow .12s ease;
}
button:hover { transform: translateY(-2px); box-shadow: 0 6px 0 #8a6a2c, 0 12px 26px rgba(0,0,0,.5); }
button:active { transform: translateY(2px); box-shadow: 0 2px 0 #8a6a2c; }
.controls-grid {
  display: grid; grid-template-columns: auto auto; gap: 5px 18px; justify-content: center;
  margin-top: 30px; font-size: 16px; color: rgba(242,234,216,.85); text-align: left;
}
.controls-grid span:nth-child(odd) { color: var(--sun); text-align: right; }
.title-hint { margin-top: 22px; font-size: 15px; font-style: italic; color: rgba(123,160,91,.9); }
.ganymede-quote { font-size: 19px; font-style: italic; color: #ffe9b0; margin-bottom: 18px; }
.stats {
  display: grid; grid-template-columns: auto auto; gap: 4px 22px; justify-content: center;
  font-size: 17px; margin-bottom: 26px; text-align: left;
}
.stats span:nth-child(odd) { color: var(--moss); text-align: right; }
.stats span:nth-child(even) { color: var(--paper); }

@media (max-width: 700px) {
  #healthbar { width: 170px; }
  .config { min-width: 60px; padding: 4px 6px 3px; }
  .cfg-name { font-size: 13px; }
  #vitals { bottom: 12px; left: 12px; }
  #wave-label { font-size: 18px; }
  #score { font-size: 24px; }
  #ganymede-line { font-size: 15px; bottom: auto; top: 15%; max-width: 86vw; }
  #interact-prompt { bottom: 34%; }
  h1 { letter-spacing: 8px; margin-left: 8px; }
}
