:root {
  --bg-void: #090b0d;
  --bg-steel: #14181c;
  --bg-plate: #1b2026;
  --bg-inset: #0e1114;
  --border-rust: #4a3525;
  --border-steel: #2e3740;
  --amber: #e6912c;
  --amber-dim: #9e6118;
  --olive: #7a8c58;
  --cyan: #38bdf8;
  --red: #dc2626;
  --red-bright: #f87171;
  --green: #4ade80;
  --text-main: #d8dee4;
  --text-muted: #8492a0;
  --font-mono: "Share Tech Mono", "Noto Sans JP", monospace;
  --font-jp: "Noto Sans JP", sans-serif;
}

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

html, body {
  min-height: 100%;
  background: var(--bg-void);
  color: var(--text-main);
  font-family: var(--font-jp);
  font-size: 14px;
  line-height: 1.55;
  overflow-x: hidden;
}

.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 900;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.16) 3px
  );
}

.oil-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 899;
  background: radial-gradient(circle at center, transparent 55%, rgba(0, 0, 0, 0.72) 100%);
}

.hidden { display: none !important; }

.steel-panel {
  position: relative;
  background: linear-gradient(165deg, #1d2228 0%, #121519 100%);
  border: 1px solid var(--border-steel);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 10px 28px rgba(0, 0, 0, 0.7);
  padding: 16px;
}

.rivet {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #333b44;
  border: 1px solid #0b0d0f;
}
.rivet.tl { top: 6px; left: 6px; }
.rivet.tr { top: 6px; right: 6px; }
.rivet.bl { bottom: 6px; left: 6px; }
.rivet.br { bottom: 6px; right: 6px; }

.auth-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    linear-gradient(rgba(9, 11, 13, 0.82), rgba(9, 11, 13, 0.92)),
    url("/assets/images/title_bg.png") center/cover no-repeat;
}

.auth-panel {
  width: 100%;
  max-width: 420px;
  border-color: var(--border-rust);
  padding: 28px 26px;
}

.auth-header { text-align: center; margin-bottom: 20px; }
.auth-header h1 {
  font-family: var(--font-mono);
  font-size: 32px;
  letter-spacing: 3px;
  color: var(--amber);
  text-shadow: 0 0 14px rgba(230, 145, 44, 0.35);
}
.subtitle { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); letter-spacing: 1.5px; }
.badge-warn {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 8px;
  background: rgba(220, 38, 38, 0.16);
  border: 1px solid var(--red);
  color: var(--red-bright);
  margin-bottom: 8px;
}

.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form label { display: flex; flex-direction: column; gap: 5px; }
.login-form label span { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); letter-spacing: 1px; }
.login-form input {
  background: var(--bg-inset);
  border: 1px solid var(--border-steel);
  color: var(--text-main);
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 16px;
}
.login-form input:focus { outline: none; border-color: var(--amber); }
.login-error {
  background: rgba(220, 38, 38, 0.15);
  border: 1px solid var(--red);
  color: var(--red-bright);
  padding: 8px 10px;
  font-size: 12px;
}
.auth-note { margin-top: 14px; font-size: 11px; color: var(--text-muted); text-align: center; }

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.top-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: #101317;
  border-bottom: 2px solid var(--border-rust);
  gap: 10px;
  flex-wrap: wrap;
}
.hud-left { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.hud-brand { font-family: var(--font-mono); font-size: 16px; font-weight: 700; color: var(--amber); letter-spacing: 2px; }
.hud-status { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }
.hud-right { display: flex; align-items: center; gap: 6px; }

.screen-root {
  flex: 1;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px;
}

.btn {
  background: #232930;
  color: var(--text-main);
  border: 1px solid #3c4652;
  padding: 7px 13px;
  font-family: var(--font-jp);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
}
.btn:hover:not(:disabled) { background: #2d353f; border-color: var(--amber); color: #fff; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-xs { padding: 4px 8px; font-size: 11px; font-family: var(--font-mono); }
.btn-lg { padding: 11px 18px; font-size: 14px; }
.btn-primary { background: linear-gradient(180deg, #b86919 0%, #8b4c0e 100%); border-color: var(--amber); color: #fff; }
.btn-primary:hover:not(:disabled) { background: linear-gradient(180deg, #cc761f 0%, #9f5712 100%); }
.btn-danger { background: #4c1717; border-color: #991b1b; color: #fecaca; }
.btn-danger:hover:not(:disabled) { background: #6b1f1f; border-color: var(--red-bright); }
.btn-olive { background: #2d3822; border-color: var(--olive); color: #e2ecd3; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-garage { display: grid; grid-template-columns: 320px 1fr; gap: 16px; }
.grid-hangar { display: grid; grid-template-columns: 340px 1fr; gap: 14px; }
@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-garage, .grid-hangar { grid-template-columns: 1fr; }
}

.hero-banner {
  position: relative;
  min-height: 220px;
  border: 1px solid var(--border-rust);
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  padding: 20px;
  margin-bottom: 16px;
  background-size: cover;
  background-position: center;
}
.hero-banner::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(9, 11, 13, 0.94) 10%, rgba(9, 11, 13, 0.35) 100%);
}
.hero-content { position: relative; z-index: 2; width: 100%; }
.hero-title { font-family: var(--font-mono); font-size: 28px; color: var(--amber); letter-spacing: 2px; }
.hero-sub { font-size: 13px; color: #cbd5e1; margin-top: 4px; }

.mech-card-img {
  width: 100%;
  height: 190px;
  object-fit: cover;
  border: 1px solid var(--border-steel);
  filter: contrast(1.08) saturate(0.85);
  margin-bottom: 10px;
}

.arena-banner-img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border: 1px solid var(--border-rust);
  margin-bottom: 10px;
}

.section-title {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--amber);
  letter-spacing: 1px;
  border-bottom: 1px solid var(--border-steel);
  padding-bottom: 6px;
  margin-bottom: 10px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.06);
  font-size: 13px;
}
.stat-label { color: var(--text-muted); }
.stat-val { font-family: var(--font-mono); color: var(--text-main); }
.warn-text { color: var(--red-bright); font-weight: 700; }
.ok-text { color: var(--green); }
.amber-text { color: var(--amber); }
.cyan-text { color: var(--cyan); }

.menu-list { display: flex; flex-direction: column; gap: 8px; }
.menu-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-align: left;
  padding: 11px 14px;
  background: var(--bg-inset);
  border: 1px solid var(--border-steel);
  color: var(--text-main);
  cursor: pointer;
}
.menu-btn:hover:not(:disabled) { border-color: var(--amber); background: #181d23; }
.menu-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.menu-key { font-family: var(--font-mono); color: var(--amber); margin-right: 8px; }

.tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 6px;
  border: 1px solid var(--border-steel);
  background: var(--bg-inset);
  color: var(--text-muted);
}
.tag-amber { border-color: var(--amber-dim); color: var(--amber); }
.tag-red { border-color: var(--red); color: var(--red-bright); }
.tag-cyan { border-color: #0369a1; color: var(--cyan); }

.bar-wrap {
  width: 100%;
  height: 12px;
  background: #0b0d0f;
  border: 1px solid var(--border-steel);
  overflow: hidden;
  margin: 4px 0 8px;
}
.bar-fill { height: 100%; transition: width 0.15s linear; }
.bar-hp-player { background: linear-gradient(90deg, #0284c7, #38bdf8); }
.bar-hp-opp { background: linear-gradient(90deg, #991b1b, #ef4444); }
.bar-heat { background: linear-gradient(90deg, #ca8a04, #ef4444); }

.battle-log {
  height: 360px;
  overflow-y: auto;
  background: var(--bg-inset);
  border: 1px solid var(--border-steel);
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.log-player { color: #7dd3fc; }
.log-opponent { color: #fca5a5; }
.log-system { color: var(--amber); font-weight: 700; }
.log-trigger { color: #fde047; font-weight: 700; }

.slider-row { margin-bottom: 10px; }
.slider-row input[type="range"] { width: 100%; accent-color: var(--amber); }

.story-box {
  background: var(--bg-inset);
  border-left: 3px solid var(--amber);
  padding: 16px 18px;
  font-size: 14px;
  white-space: pre-wrap;
  line-height: 1.75;
}

.notice-box {
  background: rgba(230, 145, 44, 0.1);
  border: 1px solid var(--amber-dim);
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 13px;
}

.scroll-box {
  max-height: 460px;
  overflow-y: auto;
  padding-right: 4px;
}

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tab-btn {
  padding: 5px 10px;
  font-size: 12px;
  background: var(--bg-inset);
  border: 1px solid var(--border-steel);
  color: var(--text-muted);
  cursor: pointer;
}
.tab-btn.active { border-color: var(--amber); color: var(--amber); background: #1e242b; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 950;
}
.modal-box { width: 100%; max-width: 680px; max-height: 82vh; overflow-y: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head h3 { font-family: var(--font-mono); color: var(--amber); }
.modal-body { font-size: 13px; line-height: 1.7; white-space: pre-wrap; }

canvas { max-width: 100%; height: auto; }

/* TACTICAL HUD OVERLAY ON MECH IMAGE */
.mech-visual-box {
  position: relative;
  margin-bottom: 10px;
  border: 1px solid var(--border-rust);
  overflow: hidden;
  background: #0a0c0e;
}
.mech-visual-box .mech-card-img { margin-bottom: 0; border: none; display: block; }
.mech-hud-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 8px;
  background: linear-gradient(to bottom, rgba(9,11,13,0.68) 0%, transparent 38%, rgba(9,11,13,0.88) 100%);
}
.mech-hud-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.mech-hud-bottom { display: flex; flex-direction: column; gap: 3px; font-family: var(--font-mono); font-size: 11px; }
.hud-chip {
  background: rgba(14, 17, 20, 0.86);
  border: 1px solid var(--border-steel);
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--amber);
}

/* BATTLE VISUALS & ANIMATIONS */
@keyframes screenShake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-5px, 3px); }
  40% { transform: translate(5px, -3px); }
  60% { transform: translate(-4px, -2px); }
  80% { transform: translate(4px, 2px); }
}
.shake-hit { animation: screenShake 0.24s ease-out; }

@keyframes flashCrit {
  0% { box-shadow: inset 0 0 0 2px var(--red-bright), 0 0 24px rgba(239, 68, 68, 0.5); }
  100% { box-shadow: none; }
}
.flash-crit { animation: flashCrit 0.35s ease-out; }

@keyframes bannerSlam {
  0% { opacity: 0; transform: scale(1.08); letter-spacing: 6px; }
  100% { opacity: 1; transform: scale(1); letter-spacing: 2px; }
}
.battle-banner {
  background: linear-gradient(90deg, rgba(220,38,38,0.18), rgba(230,145,44,0.22), rgba(220,38,38,0.18));
  border-top: 2px solid var(--amber);
  border-bottom: 2px solid var(--amber);
  padding: 10px 14px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 12px;
  animation: bannerSlam 0.3s ease-out;
}

.radar-track {
  position: relative;
  height: 26px;
  background: #0a0d10;
  border: 1px solid var(--border-steel);
  margin: 8px 0 4px;
  font-family: var(--font-mono);
  font-size: 11px;
}
.radar-marker {
  position: absolute;
  top: 3px;
  transform: translateX(-50%);
  padding: 1px 5px;
  font-weight: 700;
  transition: left 0.2s ease-out;
}
.radar-p { background: rgba(56, 189, 248, 0.22); border: 1px solid var(--cyan); color: #7dd3fc; }
.radar-o { background: rgba(239, 68, 68, 0.22); border: 1px solid var(--red); color: #fca5a5; }

.ct-grid { display: flex; gap: 8px; font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); margin-top: 4px; }

@keyframes fadeInLine {
  from { opacity: 0; transform: translateX(-4px); }
  to { opacity: 1; transform: translateX(0); }
}
.fade-line { animation: fadeInLine 0.2s ease-out; }

.typewriter-cursor::after {
  content: "▌";
  color: var(--amber);
  animation: blinkCur 0.8s infinite;
}
@keyframes blinkCur { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }

.locked-panel {
  background: repeating-linear-gradient(
    -45deg,
    rgba(20, 24, 28, 0.9),
    rgba(20, 24, 28, 0.9) 10px,
    rgba(34, 26, 18, 0.9) 10px,
    rgba(34, 26, 18, 0.9) 20px
  );
  border: 1px dashed var(--border-rust);
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
}

.portrait-box { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.portrait-img {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border: 1px solid var(--border-rust);
  filter: contrast(1.06) saturate(0.88);
  flex-shrink: 0;
}
.diff-line { font-family: var(--font-mono); font-size: 11px; margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; }
.diff-pos { color: var(--green); }
.diff-neg { color: var(--red-bright); }

@media (max-width: 640px) {
  .screen-root { padding: 10px; }
  .steel-panel { padding: 12px; }
  .hero-banner { min-height: 170px; padding: 14px; }
  .hero-title { font-size: 22px; }
  .btn { min-height: 40px; }
  .btn-xs { min-height: 34px; padding: 6px 10px; }
  .menu-btn { padding: 12px; flex-wrap: wrap; gap: 6px; }
  .battle-log { height: 270px; font-size: 12px; }
  .shop-row { flex-direction: column; align-items: flex-start !important; }
}
