@import url("https://fonts.googleapis.com/css2?family=Pixelify+Sans:wght@400;600;700&family=Young+Serif&display=swap");

:root {
  --paper: #fbf6ea;
  --paper-2: #f3ead6;
  --ink: #2a1f1a;
  --ink-2: #6b5d52;
  --red: #d93a2b;
  --red-dark: #a82a1f;
  --wood: #7a4a28;
  --wood-dark: #5c361d;
  --green: #3c5a3a;
  --floor: #e9cfa3;
  --focus: #2f6fb0;
  --pixel: "Pixelify Sans", ui-monospace, monospace;
  --serif: "Young Serif", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--floor);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}
canvas { image-rendering: pixelated; image-rendering: crisp-edges; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--red-dark); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- pixel buttons & inputs ---------- */
.btn {
  font-family: var(--pixel);
  font-size: 20px;
  font-weight: 600;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 0;
  padding: 8px 18px;
  box-shadow: 0 4px 0 var(--ink);
  transition: transform 0.06s, box-shadow 0.06s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 5px 0 var(--ink); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--red); color: #fff; }
.btn-ghost { background: transparent; box-shadow: none; border-color: transparent; text-decoration: underline; }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label, .label { font-family: var(--pixel); font-size: 15px; font-weight: 600; letter-spacing: 0.02em; }
.hint { font-size: 13px; color: var(--ink-2); line-height: 1.4; }
.input, .textarea, .select {
  font: 16px var(--sans);
  width: 100%;
  padding: 10px 12px;
  background: #fffdf7;
  border: 3px solid var(--ink);
  border-radius: 0;
  box-shadow: inset 0 3px 0 rgba(0,0,0,0.06);
  color: var(--ink);
}
.textarea { min-height: 90px; resize: vertical; }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--red); }

.chip {
  font-family: var(--pixel);
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: var(--paper);
  border: 3px solid var(--ink);
  padding: 8px 12px;
  box-shadow: 0 4px 0 var(--ink);
}
.chip .key {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  border: 2px solid var(--ink);
  background: var(--paper-2);
  font-size: 14px;
}
.chip[aria-pressed="true"], .chip[aria-checked="true"] { background: var(--red); color: #fff; }
.chip[aria-pressed="true"] .key, .chip[aria-checked="true"] .key { background: #fff; color: var(--ink); }
.chip.locked { opacity: 0.8; }

.speech {
  font-family: var(--pixel);
  font-size: 18px;
  background: #fff;
  border: 3px solid var(--ink);
  padding: 8px 14px;
  position: relative;
  box-shadow: 0 4px 0 rgba(0,0,0,0.2);
  max-width: 280px;
  text-align: center;
  line-height: 1.25;
}
.speech::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -12px;
  width: 12px;
  height: 12px;
  background: #fff;
  border-right: 3px solid var(--ink);
  border-bottom: 3px solid var(--ink);
  transform: translateX(-50%) rotate(45deg);
}

.nametag {
  font-family: var(--pixel);
  font-size: 13px;
  background: var(--paper);
  border: 2px solid var(--ink);
  padding: 1px 6px;
  white-space: nowrap;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--pixel);
  padding: 10px 16px;
  z-index: 100;
  max-width: calc(100vw - 32px);
}

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

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
