/* Middle Word Game — PlayBloo self-hosted build.
 * Warm paper theme: cream background, soft cards, terracotta accent.
 * Values are our own; the feel follows the classic warm paper word-game look. */
* { box-sizing: border-box; }

[hidden] { display: none !important; }

:root {
  --bg: #f6f1e7;
  --card: #fffdf7;
  --card-2: #fbf6ec;
  --line: #e3d8c6;
  --ink: #2e2620;
  --muted: #7d6c59;
  --accent: #a84e2a;
  --accent-soft: rgba(168, 78, 42, 0.12);
  --good: #3f8f5f;
  --good-soft: rgba(63, 143, 95, 0.14);
  --warm: #d99a2b;
  --hot: #c96b3f;
  --radius: 14px;
  --shadow: 0 6px 20px rgba(46, 38, 32, 0.07);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --serif: Georgia, "Times New Roman", serif;
}

html, body { margin: 0; padding: 0; }

body {
  background:
    radial-gradient(1100px 500px at 50% -8%, #fdf9f0 0%, rgba(253, 249, 240, 0) 60%),
    var(--bg);
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.mw {
  max-width: 560px;
  margin: 0 auto;
  padding: 18px 16px 30px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---------- header ---------- */
.mw-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.mw-brand { display: flex; align-items: center; gap: 10px; }
.mw-logo {
  width: 36px; height: 36px;
  border-radius: 11px;
  background: var(--accent);
  display: grid; place-items: center;
  font-family: var(--serif);
  font-weight: 700; font-size: 18px; color: #fff;
  box-shadow: var(--shadow);
}
.mw-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 21px;
  letter-spacing: -0.01em;
}
.mw-title em { font-style: italic; color: var(--accent); }

.mw-mode {
  display: flex; gap: 4px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  box-shadow: var(--shadow);
}
.mw-mode-btn {
  border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 13px; font-weight: 700;
  padding: 5px 14px; border-radius: 999px; cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.mw-mode-btn[aria-pressed="true"] { background: var(--accent); color: #fff; }

/* ---------- board ---------- */
.mw-board {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow);
}

.mw-bound {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card-2);
  overflow: hidden;
  transition: border-color 0.25s;
}
.mw-bound-inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px;
}
.mw-bound-word {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 17px;
  text-transform: capitalize;
  letter-spacing: 0.02em;
}
.mw-bound-meta { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.mw-bound-meta strong { font-size: 14px; font-variant-numeric: tabular-nums; }
.mw-bound-meta small { color: var(--muted); font-size: 11px; }
.mw-bound-fill {
  position: absolute; inset: 0 auto 0 0;
  width: 12%;
  background: var(--hot);
  opacity: 0.16;
  transition: width 0.4s ease, background-color 0.4s ease;
}
.mw-bound.is-hot { border-color: var(--warm); }
.mw-bound.is-win { border-color: var(--good); background: var(--good-soft); }
.mw-bound.is-guard { animation: mw-guard 0.45s ease; }
@keyframes mw-guard {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  60% { transform: translateX(4px); }
}
.mw-bound.is-updated { animation: mw-nudge 0.4s ease; }
@keyframes mw-nudge {
  0% { transform: translateY(0); }
  40% { transform: translateY(-3px); }
  100% { transform: translateY(0); }
}

/* ---------- input ---------- */
.mw-input { display: flex; gap: 8px; }
.mw-input input {
  flex: 1;
  min-width: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.mw-input input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.mw-input input::placeholder { color: var(--muted); }
.mw-input input:disabled { opacity: 0.55; }
.mw-input button {
  width: 48px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}
.mw-input button:hover { filter: brightness(1.08); }
.mw-input button:active { transform: scale(0.95); }
.mw-input button:disabled { opacity: 0.55; cursor: default; }
.mw-input.is-shake { animation: mw-shake 0.4s ease; }
@keyframes mw-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  60% { transform: translateX(5px); }
}

/* ---------- messages ---------- */
.mw-msg {
  margin: 0;
  min-height: 1.4em;
  font-size: 13.5px;
  color: var(--muted);
  text-align: center;
}
.mw-msg[data-tone="ok"] { color: var(--good); font-weight: 700; }
.mw-msg[data-tone="info"] { color: var(--accent); }
.mw-msg[data-tone="warn"] { color: var(--hot); font-weight: 700; }

/* ---------- solver ---------- */
.mw-solver {
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: var(--card-2);
}
.mw-solver summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--muted);
  user-select: none;
}
.mw-solver summary::-webkit-details-marker { display: none; }
.mw-solver[open] summary { color: var(--ink); border-bottom: 1px dashed var(--line); }
.mw-solver-icon { color: var(--accent); }
.mw-solver-count { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.mw-solver-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.mw-solver-line { margin: 0; font-size: 14px; }
.mw-solver-line strong { font-family: var(--mono); color: var(--accent); text-transform: capitalize; }
.mw-solver-note { margin: 0; font-size: 12px; color: var(--muted); }
.mw-solver-actions { display: flex; gap: 8px; }

/* ---------- buttons ---------- */
.mw-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  font-weight: 700;
  border-radius: 10px;
  padding: 9px 16px;
  cursor: pointer;
  transition: filter 0.15s ease, background 0.15s ease;
}
.mw-btn:hover { background: var(--card-2); }
.mw-btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.mw-btn-primary:hover { background: #94431f; }
.mw-btn-small { padding: 6px 12px; font-size: 12.5px; }

/* ---------- result ---------- */
.mw-result {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card-2);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mw-result[data-won="true"] { border-color: var(--good); background: var(--good-soft); }
.mw-result-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mw-result-head strong { font-size: 16px; }
.mw-result[data-won="true"] .mw-result-head strong { color: var(--good); }
.mw-result-bar { display: flex; gap: 3px; font-size: 15px; }
.mw-result p { margin: 0; font-size: 13.5px; color: var(--muted); }
.mw-result p strong { color: var(--ink); text-transform: capitalize; }
.mw-result-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- toolbar / chips ---------- */
.mw-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.mw-diff {
  display: flex; gap: 4px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  box-shadow: var(--shadow);
}
.mw-diff button {
  border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 12.5px; font-weight: 700;
  padding: 4px 12px; border-radius: 999px; cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.mw-diff button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.mw-toolbar-right { display: flex; gap: 6px; flex-wrap: wrap; }
.mw-chip {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  font: inherit; font-size: 12.5px; font-weight: 700;
  border-radius: 999px;
  padding: 5px 12px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: background 0.15s ease, color 0.15s ease;
}
.mw-chip[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

/* ---------- history ---------- */
.mw-history { border: 1px solid var(--line); border-radius: 12px; background: var(--card); box-shadow: var(--shadow); }
.mw-history summary {
  list-style: none;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  user-select: none;
}
.mw-history summary::-webkit-details-marker { display: none; }
.mw-history ul { list-style: none; margin: 0; padding: 4px 14px 12px; display: flex; flex-direction: column; gap: 6px; }
.mw-history li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13.5px;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 6px;
}
.mw-history li:last-child { border-bottom: 0; padding-bottom: 0; }
.mw-h-word { font-family: var(--mono); text-transform: capitalize; font-weight: 600; }
.mw-h-dist { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }

/* ---------- stats ---------- */
.mw-stats { display: flex; gap: 8px; }
.mw-stat {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 6px;
  text-align: center;
  box-shadow: var(--shadow);
}
.mw-stat b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.mw-stat span { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

/* ---------- footer ---------- */
.mw-foot { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.mw-foot p { margin: 2px 0; }
.mw-foot a { color: var(--accent); text-decoration: none; font-weight: 700; }
.mw-foot-brand { opacity: 0.9; }

/* ---------- confetti ---------- */
.mw-confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
}

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