:root {
  --bg: #14172b; --bg2: #1d2140; --ink: #0b0b12; --paper: #f4e9c8; --paper2: #e8d9ae;
  --hi: #ffd23f; --red: #ff3b5c; --green: #3ddc84; --blue: #3fa7ff; --text: #f4e9c8;
  --px: 'Press Start 2P', monospace; --vt: 'VT323', monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg) radial-gradient(ellipse at top, #2a2f5c 0%, var(--bg) 70%) fixed;
  color: var(--text); font-family: var(--vt); font-size: 22px; line-height: 1.15;
  -webkit-font-smoothing: none; image-rendering: pixelated;
}
body::after { /* CRT scanlines */
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 999;
  background: repeating-linear-gradient(to bottom, rgba(0,0,0,.18) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}
img { image-rendering: pixelated; }
h1, h2, h3, .px { font-family: var(--px); font-weight: normal; letter-spacing: 1px; }
h2 { font-size: 18px; color: var(--hi); text-shadow: 3px 3px 0 #000; margin: 0 0 16px; }
a { color: var(--hi); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 16px; }
.hidden { display: none !important; }

/* buttons */
.btn {
  font-family: var(--px); font-size: 12px; color: var(--ink); background: var(--paper);
  border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink), inset -3px -3px 0 var(--paper2);
  padding: 12px 16px; cursor: pointer; text-transform: uppercase; transition: transform .05s;
}
.btn:hover { background: var(--hi); }
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.big { font-size: 16px; padding: 18px 22px; }
.btn.red { background: var(--red); color: #fff; }
.btn.green { background: var(--green); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

/* top bar */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 3px solid #000; background: #0e1022; position: sticky; top: 0; z-index: 50; }
.logo-sm { font-family: var(--px); font-size: 14px; color: var(--hi); text-shadow: 2px 2px 0 var(--red); cursor: pointer; }
.music-btn { font-family: var(--px); font-size: 10px; padding: 8px 10px; }

/* title screen */
.title { min-height: calc(100vh - 60px); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 24px; padding: 16px; }
.logo {
  font-family: var(--px); font-size: clamp(30px, 8vw, 76px); color: var(--hi); margin: 0;
  text-shadow: 4px 4px 0 var(--red), 8px 8px 0 #000; letter-spacing: 2px;
  -webkit-text-stroke: 2px #000;
}
.tagline { font-family: var(--px); font-size: clamp(9px, 2vw, 13px); color: var(--paper); }
.blink { animation: blink 1s steps(1) infinite; font-family: var(--px); font-size: 14px; }
@keyframes blink { 50% { opacity: 0; } }
.title-sprites { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.title-sprites img { width: 64px; height: 64px; padding: 4px; background: rgba(244,233,200,.14); border: 2px solid rgba(0,0,0,.4); animation: bob 1.2s steps(2) infinite; }
.title-sprites img:nth-child(2n) { animation-delay: .6s; }
@keyframes bob { 50% { transform: translateY(-6px); } }

.menu { display: grid; gap: 16px; width: min(420px, 100%); }
.menu .btn { width: 100%; }

/* type badge */
.type-badge { display: inline-block; font-family: var(--px); font-size: 8px; padding: 4px 6px; background: var(--tc); color: #fff; border: 2px solid #000; text-shadow: 1px 1px 0 #000; white-space: nowrap; }

/* ROOM TRADING CARD */
.room-card {
  --tc: #888; position: relative; width: 240px; background: var(--paper); color: var(--ink);
  border: 4px solid var(--ink); box-shadow: 6px 6px 0 #000; padding: 8px;
  outline: 6px solid var(--tc); outline-offset: -14px;
  display: flex; flex-direction: column; gap: 6px; font-size: 18px;
}
.room-card::before { content: ''; position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(45deg, rgba(0,0,0,.03) 0 4px, transparent 4px 8px); }
.rc-head { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 8px 0; }
.rc-name { font-family: var(--px); font-size: 11px; line-height: 1.3; }
.rc-hp { font-family: var(--px); font-size: 8px; color: var(--red); } .rc-hp b { font-size: 14px; margin-left: 2px; }
.rc-art { margin: 0 8px; background: linear-gradient(var(--tc), #fff8); border: 3px solid var(--ink); display: grid; place-items: center; padding: 6px; height: 132px; }
.rc-art img { width: 112px; height: 112px; }
.rc-type { display: flex; justify-content: space-between; align-items: center; padding: 0 8px; }
.rc-no { font-family: var(--px); font-size: 7px; opacity: .6; }
.rc-stats { padding: 0 8px; display: grid; gap: 2px; }
.stat { display: grid; grid-template-columns: 34px 1fr 30px; align-items: center; gap: 4px; font-family: var(--px); font-size: 7px; }
.stat .bar { height: 8px; border: 2px solid var(--ink); background: #fff; }
.stat .bar i { display: block; height: 100%; background: var(--tc); }
.stat b { text-align: right; }
.rc-moves { margin: 0 8px; border-top: 2px dashed var(--ink); padding-top: 4px; }
.rc-move { display: flex; justify-content: space-between; font-size: 17px; }
.rc-desc { margin: 0 8px 8px; font-size: 16px; font-style: italic; background: var(--paper2); border: 2px solid var(--ink); padding: 4px 6px; min-height: 40px; }
.room-card.pickable { cursor: pointer; transition: transform .1s; }
.room-card.pickable:hover { transform: translateY(-4px) rotate(-1deg); }
.room-card.picked { transform: translateY(-6px); box-shadow: 0 0 0 4px var(--hi), 8px 8px 0 #000; }
.room-card .pick-num { position: absolute; top: -14px; right: -14px; width: 36px; height: 36px; display: grid; place-items: center; background: var(--hi); border: 3px solid #000; font-family: var(--px); font-size: 14px; z-index: 2; }

.card-grid { display: flex; flex-wrap: wrap; gap: 22px; justify-content: center; }

/* MOVE CARD */
.move-card {
  --tc: #888; font: inherit; text-align: left; color: var(--ink); cursor: pointer; width: 200px;
  background: var(--paper); border: 3px solid var(--ink); box-shadow: 4px 4px 0 #000; padding: 0 0 6px;
  display: flex; flex-direction: column; gap: 4px; font-size: 17px; position: relative;
}
.move-card:hover:not(:disabled) { background: #fff6d6; transform: translateY(-2px); }
.move-card:disabled { cursor: default; }
.mc-top { background: var(--tc); color: #fff; padding: 6px 8px; display: flex; gap: 6px; align-items: center; border-bottom: 3px solid var(--ink); text-shadow: 1px 1px 0 #000; }
.mc-icon { font-size: 20px; }
.mc-name { font-family: var(--px); font-size: 9px; line-height: 1.3; }
.mc-type, .mc-nums, .mc-eff, .mc-desc { padding: 0 8px; }
.mc-nums { display: flex; gap: 12px; font-family: var(--px); font-size: 8px; }
.mc-eff { font-size: 16px; }
.mc-desc { font-size: 15px; opacity: .75; font-style: italic; }

/* BATTLE */
.arena {
  position: relative; border: 4px solid #000; box-shadow: 6px 6px 0 #000; overflow: hidden;
  background: linear-gradient(#7ec8e3 0 45%, #9bd17a 45% 100%); height: 380px; color: var(--ink);
}
.arena::before { /* storage facility backdrop */
  content: ''; position: absolute; left: 0; right: 0; top: 18%; height: 27%;
  background: repeating-linear-gradient(90deg, #d0c9b8 0 70px, #b8b09b 70px 74px);
  border-top: 6px solid #e85d3f; border-bottom: 4px solid #6d6655;
}
.arena::after {
  content: ''; position: absolute; left: 0; right: 0; top: 22%; height: 21%; opacity: .55;
  background: repeating-linear-gradient(90deg, transparent 0 12px, #8c8471 12px 58px, transparent 58px 74px),
              repeating-linear-gradient(to bottom, transparent 0 6px, rgba(0,0,0,.25) 6px 8px);
}
.side { position: absolute; z-index: 2; }
.side.foe { right: 6%; top: 8%; } .side.me { left: 6%; bottom: 6%; }
.side .pad { position: absolute; left: 50%; bottom: -10px; transform: translateX(-50%); width: 170px; height: 34px; border-radius: 50%; background: rgba(0,0,0,.22); }
.side img { width: 150px; height: 150px; position: relative; display: block; }
.side.me img { transform: scaleX(-1); }
.plate { position: absolute; z-index: 3; background: var(--paper); border: 3px solid #000; box-shadow: 4px 4px 0 #000; padding: 8px 10px; width: 260px; }
.plate.foe { left: 4%; top: 6%; } .plate.me { right: 4%; bottom: 8%; }
.plate .pn { font-family: var(--px); font-size: 10px; display: flex; justify-content: space-between; gap: 6px; align-items: center; }
.hp-row { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-family: var(--px); font-size: 8px; }
.hp-bar { flex: 1; height: 10px; border: 2px solid #000; background: #333; }
.hp-bar i { display: block; height: 100%; background: var(--green); transition: width .6s steps(12); }
.hp-bar i.mid { background: var(--hi); } .hp-bar i.low { background: var(--red); }
.hp-num { font-family: var(--px); font-size: 9px; text-align: right; margin-top: 4px; }
.stages { font-family: var(--px); font-size: 7px; margin-top: 4px; min-height: 9px; color: #555; }
.team-dots { display: flex; gap: 3px; } .team-dots i { width: 10px; height: 10px; border: 2px solid #000; background: var(--red); display: block; } .team-dots i.ok { background: var(--green); }

.lunge-me { animation: lungeMe .35s steps(4); } @keyframes lungeMe { 50% { transform: translate(40px, -20px); } }
.lunge-foe { animation: lungeFoe .35s steps(4); } @keyframes lungeFoe { 50% { transform: translate(-40px, 20px); } }
.shake { animation: shake .4s steps(6); } @keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.flash { animation: flash .5s steps(2) 2; } @keyframes flash { 50% { opacity: 0; } }
.faint { animation: faint .8s forwards steps(8); } @keyframes faint { to { transform: translateY(60px); opacity: 0; } }
.enter { animation: enter .5s steps(5); } @keyframes enter { from { transform: scale(0); } }

.textbox {
  margin-top: 16px; background: var(--paper); color: var(--ink); border: 4px solid #000; box-shadow: 6px 6px 0 #000;
  padding: 14px 18px; min-height: 84px; font-family: var(--px); font-size: 13px; line-height: 1.7; position: relative; cursor: pointer;
}
.textbox::after { content: '▼'; position: absolute; right: 12px; bottom: 6px; font-size: 10px; animation: blink .8s steps(1) infinite; }
.textbox.idle::after { content: ''; }
.actions { margin-top: 16px; }
.actions .who { font-family: var(--px); font-size: 11px; color: var(--hi); margin-bottom: 10px; }
.move-row { display: flex; flex-wrap: wrap; gap: 14px; }
.eff-tag { position: absolute; top: -10px; right: -8px; font-family: var(--px); font-size: 7px; background: #000; color: var(--hi); padding: 3px 4px; }

.switch-list { display: flex; flex-wrap: wrap; gap: 12px; }
.mini { display: flex; gap: 8px; align-items: center; background: var(--paper); color: var(--ink); border: 3px solid #000; box-shadow: 4px 4px 0 #000; padding: 6px 10px; cursor: pointer; font: inherit; }
.mini img { width: 48px; height: 48px; }
.mini:disabled { opacity: .4; cursor: not-allowed; }
.mini .mn { font-family: var(--px); font-size: 9px; text-align: left; }

.panel { background: var(--bg2); border: 3px solid #000; box-shadow: 6px 6px 0 #000; padding: 16px; margin-bottom: 20px; }
.type-chart { border-collapse: collapse; font-family: var(--px); font-size: 8px; }
.type-chart td, .type-chart th { border: 2px solid #000; padding: 6px; text-align: center; }
.type-chart .x2 { background: var(--green); color: #000; } .type-chart .x5 { background: var(--red); color: #fff; }
.scroll-x { overflow-x: auto; }

.result { text-align: center; padding: 40px 16px; display: grid; gap: 22px; justify-items: center; }
.result h1 { font-size: clamp(26px, 6vw, 48px); color: var(--hi); text-shadow: 4px 4px 0 var(--red), 7px 7px 0 #000; margin: 0; }

@media (max-width: 640px) {
  body { font-size: 19px; }
  .arena { height: 300px; }
  .side img { width: 100px; height: 100px; }
  .side .pad { width: 110px; }
  .plate { width: 180px; padding: 6px; } .plate .pn { font-size: 8px; }
  .move-card { width: calc(50% - 8px); }
  .room-card { width: 100%; max-width: 280px; }
  .textbox { font-size: 11px; }
}
