:root {
  --bg: #fff7fb;
  --ink: #1d1b20;
  --muted: #5b5561;
  --accent: #b0306a;
  --tile-border: #c9c3cc;
  --tile-filled: #6e6873;
  --key: #e6e1e8;
  --correct: #2f7a3a;
  --present: #d4b23a;
  --absent: #6b6f76;
  --focus: #1f5fd1;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { overflow-x: hidden; }

main {
  max-width: 500px;
  margin: 0 auto;
  padding: 10px 8px 24px;
}

.page { padding: 48px 20px; text-align: center; }
.page h1 { color: var(--accent); font-size: 1.6rem; }

.fatal { padding: 24px 12px; font-size: 1.1rem; text-align: center; }

.top { text-align: center; }
.top h1 { margin: 0; font-size: 1.3rem; color: var(--accent); }
.team {
  display: inline-block;
  margin: 6px 0 0;
  padding: 2px 12px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  letter-spacing: .03em;
}

.legend {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 14px;
  margin: 8px 0 0;
  padding: 0;
  font-size: .85rem;
  color: var(--muted);
}
.legend li { display: flex; align-items: center; gap: 5px; }
.swatch { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.swatch.correct { background: var(--correct); }
.swatch.present { background: var(--present); }
.swatch.absent { background: var(--absent); }
.hint { text-align: center; margin: 4px 0 0; font-size: .85rem; color: var(--muted); }

.notice {
  margin: 8px 0 0;
  padding: 6px 10px;
  border-radius: 8px;
  background: #fff0c2;
  font-size: .85rem;
  text-align: center;
}
.notice.party { background: #e2f0ff; font-weight: 700; }

.board {
  list-style: none;
  margin: 10px auto 0;
  padding: 0;
  width: min(100%, 300px);
  display: grid;
  gap: 5px;
}
.row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.tile {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--tile-border);
  background: #fff;
  font-size: clamp(1.4rem, 8vw, 2rem);
  font-weight: 800;
  text-transform: uppercase;
  line-height: 1;
  user-select: none;
}
.tile.filled { border-color: var(--tile-filled); }
.tile.correct, .tile.present, .tile.absent { border-color: transparent; color: #fff; }
.tile.correct { background: var(--correct); }
.tile.present { background: var(--present); color: #1d1b20; }
.tile.absent { background: var(--absent); }

.message {
  min-height: 1.5em;
  margin: 8px 0 0;
  text-align: center;
  font-weight: 700;
}

.result {
  margin: 6px auto 0;
  padding: 12px;
  border-radius: 12px;
  text-align: center;
  max-width: 360px;
}
.result h2 { margin: 0 0 6px; font-size: 1.3rem; }
.result p { margin: 6px 0; }
.result.won { background: #dff3e2; border: 2px solid var(--correct); }
.result.lost { background: #f4eef6; border: 2px solid var(--tile-border); }
.result .clue { font-weight: 700; white-space: pre-line; }

.keyboard { margin-top: 10px; display: grid; gap: 6px; }
.krow { display: flex; gap: 4px; justify-content: center; }
.key {
  flex: 1 1 0;
  min-width: 0;
  max-width: 44px;
  height: 54px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: var(--key);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  touch-action: manipulation;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.key.wide { flex-grow: 1.6; max-width: 70px; font-size: .8rem; }
.key.correct { background: var(--correct); color: #fff; }
.key.present { background: var(--present); color: #1d1b20; }
.key.absent { background: var(--absent); color: #fff; }
.key:active { filter: brightness(.9); }
.key:disabled { opacity: .55; cursor: default; }

.tools { margin-top: 18px; text-align: center; font-size: .9rem; }
.confirm p { margin: 0 0 8px; }
.confirm .btn + .btn { margin-left: 8px; }

.btn, .link-btn {
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
.btn {
  min-height: 44px;
  padding: 8px 18px;
  border-radius: 10px;
  border: 2px solid var(--tile-filled);
  background: #fff;
  color: var(--ink);
  font-weight: 700;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { border-color: #a1262c; color: #a1262c; }
.link-btn {
  min-height: 44px;
  background: none;
  border: 0;
  color: var(--muted);
  text-decoration: underline;
}

button:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

@media (min-height: 760px) {
  .key { height: 58px; }
}
