:root {
  --ink: #173f4a;
  --cream: #fff5d6;
  --yellow: #ffd166;
  --coral: #e76f5d;
  --mint: #78c6a3;
  --paper: #fffaf0;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: #0c2730;
  color: var(--ink);
  font-family: ui-monospace, "SFMono-Regular", "Yu Gothic", "Hiragino Kaku Gothic ProN", monospace;
  overscroll-behavior: none;
}
button, input { font: inherit; }
button { touch-action: manipulation; }

.entry-shell {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 22px;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 209, 102, .23), transparent 28%),
    radial-gradient(circle at 85% 80%, rgba(120, 198, 163, .25), transparent 30%),
    linear-gradient(145deg, #163c47 0%, #0d2c36 55%, #10262e 100%);
  position: relative;
}
.entry-shell::before, .entry-shell::after {
  content: "";
  position: absolute;
  width: 280px;
  height: 280px;
  border: 2px dashed rgba(255,255,255,.08);
  transform: rotate(18deg);
}
.entry-shell::before { left: -170px; top: -110px; }
.entry-shell::after { right: -160px; bottom: -120px; }

.entry-card {
  width: min(440px, 100%);
  position: relative;
  z-index: 1;
  background: var(--paper);
  border: 4px solid var(--ink);
  box-shadow: 9px 9px 0 rgba(0,0,0,.28), inset 0 0 0 3px #e6d6ad;
  padding: 28px;
}
.eyebrow { font-size: 10px; letter-spacing: .18em; font-weight: 900; color: #628084; }
.entry-card h1, .game-header h1 {
  margin: 5px 0 0;
  color: var(--ink);
  font-size: clamp(36px, 10vw, 54px);
  line-height: 1;
  letter-spacing: -.08em;
  font-weight: 1000;
  text-shadow: 3px 3px 0 #a6d9c2;
}
.entry-card h1 span, .game-header h1 span { color: var(--coral); }
.tagline { margin: 12px 0 18px; font-size: 12px; line-height: 1.7; font-weight: 800; }

.entry-map-preview {
  height: 105px;
  position: relative;
  overflow: hidden;
  border: 3px solid var(--ink);
  background-color: #8fc180;
  background-image: linear-gradient(rgba(255,255,255,.07) 50%, transparent 50%), linear-gradient(90deg, rgba(255,255,255,.07) 50%, transparent 50%);
  background-size: 22px 22px;
  image-rendering: pixelated;
}
.preview-road { position: absolute; left: 0; right: 0; bottom: 12px; height: 33px; background: #737779; border-block: 4px solid #54595b; }
.preview-road::after { content: ""; position: absolute; left: 0; right: 0; top: 13px; border-top: 3px dashed #e8d37a; }
.preview-shop { position: absolute; left: 18px; top: 12px; width: 98px; height: 55px; padding-top: 19px; text-align: center; background: #f1d69d; border: 4px solid #4e4350; border-top: 15px solid #dc675f; font-size: 8px; font-weight: 1000; line-height: 1; }
.preview-tree { position: absolute; width: 23px; height: 27px; background: #3f8d68; border: 5px solid #286a57; top: 20px; }
.preview-tree::after { content: ""; position: absolute; width: 6px; height: 18px; background: #76533b; left: 4px; top: 19px; }
.tree-one { right: 32px; }
.tree-two { right: 72px; top: 13px; }
.preview-character { position: absolute; left: 54%; bottom: 19px; width: 20px; height: 45px; background: #e66d5b; border: 3px solid #743f50; }
.preview-character::before { content: ""; position: absolute; left: 1px; top: -17px; width: 13px; height: 16px; background: #f0bd8b; border: 3px solid #432f36; }
.preview-character i, .preview-character b { position: absolute; bottom: -7px; width: 6px; height: 9px; background: #36435a; }
.preview-character i { left: 1px; }
.preview-character b { right: 1px; }

.field-label, .palette-field legend { font-size: 11px; font-weight: 900; letter-spacing: .08em; }
.field-label { display: block; margin: 19px 0 7px; }
.name-input {
  width: 100%;
  min-height: 48px;
  border: 3px solid var(--ink);
  border-radius: 0;
  background: white;
  padding: 8px 12px;
  font-size: 17px;
  font-weight: 900;
  outline: none;
}
.name-input:focus { box-shadow: 0 0 0 4px rgba(255, 209, 102, .7); }
.palette-field { border: 0; margin: 14px 0 16px; padding: 0; }
.palette-list { display: flex; gap: 10px; margin-top: 8px; }
.palette-choice { width: 32px; height: 32px; padding: 0; border: 3px solid var(--ink); background: var(--swatch); box-shadow: 3px 3px 0 #b9ad93; cursor: pointer; }
.palette-choice.selected { transform: translate(2px,2px); box-shadow: 0 0 0 3px var(--yellow); }
.enter-button {
  width: 100%;
  min-height: 52px;
  border: 3px solid var(--ink);
  background: var(--yellow);
  color: var(--ink);
  font-size: 14px;
  font-weight: 1000;
  box-shadow: 4px 4px 0 var(--ink);
  cursor: pointer;
}
.enter-button:active { transform: translate(3px,3px); box-shadow: 1px 1px 0 var(--ink); }
.enter-button:disabled { opacity: .6; }
.entry-note { text-align: center; font-size: 9px; color: #627477; margin: 14px 0 0; }

.game-shell {
  width: min(760px, 100%);
  min-height: 100svh;
  margin: 0 auto;
  background: #f5e9c8;
  display: flex;
  flex-direction: column;
  border-inline: 3px solid #081d24;
  box-shadow: 0 0 60px rgba(0,0,0,.4);
}
.game-header {
  min-height: 66px;
  padding: 9px 14px;
  background: #fff8df;
  border-bottom: 4px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.game-header p { margin: 0 0 1px; font-size: 7px; font-weight: 1000; letter-spacing: .15em; color: #728184; }
.game-header h1 { margin: 0; font-size: 28px; text-shadow: 2px 2px 0 #a6d9c2; }
.room-status { display: flex; align-items: center; gap: 8px; border-left: 2px solid #d8cba7; padding-left: 12px; }
.room-status div { display: flex; flex-direction: column; }
.room-status b { font-size: 11px; }
.room-status small { font-size: 8px; color: #63777b; }
.status-light { width: 10px; height: 10px; border-radius: 50%; background: #c66c66; box-shadow: 0 0 0 3px #e8c8b8; }
.status-light.online { background: #43b77b; box-shadow: 0 0 0 3px #bce3bd, 0 0 8px #43b77b; }

.game-stage { position: relative; width: 100%; background: #203a42; overflow: hidden; border-bottom: 4px solid var(--ink); }
.game-canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; image-rendering: crisp-edges; }
.location-ribbon { position: absolute; z-index: 3; top: 8px; left: 8px; background: rgba(24,54,63,.92); color: #fff4cf; border: 2px solid #fff4cf; padding: 5px 9px; font-size: 9px; font-weight: 900; box-shadow: 3px 3px 0 rgba(0,0,0,.3); }
.join-notice { position: absolute; z-index: 4; top: 46px; left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 30px); background: #fff6d4; color: var(--ink); border: 3px solid var(--ink); padding: 7px 12px; font-size: 10px; font-weight: 1000; box-shadow: 4px 4px 0 rgba(0,0,0,.34); animation: notice-in .25s steps(3) both; }
@keyframes notice-in { from { opacity: 0; transform: translate(-50%, -8px); } }
.quest-chip { position: absolute; z-index: 3; right: 8px; bottom: 8px; background: rgba(255,248,223,.92); border: 2px solid var(--ink); padding: 5px 8px; font-size: 8px; font-weight: 900; box-shadow: 3px 3px 0 rgba(0,0,0,.25); }
.quest-chip span { display: inline-grid; place-items: center; width: 15px; height: 15px; margin-right: 3px; background: var(--coral); color: white; border-radius: 50%; }

.message-box {
  min-height: 122px;
  margin: 8px 10px 0;
  padding: 10px 12px 10px 30px;
  position: relative;
  background: #173f4a;
  color: #fff6d7;
  border: 3px solid #f8e4a9;
  outline: 3px solid #173f4a;
  box-shadow: 4px 4px 0 #9c8b69;
  font-size: 11px;
  line-height: 1.7;
  font-weight: 800;
}
.message-box p { margin: 0; }
.message-caret { position: absolute; left: 10px; top: 12px; color: var(--yellow); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .25; } }

.mobile-controls {
  min-height: 176px;
  padding: 14px 22px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(90deg, transparent 49%, rgba(23,63,74,.07) 50%, transparent 51%), #eadbb7;
}
.dpad { width: 132px; height: 132px; position: relative; filter: drop-shadow(4px 5px 0 rgba(45,54,55,.28)); }
.dpad button, .dpad-center { position: absolute; width: 44px; height: 44px; border: 0; background: #263e47; color: #f4dd9d; font-size: 13px; font-weight: 1000; }
.dpad button:active { background: #e76f5d; transform: translateY(2px); }
.dpad-up { left: 44px; top: 0; }
.dpad-left { left: 0; top: 44px; }
.dpad-center { left: 44px; top: 44px; }
.dpad-center::after { content: ""; position: absolute; inset: 15px; border-radius: 50%; background: #183039; }
.dpad-right { right: 0; top: 44px; }
.dpad-down { left: 44px; bottom: 0; }
.action-pad { display: flex; align-items: center; gap: 17px; padding-right: 4px; }
.a-button { width: 82px; height: 82px; border: 4px solid #792f37; border-radius: 50%; background: var(--coral); color: #fff4d6; box-shadow: 4px 6px 0 #682d35; font-weight: 1000; }
.a-button span { display: block; font-size: 30px; line-height: .9; }
.a-button small { font-size: 8px; }
.a-button:active { transform: translateY(4px); box-shadow: 2px 2px 0 #682d35; }
.menu-button { border: 3px solid var(--ink); background: #f9e39d; color: var(--ink); padding: 7px 9px; font-size: 8px; font-weight: 1000; box-shadow: 3px 3px 0 #8e815f; transform: rotate(-8deg); }
.prototype-footer { margin-top: auto; padding: 7px 11px; background: #173f4a; color: #c4dbd4; display: flex; justify-content: space-between; gap: 10px; font-size: 7px; letter-spacing: .08em; }

.menu-backdrop { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 22px; background: rgba(8,29,36,.78); backdrop-filter: blur(3px); }
.player-menu { width: min(370px, 100%); position: relative; background: #fff8df; border: 4px solid var(--ink); outline: 3px solid #f2d489; padding: 25px; box-shadow: 9px 9px 0 rgba(0,0,0,.35); }
.menu-close { position: absolute; top: 9px; right: 9px; width: 32px; height: 32px; border: 3px solid var(--ink); background: var(--coral); color: white; font-size: 18px; font-weight: 1000; }
.menu-kicker { margin: 0; font-size: 9px; color: #6c7c7d; font-weight: 900; letter-spacing: .15em; }
.player-menu h2 { margin: 5px 0 18px; font-size: 28px; }
.player-menu dl { margin: 0; border: 3px solid var(--ink); }
.player-menu dl div { display: grid; grid-template-columns: 42% 58%; border-bottom: 2px solid var(--ink); }
.player-menu dl div:last-child { border-bottom: 0; }
.player-menu dt, .player-menu dd { margin: 0; padding: 8px 10px; font-size: 11px; }
.player-menu dt { background: #d8e7d7; font-weight: 900; border-right: 2px solid var(--ink); }
.menu-note { margin: 14px 0 0; font-size: 9px; color: #68777a; }

@media (min-width: 760px) {
  .game-shell { min-height: 100vh; }
  .game-stage { max-height: 500px; }
  .mobile-controls { min-height: 154px; }
}
@media (max-width: 480px) {
  .entry-card { padding: 22px; }
  .game-shell { border: 0; }
  .game-header { min-height: 58px; padding: 7px 10px; }
  .game-header h1 { font-size: 24px; }
  .game-stage { min-height: 0; }
  .message-box { min-height: 114px; font-size: 10px; }
  .mobile-controls { min-height: 164px; padding: 10px 16px; }
  .dpad { transform: scale(.88); transform-origin: left center; }
  .action-pad { gap: 10px; }
  .a-button { width: 72px; height: 72px; }
  .prototype-footer span:last-child { display: none; }
}
@media (max-height: 700px) and (orientation: landscape) {
  .game-shell { width: 100%; min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) 225px; grid-template-rows: 56px minmax(0, 1fr) 50px; }
  .game-header { grid-column: 1 / -1; }
  .game-stage { grid-column: 1; grid-row: 2 / 4; }
  .message-box { grid-column: 2; grid-row: 2; margin: 8px; align-self: start; }
  .mobile-controls { grid-column: 2; grid-row: 3; min-height: 0; padding: 3px 12px; }
  .dpad { transform: scale(.45); transform-origin: left center; width: 65px; height: 65px; }
  .a-button { width: 52px; height: 52px; }
  .a-button span { font-size: 20px; }
  .menu-button, .prototype-footer { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

.b-button { width: 62px; height: 62px; border: 4px solid #263e47; border-radius: 50%; background: #f4dd9d; color: #263e47; box-shadow: 4px 6px 0 #8e815f; font-weight: 1000; }
.b-button span { display: block; font-size: 23px; line-height: .9; }
.b-button small { font-size: 7px; }
.b-button:active { transform: translateY(4px); box-shadow: 2px 2px 0 #8e815f; }
.a-button small { display: block; line-height: 1.1; max-width: 62px; margin: 3px auto 0; }

/* ===== BUILD 03: 黒×金コントローラー / STATUS ===== */
.entry-map-preview {
  background-image: url('/town-map.png?v=20260821-current');
  background-size: cover;
  background-position: 52% 78%;
}
.entry-map-preview > * { display: none; }

.premium-controls {
  min-height: 190px;
  display: grid;
  grid-template-columns: 154px 1fr 178px;
  align-items: center;
  gap: 8px;
  padding: 15px 20px;
  position: relative;
  background:
    linear-gradient(180deg, rgba(255,255,255,.035), transparent 28%),
    radial-gradient(circle at 50% 50%, #232323 0%, #111 55%, #070707 100%);
  border-top: 2px solid #8f6b2f;
  border-bottom: 2px solid #503819;
  box-shadow: inset 0 1px 0 #d0a35b, inset 0 -1px 0 #1d140a;
}
.premium-controls::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .14;
  pointer-events: none;
  background-image: repeating-radial-gradient(ellipse at 20% 20%, #fff 0 1px, transparent 1px 5px);
  mix-blend-mode: soft-light;
}
.premium-dpad {
  width: 138px;
  height: 138px;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 5px 5px rgba(0,0,0,.65));
}
.premium-dpad button, .premium-dpad i {
  position: absolute;
  width: 46px;
  height: 46px;
  border: 1px solid #c49348;
  background: linear-gradient(#333, #141414 58%, #090909);
  color: #e5bc73;
  display: grid;
  place-items: center;
  font-style: normal;
  font-size: 17px;
  text-shadow: 0 1px 1px #000;
  box-shadow: inset 0 0 0 2px #080808, inset 0 1px 0 rgba(255,255,255,.18);
}
.premium-dpad button:active { transform: translateY(2px); filter: brightness(1.35); }
.premium-dpad .pd-up { left: 46px; top: 0; border-radius: 8px 8px 0 0; }
.premium-dpad .pd-left { left: 0; top: 46px; border-radius: 8px 0 0 8px; }
.premium-dpad i { left: 46px; top: 46px; border-color: #4d3a20; }
.premium-dpad i::after { content: ""; width: 18px; height: 18px; border-radius: 50%; background: #050505; box-shadow: inset 0 1px 3px #000, 0 1px 0 #555; }
.premium-dpad .pd-right { left: 92px; top: 46px; border-radius: 0 8px 8px 0; }
.premium-dpad .pd-down { left: 46px; top: 92px; border-radius: 0 0 8px 8px; }
.status-button {
  z-index: 1;
  justify-self: center;
  width: 68px;
  height: 34px;
  border: 2px solid #c49348;
  border-radius: 17px;
  background: linear-gradient(#2e2e2e,#080808);
  color: #e8c77d;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .08em;
  box-shadow: inset 0 0 0 2px #050505, 0 4px 6px rgba(0,0,0,.5);
}
.status-button:active { transform: translateY(2px); }
.abxy-pad {
  width: 168px;
  height: 150px;
  position: relative;
  z-index: 1;
  justify-self: end;
}
.face-button {
  position: absolute;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: 2px solid #d3a24c;
  background: radial-gradient(circle at 38% 25%, #444 0%, #161616 38%, #050505 72%);
  color: #e9c47c;
  font-size: 25px;
  font-weight: 500;
  text-shadow: 0 2px 2px #000;
  box-shadow: inset 0 0 0 3px #050505, inset 0 0 0 4px #8d6b35, 0 5px 9px rgba(0,0,0,.7);
}
.face-button:active { transform: translateY(3px); filter: brightness(1.3); }
.face-top { left: 54px; top: 0; }
.face-left { left: 0; top: 44px; }
.face-right { right: 0; top: 44px; }
.face-bottom { left: 54px; bottom: 0; }

.status-backdrop {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0,0,0,.84);
}
.status-panel {
  width: min(520px, 100%);
  position: relative;
  color: #fff;
  background: #050505;
  border: 3px solid #fff;
  outline: 4px solid #050505;
  padding: 18px;
  font-family: ui-monospace, "Yu Gothic", monospace;
  box-shadow: 0 0 0 6px #fff, 10px 12px 0 rgba(0,0,0,.45);
}
.status-panel h2 { margin: 0 0 12px; text-align: center; font-size: 18px; letter-spacing: .18em; }
.status-name { border: 2px solid #fff; padding: 9px 12px; margin-bottom: 10px; font-size: 18px; font-weight: 900; }
.status-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.status-columns dl { margin: 0; border: 2px solid #fff; padding: 6px 9px; }
.status-columns dl div { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-size: 11px; }
.status-columns dt { color: #d9d9d9; }
.status-columns dd { margin: 0; font-weight: 900; }
.status-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.status-cards div { border: 2px solid #fff; padding: 8px 11px; display: flex; justify-content: space-between; }
.status-cards span { font-weight: 900; }
.status-close { position: absolute; right: 8px; top: 8px; width: 30px; height: 30px; border: 2px solid #fff; background: #050505; color: #fff; font-weight: 900; }

@media (max-width: 520px) {
  .premium-controls { min-height: 164px; grid-template-columns: 118px 1fr 138px; padding: 10px; gap: 3px; }
  .premium-dpad { transform: scale(.78); transform-origin: left center; width: 108px; height: 108px; }
  .abxy-pad { transform: scale(.78); transform-origin: right center; width: 132px; height: 118px; }
  .status-button { width: 56px; height: 30px; font-size: 7px; }
  .status-columns { grid-template-columns: 1fr; }
}

/* ABXYは前回指定どおり4ボタンとも従来比約1.2倍。 */
.abxy-pad { width: 184px; height: 166px; }
.face-button { width: 72px; height: 72px; font-size: 29px; }
.face-top { left: 56px; top: 0; }
.face-left { left: 0; top: 47px; }
.face-right { right: 0; top: 47px; }
.face-bottom { left: 56px; bottom: 0; }
@media (max-width: 520px) {
  .abxy-pad { width: 144px; height: 130px; }
}


.entry-card-gamepad {
  width: min(980px, 100%);
  min-height: min(56vw, 540px);
  padding: 0;
  border: 0;
  box-shadow: 0 18px 50px rgba(0,0,0,.45);
  background: url("/login-screen.png") center center / cover no-repeat;
  overflow: hidden;
}
.entry-overlay {
  width: min(360px, calc(100% - 24px));
  margin: 28px;
  padding: 24px;
  background: rgba(12, 12, 16, 0.72);
  border: 2px solid rgba(255, 214, 140, 0.8);
  box-shadow: 0 10px 24px rgba(0,0,0,.45);
  color: #f6e2b2;
  backdrop-filter: blur(4px);
}
.entry-card-gamepad h1 { color: #fff3cf; text-shadow: 0 0 10px rgba(255, 209, 102, .22); }
.entry-card-gamepad .eyebrow,
.entry-card-gamepad .tagline,
.entry-card-gamepad .field-label,
.entry-card-gamepad .entry-note { color: #ecd7a5; }
.entry-card-gamepad .name-input {
  background: rgba(255,255,255,.95);
  border-color: #3a2e22;
  color: #23160f;
}
.entry-card-gamepad .enter-button {
  margin-top: 14px;
  background: linear-gradient(180deg, #f7d48a 0%, #c89643 100%);
  color: #2b2016;
  border-color: #594224;
  box-shadow: 3px 3px 0 rgba(0,0,0,.45);
}
@media (max-width: 900px) {
  .entry-card-gamepad { min-height: 72vw; background-position: center; }
  .entry-overlay { margin: 14px; padding: 16px; width: min(340px, calc(100% - 18px)); }
}


/* ===== BUILD 11: login1 / cont1 ===== */
.login1-shell {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 12px;
  background: #020812;
}
.login1-frame {
  position: relative;
  width: min(619px, 100%);
  aspect-ratio: 619 / 617;
  overflow: hidden;
  box-shadow: 0 18px 60px rgba(0,0,0,.65);
}
.login1-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  pointer-events: none;
}
.login1-name-input {
  position: absolute;
  left: 21.75%;
  top: 64.65%;
  width: 58.25%;
  height: 7.55%;
  padding: 0 2.2%;
  border: 1px solid rgba(128,160,180,.9);
  outline: 1px solid rgba(230,244,250,.72);
  background: rgba(240,245,247,.98);
  color: #21313c;
  font-size: clamp(13px, 2.5vw, 18px);
  font-weight: 800;
  box-shadow: inset 0 0 8px rgba(30,60,80,.12);
}
.login1-name-input:focus {
  box-shadow: 0 0 0 2px rgba(120,200,255,.85), 0 0 18px rgba(80,180,255,.55);
}
.login1-color-buttons {
  /* login1.png already contains the four colored swatches.
     These are transparent hit areas aligned exactly over those four boxes,
     preventing a second set of colored squares from being drawn on top. */
  position: absolute;
  left: 21.45%;
  top: 76.45%;
  width: 24.65%;
  height: 5.9%;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 3%;
  align-items: stretch;
}
.login1-color {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  border-radius: 0;
  box-shadow: none;
  transform: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.login1-color.selected {
  outline: 3px solid #ffd166;
  outline-offset: -5px;
  box-shadow: 0 0 8px rgba(255,209,102,.65);
}
.login1-enter {
  position: absolute;
  left: 21.75%;
  top: 84.0%;
  width: 58.25%;
  height: 8.95%;
  border: 1px solid rgba(210,232,245,.9);
  outline: 1px solid rgba(75,105,125,.9);
  background: rgba(9,23,34,.83);
  color: #fff;
  cursor: pointer;
  font-size: clamp(14px, 2.8vw, 20px);
  font-weight: 1000;
  text-shadow: 0 1px 2px #000;
}
.login1-enter:hover,
.login1-enter:focus-visible {
  background: rgba(18,39,54,.92);
  box-shadow: 0 0 16px rgba(100,205,255,.45);
}
.login1-enter:disabled { opacity: .72; cursor: wait; }

.cont1-controls {
  position: relative;
  width: 100%;
  aspect-ratio: 1774 / 887;
  overflow: hidden;
  background: #050505;
  border-top: 1px solid #9a7134;
  border-bottom: 1px solid #5c3e1e;
}
.cont1-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
}
.cont1-hotspot {
  position: absolute;
  border: 0;
  padding: 0;
  background: transparent;
  color: transparent;
  cursor: pointer;
  touch-action: manipulation;
}
.cont1-hotspot:active { filter: brightness(1.2); }
.dpad-up    { left: 14.6%; top: 24.0%; width: 6.7%; height: 18.0%; }
.dpad-left  { left: 6.2%;  top: 39.5%; width: 9.2%; height: 16.5%; }
.dpad-right { left: 20.4%; top: 39.5%; width: 9.2%; height: 16.5%; }
.dpad-down  { left: 14.6%; top: 55.0%; width: 6.7%; height: 18.0%; }
.cont1-start { left: 46.0%; top: 41.0%; width: 6.4%; height: 13.0%; border-radius: 50%; }

.cont1-x,
.cont1-y,
.cont1-a,
.cont1-b {
  width: 11.5%;
  aspect-ratio: 1;
  border-radius: 50%;
  transform: translate(-50%,-50%);
  display: grid;
  place-items: center;
}
.cont1-x { left: 77.85%; top: 28.9%; }
.cont1-y { left: 67.45%; top: 47.4%; }
.cont1-a { left: 87.25%; top: 47.4%; }
.cont1-b { left: 77.85%; top: 66.1%; }
.cont1-x span,
.cont1-y span,
.cont1-a span,
.cont1-b span {
  width: 48%;
  height: 48%;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 38% 28%, #343434 0%, #171717 45%, #090909 100%);
  color: #e9c47c;
  font-size: clamp(17px, 3.1vw, 55px);
  line-height: 1;
  font-weight: 500;
  text-shadow: 0 2px 2px #000;
  box-shadow: inset 0 0 10px rgba(0,0,0,.45);
}
@media (max-width: 600px) {
  .login1-shell { padding: 0; }
  .login1-frame { width: 100vw; }
  .cont1-controls { min-height: 190px; }
  .cont1-x span,
  .cont1-y span,
  .cont1-a span,
  .cont1-b span { font-size: clamp(18px, 7vw, 34px); }
}

/* ===== BUILD 12: town label / controller labels / layout ===== */
.cont1-controls {
  flex: 0 0 auto;
  margin: 0;
}
/* The source cont1 image still contains the old Y/X/B/A glyphs.
   These opaque inner discs fully cover them so only the HTML labels remain visible. */
.cont1-x span,
.cont1-y span,
.cont1-a span,
.cont1-b span {
  width: 82%;
  height: 82%;
  background: radial-gradient(circle at 38% 28%, #3b3b3b 0%, #181818 45%, #070707 100%);
  box-shadow: inset 0 0 0 1px rgba(214,164,76,.25), inset 0 0 12px rgba(0,0,0,.7);
  font-size: clamp(22px, 4.1vw, 62px);
}
@media (max-width: 600px) {
  .cont1-x span,
  .cont1-y span,
  .cont1-a span,
  .cont1-b span {
    font-size: clamp(22px, 9vw, 40px);
  }
}


/* ===== BUILD 13: continuous movement / idle frame / fixed viewport ===== */
html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  overscroll-behavior: none;
}

.game-shell {
  width: min(760px, 100%);
  height: 100dvh;
  min-height: 0;
  max-height: 100dvh;
  overflow: hidden;
}

.game-header {
  flex: 0 0 auto;
}

.game-stage {
  flex: 1 1 auto;
  min-height: 96px;
  overflow: hidden;
}

.game-canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #203a42;
}

.message-box {
  flex: 0 0 122px;
  min-height: 122px;
  max-height: 122px;
  overflow: auto;
  margin-top: 8px;
}

.prototype-footer {
  flex: 0 0 auto;
  margin-top: 0;
}

/* cont1 is the final item in the game-shell.  Cap its width so it no longer
   consumes most of the viewport, while keeping the original 2:1 proportions. */
.cont1-controls {
  flex: 0 0 auto;
  width: min(100%, 430px);
  aspect-ratio: 1774 / 887;
  align-self: center;
  margin-top: 0;
  margin-bottom: 0;
  box-shadow: 0 0 0 100vmax #050505;
  clip-path: inset(0 -100vmax);
}

.cont1-hotspot {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

@media (max-width: 600px) {
  .game-shell {
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
  }

  .game-header {
    min-height: 52px;
    padding-block: 5px;
  }

  .message-box {
    flex-basis: 104px;
    min-height: 104px;
    max-height: 104px;
    margin: 5px 7px 0;
  }

  .prototype-footer {
    min-height: 18px;
    padding-block: 4px;
  }

  .cont1-controls {
    width: min(100%, 390px);
    min-height: 0;
  }
}

@media (max-height: 680px) {
  .game-header {
    min-height: 46px;
    padding-block: 4px;
  }

  .game-header h1 {
    font-size: 22px;
  }

  .message-box {
    flex-basis: 88px;
    min-height: 88px;
    max-height: 88px;
    margin-top: 4px;
  }

  .prototype-footer {
    display: none;
  }

  .cont1-controls {
    width: min(100%, 340px);
  }
}


/* Cancel the older landscape side-panel layout: BUILD 13 always stays
   one-screen vertical with cont1 at the very bottom. */
@media (max-height: 700px) and (orientation: landscape) {
  .game-shell {
    display: flex;
    flex-direction: column;
    grid-template-columns: none;
    grid-template-rows: none;
  }

  .game-header,
  .game-stage,
  .message-box,
  .cont1-controls {
    grid-column: auto;
    grid-row: auto;
  }

  .message-box {
    align-self: stretch;
    margin-inline: 7px;
  }

  .cont1-controls {
    width: min(100%, 300px);
  }
}


/* ===== BUILD 14: LOCAL DEVELOPMENT MODE ===== */
.dev-room-status {
  gap: 7px;
}

.dev-open-button {
  margin-left: 5px;
  min-width: 42px;
  height: 30px;
  border: 2px solid #173f4a;
  background: #ffd166;
  color: #173f4a;
  font-size: 9px;
  font-weight: 1000;
  cursor: pointer;
}

.dev-panel {
  position: fixed;
  z-index: 50;
  top: 10px;
  right: 10px;
  width: min(310px, calc(100vw - 20px));
  max-height: calc(100dvh - 20px);
  overflow: auto;
  padding: 12px;
  border: 3px solid #f4d17d;
  background: rgba(8, 20, 25, .96);
  color: #fff4ce;
  box-shadow: 0 12px 40px rgba(0,0,0,.55);
  font-size: 10px;
}

.dev-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(244,209,125,.4);
}

.dev-panel-head strong {
  letter-spacing: .1em;
}

.dev-panel-head button {
  width: 28px;
  height: 28px;
  border: 1px solid #f4d17d;
  background: transparent;
  color: #fff4ce;
  font-size: 18px;
}

.dev-readout {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 5px 8px;
  margin-bottom: 10px;
}

.dev-readout span {
  color: #8fb6bd;
}

.dev-toggle,
.dev-actions button,
.dev-teleport button {
  width: 100%;
  min-height: 34px;
  margin-top: 6px;
  border: 1px solid #6b8790;
  background: #173f4a;
  color: #fff4ce;
  font-weight: 900;
}

.dev-toggle.active {
  border-color: #74e0aa;
  background: #1e674e;
}

.dev-toggle.danger.active {
  border-color: #ffab86;
  background: #813f34;
}

.dev-teleport {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 10px;
}

.dev-teleport label {
  display: grid;
  gap: 3px;
}

.dev-teleport input {
  width: 100%;
  min-height: 32px;
  border: 1px solid #78949c;
  background: #f3f4ed;
  color: #10191d;
  padding: 4px 6px;
  font-weight: 900;
}

.dev-teleport button {
  grid-column: 1 / -1;
}

.dev-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.dev-panel p {
  margin: 10px 0 0;
  color: #9eb4b8;
  line-height: 1.5;
  font-size: 9px;
}


/* ===== F-0.02: minimal mobile map editing / shared map data ===== */
.map-data-box {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(244,209,125,.4);
  display: grid;
  gap: 7px;
}
.map-data-box strong { font-size: 10px; letter-spacing: .04em; }
.map-data-box small { color: #9fc3c9; line-height: 1.4; }
.map-data-box button,
.map-data-import {
  width: 100%;
  min-height: 36px;
  border: 1px solid #6b8790;
  background: #173f4a;
  color: #fff4ce;
  font-weight: 900;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 6px;
  cursor: pointer;
}
.map-data-import input { display: none; }
.map-data-box .map-data-reset { background: #4f342f; border-color: #a96f61; }


/* ===== F-0.03 BATTLE: NPC1 contact battle / rolling HP ===== */
.battle-shell {
  width:min(820px,100%);
  min-height:100dvh;
  margin:0 auto;
  overflow:hidden;
  display:grid;
  grid-template-rows:auto auto auto auto auto;
  align-content:start;
  background:#050505;
  color:#fff;
  border-inline:3px solid #070707;
  box-shadow:0 0 60px rgba(0,0,0,.65);
}
.battle-message {
  position:relative;
  z-index:5;
  width:min(610px,calc(100% - 30px));
  min-height:82px;
  margin:12px auto 9px;
  padding:14px 18px 13px 44px;
  background:#050505;
  color:#fff;
  border:3px solid #f3f3f3;
  outline:2px solid #707070;
  border-radius:18px;
  box-shadow:0 0 0 2px #111,5px 6px 0 rgba(0,0,0,.45);
  font-size:clamp(14px,2.2vw,20px);
  line-height:1.45;
  font-weight:900;
  letter-spacing:.02em;
}
.battle-message p { margin:0; }
.battle-caret { position:absolute; left:17px; top:17px; color:#fff; animation:battle-caret-blink .8s steps(2) infinite; }
@keyframes battle-caret-blink { 50%{opacity:.25;} }

.battle-impact-stack {
  min-width:0;
  transform:translateY(0);
  will-change:transform;
}
.battle-impact-stack.player-hit {
  animation:battle-player-hit .34s cubic-bezier(.36,.07,.19,.97) 1;
}
@keyframes battle-player-hit {
  0%,100%{transform:translateY(0)}
  16%{transform:translateY(-8px)}
  32%{transform:translateY(7px)}
  49%{transform:translateY(-6px)}
  66%{transform:translateY(5px)}
  82%{transform:translateY(-3px)}
}

.battle-arena {
  position:relative;
  height:clamp(235px,42dvh,390px);
  overflow:hidden;
  isolation:isolate;
  border-block:2px solid #0c0c0c;
  background:#171044;
}
.battle-pattern {
  position:absolute;
  inset:-16%;
  z-index:-2;
  overflow:hidden;
  background:
    repeating-conic-gradient(from 15deg at 50% 50%, #21185a 0 8deg, #8c2c8f 8deg 15deg, #d2a61c 15deg 23deg, #113d5a 23deg 31deg),
    repeating-linear-gradient(62deg, rgba(255,255,255,.12) 0 4px, transparent 4px 22px);
  background-blend-mode:screen,normal;
  animation:battle-geo-base 10.8s linear infinite;
  filter:saturate(1.12) contrast(1.1);
}
.battle-pattern::before,
.battle-pattern::after,
.geo-layer {
  content:"";
  position:absolute;
  inset:-20%;
  pointer-events:none;
}
.battle-pattern::before {
  background:
    repeating-linear-gradient(0deg, transparent 0 32px, rgba(255,214,61,.34) 33px 44px, transparent 45px 77px),
    repeating-linear-gradient(90deg, transparent 0 42px, rgba(93,232,218,.2) 43px 54px, transparent 55px 96px);
  transform:rotate(17deg) scale(1.15);
  animation:battle-geo-grid 6.7s cubic-bezier(.45,.05,.55,.95) infinite alternate;
  mix-blend-mode:screen;
}
.battle-pattern::after {
  background:
    radial-gradient(circle at 18% 28%, transparent 0 34px, rgba(255,228,74,.75) 35px 49px, transparent 50px 82px),
    radial-gradient(circle at 78% 62%, transparent 0 48px, rgba(200,79,181,.72) 49px 64px, transparent 65px 104px),
    radial-gradient(circle at 52% 38%, rgba(39,210,214,.28) 0 26px, transparent 27px 74px);
  animation:battle-geo-orbits 8.3s ease-in-out infinite alternate;
  mix-blend-mode:screen;
}
.geo-layer { display:block; }
.geo-layer-a {
  background:repeating-conic-gradient(from 0deg at 30% 45%, transparent 0 11deg, rgba(255,220,64,.33) 12deg 18deg, transparent 19deg 32deg);
  animation:battle-geo-a 5.4s steps(9,end) infinite;
}
.geo-layer-b {
  background:repeating-linear-gradient(135deg, transparent 0 38px, rgba(74,220,205,.28) 39px 52px, transparent 53px 87px);
  clip-path:polygon(0 8%,100% 0,91% 92%,8% 100%);
  animation:battle-geo-b 7.1s cubic-bezier(.22,.61,.36,1) infinite alternate;
}
.geo-layer-c {
  background:conic-gradient(from 90deg at 50% 50%, rgba(255,198,36,.15), transparent 18%, rgba(191,62,178,.22) 35%, transparent 54%, rgba(66,226,207,.15) 72%, transparent 90%);
  animation:battle-geo-c 4.9s ease-in-out infinite alternate;
}
@keyframes battle-geo-base {
  0%{transform:translate(-2%,-1%) rotate(0deg) scale(1.05)}
  17%{transform:translate(1.2%,-2.4%) rotate(2deg) scale(1.12)}
  38%{transform:translate(-1.7%,1.5%) rotate(-1deg) scale(1.08)}
  63%{transform:translate(2.3%,.7%) rotate(3.5deg) scale(1.15)}
  81%{transform:translate(-.6%,2%) rotate(1deg) scale(1.09)}
  100%{transform:translate(-2%,-1%) rotate(6deg) scale(1.05)}
}
@keyframes battle-geo-grid {
  0%{transform:translate(-2%,1%) rotate(13deg) skewX(-3deg) scale(1.12)}
  31%{transform:translate(3%,-2%) rotate(19deg) skewX(4deg) scale(1.2)}
  67%{transform:translate(-1%,3%) rotate(10deg) skewY(-4deg) scale(1.16)}
  100%{transform:translate(2%,-1%) rotate(23deg) skewX(2deg) scale(1.22)}
}
@keyframes battle-geo-orbits {
  0%{transform:translate(-4%,2%) rotate(-4deg) scale(.98)}
  46%{transform:translate(3%,-3%) rotate(5deg) scale(1.12)}
  100%{transform:translate(-1%,4%) rotate(-1deg) scale(1.05)}
}
@keyframes battle-geo-a {
  0%,100%{transform:translate(-2%,-1%) rotate(0deg) scale(1.05)}
  22%{transform:translate(3%,-2%) rotate(13deg) scale(1.18)}
  48%{transform:translate(-1%,4%) rotate(7deg) scale(1.08)}
  73%{transform:translate(4%,1%) rotate(19deg) scale(1.2)}
}
@keyframes battle-geo-b {
  0%{transform:translate(-5%,1%) rotate(-8deg) scale(1.02)}
  35%{transform:translate(2%,-4%) rotate(2deg) scale(1.12)}
  71%{transform:translate(-2%,3%) rotate(-3deg) scale(1.07)}
  100%{transform:translate(4%,-1%) rotate(7deg) scale(1.18)}
}
@keyframes battle-geo-c {
  0%{transform:rotate(-8deg) scale(.95);opacity:.52}
  42%{transform:rotate(11deg) scale(1.14);opacity:.8}
  100%{transform:rotate(-2deg) scale(1.04);opacity:.6}
}

.battle-enemy-wrap { position:absolute; inset:0; display:grid; place-items:center; padding:5px 20px 16px; }
.battle-enemy {
  display:block;
  width:min(58%,455px);
  max-height:88%;
  object-fit:contain;
  image-rendering:pixelated;
  filter:drop-shadow(0 9px 3px rgba(0,0,0,.38));
  transform-origin:center bottom;
}
.battle-enemy.hit { animation:enemy-hit .30s cubic-bezier(.36,.07,.19,.97) 1; }
@keyframes enemy-hit {
  0%,100%{transform:translateY(0);filter:brightness(1) drop-shadow(0 9px 3px rgba(0,0,0,.38))}
  18%{transform:translateY(-7px);filter:brightness(1.15) drop-shadow(0 9px 3px rgba(0,0,0,.38))}
  38%{transform:translateY(6px);filter:brightness(2.65) saturate(1.12) drop-shadow(0 0 16px rgba(255,255,255,.88))}
  58%{transform:translateY(-4px);filter:brightness(1.5) drop-shadow(0 6px 5px rgba(255,255,255,.28))}
  78%{transform:translateY(3px);filter:brightness(1.08) drop-shadow(0 9px 3px rgba(0,0,0,.38))}
}

.battle-command-strip {
  width:calc(100% - 24px);
  margin:8px 12px 7px;
  min-height:62px;
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:7px;
  padding:7px 9px;
  border:3px solid #f5f5f5;
  outline:2px solid #747474;
  border-radius:11px;
  background:#070707;
  box-shadow:4px 5px 0 rgba(0,0,0,.45);
}
.battle-command-strip button {
  position:relative;
  z-index:3;
  min-width:0;
  min-height:48px;
  border:1px solid transparent;
  border-radius:7px;
  background:transparent;
  color:#fff;
  text-align:center;
  padding:7px 8px;
  font-size:15px;
  font-weight:900;
  cursor:pointer;
  touch-action:manipulation;
  -webkit-tap-highlight-color:rgba(255,255,255,.16);
  user-select:none;
}
.battle-command-strip button small { color:#9c9c9c; font-size:9px; }
.battle-command-strip button:hover:not(:disabled),
.battle-command-strip button:focus-visible:not(:disabled) { background:#222; outline:2px solid #fff; }
.battle-command-strip button:active:not(:disabled) {
  background:#f3f3f3;
  color:#080808;
  transform:translateY(2px);
}
.battle-command-strip button:disabled { opacity:.42; cursor:wait; }
.battle-command-strip .battle-return { grid-column:1/-1; background:#f2f2f2; color:#050505; }

.battle-party-strip { padding:0 12px 10px; background:#050505; }
.battle-party-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:9px; align-items:start; }
.battle-status-card {
  min-width:0;
  padding:8px 8px 9px;
  border:3px solid #f5f5f5;
  outline:2px solid #747474;
  border-radius:10px;
  background:#101018;
  box-shadow:4px 5px 0 rgba(0,0,0,.45);
  display:flex;
  flex-direction:column;
  gap:5px;
}
.battle-status-card>strong { font-size:15px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; text-align:center; }
.battle-status-slot { min-height:112px; visibility:hidden; }
.battle-meter-row { display:grid; grid-template-columns:26px 1fr; gap:4px; align-items:center; }
.battle-meter-row>span { font-size:14px; font-weight:1000; text-align:center; }
.hp-drums { display:flex; justify-content:center; gap:1px; perspective:200px; min-width:0; }
.hp-digit {
  width:26px;
  height:31px;
  display:grid;
  place-items:center;
  overflow:hidden;
  background:linear-gradient(#f6f6f6 0 46%,#cfcfcf 47% 53%,#f7f7f7 54% 100%);
  border:2px solid #8d8d8d;
  color:#090909;
  font-family:"Courier New",ui-monospace,monospace;
  font-size:22px;
  line-height:1;
  font-weight:1000;
  text-shadow:1px 1px 0 #fff;
  animation:hp-roll .11s ease-out;
}
.mp-drums .hp-digit { background:linear-gradient(#ecebff 0 46%,#bfc1d8 47% 53%,#f4f2ff 54% 100%); }
@keyframes hp-roll { from{transform:rotateX(64deg) translateY(-7px);filter:blur(.4px)} to{transform:rotateX(0) translateY(0);filter:none} }

.battle-footer { min-height:22px; display:grid; place-items:center; background:#151515; color:#a9a9a9; border-top:1px solid #333; font-size:8px; letter-spacing:.08em; }

@media(max-width:600px){
  .battle-message{min-height:72px;margin-top:7px;padding:11px 12px 9px 34px;border-radius:14px}
  .battle-caret{left:12px;top:13px}
  .battle-arena{height:clamp(205px,38dvh,300px)}
  .battle-enemy{width:min(72%,430px)}
  .battle-command-strip{width:calc(100% - 14px);margin:6px 7px;grid-template-columns:repeat(4,1fr);gap:3px;padding:5px}
  .battle-command-strip button{min-height:52px;padding:6px 2px;font-size:12px}
  .battle-party-strip{padding:0 7px 8px}
  .battle-party-grid{gap:4px}
  .battle-status-card{padding:6px 4px;gap:4px}
  .battle-status-card>strong{font-size:11px}
  .battle-meter-row{grid-template-columns:20px 1fr;gap:1px}
  .battle-meter-row>span{font-size:11px}
  .hp-digit{width:20px;height:27px;font-size:18px}
  .battle-status-slot{min-height:94px}
}
@media(prefers-reduced-motion:reduce){
  .battle-pattern,.battle-pattern::before,.battle-pattern::after,.geo-layer,.battle-caret,.hp-digit,.battle-enemy.hit,.battle-impact-stack.player-hit{animation:none!important}
}

/* ===== UI5: field battle entry + MOTHER-like framed battle layout (original F styling) ===== */
.game-shell.battle-transition-active .game-stage {
  transform-origin:50% 50%;
  animation:f-battle-field-warp .98s cubic-bezier(.65,.02,.3,1) forwards;
  overflow:hidden;
}
.game-shell.battle-transition-active .game-canvas {
  animation:f-battle-canvas-color .98s steps(9,end) forwards;
}
.battle-entry-fx {
  position:absolute;
  inset:0;
  z-index:40;
  pointer-events:none;
  overflow:hidden;
  background:
    repeating-conic-gradient(from 0deg at 50% 50%, rgba(255,255,255,.04) 0 8deg, rgba(0,0,0,.12) 8deg 16deg),
    radial-gradient(circle at 50% 50%, transparent 0 6%, rgba(255,255,255,.08) 6.5% 7.5%, transparent 8% 100%);
  mix-blend-mode:screen;
  animation:f-battle-entry-overlay .98s steps(10,end) forwards;
}
.battle-entry-ring {
  position:absolute;
  left:50%;
  top:50%;
  width:140%;
  aspect-ratio:1;
  border:clamp(6px,1.2vw,16px) solid rgba(255,240,145,.82);
  transform:translate(-50%,-50%) rotate(0deg) scale(1.4);
  clip-path:polygon(50% 0,61% 36%,100% 50%,64% 61%,50% 100%,38% 64%,0 50%,36% 38%);
  opacity:.72;
}
.battle-entry-ring.ring-a { animation:f-entry-ring-a .98s cubic-bezier(.7,.03,.26,1) forwards; }
.battle-entry-ring.ring-b { width:110%; border-color:rgba(84,233,220,.78); animation:f-entry-ring-b .98s cubic-bezier(.68,.01,.22,1) forwards; }
.battle-entry-ring.ring-c { width:82%; border-color:rgba(220,84,196,.78); animation:f-entry-ring-c .98s cubic-bezier(.6,.02,.28,1) forwards; }
.battle-entry-grid {
  position:absolute;
  inset:-30%;
  background:
    repeating-linear-gradient(23deg,transparent 0 34px,rgba(255,224,76,.18) 35px 42px,transparent 43px 79px),
    repeating-linear-gradient(113deg,transparent 0 46px,rgba(65,230,213,.14) 47px 55px,transparent 56px 102px);
  transform:rotate(0deg) scale(1.3);
  animation:f-entry-grid .98s steps(8,end) forwards;
}
.entry-variant-1 { filter:hue-rotate(52deg) saturate(1.35); }
.entry-variant-2 { filter:hue-rotate(118deg) contrast(1.22); }
.entry-variant-3 { filter:hue-rotate(218deg) saturate(1.25); }
@keyframes f-battle-field-warp {
  0%{transform:scale(1) rotate(0deg) skew(0);filter:none}
  18%{transform:scale(1.035) rotate(-1.1deg) skewX(1.5deg);filter:contrast(1.15)}
  38%{transform:scale(1.09) rotate(2.5deg) skewY(-2deg);filter:contrast(1.35) saturate(1.45)}
  62%{transform:scale(1.18) rotate(-4deg) skewX(3deg);filter:hue-rotate(80deg) contrast(1.6) saturate(1.8)}
  82%{transform:scale(1.31) rotate(7deg) skewY(-5deg);filter:hue-rotate(190deg) contrast(1.9) saturate(2.1)}
  100%{transform:scale(1.48) rotate(-12deg) skewX(7deg);filter:hue-rotate(300deg) contrast(2.2) saturate(2.4);opacity:.04}
}
@keyframes f-battle-canvas-color {
  0%{filter:none}
  22%{filter:sepia(.25) saturate(1.35)}
  44%{filter:hue-rotate(65deg) saturate(1.55) contrast(1.2)}
  66%{filter:hue-rotate(155deg) invert(.12) saturate(1.9) contrast(1.35)}
  84%{filter:hue-rotate(250deg) invert(.28) saturate(2.3) contrast(1.55)}
  100%{filter:hue-rotate(330deg) invert(.8) saturate(2.8) contrast(1.8)}
}
@keyframes f-battle-entry-overlay { 0%{opacity:0} 15%{opacity:.45} 58%{opacity:1} 100%{opacity:.08} }
@keyframes f-entry-ring-a { 0%{transform:translate(-50%,-50%) rotate(0) scale(1.45);opacity:0} 18%{opacity:.9} 100%{transform:translate(-50%,-50%) rotate(205deg) scale(.04);opacity:1} }
@keyframes f-entry-ring-b { 0%{transform:translate(-50%,-50%) rotate(22deg) scale(1.65);opacity:.05} 27%{opacity:.75} 100%{transform:translate(-50%,-50%) rotate(-255deg) scale(.025);opacity:.9} }
@keyframes f-entry-ring-c { 0%{transform:translate(-50%,-50%) rotate(-18deg) scale(1.8);opacity:.05} 38%{opacity:.75} 100%{transform:translate(-50%,-50%) rotate(310deg) scale(.015);opacity:.85} }
@keyframes f-entry-grid { 0%{transform:rotate(0) scale(1.15);opacity:0} 24%{opacity:.75} 100%{transform:rotate(63deg) scale(2.8);opacity:.08} }

/* Top dialogue frame: compact black box with layered gray/ivory rim. */
.battle-message {
  width:min(620px,calc(100% - 34px));
  min-height:86px;
  margin:12px auto 10px;
  padding:14px 20px 13px 46px;
  border:4px solid #e7e5d8;
  outline:3px solid #5e605d;
  border-radius:12px;
  background:#020202;
  box-shadow:0 0 0 2px #121212, inset 0 0 0 1px #8c8c84, 5px 6px 0 rgba(0,0,0,.52);
  font-family:ui-monospace,"MS Gothic","Courier New",monospace;
  font-size:clamp(15px,2.25vw,21px);
  line-height:1.5;
  letter-spacing:.025em;
}
.battle-caret { left:18px; top:18px; }

/* Much more geometric battle field. Multiple incommensurate motions imitate randomness. */
.battle-pattern {
  inset:-22%;
  background:
    repeating-conic-gradient(from 7deg at 50% 50%, #11164f 0 7deg,#5e216d 7deg 14deg,#c29119 14deg 21deg,#0b5260 21deg 28deg,#24206d 28deg 35deg),
    repeating-linear-gradient(45deg,rgba(255,255,255,.08) 0 3px,transparent 3px 18px),
    repeating-linear-gradient(135deg,transparent 0 27px,rgba(0,0,0,.17) 27px 33px,transparent 33px 62px);
  background-blend-mode:screen,screen,multiply;
  animation:battle-geo-base 8.9s linear infinite;
  filter:saturate(1.28) contrast(1.22);
}
.battle-pattern.pattern-1 { filter:hue-rotate(55deg) saturate(1.38) contrast(1.22); }
.battle-pattern.pattern-2 { filter:hue-rotate(125deg) saturate(1.24) contrast(1.34); }
.battle-pattern.pattern-3 { filter:hue-rotate(225deg) saturate(1.42) contrast(1.19); }
.geo-layer-d {
  inset:-35%;
  background:
    conic-gradient(from 18deg at 18% 36%,transparent 0 11%,rgba(255,225,55,.38) 11% 18%,transparent 18% 100%),
    conic-gradient(from 198deg at 76% 62%,transparent 0 16%,rgba(52,235,221,.27) 16% 23%,transparent 23% 100%);
  clip-path:polygon(0 14%,22% 0,43% 19%,67% 4%,100% 23%,82% 47%,100% 72%,71% 100%,45% 80%,18% 100%,0 72%,17% 48%);
  animation:battle-geo-d 6.13s steps(13,end) infinite;
  mix-blend-mode:screen;
}
.geo-layer-e {
  inset:-25%;
  background:
    repeating-linear-gradient(0deg,transparent 0 46px,rgba(242,198,36,.22) 47px 61px,transparent 62px 112px),
    repeating-linear-gradient(90deg,transparent 0 58px,rgba(163,62,182,.2) 59px 74px,transparent 75px 132px);
  clip-path:polygon(0 0,100% 0,100% 100%,0 100%,0 76%,18% 61%,3% 46%,20% 31%,0 17%);
  animation:battle-geo-e 7.77s cubic-bezier(.37,.01,.63,.99) infinite alternate;
  mix-blend-mode:overlay;
}
@keyframes battle-geo-d {
  0%,100%{transform:translate(-2%,-1%) rotate(0deg) scale(1.02)}
  13%{transform:translate(5%,-4%) rotate(31deg) scale(1.18)}
  37%{transform:translate(-4%,3%) rotate(66deg) scale(1.08)}
  54%{transform:translate(3%,5%) rotate(111deg) scale(1.25)}
  79%{transform:translate(-1%,-5%) rotate(153deg) scale(1.12)}
}
@keyframes battle-geo-e {
  0%{transform:translate(-6%,2%) rotate(-15deg) skewX(-5deg) scale(1.08)}
  29%{transform:translate(4%,-5%) rotate(7deg) skewY(4deg) scale(1.19)}
  61%{transform:translate(-2%,4%) rotate(-3deg) skewX(5deg) scale(1.12)}
  100%{transform:translate(6%,-1%) rotate(19deg) skewY(-6deg) scale(1.24)}
}

/* Party boxes: lavender patterned panel and double bevel rim like the supplied reference, but F-specific. */
.battle-party-strip { padding:0 14px 12px; background:#030303; }
.battle-party-grid { gap:10px; }
.battle-status-card {
  position:relative;
  padding:8px 8px 10px;
  border:4px solid #e4e4d8;
  outline:3px solid #60615e;
  border-radius:9px;
  background:
    linear-gradient(rgba(128,125,184,.92),rgba(116,116,172,.92)),
    repeating-linear-gradient(0deg,rgba(255,255,255,.08) 0 2px,transparent 2px 4px),
    repeating-linear-gradient(90deg,rgba(0,0,0,.06) 0 2px,transparent 2px 4px);
  background-blend-mode:normal,screen,multiply;
  box-shadow:0 0 0 2px #151515, inset 0 0 0 2px #8b8b86, 4px 5px 0 rgba(0,0,0,.55);
  font-family:ui-monospace,"MS Gothic","Courier New",monospace;
  color:#fff;
  text-shadow:1px 1px 0 rgba(0,0,0,.65);
}
.battle-status-card::before {
  content:"";
  position:absolute;
  inset:3px;
  border:1px solid rgba(255,255,255,.2);
  border-radius:4px;
  pointer-events:none;
}
.battle-status-card>strong {
  position:relative;
  z-index:1;
  min-height:22px;
  display:grid;
  place-items:center;
  font-size:16px;
  font-weight:900;
  letter-spacing:.08em;
}
.battle-meter-row { position:relative;z-index:1;grid-template-columns:30px 1fr;gap:3px; }
.battle-meter-row>span { font-family:ui-monospace,"MS Gothic",monospace;font-size:15px;text-shadow:1px 1px #3b3b55; }
.hp-digit {
  width:27px;
  height:31px;
  border:2px solid #262626;
  border-radius:2px;
  background:linear-gradient(#f0efe6 0 44%,#aaa99f 45% 53%,#f4f3e9 54% 100%);
  box-shadow:inset 1px 1px 0 #fff,inset -1px -1px 0 #777;
  font-size:22px;
  text-shadow:none;
}
.mp-drums .hp-digit { background:linear-gradient(#eeeeea 0 44%,#a7a8a4 45% 53%,#f5f5ef 54% 100%); }

@media(max-width:600px){
  .battle-message{width:calc(100% - 20px);padding-left:38px;border-width:3px;outline-width:2px;border-radius:9px}
  .battle-status-card{border-width:3px;outline-width:2px;border-radius:7px}
  .battle-meter-row{grid-template-columns:22px 1fr}
}
@media(prefers-reduced-motion:reduce){
  .game-shell.battle-transition-active .game-stage,.game-shell.battle-transition-active .game-canvas,.battle-entry-fx,.battle-entry-ring,.battle-entry-grid,.geo-layer-d,.geo-layer-e{animation:none!important}
}

/* UI5 reference adjustment: top message has no cursor marker. */
.battle-message{padding-left:24px}
.battle-caret{display:none}
@media(max-width:600px){.battle-message{padding-left:16px}}

/* ===== UI7: two-row command deck + geometric party card + idle enemy animation ===== */
.battle-command-strip {
  min-height: 126px;
  grid-template-columns: repeat(4,minmax(0,1fr));
  grid-template-rows: repeat(2,minmax(48px,1fr));
  align-items: stretch;
}
.battle-command-strip button {
  min-height: 50px;
  touch-action: manipulation;
}
.battle-command-strip .battle-return,
.battle-auto-return {
  grid-column: 1 / -1;
  grid-row: 1 / -1;
}
.battle-auto-return {
  display:grid;
  place-items:center;
  min-height:100%;
  padding:12px;
  border-radius:7px;
  background:rgba(255,255,255,.08);
  color:#fff;
  font-weight:900;
  text-align:center;
}

.battle-status-card {
  min-height: 168px;
  justify-content:center;
  gap:10px;
  background:
    repeating-conic-gradient(from 45deg at 50% 50%,
      rgba(255,255,255,.13) 0 11.25deg,
      transparent 11.25deg 22.5deg,
      rgba(45,35,92,.22) 22.5deg 33.75deg,
      transparent 33.75deg 45deg),
    repeating-linear-gradient(45deg,
      rgba(255,255,255,.06) 0 6px,
      transparent 6px 18px,
      rgba(34,25,82,.14) 18px 26px,
      transparent 26px 38px),
    linear-gradient(145deg,#8279bb 0%,#665c9e 48%,#8c77b6 100%);
  background-size:58px 58px,42px 42px,100% 100%;
  animation:battle-status-geometry 9.6s linear infinite;
}
.battle-status-card::after {
  content:"";
  position:absolute;
  inset:8px;
  pointer-events:none;
  border-radius:4px;
  background:
    linear-gradient(30deg,transparent 0 44%,rgba(255,255,255,.08) 45% 48%,transparent 49% 100%),
    linear-gradient(150deg,transparent 0 44%,rgba(19,13,53,.12) 45% 48%,transparent 49% 100%);
  background-size:34px 34px;
  mix-blend-mode:screen;
  opacity:.75;
}
.battle-status-card > strong,
.battle-status-card .battle-meter-row { z-index:2; }
.battle-status-slot { min-height:168px; }
@keyframes battle-status-geometry {
  from { background-position:0 0,0 0,0 0; }
  to { background-position:58px 58px,-42px 42px,0 0; }
}

.battle-enemy {
  will-change:transform,filter;
}
.battle-enemy.idle-normal { transform:none; }
/* The breathe PNG itself only changes the shoulder/abdomen area.
   Do not translate the whole sprite: the feet must stay planted. */
.battle-enemy.idle-breathe { transform:none; }
.battle-enemy.idle-blink { transform:none; }
.battle-enemy.hit { animation:enemy-hit .30s cubic-bezier(.36,.07,.19,.97) 1!important; }

@media(max-width:600px){
  .battle-command-strip{
    min-height:116px;
    grid-template-columns:repeat(2,minmax(0,1fr));
    grid-template-rows:repeat(2,minmax(50px,1fr));
    gap:5px;
  }
  .battle-command-strip button{min-height:50px;font-size:13px}
  .battle-auto-return{grid-column:1/-1;grid-row:1/-1}
  .battle-status-card{min-height:141px;padding:10px 5px;gap:8px}
  .battle-status-slot{min-height:141px}
}

@media(prefers-reduced-motion:reduce){
  .battle-status-card{animation:none!important}
  .battle-enemy.idle-breathe,.battle-enemy.idle-blink{transform:none!important}
}


/* ===== UI9: reference-inspired cute command row + 4-party strip + black diamond drums ===== */
.battle-shell{
  background:#080510;
}
.battle-arena{
  border-top:1px solid rgba(255,255,255,.08);
  border-bottom:1px solid rgba(255,255,255,.08);
}
.battle-pattern{
  background:
    radial-gradient(circle at 50% 50%,rgba(255,77,196,.18),transparent 30%),
    repeating-conic-gradient(from 45deg at 50% 50%,
      rgba(255,46,184,.24) 0 8deg,
      rgba(32,12,92,.05) 8deg 16deg,
      rgba(255,148,36,.18) 16deg 24deg,
      rgba(18,20,90,.05) 24deg 32deg),
    linear-gradient(135deg,#17062d 0%,#26104a 45%,#0b153b 100%);
  background-size:100% 100%,160px 160px,100% 100%;
  animation:battle-ui9-kaleido 8.4s linear infinite;
}
.battle-pattern::before{
  background:
    linear-gradient(45deg,transparent 42%,rgba(255,79,205,.8) 43% 47%,transparent 48% 100%),
    linear-gradient(-45deg,transparent 42%,rgba(48,162,255,.72) 43% 47%,transparent 48% 100%);
  background-size:92px 92px;
  opacity:.72;
  animation:battle-ui9-diamond-shift 5.8s linear infinite;
}
.battle-pattern::after{
  background:
    repeating-linear-gradient(45deg,transparent 0 24px,rgba(255,173,42,.25) 25px 33px,transparent 34px 58px),
    repeating-linear-gradient(-45deg,transparent 0 31px,rgba(197,43,255,.24) 32px 40px,transparent 41px 67px);
  background-size:130px 130px,158px 158px;
  opacity:.68;
  animation:battle-ui9-chevron 7.2s ease-in-out infinite alternate;
}
@keyframes battle-ui9-kaleido{from{background-position:0 0,0 0,0 0}to{background-position:0 0,160px 160px,0 0}}
@keyframes battle-ui9-diamond-shift{from{background-position:0 0,0 0}to{background-position:92px -92px,-92px 92px}}
@keyframes battle-ui9-chevron{from{transform:scale(1.02) rotate(0deg)}to{transform:scale(1.12) rotate(2deg)}}

/* Commands: always one horizontal row, including phones. */
.battle-command-strip{
  min-height:88px;
  width:calc(100% - 28px);
  margin:8px 14px 7px;
  padding:7px;
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  grid-template-rows:1fr;
  gap:8px;
  background:#180b2a;
  border:3px solid #f4e7d4;
  outline:2px solid #ff8cc7;
  border-radius:16px;
  box-shadow:0 0 0 3px #49254f,0 8px 18px rgba(0,0,0,.34);
}
.battle-command-strip button.battle-command{
  position:relative;
  min-height:68px;
  border:3px solid #fff2d6;
  outline:2px solid rgba(60,20,62,.9);
  border-radius:15px;
  box-shadow:inset 0 0 0 3px rgba(255,255,255,.18),0 3px 0 rgba(20,5,35,.72);
  color:#fff;
  font-size:clamp(13px,2vw,22px);
  font-weight:1000;
  letter-spacing:.02em;
  text-shadow:0 2px 0 rgba(32,6,46,.9);
  display:flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  overflow:hidden;
}
.battle-command-strip button.battle-command::after{
  content:"";position:absolute;inset:0;pointer-events:none;
  background:repeating-linear-gradient(45deg,rgba(255,255,255,.13) 0 8px,transparent 8px 17px);
  mix-blend-mode:screen;opacity:.55;
}
.battle-command.attack{background:linear-gradient(135deg,#ff3f89,#d91f66)}
.battle-command.defend{background:linear-gradient(135deg,#2d9cff,#1767de)}
.battle-command.heal{background:linear-gradient(135deg,#39da83,#11a85d)}
.battle-command.run{background:linear-gradient(135deg,#ffb231,#ee7e12)}
.battle-command .cmd-icon{font-size:clamp(18px,2.7vw,31px);filter:drop-shadow(0 2px 0 rgba(0,0,0,.35));z-index:1}
.battle-command span,.battle-command small{z-index:1}
.battle-command small{position:absolute;right:7px;bottom:4px;font-size:8px;color:rgba(255,255,255,.8)!important}
.battle-command-strip button.battle-command:hover:not(:disabled),
.battle-command-strip button.battle-command:focus-visible:not(:disabled){filter:brightness(1.12);transform:translateY(-1px)}
.battle-command-strip button.battle-command:active:not(:disabled){transform:translateY(2px) scale(.985);filter:brightness(.94)}

.battle-party-strip{padding:0 14px 12px;background:#080510}
.battle-party-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px;align-items:stretch}
.battle-status-card,.battle-status-slot{
  position:relative;
  min-height:176px;
  border:3px solid #f4e7d4;
  outline:2px solid #ff8bc7;
  border-radius:14px;
  overflow:hidden;
  box-shadow:0 0 0 3px #4a2451,inset 0 0 18px rgba(0,0,0,.8);
}
.battle-status-card{
  display:flex;
  flex-direction:column;
  justify-content:flex-start;
  gap:5px;
  padding:8px;
  background-color:#050507;
  background-image:
    linear-gradient(45deg,transparent 39%,rgba(255,59,132,.95) 40% 44%,transparent 45% 100%),
    linear-gradient(-45deg,transparent 39%,rgba(22,178,255,.95) 40% 44%,transparent 45% 100%),
    linear-gradient(45deg,transparent 39%,rgba(74,224,91,.9) 40% 44%,transparent 45% 100%),
    linear-gradient(-45deg,transparent 39%,rgba(255,165,25,.9) 40% 44%,transparent 45% 100%),
    linear-gradient(#050507,#050507);
  background-size:48px 48px,64px 64px,82px 82px,104px 104px,100% 100%;
  animation:battle-ui9-status-diamonds 10.5s linear infinite;
}
.battle-status-card::before{
  content:"";position:absolute;inset:0;pointer-events:none;
  background:radial-gradient(circle at 30% 20%,rgba(255,255,255,.10),transparent 18%),radial-gradient(circle at 75% 78%,rgba(255,255,255,.08),transparent 20%);
  opacity:.8;
}
.battle-status-card::after{display:none}
@keyframes battle-ui9-status-diamonds{
  from{background-position:0 0,0 0,0 0,0 0,0 0}
  to{background-position:48px 48px,-64px 64px,82px -82px,-104px -104px,0 0}
}
.battle-status-card>strong{
  position:relative;z-index:2;
  min-height:22px;
  display:flex;align-items:center;justify-content:center;
  font-size:clamp(11px,1.5vw,18px);
  color:#fff;text-shadow:2px 2px #1b0827;
}
.battle-status-body{position:relative;z-index:2;display:grid;grid-template-columns:minmax(38px,.7fr) minmax(88px,1.3fr);gap:7px;align-items:end;flex:1}
.battle-hero-portrait{display:flex;align-items:flex-end;justify-content:center;min-width:0;height:116px;overflow:hidden}
.battle-hero-portrait img{display:block;width:min(100%,74px);height:auto;image-rendering:pixelated;filter:drop-shadow(0 3px 0 rgba(0,0,0,.55))}
.battle-meters{display:flex;flex-direction:column;gap:8px;align-self:center;min-width:0}
.battle-meter-row{display:grid;grid-template-columns:28px 1fr;gap:4px;align-items:center;position:relative;z-index:3}
.battle-meter-row>span{font-size:clamp(12px,1.5vw,17px);font-weight:1000;color:#fff;text-shadow:2px 2px #1e0a29}
.hp-drums{display:flex;gap:2px;justify-content:center;min-width:0;perspective:300px}
.hp-digit{
  position:relative;
  width:clamp(22px,3vw,34px);
  height:clamp(34px,4vw,45px);
  display:grid;place-items:center;
  border:2px solid #f6eadc;
  border-radius:7px;
  overflow:hidden;
  background:linear-gradient(#fff9ec 0 45%,#d8c9b8 46% 52%,#fffdf5 53% 100%);
  box-shadow:inset 0 0 0 2px rgba(255,255,255,.5),inset 0 -5px 8px rgba(80,40,30,.12),0 2px 0 #2b132c;
  color:#e73374;
  font-family:ui-monospace,"MS Gothic",monospace;
  font-size:clamp(20px,3vw,31px);
  font-weight:1000;
  line-height:1;
  animation:hp-roll .13s cubic-bezier(.22,.75,.3,1);
}
.hp-digit::before{content:"";position:absolute;left:2px;right:2px;top:49%;height:2px;background:rgba(56,31,51,.22);box-shadow:0 -1px rgba(255,255,255,.6);z-index:2}
.hp-digit::after{content:"";position:absolute;inset:3px 4px auto;height:4px;border-radius:50%;background:rgba(255,255,255,.58);filter:blur(.4px)}
.hp-digit i{font-style:normal;position:relative;z-index:1;text-shadow:0 1px 0 #fff}
.mp-drums .hp-digit{color:#2585e8;background:linear-gradient(#eef9ff 0 45%,#bdddf0 46% 52%,#f6fcff 53% 100%)}
.battle-status-slot{
  display:grid;
  grid-template-columns:42% 1fr;
  grid-template-rows:1fr 1fr;
  gap:7px;
  align-items:center;
  padding:17px 13px;
  background-color:#12071d;
  background-image:
    linear-gradient(45deg,transparent 40%,rgba(255,74,192,.12) 41% 45%,transparent 46% 100%),
    linear-gradient(-45deg,transparent 40%,rgba(83,80,255,.10) 41% 45%,transparent 46% 100%);
  background-size:56px 56px,72px 72px;
}
.party-silhouette{grid-row:1/-1;width:54px;height:68px;max-width:100%;justify-self:center;border:2px solid rgba(255,229,245,.22);border-radius:50% 50% 42% 42%/34% 34% 66% 66%;opacity:.7}
.party-slot-line{height:22px;border:2px solid rgba(255,229,245,.18);border-radius:9px;opacity:.8}
.party-slot-line.short{width:75%}

@media(max-width:600px){
  .battle-command-strip{min-height:66px;width:calc(100% - 12px);margin:6px;padding:4px;gap:3px;border-width:2px;border-radius:11px}
  .battle-command-strip button.battle-command{min-height:54px;padding:4px 1px;border-width:2px;border-radius:9px;font-size:clamp(9px,3.1vw,12px);gap:2px}
  .battle-command .cmd-icon{font-size:clamp(15px,5vw,21px)}
  .battle-command small{display:none}
  .battle-party-strip{padding:0 5px 7px}
  .battle-party-grid{gap:3px;grid-template-columns:repeat(4,minmax(0,1fr))}
  .battle-status-card,.battle-status-slot{min-height:122px;border-width:2px;outline-width:1px;border-radius:8px}
  .battle-status-card{padding:4px 2px;gap:1px;background-size:30px 30px,40px 40px,52px 52px,68px 68px,100% 100%}
  .battle-status-card>strong{font-size:8px;min-height:12px}
  .battle-status-body{grid-template-columns:34% 66%;gap:1px}
  .battle-hero-portrait{height:88px}
  .battle-hero-portrait img{width:min(100%,50px)}
  .battle-meters{gap:5px}
  .battle-meter-row{grid-template-columns:15px 1fr;gap:1px}
  .battle-meter-row>span{font-size:8px}
  .hp-drums{gap:1px}
  .hp-digit{width:clamp(12px,5vw,18px);height:25px;border-width:1px;border-radius:4px;font-size:16px}
  .battle-status-slot{padding:11px 4px;grid-template-columns:40% 1fr;gap:3px}
  .party-silhouette{width:25px;height:39px;border-width:1px}
  .party-slot-line{height:13px;border-width:1px;border-radius:5px}
}
@media(prefers-reduced-motion:reduce){
  .battle-pattern,.battle-pattern::before,.battle-pattern::after,.battle-status-card{animation:none!important}
}


/* ===== UI10 fixes: command fidelity, slower drum roll, static diamonds, anti-black-flash ===== */
.battle-pattern,
.battle-pattern::before,
.battle-pattern::after{
  will-change: background-position;
  transform: translateZ(0);
  backface-visibility: hidden;
}
.battle-pattern.pattern-1,
.battle-pattern.pattern-2,
.battle-pattern.pattern-3{filter:none!important}
.battle-pattern{
  background:
    radial-gradient(circle at 50% 50%,rgba(255,77,196,.16),transparent 28%),
    linear-gradient(45deg, transparent 0 43%, rgba(255,66,172,.52) 43% 46%, transparent 46% 54%, rgba(41,140,255,.52) 54% 57%, transparent 57% 100%),
    linear-gradient(-45deg, transparent 0 43%, rgba(255,171,39,.46) 43% 46%, transparent 46% 54%, rgba(168,45,255,.46) 54% 57%, transparent 57% 100%),
    linear-gradient(135deg,#150728 0%,#2a0f4e 45%,#091638 100%)!important;
  background-size:100% 100%,88px 88px,118px 118px,100% 100%!important;
  animation:battle-ui10-bg-main 7.8s linear infinite!important;
}
.battle-pattern::before{
  opacity:.72!important;
  background:
    radial-gradient(circle at 50% 50%, rgba(255,233,120,.18) 0 6%, transparent 7% 100%),
    linear-gradient(45deg, transparent 0 44%, rgba(255,82,197,.65) 44% 47%, transparent 47% 53%, rgba(44,183,255,.55) 53% 56%, transparent 56% 100%)!important;
  background-size:140px 140px,96px 96px!important;
  animation:battle-ui10-bg-before 6.5s linear infinite!important;
  transform:none!important;
}
.battle-pattern::after{
  opacity:.64!important;
  background:
    linear-gradient(-45deg, transparent 0 44%, rgba(255,174,56,.58) 44% 47%, transparent 47% 53%, rgba(159,61,255,.45) 53% 56%, transparent 56% 100%),
    linear-gradient(45deg, transparent 0 44%, rgba(39,144,255,.32) 44% 47%, transparent 47% 53%, rgba(255,74,181,.32) 53% 56%, transparent 56% 100%)!important;
  background-size:160px 160px,122px 122px!important;
  animation:battle-ui10-bg-after 8.8s linear infinite!important;
  transform:none!important;
}
@keyframes battle-ui10-bg-main{from{background-position:0 0,0 0,0 0,0 0}to{background-position:0 0,88px 88px,-118px 118px,0 0}}
@keyframes battle-ui10-bg-before{from{background-position:0 0,0 0}to{background-position:140px 0,-96px 96px}}
@keyframes battle-ui10-bg-after{from{background-position:0 0,0 0}to{background-position:-160px 160px,122px -122px}}

.battle-command-strip{
  align-items:stretch;
}
.battle-command-strip button.battle-command{
  justify-content:flex-start!important;
  padding:8px 10px 8px 12px!important;
  gap:10px!important;
}
.battle-command .cmd-badge{
  position:relative;
  z-index:1;
  flex:0 0 auto;
  width:clamp(28px,3vw,38px);
  height:clamp(28px,3vw,38px);
  display:grid;
  place-items:center;
  border-radius:10px;
  background:rgba(255,255,255,.94);
  color:#5b1746;
  border:2px solid rgba(60,20,62,.95);
  box-shadow:inset 0 0 0 2px rgba(255,255,255,.55),0 2px 0 rgba(20,5,35,.4);
  font-size:clamp(15px,2.1vw,23px);
  line-height:1;
}
.battle-command .cmd-label{position:relative;z-index:1;display:block;line-height:1;letter-spacing:.01em}

.battle-status-card{
  animation:none!important;
  background-color:#050507!important;
  background-image:
    linear-gradient(45deg, transparent 0 42%, rgba(255,71,171,.70) 42% 48%, transparent 48% 100%),
    linear-gradient(-45deg, transparent 0 42%, rgba(38,170,255,.70) 42% 48%, transparent 48% 100%),
    linear-gradient(45deg, transparent 0 42%, rgba(103,228,95,.70) 42% 48%, transparent 48% 100%),
    linear-gradient(-45deg, transparent 0 42%, rgba(255,173,44,.70) 42% 48%, transparent 48% 100%),
    linear-gradient(45deg, rgba(0,0,0,1) 0 50%, rgba(26,10,35,1) 50% 100%)!important;
  background-size:34px 34px,52px 52px,70px 70px,88px 88px,100% 100%!important;
  background-position:0 0,10px 6px,18px 18px,6px 22px,0 0!important;
}
.battle-status-card::before{display:none!important}
.battle-status-body{align-items:start!important}
.battle-hero-portrait{height:118px!important;align-items:flex-start!important;padding-top:2px}
.battle-hero-portrait img{transform:translateY(-8px)}
.battle-meters{padding-top:6px}
.hp-digit{animation:hp-roll .24s cubic-bezier(.18,.8,.3,1)!important}

@media(max-width:600px){
  .battle-command-strip button.battle-command{padding:4px 5px 4px 6px!important;gap:4px!important}
  .battle-command .cmd-badge{width:20px;height:20px;border-radius:6px;font-size:12px;border-width:1px}
  .battle-hero-portrait img{transform:translateY(-6px)}
}

/* ===== UI11: reference-matched battle polish / stable random background ===== */
.battle-shell{background:#090510}
.battle-message{
  width:min(690px,calc(100% - 28px));
  min-height:86px;
  margin:10px auto 8px;
  padding:16px 54px 14px 22px;
  background:linear-gradient(180deg,#1b0828 0%,#12051f 100%);
  border:4px solid #fff3dc;
  outline:4px solid #f088b9;
  border-radius:18px;
  box-shadow:0 0 0 2px #61205e,0 6px 0 #351331,0 9px 18px rgba(0,0,0,.42),inset 0 0 0 2px #4b184d;
  color:#fff8e8;
  font-size:clamp(15px,2.25vw,22px);
  text-shadow:2px 2px 0 #32102d;
}
.battle-caret{
  left:auto!important;
  right:19px!important;
  top:auto!important;
  bottom:12px!important;
  color:#ffafd0!important;
  filter:drop-shadow(0 2px 0 #4c1748);
}

/* Opaque base is always present. Old transform/filter/mix-blend animations are disabled
   to avoid the periodic mobile GPU compositor black frame. */
.battle-arena{background:#160829!important}
.battle-pattern{
  inset:-8%!important;
  filter:none!important;
  transform:none!important;
  animation:none!important;
  mix-blend-mode:normal!important;
  opacity:1!important;
  transition:background-position 1.15s cubic-bezier(.32,.04,.32,1)!important;
  background-color:#1b0832!important;
  background-image:
    linear-gradient(45deg, transparent 0 42%, rgba(255,55,174,.86) 43% 47%, transparent 48% 100%),
    linear-gradient(-45deg, transparent 0 42%, rgba(45,125,255,.78) 43% 47%, transparent 48% 100%),
    linear-gradient(45deg, transparent 0 45%, rgba(255,159,39,.66) 46% 49%, transparent 50% 100%),
    radial-gradient(circle at 50% 50%,rgba(217,64,255,.20),transparent 55%),
    linear-gradient(135deg,#17062f,#2a0b4c 50%,#0d1740)!important;
  background-size:96px 96px,132px 132px,176px 176px,100% 100%,100% 100%!important;
  background-position:var(--bx) var(--by),calc(var(--bx) * -1) var(--by),var(--bx) calc(var(--by) * -1),0 0,0 0!important;
}
.battle-pattern::before,
.battle-pattern::after,
.geo-layer{
  animation:none!important;
  transform:none!important;
  filter:none!important;
  mix-blend-mode:normal!important;
  opacity:.78!important;
  transition:background-position 1.2s cubic-bezier(.32,.04,.32,1)!important;
}
.battle-pattern::before{
  background-image:
    linear-gradient(45deg,transparent 0 39%,rgba(255,126,208,.72) 40% 45%,transparent 46% 54%,rgba(255,126,208,.72) 55% 60%,transparent 61%),
    linear-gradient(-45deg,transparent 0 39%,rgba(30,189,255,.64) 40% 45%,transparent 46% 54%,rgba(30,189,255,.64) 55% 60%,transparent 61%)!important;
  background-size:158px 158px,204px 204px!important;
  background-position:var(--ax) var(--ay),calc(var(--ax) * -1) calc(var(--ay) * -1)!important;
}
.battle-pattern::after{
  background-image:
    linear-gradient(45deg,transparent 0 45%,rgba(255,170,39,.72) 46% 49%,transparent 50%),
    linear-gradient(-45deg,transparent 0 45%,rgba(139,56,255,.62) 46% 49%,transparent 50%)!important;
  background-size:228px 228px,286px 286px!important;
  background-position:var(--cx) var(--cy),calc(var(--cx) * -1) var(--cy)!important;
}
.geo-layer{inset:-10%!important;clip-path:none!important}
.geo-layer-a{
  background:radial-gradient(circle at 50% 50%,transparent 0 18px,rgba(255,93,204,.55) 19px 23px,transparent 24px 48px)!important;
  background-size:106px 106px!important;
  background-position:var(--dx) var(--dy)!important;
}
.geo-layer-b{
  background:linear-gradient(45deg,transparent 0 46%,rgba(41,146,255,.44) 47% 49%,transparent 50%)!important;
  background-size:72px 72px!important;
  background-position:var(--ex) var(--ey)!important;
}
.geo-layer-c{
  background:linear-gradient(-45deg,transparent 0 46%,rgba(255,178,38,.36) 47% 49%,transparent 50%)!important;
  background-size:124px 124px!important;
  background-position:calc(var(--dx) * -1) var(--ey)!important;
}
.geo-layer-d{
  background:linear-gradient(45deg,transparent 0 47%,rgba(109,255,208,.26) 48% 49%,transparent 50%)!important;
  background-size:188px 188px!important;
  background-position:var(--ax) var(--cy)!important;
}
.geo-layer-e{
  background:radial-gradient(circle at 50% 50%,rgba(255,255,255,.15) 0 2px,transparent 3px)!important;
  background-size:34px 34px!important;
  background-position:var(--ex) var(--by)!important;
}

/* Enemy animation uses the three supplied frames. Feet remain anchored. */
.battle-enemy{transform-origin:center bottom!important;transition:transform .24s ease-out!important}
.battle-enemy.idle-normal{transform:scaleY(1)!important}
.battle-enemy.idle-breathe{transform:scaleY(1.012)!important}
.battle-enemy.idle-blink{transform:scaleY(1)!important}
.battle-enemy.hit{animation:enemy-hit .30s cubic-bezier(.36,.07,.19,.97) 1!important}

/* Cute four-command row. Each command has its own left icon compartment. */
.battle-command-strip{
  min-height:84px!important;
  width:calc(100% - 26px)!important;
  margin:7px 13px!important;
  padding:7px!important;
  gap:8px!important;
  background:#180925!important;
  border:3px solid #fff1da!important;
  outline:3px solid #e77fba!important;
  border-radius:16px!important;
  box-shadow:0 0 0 2px #572253,0 6px 0 #32132e,0 8px 16px rgba(0,0,0,.36)!important;
}
.battle-command-strip button.battle-command{
  min-height:66px!important;
  padding:6px 9px!important;
  border:3px solid #fff3de!important;
  outline:2px solid #55194b!important;
  border-radius:15px!important;
  gap:8px!important;
  justify-content:flex-start!important;
  color:#fffdf4!important;
  text-shadow:0 2px 0 #4b1644!important;
  box-shadow:inset 0 0 0 3px rgba(255,255,255,.17),0 3px 0 #47163f!important;
}
.battle-command.attack{background:linear-gradient(135deg,#ff5a91,#d91f65)!important}
.battle-command.defend{background:linear-gradient(135deg,#35a7ff,#176be2)!important}
.battle-command.heal{background:linear-gradient(135deg,#47dc83,#15a960)!important}
.battle-command.run{background:linear-gradient(135deg,#ffb83e,#ed8516)!important}
.battle-command .cmd-badge{
  width:clamp(31px,3.4vw,43px)!important;
  height:clamp(31px,3.4vw,43px)!important;
  padding:2px!important;
  flex:0 0 auto!important;
  display:grid!important;
  place-items:center!important;
  border:0!important;
  border-right:2px solid rgba(83,21,70,.45)!important;
  border-radius:0!important;
  background:transparent!important;
  box-shadow:none!important;
}
.battle-command .cmd-badge svg{width:100%;height:100%;display:block;filter:drop-shadow(0 2px 0 rgba(75,17,63,.35))}
.battle-command .cmd-label{flex:1;text-align:center;font-size:clamp(13px,2vw,22px);white-space:nowrap}

/* Static reference-style status background: black plus overlapping translucent coloured diamonds. */
.battle-status-card{
  animation:none!important;
  background-color:#030306!important;
  background-image:
    linear-gradient(45deg,transparent 0 40%,rgba(255,45,123,.70) 41% 45%,transparent 46% 100%),
    linear-gradient(-45deg,transparent 0 40%,rgba(42,115,255,.70) 41% 45%,transparent 46% 100%),
    linear-gradient(45deg,transparent 0 40%,rgba(39,206,91,.70) 41% 45%,transparent 46% 100%),
    linear-gradient(-45deg,transparent 0 40%,rgba(255,159,22,.70) 41% 45%,transparent 46% 100%),
    linear-gradient(45deg,transparent 0 44%,rgba(201,43,255,.58) 45% 48%,transparent 49% 100%),
    linear-gradient(#030306,#030306)!important;
  background-size:35px 35px,47px 47px,61px 61px,79px 79px,99px 99px,100% 100%!important;
  background-position:0 0,8px 5px,14px 18px,4px 24px,20px 6px,0 0!important;
}
.battle-status-card::before,.battle-status-card::after{display:none!important}
.battle-status-body{align-items:end!important}
.battle-hero-portrait{
  height:100%!important;
  min-height:110px!important;
  padding:0!important;
  display:flex!important;
  align-items:flex-end!important;
  justify-content:center!important;
  overflow:visible!important;
}
.battle-hero-portrait img{
  transform:none!important;
  margin:0!important;
  align-self:flex-end!important;
  width:min(100%,74px)!important;
}
.battle-meters{align-self:end!important;padding:0!important;margin:0!important}

/* Make drum rotation visibly readable instead of instant digit replacement. */
.hp-digit{animation:hp-roll .34s cubic-bezier(.18,.72,.25,1)!important}

@media(max-width:600px){
  .battle-message{min-height:68px;padding:10px 38px 9px 14px;border-width:3px;outline-width:2px;border-radius:12px}
  .battle-caret{right:11px!important;bottom:8px!important}
  .battle-command-strip{min-height:60px!important;width:calc(100% - 10px)!important;margin:5px!important;padding:4px!important;gap:3px!important;border-width:2px!important;outline-width:2px!important;border-radius:10px!important}
  .battle-command-strip button.battle-command{min-height:50px!important;padding:3px 2px!important;gap:2px!important;border-width:2px!important;border-radius:8px!important}
  .battle-command .cmd-badge{width:20px!important;height:22px!important;border-right-width:1px!important}
  .battle-command .cmd-label{font-size:clamp(9px,3vw,12px)!important}
  .battle-hero-portrait{min-height:82px!important}
  .battle-hero-portrait img{width:min(100%,50px)!important}
}


/* ===== UI12: multiline battle messages, mood row, npc slot placeholders ===== */
.battle-message p{white-space:pre-line; line-height:1.18;}
.battle-status-card,.battle-status-slot{min-height:168px!important;}
.battle-status-card{padding:8px 6px!important;}
.battle-status-body{align-items:end!important;grid-template-columns:minmax(44px,.72fr) minmax(92px,1.28fr)!important;}
.battle-hero-portrait{height:136px!important;display:flex;align-items:flex-end!important;justify-content:center;}
.battle-hero-portrait img{transform:none!important;max-height:132px;}
.battle-meters{gap:6px!important;align-self:end!important;}
.battle-meter-row{grid-template-columns:44px 1fr!important;}
.battle-meter-row>span{font-size:clamp(11px,1.35vw,16px)!important;letter-spacing:-.02em;}
.mood-drums{border-color:#f3c66b!important;background:linear-gradient(180deg,#fff7d8 0%,#ffe9a4 100%)!important;}
.mood-drums .hp-digit{color:#7a4814!important;}
.party-slot-line{display:block;height:12px;border-radius:999px;background:rgba(255,210,246,.16);border:2px solid rgba(255,170,233,.28);}
.battle-status-slot{display:grid!important;grid-template-columns:36px 1fr;grid-template-rows:1fr auto auto auto;gap:7px 10px;align-items:center;padding:10px 8px!important;}
.party-silhouette{grid-row:1 / span 4;align-self:center;justify-self:center;width:28px;height:44px;border-radius:18px 18px 10px 10px;border:3px solid rgba(255,195,243,.26);position:relative;opacity:.86;}
.party-silhouette::before{content:"";position:absolute;left:50%;top:-16px;transform:translateX(-50%);width:18px;height:18px;border-radius:50%;border:3px solid rgba(255,195,243,.26);}
@media(max-width:600px){
  .battle-status-card,.battle-status-slot{min-height:132px!important;}
  .battle-status-card{padding:4px 2px!important;}
  .battle-status-body{grid-template-columns:34% 66%!important;gap:1px!important;}
  .battle-hero-portrait{height:106px!important;}
  .battle-hero-portrait img{max-height:102px;}
  .battle-meter-row{grid-template-columns:24px 1fr!important;}
  .battle-meter-row>span{font-size:7px!important;}
  .battle-status-slot{grid-template-columns:18px 1fr;gap:3px 4px;padding:5px 3px!important;}
  .party-silhouette{width:14px;height:26px;border-width:2px;}
  .party-silhouette::before{width:9px;height:9px;top:-9px;border-width:2px;}
  .party-slot-line{height:6px;border-width:1px;}
}


/* ===== UI13: wide 3-line typewriter message / clean controller / rotating-ring dpad ===== */
.battle-message{
  width:calc(100% - 26px)!important;
  max-width:none!important;
  min-height:126px!important;
  margin:10px 13px 8px!important;
  padding:15px 54px 15px 22px!important;
  display:flex!important;
  align-items:flex-start!important;
}
.battle-typewriter-lines{
  width:100%;
  min-height:84px;
  display:grid;
  grid-template-rows:repeat(3,1fr);
  align-content:start;
  overflow:hidden;
}
.battle-typewriter-line{
  min-height:28px;
  line-height:1.25;
  white-space:pre-wrap;
  overflow:hidden;
}
.battle-message .battle-caret{right:19px!important;bottom:13px!important;}

/* Cover the printed source-image ABXY glyphs completely, then draw one clean HTML label. */
.cont1-x,.cont1-y,.cont1-a,.cont1-b{
  background:radial-gradient(circle at 36% 28%,#3b3b3b 0%,#151515 50%,#050505 100%)!important;
  border:2px solid rgba(221,172,82,.72)!important;
  box-shadow:inset 0 0 0 3px rgba(0,0,0,.48),0 2px 5px rgba(0,0,0,.7)!important;
  color:#edc778!important;
  z-index:5!important;
}
.cont1-x span,.cont1-y span,.cont1-a span,.cont1-b span{
  width:100%!important;height:100%!important;
  background:transparent!important;
  box-shadow:none!important;
  border-radius:50%!important;
  font-size:clamp(22px,4vw,58px)!important;
  font-weight:800!important;
  color:#edc778!important;
  text-shadow:0 2px 2px #000!important;
}

/* Custom circular D-pad: cross stays fixed for usability; ornament rings rotate. */
.cont1-spin-dpad{
  position:absolute;
  left:5.6%;
  top:23.5%;
  width:25.4%;
  aspect-ratio:1;
  z-index:4;
  border-radius:50%;
  background:radial-gradient(circle,#111 0 31%,#080808 32% 55%,#16120c 56% 100%);
  border:3px solid #9e742f;
  box-shadow:inset 0 0 0 5px #090909,inset 0 0 14px rgba(230,179,80,.32),0 4px 10px rgba(0,0,0,.7);
  pointer-events:none;
}
.spin-ring{position:absolute;inset:7%;border-radius:50%;border:3px dashed #c99842;opacity:.9;animation:cont1-ring-spin 4.8s linear infinite;}
.spin-ring.ring-two{inset:17%;border-style:dotted;border-color:#78501e;animation-duration:3.1s;animation-direction:reverse;}
@keyframes cont1-ring-spin{to{transform:rotate(360deg)}}
.spin-cross{position:absolute;width:31%;height:31%;display:grid;place-items:center;background:linear-gradient(#3a3020,#17130d);border:2px solid #b2853d;color:#f3d28f;font-size:clamp(12px,2.6vw,34px);font-weight:900;box-shadow:inset 0 0 8px #050505;}
.spin-up{left:34.5%;top:8%;border-radius:9px 9px 3px 3px}.spin-down{left:34.5%;bottom:8%;border-radius:3px 3px 9px 9px}.spin-left{left:8%;top:34.5%;border-radius:9px 3px 3px 9px}.spin-right{right:8%;top:34.5%;border-radius:3px 9px 9px 3px}.spin-core{position:absolute;left:34.5%;top:34.5%;width:31%;height:31%;border-radius:50%;background:radial-gradient(circle at 38% 30%,#333,#0c0c0c 70%);border:2px solid #8d672d;box-shadow:inset 0 0 8px #000;}
/* Hit areas sit above the custom visual. */
.dpad-up,.dpad-left,.dpad-right,.dpad-down{z-index:6!important;}

@media(max-width:600px){
  .battle-message{width:calc(100% - 10px)!important;margin:6px 5px!important;min-height:100px!important;padding:10px 35px 9px 13px!important;}
  .battle-typewriter-lines{min-height:72px;}
  .battle-typewriter-line{min-height:24px;line-height:1.2;font-size:clamp(12px,3.5vw,16px);}
  .cont1-x span,.cont1-y span,.cont1-a span,.cont1-b span{font-size:clamp(20px,8vw,38px)!important;}
}

/* ===== UI14: 360-degree joystick + rebuilt ABXY cluster ===== */
.cont1-joystick-zone{
  position:absolute;
  left:4.5%;
  top:18.5%;
  width:28.5%;
  aspect-ratio:1;
  z-index:8;
  border-radius:50%;
  touch-action:none;
  -webkit-tap-highlight-color:transparent;
  user-select:none;
  cursor:grab;
}
.cont1-joystick-zone.active{cursor:grabbing}
.joystick-base{
  position:absolute;
  inset:5%;
  border-radius:50%;
  background:
    radial-gradient(circle at 50% 50%,#0a0a0a 0 31%,#17130c 32% 48%,#080808 49% 65%,#20170b 66% 100%);
  border:3px solid #bd8d3c;
  box-shadow:
    inset 0 0 0 5px #050505,
    inset 0 0 0 8px rgba(185,132,48,.34),
    inset 0 0 22px rgba(226,174,73,.28),
    0 5px 12px rgba(0,0,0,.78);
  pointer-events:none;
}
.joystick-guide{
  position:absolute;
  left:50%;top:50%;
  width:72%;height:1px;
  transform-origin:center;
  background:linear-gradient(90deg,transparent,#8c652b 18%,#c99b4b 50%,#8c652b 82%,transparent);
  opacity:.68;
}
.joystick-guide.g1{transform:translate(-50%,-50%)}
.joystick-guide.g2{transform:translate(-50%,-50%) rotate(90deg)}
.joystick-knob{
  position:absolute;
  left:50%;top:50%;
  width:38%;
  aspect-ratio:1;
  border-radius:50%;
  transform:translate(-50%,-50%);
  background:
    radial-gradient(circle at 34% 28%,#4d4a43 0 8%,#25231e 24%,#0d0d0c 68%,#050505 100%);
  border:3px solid #b88638;
  box-shadow:
    inset 0 0 0 3px #080808,
    inset 0 0 12px rgba(255,205,101,.20),
    0 4px 8px rgba(0,0,0,.85);
  transition:transform 45ms linear;
}
.cont1-joystick-zone:not(.active) .joystick-knob{transition:transform 130ms cubic-bezier(.2,.85,.25,1.2)}

/* Hide the old baked-in ABXY artwork before drawing the actual buttons. */
.cont1-button-plate{
  position:absolute;
  left:59.8%;
  top:9.5%;
  width:38.2%;
  height:80%;
  z-index:3;
  border-radius:44%;
  background:
    radial-gradient(ellipse at 50% 50%,rgba(20,20,20,.97) 0 57%,rgba(8,8,8,.98) 72%,rgba(4,4,4,.98) 100%);
  box-shadow:inset 0 0 24px rgba(0,0,0,.95);
  pointer-events:none;
}
.cont1-x,.cont1-y,.cont1-a,.cont1-b{
  width:12.4%!important;
  aspect-ratio:1!important;
  transform:translate(-50%,-50%)!important;
  border-radius:50%!important;
  z-index:9!important;
  display:grid!important;
  place-items:center!important;
  overflow:hidden!important;
  background:
    radial-gradient(circle at 36% 29%,#343434 0 7%,#202020 28%,#0c0c0c 67%,#050505 100%)!important;
  border:3px solid #b88738!important;
  outline:2px solid #21170a!important;
  box-shadow:
    inset 0 0 0 3px #050505,
    inset 0 0 0 5px rgba(190,139,58,.22),
    0 4px 8px rgba(0,0,0,.82)!important;
}
.cont1-x{left:78.0%!important;top:26.3%!important}
.cont1-y{left:67.5%!important;top:48.3%!important}
.cont1-a{left:88.5%!important;top:48.3%!important}
.cont1-b{left:78.0%!important;top:70.3%!important}
.cont1-x span,.cont1-y span,.cont1-a span,.cont1-b span{
  position:absolute!important;
  inset:0!important;
  width:100%!important;
  height:100%!important;
  display:grid!important;
  place-items:center!important;
  border-radius:50%!important;
  background:transparent!important;
  box-shadow:none!important;
  color:#f1c96f!important;
  font-size:clamp(24px,4.25vw,54px)!important;
  font-family:Georgia,"Times New Roman",serif!important;
  font-weight:500!important;
  line-height:1!important;
  letter-spacing:0!important;
  text-align:center!important;
  text-shadow:0 2px 2px #000!important;
  transform:translateY(-1%)!important;
}
.cont1-x:active,.cont1-y:active,.cont1-a:active,.cont1-b:active{
  filter:brightness(1.22)!important;
  box-shadow:inset 0 0 0 3px #050505,inset 0 0 12px rgba(241,201,111,.38),0 2px 4px rgba(0,0,0,.82)!important;
}

@media(max-width:600px){
  .cont1-joystick-zone{left:4%;top:17%;width:29.5%}
  .joystick-base{border-width:2px}
  .joystick-knob{border-width:2px}
  .cont1-x,.cont1-y,.cont1-a,.cont1-b{width:12.8%!important;border-width:2px!important;outline-width:1px!important}
  .cont1-x span,.cont1-y span,.cont1-a span,.cont1-b span{font-size:clamp(25px,8.2vw,39px)!important}
}


/* ===== UI15: auto switch PC/mobile controls ===== */
.game-stage{position:relative;}
.mobile-controls{
  position:fixed;
  left:0; right:0; bottom:max(10px, env(safe-area-inset-bottom));
  width:min(760px,100%);
  margin:0 auto;
  height:180px;
  pointer-events:none;
  z-index:34;
}
.mobile-stick-zone,.mobile-status-button,.mobile-abxy,.mobile-button{pointer-events:auto;}
.mobile-stick-zone{
  position:absolute;left:10px;bottom:0;
  width:134px;height:134px;border-radius:50%;
  touch-action:none;-webkit-tap-highlight-color:transparent;user-select:none;
}
.mobile-stick-base{
  position:absolute;inset:0;border-radius:50%;
  background:radial-gradient(circle at 50% 45%, rgba(255,255,255,.18) 0 20%, rgba(56,84,99,.24) 21% 56%, rgba(10,19,26,.22) 57% 100%);
  border:2px solid rgba(236,247,255,.34);
  box-shadow:inset 0 0 18px rgba(255,255,255,.12), 0 8px 22px rgba(0,0,0,.18);
  backdrop-filter: blur(4px);
}
.mobile-stick-ring{position:absolute;inset:12%;border-radius:50%;border:2px solid rgba(255,255,255,.22);}
.mobile-stick-dot{position:absolute;left:50%;top:50%;width:8px;height:8px;border-radius:50%;background:rgba(255,255,255,.5);transform:translate(-50%,-50%);}
.mobile-stick-knob{position:absolute;left:50%;top:50%;width:43%;aspect-ratio:1;border-radius:50%;transform:translate(-50%,-50%);background:radial-gradient(circle at 35% 30%, rgba(255,255,255,.66) 0 8%, rgba(206,227,240,.54) 9% 24%, rgba(68,108,131,.58) 25% 62%, rgba(13,25,34,.72) 63% 100%);border:2px solid rgba(255,255,255,.32);box-shadow:0 4px 12px rgba(0,0,0,.22), inset 0 0 12px rgba(255,255,255,.16);transition:transform 45ms linear;}
.mobile-stick-zone:not(.active) .mobile-stick-knob{transition:transform 130ms cubic-bezier(.2,.85,.25,1.2)}
.mobile-status-button{
  position:absolute;left:50%;bottom:18px;transform:translateX(-50%);
  min-width:94px;height:42px;padding:0 18px;border-radius:999px;
  border:2px solid rgba(255,255,255,.30);
  background:linear-gradient(180deg, rgba(58,88,105,.52) 0%, rgba(16,33,43,.64) 100%);
  color:#f1f7fb;font-size:14px;font-weight:800;letter-spacing:.06em;
  backdrop-filter: blur(4px);box-shadow:0 6px 16px rgba(0,0,0,.18);
}
.mobile-abxy{position:absolute;right:10px;bottom:2px;width:150px;height:150px;}
.mobile-button{position:absolute;width:60px;height:60px;border-radius:50%;border:2px solid rgba(255,255,255,.33);background:radial-gradient(circle at 35% 30%, rgba(255,255,255,.28) 0 8%, rgba(120,162,186,.20) 9% 28%, rgba(28,58,76,.45) 29% 66%, rgba(10,20,28,.58) 67% 100%);color:#f9fbff;backdrop-filter: blur(4px);box-shadow:0 6px 16px rgba(0,0,0,.18);}
.mobile-button span{display:grid;place-items:center;width:100%;height:100%;font-size:28px;font-weight:800;line-height:1;text-shadow:0 1px 2px rgba(0,0,0,.45);}
.mobile-x{left:45px;top:0;}
.mobile-y{left:0;top:45px;}
.mobile-a{right:0;top:45px;}
.mobile-b{left:45px;bottom:0;}
@media (pointer: coarse){
  .prototype-footer{padding-bottom:4px;}
}
@media (min-width: 601px){
  .mobile-controls{width:min(760px, calc(100vw - 20px));}
}


/* ===== UI17: integrated mobile edit/sync workflow ===== */
.dev-map-edit-buttons,.dev-sync-actions{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-top:8px}.dev-map-edit-buttons button,.dev-sync-actions button{min-height:48px;border:2px solid #6f8f98;color:#fff7d8;font-weight:900;font-size:10px;padding:8px}.dev-map-edit-buttons .walkable{background:#1f6b50;border-color:#6bc89d}.dev-map-edit-buttons .blocked{background:#743e36;border-color:#c87a69}.dev-test-play{background:#245f86!important;border-color:#79b8dc!important}.dev-sync-file{background:#7b5723!important;border-color:#d9b66b!important}@media(max-width:600px){.dev-map-edit-buttons,.dev-sync-actions{grid-template-columns:1fr}.dev-map-edit-buttons button,.dev-sync-actions button{font-size:12px;min-height:52px}}
