/* ==========================================================================
   Fishing Multiverse - main menu
   Units: --s = size of ONE logical game pixel in CSS px (set by main.js so it
   is always an integer number of device pixels). Layout sizes are expressed as
   multiples of --s so UI pixels line up with the canvas pixels.
   ========================================================================== */

@font-face {
  font-family: 'Press Start 2P';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/press-start-2p-latin-400-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122;
}
@font-face {
  font-family: 'Kanit';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/kanit-thai-600-normal.woff2') format('woff2');
  unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC;
}
@font-face {
  font-family: 'Kanit';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/kanit-latin-600-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122;
}

:root {
  --ink: #0b1020;
  --deep: #071630;
  --foam: #d8f6ff;
  --font-pixel: 'Press Start 2P', 'Courier New', monospace;
  --font-th: 'Kanit', 'Noto Sans Thai', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #050c1c;
}

body {
  display: grid;
  place-items: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  font-family: var(--font-th);
}

/* ---------- 9:16 stage ---------- */
.game {
  --s: 2px;
  position: relative;
  width: min(100vw, calc(100vh * 9 / 16));
  width: min(100vw, calc(100dvh * 9 / 16));
  aspect-ratio: 9 / 16;
  overflow: hidden;
  background: var(--deep);
  box-shadow: 0 0 0 var(--s) var(--ink), 0 0 60px rgba(0, 0, 0, 0.6);
}

.scene {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  margin: 0 auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  image-rendering: pixelated; /* last one wins where supported */
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- button column ---------- */
.menu {
  position: absolute;
  left: 0;
  right: 0;
  top: 53%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(var(--s) * 6);
  margin: 0;
  padding: 0;
}

.pxwrap {
  width: calc(var(--s) * 140);
  filter: drop-shadow(0 calc(var(--s) * 2) 0 rgba(0, 0, 0, 0.55));
}
.pxwrap:has(:focus-visible) {
  outline: var(--s) dashed #ffffff;
  outline-offset: calc(var(--s) * 2);
}
.pxwrap--primary {
  animation: idle-bob 1.6s linear infinite;
}
@keyframes idle-bob {
  0%, 49% { transform: translateY(0); }
  50%, 100% { transform: translateY(calc(var(--s) * -1)); }
}

/* Stepped-corner pixel button: outer shape = outline, ::before = face. */
.pxbtn {
  --n: calc(var(--s) * 2);          /* corner notch */
  --b: calc(var(--s) * 2);          /* outline thickness */
  --hi: #9cdcf5;
  --face: #2a7fb8;
  --shade: #1b5a8a;
  --line: #06182c;
  --rivet: rgba(0, 0, 0, 0.35);
  --text: #ffffff;
  --sub: #bfe8ff;
  --clip: polygon(
    0 var(--n), var(--n) var(--n), var(--n) 0,
    calc(100% - var(--n)) 0, calc(100% - var(--n)) var(--n), 100% var(--n),
    100% calc(100% - var(--n)), calc(100% - var(--n)) calc(100% - var(--n)), calc(100% - var(--n)) 100%,
    var(--n) 100%, var(--n) calc(100% - var(--n)), 0 calc(100% - var(--n))
  );

  position: relative;
  display: flex;
  align-items: center;
  gap: calc(var(--s) * 8);
  width: 100%;
  height: calc(var(--s) * 23);
  margin: 0;
  padding: 0 calc(var(--s) * 10);
  border: 0;
  background: var(--line);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  clip-path: var(--clip);
}
.pxbtn::before {
  content: '';
  position: absolute;
  inset: var(--b);
  background: linear-gradient(
    to bottom,
    var(--hi) 0 var(--s),
    var(--face) var(--s) calc(100% - var(--s) * 3),
    var(--shade) calc(100% - var(--s) * 3) 100%
  );
  clip-path: var(--clip);
}
.pxbtn::after {
  content: '';
  position: absolute;
  inset: var(--b);
  pointer-events: none;
  background:
    linear-gradient(var(--rivet), var(--rivet)) calc(var(--s) * 3) calc(var(--s) * 3) / var(--s) var(--s) no-repeat,
    linear-gradient(var(--rivet), var(--rivet)) calc(100% - var(--s) * 3) calc(var(--s) * 3) / var(--s) var(--s) no-repeat,
    linear-gradient(var(--rivet), var(--rivet)) calc(var(--s) * 3) calc(100% - var(--s) * 6) / var(--s) var(--s) no-repeat,
    linear-gradient(var(--rivet), var(--rivet)) calc(100% - var(--s) * 3) calc(100% - var(--s) * 6) / var(--s) var(--s) no-repeat;
}
.pxbtn:focus { outline: none; }
.pxbtn:active {
  transform: translateY(calc(var(--s) * 2));
  filter: brightness(0.92);
}
@media (hover: hover) {
  .pxbtn:hover { filter: brightness(1.12); }
}

.pxbtn--primary {
  --hi: #ffe27a;
  --face: #ffa826;
  --shade: #d9701a;
  --line: #3a1a08;
  --rivet: rgba(90, 40, 0, 0.5);
  --sub: #6a2f06;
  height: calc(var(--s) * 28);
}

.pxbtn__icon {
  position: relative;
  z-index: 1;
  flex: none;
  width: calc(var(--s) * 13);
  height: calc(var(--s) * 13);
  image-rendering: pixelated;
}
.pxbtn__text {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: calc(var(--s) * 3);
  min-width: 0;
}
.pxbtn__th {
  font-family: var(--font-th);
  font-weight: 600;
  font-size: calc(var(--s) * 9);
  line-height: 1;
  text-shadow: var(--s) var(--s) 0 var(--line);
}
.pxbtn--primary .pxbtn__th {
  font-size: calc(var(--s) * 11);
}
.pxbtn__en {
  font-family: var(--font-pixel);
  font-size: calc(var(--s) * 4);
  line-height: 1;
  color: var(--sub);
  white-space: nowrap;
}

/* ---------- footer ---------- */
.footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--s) * 5 + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(var(--s) * 3);
  margin: 0;
  font-family: var(--font-pixel);
  font-size: calc(var(--s) * 4);
  line-height: 1;
  text-align: center;
  pointer-events: none;
}
.footer p { margin: 0; }
.version { color: #7fb6d8; }
.credit {
  color: var(--foam);
  text-shadow: var(--s) var(--s) 0 #050a18;
}

/* ---------- toast ---------- */
.toast {
  position: absolute;
  left: 50%;
  bottom: calc(var(--s) * 3);
  width: max-content;
  max-width: calc(var(--s) * 150);
  padding: calc(var(--s) * 3) calc(var(--s) * 5);
  background: var(--ink);
  border: var(--s) solid #4df2ff;
  color: #ffffff;
  font-family: var(--font-th);
  font-weight: 600;
  font-size: calc(var(--s) * 6);
  line-height: 1.35;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, calc(var(--s) * 4));
  transition: opacity 0.12s steps(2), transform 0.12s steps(2);
  pointer-events: none;
}
.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.nojs {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  color: var(--foam);
  text-align: center;
  font-size: 16px;
}

@media (prefers-reduced-motion: reduce) {
  .pxwrap--primary { animation: none; }
  .toast { transition: none; }
}
