/* MAMONO site. Dark arcade layout: fixed top nav, the game fills the screen on
   the play page, shared components for the dex, token and guide pages. Fully
   responsive, keyboard on desktop and a touch pad on phones. */

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

:root {
  --bg: #0a0b14;
  --bg2: #0f1120;
  --panel: #161930;
  --panel2: #1d2140;
  --line: #2b3055;
  --ink: #ecebf6;
  --dim: #8e8cb4;
  --gold: #f3cb57;
  --green: #58e08c;
  --pink: #e85a9c;
  --blue: #5a9cf0;
  --nav-h: 58px;
  --pixel: "Press Start 2P", "Courier New", monospace;
  --mono: "Courier New", ui-monospace, Menlo, Consolas, monospace;
}

html, body { height: 100%; }

body {
  background: radial-gradient(1200px 600px at 50% -10%, #1a1d3a 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--green); text-decoration: none; }
a:hover { color: var(--gold); }

/* ---------- top nav ---------- */
.topnav {
  position: fixed; top: 0; left: 0; right: 0; height: var(--nav-h);
  display: flex; align-items: center; gap: 18px;
  padding: 0 18px;
  background: rgba(12, 14, 28, 0.92);
  border-bottom: 2px solid var(--line);
  backdrop-filter: blur(8px);
  z-index: 50;
}
.brand {
  font-family: var(--pixel);
  font-size: 16px;
  color: var(--gold);
  letter-spacing: 1px;
  text-shadow: 2px 2px 0 #6a4a08;
}
.brand:hover { color: var(--gold); filter: brightness(1.15); }
.navlinks { display: flex; align-items: center; gap: 20px; margin-left: auto; }
.navlinks a {
  font-family: var(--pixel);
  font-size: 10px;
  color: var(--dim);
  padding: 6px 2px;
  border-bottom: 2px solid transparent;
  letter-spacing: 0.5px;
}
.navlinks a:hover { color: var(--ink); }
.navlinks a.active { color: var(--gold); border-bottom-color: var(--gold); }
.navca { font-size: 11px; color: var(--dim); margin-left: 10px; }
.navca b { color: var(--green); font-weight: 700; }
.navtoggle { display: none; margin-left: auto; background: none; border: none; color: var(--ink); font-size: 22px; cursor: pointer; }

/* ---------- play page: full screen stage ---------- */
.page-play { overflow: hidden; }
.stage {
  position: fixed; top: var(--nav-h); left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 14px;
  background:
    radial-gradient(800px 400px at 50% 0%, rgba(90, 70, 160, 0.18), transparent 70%),
    repeating-linear-gradient(45deg, rgba(255,255,255,0.012) 0 2px, transparent 2px 18px);
}

.gameframe {
  position: relative;
  height: 100%; width: 100%;
  display: flex; align-items: center; justify-content: center;
}

/* the canvas display size is set in JS to the largest 10:9 box that fits */
#game {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #12101c;
  border: 3px solid #2c2f52;
  border-radius: 8px;
  box-shadow: 0 0 0 2px #0a0b14, 0 18px 60px rgba(0,0,0,0.6), 0 0 70px rgba(90,70,180,0.25);
  outline: none;
}

/* start overlay sits over the canvas. Its content is anchored low with a scrim
   so the animated canvas title shows above the entry controls. */
.startpanel {
  position: absolute; left: 50%; top: 0; bottom: 0;
  transform: translateX(-50%);
  width: 100%; max-width: 520px;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  gap: 11px; padding: 24px 24px 7%;
  text-align: center;
  background: linear-gradient(to top, rgba(8,9,18,0.92) 0%, rgba(8,9,18,0.78) 34%, rgba(8,9,18,0.12) 62%, transparent 80%);
}
.startpanel.hidden { display: none; }
.startpanel input {
  width: min(360px, 80vw);
  background: rgba(8, 9, 18, 0.9); border: 2px solid var(--line); color: var(--ink);
  padding: 12px 14px; font-family: var(--mono); font-size: 15px; text-align: center; border-radius: 8px; outline: none;
}
.startpanel input:focus { border-color: var(--gold); }

button {
  font-family: var(--mono); cursor: pointer; border: 2px solid var(--line);
  background: var(--panel); color: var(--ink); border-radius: 8px;
  padding: 12px 16px; font-size: 14px; font-weight: 700; letter-spacing: 0.04em;
}
button:hover { border-color: var(--green); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: default; }
.big.gold { background: linear-gradient(180deg, #ffd96a, var(--gold)); color: #241a04; border-color: #a8842c; font-size: 15px; width: min(360px, 80vw); }
.big.gold:hover { filter: brightness(1.08); }
.entryrow { display: flex; gap: 10px; width: min(360px, 80vw); }
.entryrow button { flex: 1; font-size: 13px; }
.gate { color: var(--dim); font-size: 12px; min-height: 16px; max-width: 360px; }
.status { color: var(--gold); font-size: 13px; min-height: 16px; }
.sp-keys { color: var(--dim); font-size: 11px; margin-top: 6px; }

/* ---------- touch controls ---------- */
.controls {
  display: none;
  position: absolute; left: 0; right: 0; bottom: 8px;
  justify-content: space-between; align-items: flex-end;
  padding: 0 14px; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none;
  pointer-events: none;
}
.controls > * { pointer-events: auto; }
@media (pointer: coarse) {
  body.playing .controls { display: flex; }
}
.dpad {
  display: grid;
  grid-template-columns: 46px 46px 46px; grid-template-rows: 46px 46px 46px;
  grid-template-areas: ". up ." "left . right" ". down ."; gap: 2px;
}
.pad { background: rgba(28,30,56,0.85); border: 2px solid #3a3d68; color: var(--dim); font-size: 16px; border-radius: 8px; }
.pad.active, .ab-btn.active, .startbtn.active { background: var(--gold); color: #241a04; }
.pad.up { grid-area: up; } .pad.down { grid-area: down; }
.pad.left { grid-area: left; } .pad.right { grid-area: right; }
.abwrap { display: flex; flex-direction: column; align-items: flex-end; gap: 12px; }
.ab { display: flex; gap: 14px; transform: rotate(-12deg); }
.ab-btn { width: 56px; height: 56px; border-radius: 50%; background: rgba(140,40,64,0.9); border: 2px solid #c8506c; color: #ffd9e2; font-size: 18px; font-weight: 900; }
.startbtn { background: rgba(28,30,56,0.85); border: 2px solid #3a3d68; color: var(--dim); font-size: 10px; padding: 6px 16px; border-radius: 12px; }

/* ---------- chat ---------- */
#chatbox {
  display: none;
  position: fixed; right: 14px; bottom: 14px;
  width: 300px; max-width: calc(100vw - 28px); max-height: 56vh;
  flex-direction: column;
  background: rgba(16,18,38,0.96); border: 2px solid var(--line); border-radius: 10px; overflow: hidden; z-index: 30;
}
.chathead { font-family: var(--pixel); font-size: 8px; color: var(--gold); padding: 8px 10px; border-bottom: 2px solid var(--line); letter-spacing: 1px; }
#chatlog { flex: 1; min-height: 120px; overflow-y: auto; padding: 8px 10px; font-size: 12px; }
.chatline { margin-bottom: 3px; word-break: break-word; }
.chatline b { color: var(--green); font-weight: 700; }
.chatline.sys, .chatline.sys b { color: var(--dim); }
#chatinput { border: none; border-top: 2px solid var(--line); background: #0c0e1c; color: var(--ink); padding: 10px 12px; font-family: var(--mono); font-size: 13px; outline: none; }

/* ---------- content pages (dex / token / guide) ---------- */
.page-content { min-height: 100%; }
.content {
  max-width: 1080px;
  margin: 0 auto;
  padding: calc(var(--nav-h) + 32px) 20px 80px;
}
.page-head { text-align: center; margin-bottom: 14px; }
.page-head h1 {
  font-family: var(--pixel); font-size: clamp(20px, 4vw, 30px); color: var(--gold);
  letter-spacing: 1px; text-shadow: 3px 3px 0 rgba(0,0,0,0.4); line-height: 1.5;
}
.page-head p { color: var(--dim); margin-top: 12px; max-width: 70ch; margin-left: auto; margin-right: auto; }

.content h2 {
  font-family: var(--pixel); font-size: 14px; color: var(--green);
  margin: 40px 0 16px; letter-spacing: 0.5px; line-height: 1.6;
}
.content h3 { color: var(--gold); font-size: 15px; margin-bottom: 8px; }
.content p { color: var(--ink); max-width: 75ch; margin-bottom: 12px; }
.content ul { color: var(--ink); margin: 0 0 12px 20px; }
.content li { margin-bottom: 6px; }
.content strong { color: var(--gold); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin: 8px 0 16px; }
.card { background: var(--panel); border: 2px solid var(--line); border-radius: 12px; padding: 18px; transition: border-color 0.15s, transform 0.15s; }
.card:hover { border-color: var(--gold); transform: translateY(-2px); }
.card p { color: var(--dim); font-size: 13px; }

.tablewrap { overflow-x: auto; margin: 8px 0 18px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); }
th { color: var(--green); font-family: var(--pixel); font-size: 9px; letter-spacing: 0.5px; }
td:first-child { color: var(--gold); }

/* dex grid */
.dexbar { display: flex; gap: 10px; align-items: center; justify-content: center; margin-bottom: 20px; flex-wrap: wrap; }
.dexbar input {
  background: var(--panel); border: 2px solid var(--line); color: var(--ink);
  padding: 10px 14px; border-radius: 8px; font-family: var(--mono); font-size: 14px; outline: none; min-width: 220px;
}
.dexbar input:focus { border-color: var(--gold); }
.dexcount { color: var(--dim); font-size: 13px; }

#dexgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; }
.dexcell {
  background: var(--panel); border: 2px solid var(--line); border-radius: 10px;
  padding: 10px 6px 12px; display: flex; flex-direction: column; align-items: center; gap: 5px;
  transition: border-color 0.15s, transform 0.15s; cursor: default;
}
.dexcell:hover { border-color: var(--gold); transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
.dexcell canvas { width: 72px; height: 72px; image-rendering: pixelated; image-rendering: crisp-edges; }
.dexcell .num { font-size: 10px; color: var(--dim); }
.dexcell .nm { font-size: 12px; color: var(--ink); text-align: center; }
.dexcell .ty { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.chip { font-size: 9px; padding: 2px 6px; border-radius: 10px; color: #11131f; font-weight: 700; }

footer { margin-top: 56px; border-top: 2px solid var(--line); padding-top: 20px; color: var(--dim); font-size: 12px; text-align: center; }
footer .ca { color: var(--green); margin-bottom: 8px; word-break: break-all; }
.btnrow { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.btnrow a { font-family: var(--pixel); font-size: 10px; padding: 12px 18px; border: 2px solid var(--line); border-radius: 8px; color: var(--ink); }
.btnrow a.primary { background: linear-gradient(180deg, #ffd96a, var(--gold)); color: #241a04; border-color: #a8842c; }
.btnrow a:hover { border-color: var(--green); }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .navtoggle { display: block; }
  .navlinks {
    display: none; position: fixed; top: var(--nav-h); left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0; margin: 0;
    background: rgba(12,14,28,0.98); border-bottom: 2px solid var(--line);
  }
  .navlinks.open { display: flex; }
  .navlinks a { padding: 14px 18px; border-bottom: 1px solid var(--line); }
  .navlinks a.active { border-bottom-color: var(--line); }
  .navca { padding: 12px 18px; margin: 0; }
  .stage { padding: 6px; }
}
@media (max-width: 480px) {
  .ab-btn { width: 50px; height: 50px; }
  .dpad { grid-template-columns: 42px 42px 42px; grid-template-rows: 42px 42px 42px; }
}
