:root {
  color-scheme: light;
  --paper: #FAF8F3;
  --card: #FFFFFF;
  --ink: #16181D;
  --muted: #6B6F78;
  --rule: #D9D5CC;
  --soft: #EFECE4;
  --key: #DCD8CF;
  --accent: #2F5D8A;
  --mini: #4C7BD9;
  --wordle: #5A9E5C;
  --connect: #8A63C9;
  --strands: #3A9C9A;
  --hit: #5A9E5C;
  --near: #D4A93C;
  --miss: #7B7F87;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #15171B;
    --card: #1E2127;
    --ink: #ECEDEF;
    --muted: #9AA0AA;
    --rule: #33373F;
    --soft: #262A31;
    --key: #3A3F48;
    --accent: #8DB4E0;
    --miss: #4A4F57;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
}
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--rule); background: var(--card);
}
.topbar .home { text-decoration: none; font-family: "Iowan Old Style", Georgia, serif; font-weight: 700; font-size: 1.05rem; }
.topbar .title { font-weight: 700; font-size: 1.05rem; }
.picker { display: flex; gap: 6px; }
.picker a {
  min-width: 34px; height: 34px; padding: 0 8px; display: inline-grid; place-items: center;
  border: 1px solid var(--rule); border-radius: 999px; text-decoration: none; font-weight: 600; font-size: .9rem;
  position: relative;
}
.picker a.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.picker a.done::after {
  content: ""; position: absolute; right: -2px; top: -2px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--hit); border: 2px solid var(--card);
}

.game { max-width: 560px; margin: 0 auto; padding: 18px 16px 40px; }
.game h1 { font-family: "Iowan Old Style", Georgia, serif; font-size: 1.9rem; margin: 0 0 2px; }
.game .sub { color: var(--muted); margin: 0 0 18px; }

.btn {
  border: 1px solid var(--ink); background: transparent; border-radius: 999px;
  padding: 10px 18px; font-weight: 600; min-height: 44px;
}
.btn.solid { background: var(--ink); color: var(--paper); }
.btn:disabled { opacity: .35; cursor: default; }
.row-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }

#toast {
  position: fixed; left: 50%; top: 70px; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 6px; align-items: center; z-index: 50; pointer-events: none;
}
#toast div {
  background: var(--ink); color: var(--paper); padding: 10px 14px; border-radius: 6px; font-weight: 600; font-size: .9rem;
  animation: toastIn .15s ease-out;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(-6px); } }

.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 40; padding: 16px;
}
.modal {
  background: var(--card); border-radius: 12px; padding: 26px 22px 22px; max-width: 380px; width: 100%; text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
.modal h2 { font-family: "Iowan Old Style", Georgia, serif; margin: 0 0 8px; font-size: 1.7rem; }
.modal p { color: var(--muted); margin: 0 0 6px; line-height: 1.5; }

.kbd { display: flex; flex-direction: column; gap: 8px; margin: 18px auto 0; max-width: 500px; user-select: none; }
.kbd-row { display: flex; gap: 6px; justify-content: center; }
.kbd button {
  flex: 1; max-width: 44px; height: 54px; border: 0; border-radius: 5px; background: var(--key);
  font-weight: 700; text-transform: uppercase; font-size: .95rem; padding: 0;
}
.kbd button.wide { max-width: 68px; flex: 1.5; font-size: .75rem; }
.kbd button[data-state="hit"] { background: var(--hit); color: #fff; }
.kbd button[data-state="near"] { background: var(--near); color: #fff; }
.kbd button[data-state="miss"] { background: var(--miss); color: #fff; }
@media (max-width: 380px) { .kbd-row { gap: 4px; } .kbd button { height: 50px; } }

@keyframes shake {
  10%, 90% { transform: translateX(-1px); } 20%, 80% { transform: translateX(3px); }
  30%, 50%, 70% { transform: translateX(-5px); } 40%, 60% { transform: translateX(5px); }
}
.shake { animation: shake .45s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
