/* PPAO GAME — 8-bit theme (original pixel art, no third-party game assets) */
:root {
  --sky: #5c94fc;
  --sky-dark: #3c6fd8;
  --ink: #1a1018;
  --white: #fcfcfc;
  --brick: #c84c0c;
  --brick-dark: #7c2c00;
  --brick-light: #fcbcb0;
  --grass: #00a800;
  --grass-dark: #005800;
  --gold: #fcc000;
  --gold-dark: #b86800;
  --red: #e40058;
  --px: 4px; /* one "pixel" in the UI */
  --font-pixel: "Press Start 2P", "Courier New", monospace;
  --font-thai: "Sukhumvit Set", "Thonburi", "Noto Sans Thai", "Leelawadee UI", Tahoma, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--sky);
  color: var(--white);
  font-family: var(--font-pixel);
  overflow: hidden;
  -webkit-font-smoothing: none;
  image-rendering: pixelated;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
img, svg { image-rendering: pixelated; shape-rendering: crispEdges; }

/* ---------- Scenery ---------- */
.scene { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.cloud { position: absolute; width: calc(var(--px) * 32); animation: drift linear infinite; }
.cloud.c1 { top: 10%; animation-duration: 70s; animation-delay: -10s; }
.cloud.c2 { top: 22%; width: calc(var(--px) * 24); animation-duration: 95s; animation-delay: -55s; }
.cloud.c3 { top: 6%;  width: calc(var(--px) * 40); animation-duration: 120s; animation-delay: -90s; }
@keyframes drift { from { transform: translateX(-30vw); } to { transform: translateX(120vw); } }

.hill { position: absolute; bottom: calc(var(--px) * 16); }
.hill.h1 { left: 4%;  width: calc(var(--px) * 80); }
.hill.h2 { right: 6%; width: calc(var(--px) * 52); }
.bush { position: absolute; bottom: calc(var(--px) * 16); left: 46%; width: calc(var(--px) * 40); }

.ground {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: calc(var(--px) * 16);
  /* 16x16 brick tile, original pixel pattern */
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' shape-rendering='crispEdges'%3E%3Crect width='16' height='16' fill='%23c84c0c'/%3E%3Crect width='16' height='1' fill='%23fcbcb0'/%3E%3Crect y='7' width='16' height='1' fill='%237c2c00'/%3E%3Crect y='8' width='16' height='1' fill='%23fcbcb0'/%3E%3Crect y='15' width='16' height='1' fill='%237c2c00'/%3E%3Crect x='7' y='1' width='1' height='6' fill='%237c2c00'/%3E%3Crect x='15' y='9' width='1' height='6' fill='%237c2c00'/%3E%3Crect x='0' y='1' width='1' height='6' fill='%23fcbcb0'/%3E%3Crect x='8' y='9' width='1' height='6' fill='%23fcbcb0'/%3E%3C/svg%3E") repeat-x left top / calc(var(--px) * 16) calc(var(--px) * 16);
  box-shadow: 0 calc(var(--px) * -1) 0 var(--ink);
}

/* ---------- Login ---------- */
.login {
  position: relative; z-index: 1;
  height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: calc(var(--px) * 12);
  padding-bottom: calc(var(--px) * 24);
}
.title {
  font-size: clamp(28px, 8vw, 72px);
  letter-spacing: 0.06em;
  color: var(--white);
  text-shadow:
    var(--px) var(--px) 0 var(--ink),
    calc(var(--px) * 2) calc(var(--px) * 2) 0 var(--ink);
  text-align: center;
  line-height: 1.2;
}
.title .accent { color: var(--gold); }

.pin-wrap { position: relative; }
.pin {
  width: min(92vw, 560px);
  font-family: var(--font-pixel);
  font-size: clamp(14px, 3.6vw, 26px);
  letter-spacing: 0.4em;
  text-align: center;
  padding: calc(var(--px) * 4) calc(var(--px) * 3) calc(var(--px) * 4) calc(var(--px) * 5);
  color: var(--ink);
  background: var(--white);
  border: 0;
  outline: none;
  box-shadow:
    0 0 0 var(--px) var(--ink),
    inset calc(var(--px) * -1) calc(var(--px) * -1) 0 #bcbcbc,
    calc(var(--px) * 2) calc(var(--px) * 2) 0 var(--px) var(--ink);
  caret-color: var(--red);
  border-radius: 0;
  -webkit-appearance: none;
}
.pin::placeholder { color: #bcbcbc; letter-spacing: 0.4em; }
.pin:focus { box-shadow:
    0 0 0 var(--px) var(--ink),
    0 0 0 calc(var(--px) * 2) var(--gold),
    calc(var(--px) * 3) calc(var(--px) * 3) 0 calc(var(--px) * 2) var(--ink); }
.pin.shake { animation: shake .4s steps(4) 1; background: #fcd8d8; }
.pin.ok { background: #b8f8b8; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(calc(var(--px) * -3)); }
  75% { transform: translateX(calc(var(--px) * 3)); }
}

/* ---------- Home (phone-like springboard) ---------- */
.home { position: relative; z-index: 1; height: 100%; display: flex; flex-direction: column; }
.statusbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(var(--px) * 3) calc(var(--px) * 5);
  font-size: 12px;
  text-shadow: 2px 2px 0 var(--ink);
}
.statusbar .right { display: flex; gap: calc(var(--px) * 3); align-items: center; }
.battery { width: calc(var(--px) * 9); height: calc(var(--px) * 4); display: inline-block; position: relative;
  box-shadow: 0 0 0 2px var(--white), 2px 2px 0 2px var(--ink); background: linear-gradient(90deg, var(--grass) 75%, transparent 75%); }
.battery::after { content: ""; position: absolute; right: -6px; top: 4px; width: 3px; height: 8px; background: var(--white); }

.grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(72px, 19vw, 150px), 1fr));
  align-content: start;
  justify-items: center;
  gap: calc(var(--px) * 8) calc(var(--px) * 2);
  padding: calc(var(--px) * 8) calc(var(--px) * 4);
  max-width: 1000px; width: 100%; margin: 0 auto;
}
.app {
  display: flex; flex-direction: column; align-items: center; gap: calc(var(--px) * 3);
  text-decoration: none; color: var(--white); cursor: pointer;
  background: none; border: 0; font: inherit;
}
.app .tile {
  width: clamp(60px, 16vw, 128px); aspect-ratio: 1;
  background: #fff6e2;
  box-shadow:
    0 0 0 var(--px) var(--ink),
    inset calc(var(--px) * -2) calc(var(--px) * -2) 0 rgba(0,0,0,.18),
    inset calc(var(--px) * 2) calc(var(--px) * 2) 0 rgba(255,255,255,.6),
    calc(var(--px) * 2) calc(var(--px) * 2) 0 var(--px) var(--ink);
  /* stepped "rounded" corners like a pixel squircle */
  clip-path: polygon(
    0 12px, 4px 12px, 4px 4px, 12px 4px, 12px 0,
    calc(100% - 12px) 0, calc(100% - 12px) 4px, calc(100% - 4px) 4px, calc(100% - 4px) 12px, 100% 12px,
    100% calc(100% - 12px), calc(100% - 4px) calc(100% - 12px), calc(100% - 4px) calc(100% - 4px), calc(100% - 12px) calc(100% - 4px), calc(100% - 12px) 100%,
    12px 100%, 12px calc(100% - 4px), 4px calc(100% - 4px), 4px calc(100% - 12px), 0 calc(100% - 12px));
  display: grid; place-items: center; overflow: hidden;
  transition: transform .08s steps(2);
}
.app .tile img { width: 100%; height: 100%; object-fit: cover; }
.app:hover .tile, .app:focus-visible .tile { transform: translateY(calc(var(--px) * -2)); }
.app:active .tile { transform: translateY(var(--px)); }
.app .label {
  font-family: var(--font-thai); font-weight: 700;
  font-size: clamp(14px, 3.4vw, 18px);
  text-shadow: 2px 2px 0 var(--ink), -1px -1px 0 var(--ink), 1px -1px 0 var(--ink), -1px 1px 0 var(--ink);
}
.app.empty .tile { background: rgba(255,255,255,.18); box-shadow: inset 0 0 0 var(--px) rgba(255,255,255,.45); }
.app.empty .tile span { font-size: 28px; color: rgba(255,255,255,.7); }
.app.empty .label { opacity: .75; }

.dock-wrap { position: relative; padding: 0 calc(var(--px) * 4) calc(var(--px) * 20); display: flex; justify-content: center; }
.dock {
  display: flex; gap: calc(var(--px) * 8); padding: calc(var(--px) * 4) calc(var(--px) * 8);
  background: rgba(26, 16, 24, .35);
  box-shadow: 0 0 0 var(--px) rgba(26,16,24,.5);
}
.dock .app .tile { width: clamp(64px, 14vw, 88px); }
.dock .app .label { font-size: 13px; }
.tile.coin { background: var(--gold); }
.tile.pipe { background: var(--grass); }

/* Launch overlay */
.launch {
  position: fixed; inset: 0; z-index: 10; background: var(--ink);
  display: none; flex-direction: column; align-items: center; justify-content: center; gap: 24px;
}
.launch.show { display: flex; }
.launch img { width: min(70vw, 480px); background: #fff6e2; padding: 16px; box-shadow: 0 0 0 4px var(--white); }
.launch p { font-size: 14px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) { .cloud { animation: none; left: 20%; } }
