/* ===== Pixel Art RPG — บ้านของ AI ===== */
:root {
  --bg: #1a1c2c;
  --panel: #262b44;
  --ink: #f4f4f4;
  --muted: #a0a0c0;
  --line: #3a4466;
  --wood: #7a4f2a;
  --wood-dark: #5a3a1e;
  --leaf: #4caf50;
  --sun: #ffcd75;
  --pixel: 2px;
  --radius: 0px;
  --shadow: 2px 2px 0 #000;
  --fest-1: #ffd23f;
  --fest-2: #4ea8de;
  --fest-3: #ff6b6b;
  /* mockup palette */
  --px-bg:#1a1c2c; --px-wall:#5d4e37; --px-floor:#8b7355; --px-grass:#38b764;
  --px-grass-dark:#25784a; --px-path:#d9a066; --px-door:#b13e53; --px-accent:#ffcd75;
  --px-text:#f4f4f4; --px-muted:#94b0c2; --tile:32px;
  /* scene palette */
  --scene-bg:#CFC7B4; --scene-wood:#D9A77A; --scene-brick:#9C6847;
  --scene-green:#7E8A47; --scene-green-dark:#649436; --scene-text:#3A2F25;
  --scene-muted:#7F6C55; --scene-accent:#E0BB8B;
}

* { box-sizing: border-box; image-rendering: pixelated; }

html, body { margin: 0; }

body {
  font-family: "Tahoma", "Leelawadee UI", "Noto Sans Thai", monospace;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: none;
  font-smoothing: none;
}

body.night { --bg: #0d0f1a; --panel: #16182a; --ink: #e0e0ff; }
body.dusk  { --bg: #2a1f2e; --panel: #3a2a3e; }

/* tile grid background */
body {
  background-image:
    linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);
  background-size: 16px 16px;
}

.sky {
  position: fixed; inset: 0; z-index: -1;
  background: linear-gradient(180deg, #2a3a5c 0%, #1a1c2c 100%);
}
.sky.night { background: linear-gradient(180deg, #05070f 0%, #0d0f1a 100%); }
.sky.dusk  { background: linear-gradient(180deg, #5c3a2a 0%, #2a1f2e 100%); }

.orb {
  position: absolute; width: 16px; height: 16px;
  background: var(--sun); box-shadow: 0 0 0 2px #000;
  transition: left 2s steps(8), top 2s steps(8);
}
.sky.night .orb { background: #e8ecf7; }

.clouds {
  position: absolute; inset: 0; opacity: .35;
  background: radial-gradient(circle at 20% 30%, rgba(255,255,255,.5) 0 6px, transparent 7px),
              radial-gradient(circle at 72% 22%, rgba(255,255,255,.4) 0 5px, transparent 6px);
  animation: drift 90s steps(60) infinite;
}
@keyframes drift { from { transform: translateX(-4%); } to { transform: translateX(4%); } }

.wrap { max-width: 960px; margin: 0 auto; padding: 16px; }

.brand { margin-bottom: 12px; border: 2px solid var(--line); background: var(--panel); padding: 10px; box-shadow: var(--shadow); }
.brand-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.eyebrow { margin: 0; font-size: 10px; letter-spacing: .1em; color: var(--wood); text-transform: uppercase; }
.clock { margin: 0; font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); }
h1 { font-size: 14px; margin: 6px 0; font-weight: 700; }
.lead { margin: 0 0 8px; color: var(--muted); font-size: 11px; }
.status { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.dot { width: 8px; height: 8px; background: #555; box-shadow: 0 0 0 1px #000; }
.dot.on { background: var(--leaf); }
.sep { opacity: .5; }

/* game menu tabs */
.nav {
  display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0 12px;
  border: 2px solid var(--line); background: var(--panel); padding: 6px; box-shadow: var(--shadow);
}
.tab {
  border: 2px solid var(--line); background: #1a1c2c; color: var(--ink);
  padding: 6px 10px; font: inherit; font-size: 11px; cursor: pointer;
  border-radius: 0; box-shadow: 2px 2px 0 #000;
}
.tab:hover { background: var(--wood-dark); }
.tab.is-on { background: var(--wood); border-color: var(--sun); color: #fff; }
.tab.is-locked { opacity: .55; }

.room { display: none; animation: none; }
.room.is-on { display: block; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.head h2 { font-size: 13px; margin: 0 0 4px; }
.head p { margin: 0 0 10px; color: var(--muted); font-size: 11px; }

.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.card {
  background: var(--panel); border: 2px solid var(--line); border-radius: 0;
  padding: 10px; box-shadow: var(--shadow); margin-bottom: 10px;
}
.label { margin: 0 0 4px; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--sun); }
body.night .label { color: #c8a483; }
.big { font-size: 13px; margin: 0 0 4px; }
.muted { color: var(--muted); font-size: 11px; margin: 0; }
.tiny { color: var(--muted); font-size: 10px; margin: 6px 0 0; }
hr { border: 0; border-top: 2px dashed var(--line); margin: 10px 0; }

input, textarea {
  width: 100%; font: inherit; font-size: 12px; color: var(--ink);
  background: #0d0f1a; border: 2px solid var(--line); border-radius: 0;
  padding: 6px 8px; margin-bottom: 6px; resize: vertical;
}
input:focus, textarea:focus { outline: 2px solid var(--sun); border-color: var(--sun); }

.btn {
  font: inherit; font-size: 11px; border: 2px solid #000;
  background: var(--wood); color: #fff; padding: 6px 12px; border-radius: 0;
  cursor: pointer; box-shadow: 2px 2px 0 #000;
}
.btn:hover { filter: brightness(1.1); }
.btn:disabled { opacity: .5; cursor: default; box-shadow: none; }

.list { list-style: none; margin: 8px 0 0; padding: 0; }
.list li { border-top: 1px dashed var(--line); padding: 6px 0; font-size: 11px; }
.list li:first-child { border-top: 0; }
.list .who { color: var(--sun); font-weight: 700; }
.notes li::before { content: "> "; color: var(--wood); }

.chips, .gift-picker { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip {
  font: inherit; font-size: 11px; border: 2px solid var(--line);
  background: #1a1c2c; color: var(--ink); padding: 4px 8px; border-radius: 0; cursor: pointer;
  box-shadow: 2px 2px 0 #000;
}
.chip:hover { border-color: var(--sun); }
.chip:disabled { opacity: .5; }

.gifts { list-style: none; margin: 8px 0 0; padding: 0; font-size: 11px; }
.gifts li { padding: 3px 0; }

/* window */
.window {
  position: relative; height: 140px; border: 2px solid var(--line);
  overflow: hidden; background: linear-gradient(180deg, #2a4a6c, #1a2a3c);
  margin-bottom: 10px;
}
.window.night { background: linear-gradient(180deg, #0a0e1c, #1a1e3c); }
.window.dusk  { background: linear-gradient(180deg, #5c3a2a, #3a2a1e); }
.window.rain  { background: linear-gradient(180deg, #3a4a5c, #2a3a4c); }
.hills {
  position: absolute; bottom: 0; left: 0; right: 0; height: 46%;
  background: linear-gradient(#3a5a3a, #2a4a2a);
}
.sun { position: absolute; width: 16px; height: 16px; background: #ffcd75; box-shadow: 0 0 0 2px #000; }

/* shelf */
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.book {
  background: var(--panel); border: 2px solid var(--line); border-radius: 0;
  padding: 8px; border-left: 4px solid var(--wood); box-shadow: var(--shadow);
}
.book h3 { margin: 0 0 4px; font-size: 12px; font-weight: 700; }
.book p { margin: 0; font-size: 10px; color: var(--muted); }

/* cat game */
.game { margin-top: 6px; }
.spots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.spot {
  height: 48px; border: 2px dashed var(--line); background: #1a1c2c;
  cursor: pointer; font-size: 16px; display: grid; place-items: center; border-radius: 0;
}
.spot:hover { border-color: var(--sun); }
.spot.found { border-style: solid; border-color: var(--leaf); background: #1a2a1c; }

/* garden */
.garden-card { padding: 10px; }
.garden-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.garden {
  position: relative; display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px; min-height: 180px; padding: 10px; border: 2px solid var(--line);
  background: #2a3a2c; overflow: hidden; border-radius: 0;
}
body.night .garden { background: #1a2a1e; border-color: #2a3a2e; }
.plant {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  min-height: 110px; font-size: 10px; text-align: center; color: var(--muted);
}
.plant .stem { width: 4px; background: var(--leaf); margin-bottom: 4px; transition: height .3s steps(4); }
.plant .top { font-size: 18px; line-height: 1; margin-bottom: 2px; }
.plant .name { font-size: 9px; }
.plant .age { font-size: 8px; opacity: .75; }
.cat-nap {
  position: absolute; font-size: 20px; transition: left .4s steps(8), top .4s steps(8);
  pointer-events: none;
}

.toast {
  position: fixed; left: 50%; bottom: 16px; transform: translate(-50%, 20px);
  background: #0d0f1a; color: var(--ink); border: 2px solid var(--sun);
  padding: 8px 14px; font-size: 11px; opacity: 0; pointer-events: none;
  transition: opacity .15s steps(4), transform .15s steps(4); z-index: 20; border-radius: 0;
  box-shadow: var(--shadow);
}
.toast.show { opacity: .95; transform: translate(-50%, 0); }

footer { margin-top: 16px; padding-top: 10px; border-top: 2px dashed var(--line); color: var(--muted); font-size: 10px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* isometric scene */
.scene-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 80vh;
  background: url('assets/ai-home-scene.jpg') center/cover no-repeat;
  image-rendering: auto;
  overflow: hidden;
  border: 2px solid var(--px-wall);
  margin: 0 auto 12px;
}
.room-hotspot {
  position: absolute;
  background: rgba(255,255,255,0.08);
  border: 1px dashed rgba(255,255,255,0.35);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  cursor: pointer;
  border-radius: 0;
}
.room-hotspot:hover { background: rgba(255,255,255,0.18); }
.char {
  position: absolute;
  font-size: 22px;
  pointer-events: none;
  animation: walk-a 10s linear infinite;
}
.char-a { left: 10%; top: 70%; animation-name: walk-a; }
.char-b { left: 5%; top: 60%; animation-name: walk-b; animation-duration: 8s; }
.char-c { left: 40%; top: 75%; animation-name: walk-c; animation-duration: 12s; }
@keyframes walk-a {
  0% { left: 10%; top: 70%; }
  25% { left: 34%; top: 45%; }
  50% { left: 64%; top: 40%; }
  75% { left: 34%; top: 45%; }
  100% { left: 10%; top: 70%; }
}
@keyframes walk-b {
  0% { left: 5%; top: 60%; }
  50% { left: 34%; top: 45%; }
  100% { left: 5%; top: 60%; }
}
@keyframes walk-c {
  0% { left: 40%; top: 75%; }
  33% { left: 34%; top: 45%; }
  66% { left: 62%; top: 15%; }
  100% { left: 40%; top: 75%; }
}
@media (prefers-reduced-motion: reduce) {
  .char { animation: none !important; }
}

@media (max-width: 720px) {
  .duo { grid-template-columns: 1fr; }
  .wrap { padding: 10px; }
  .garden { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); }
  .nav { gap: 3px; }
  .tab { font-size: 10px; padding: 5px 7px; }
}
@media (max-width: 375px) {
  .tab { font-size: 9px; padding: 4px 6px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}