:root { --ink: #f3efe2; --dim: #a9a594; --panel: rgba(14, 18, 30, 0.86); --edge: #d8b56a; --hp: #7ed36b; --sp: #6bb7ff; --bad: #ff6b6b; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #10141f; color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif; user-select: none; -webkit-user-select: none; touch-action: none; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#ui { position: fixed; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }
.hidden { display: none !important; }
.panel { background: var(--panel); border: 2px solid var(--edge); border-radius: 10px; box-shadow: 0 6px 24px #0008; padding: 12px 16px; }

#hud { position: absolute; top: 12px; left: 16px; right: 16px; display: flex; justify-content: space-between; font-size: 15px;
  text-shadow: 0 2px 3px #000; pointer-events: none; }
#prompt { position: absolute; bottom: 30%; left: 50%; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--edge);
  padding: 6px 14px; border-radius: 20px; font-size: 14px; pointer-events: none; }
#toast { position: absolute; top: 48px; left: 50%; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--edge);
  padding: 8px 18px; border-radius: 8px; pointer-events: none; }

#dialog { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); width: min(760px, calc(100% - 32px)); min-height: 120px;
  background: var(--panel); border: 2px solid var(--edge); border-radius: 12px; padding: 14px 20px 22px; font-size: 18px; line-height: 1.45; }
#dialog-who { color: var(--edge); font-weight: bold; margin-bottom: 4px; font-size: 16px; }
#dialog-who:empty { display: none; }
#dialog-next { position: absolute; right: 16px; bottom: 6px; color: var(--edge); animation: bob 0.8s infinite alternate; }
#dialog-choices div, .menu-item { padding: 4px 10px; border-radius: 6px; cursor: pointer; }
.sel { background: #d8b56a33; outline: 1px solid var(--edge); }
@keyframes bob { from { transform: translateY(0) } to { transform: translateY(3px) } }

#menu { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(720px, calc(100% - 32px)); max-height: calc(100% - 64px); overflow: auto; }
#menu h2 { margin: 0 0 8px; color: var(--edge); font-size: 18px; }
.cols { display: flex; gap: 16px; flex-wrap: wrap; }
.cols > .side { min-width: 140px; }
.cols > .main { flex: 1; min-width: 240px; }
.member { border-bottom: 1px solid #fff2; padding: 6px 0; }
.bar { height: 7px; background: #0008; border-radius: 4px; overflow: hidden; margin: 2px 0 4px; }
.bar > i { display: block; height: 100%; background: var(--hp); }
.bar.sp > i { background: var(--sp); }
.small-txt { font-size: 13px; color: var(--dim); }
.seq { font-family: monospace; letter-spacing: 2px; color: var(--edge); }

#battle-party { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); display: flex; gap: 10px; flex-wrap: wrap; justify-content: center;
  width: calc(100% - 24px); pointer-events: none; }
#battle-party .pm { background: var(--panel); border: 1px solid #fff3; border-radius: 8px; padding: 6px 10px; width: 190px; font-size: 14px; }
#battle-party .pm.active { border-color: var(--edge); box-shadow: 0 0 10px #d8b56a88; }
#battle-party .pm.down { opacity: 0.5; }
#battle-cmd { position: absolute; left: 16px; bottom: 110px; min-width: 170px; }
#battle-string { position: absolute; left: 50%; bottom: 110px; transform: translateX(-50%); width: min(560px, calc(100% - 32px)); }
.slots { display: flex; gap: 6px; margin: 6px 0 10px; }
.slot { width: 44px; height: 44px; border: 2px solid #fff4; border-radius: 8px; display: grid; place-items: center; font-size: 24px; }
.slot.filled { border-color: var(--edge); background: #d8b56a22; }
.slot.tech { background: #6bb7ff33; border-color: var(--sp); }
.techs div { font-size: 14px; padding: 2px 0; }
.techs .ready { color: var(--ink); } .techs .nosp { color: var(--dim); } .techs .unknown { color: #777; }
.dpad { display: flex; gap: 6px; margin-top: 8px; }
.dpad button, #tbtns button { font: inherit; font-size: 20px; color: var(--ink); background: #ffffff18; border: 1px solid #fff5; border-radius: 10px;
  width: 52px; height: 52px; touch-action: none; }
#battle-log { position: absolute; top: 44px; left: 50%; transform: translateX(-50%); text-align: center; font-size: 18px; text-shadow: 0 2px 4px #000;
  pointer-events: none; min-height: 26px; }

#popups { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.pop { position: absolute; font-weight: bold; font-size: 26px; text-shadow: 0 2px 0 #000, 0 0 6px #000; transform: translate(-50%, -50%);
  animation: rise 1s ease-out forwards; }
.pop.heal { color: var(--hp); } .pop.tech { color: #ffd76b; font-size: 22px; } .pop.miss { color: var(--dim); font-size: 20px; }
@keyframes rise { from { opacity: 1; margin-top: 0 } to { opacity: 0; margin-top: -60px } }

#fade { position: absolute; inset: 0; background: #000; opacity: 0; transition: opacity 0.35s; pointer-events: none; }
#title { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, #2b3d5c99, #0b0e16ee); text-align: center; padding: 16px; }
#title h1 { font-size: clamp(48px, 12vw, 96px); margin: 0; letter-spacing: 6px; color: #f6dfa0; text-shadow: 0 4px 0 #6a4d1f, 0 0 30px #f6dfa066; }
#title .sub { color: var(--dim); margin: 6px 0 28px; font-style: italic; }
#title-menu { display: flex; flex-direction: column; gap: 6px; min-width: 220px; font-size: 20px; }
#title .keys { margin-top: 36px; font-size: 13px; color: var(--dim); max-width: 520px; }

#touch { position: fixed; inset: 0; pointer-events: none; }
#stick { position: absolute; left: 24px; bottom: 24px; width: 130px; height: 130px; border-radius: 50%; background: #ffffff10; border: 2px solid #fff3;
  pointer-events: auto; touch-action: none; }
#stick-knob { position: absolute; left: 40px; top: 40px; width: 50px; height: 50px; border-radius: 50%; background: #ffffff40; }
#tbtns { position: absolute; right: 20px; bottom: 28px; display: flex; gap: 12px; align-items: flex-end; pointer-events: auto; }
#tbtns button { width: 64px; height: 64px; border-radius: 50%; font-weight: bold; }
#tbtns button.small { width: 44px; height: 44px; font-size: 18px; }
@media (max-width: 640px) {
  #battle-party .pm { width: 150px; font-size: 12px; }
  #battle-cmd { bottom: 150px; }
  #battle-string { bottom: 150px; }
  #dialog { font-size: 16px; bottom: 170px; }
}
