:root {
  --bg: #fff7e6; --card: #ffffff; --text: #2b2d42; --muted: #6b6f85;
  --primary: #6c5ce7; --primary-text: #fff; --accent: #ff9f1c; --good: #2ecc71; --bad: #e74c3c;
  --tile: #e8f4ff; --tile-border: #74b9ff; --shadow: 0 6px 20px rgba(0,0,0,.08); --border: #eadfc8;
}
[data-theme="dark"] {
  --bg: #14152b; --card: #1f2142; --text: #f1f2ff; --muted: #a3a6c8;
  --primary: #8c7dff; --primary-text: #12122a; --accent: #ffb84d; --good: #4cd98a; --bad: #ff6b6b;
  --tile: #2a2d5c; --tile-border: #5b8cff; --shadow: 0 6px 20px rgba(0,0,0,.4); --border: #33366b;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: ui-rounded, "Nunito", "Segoe UI", system-ui, sans-serif; line-height: 1.5;
  transition: background .25s, color .25s;
}
.top { display: flex; justify-content: space-between; align-items: center; max-width: 760px; margin: 0 auto; padding: 16px; }
.logo { margin: 0; font-size: 1.8rem; }
.logo span { color: var(--primary); }
main { max-width: 760px; margin: 0 auto; padding: 0 16px 32px; display: grid; gap: 16px; }
.card { background: var(--card); border: 2px solid var(--border); border-radius: 20px; padding: 20px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 8px; }
.intro p { margin: 0; color: var(--muted); }
.settings { display: flex; flex-wrap: wrap; gap: 16px; align-items: end; }
.settings label { display: grid; gap: 4px; font-weight: 700; }
select {
  font: inherit; padding: 8px 12px; border-radius: 12px; border: 2px solid var(--border);
  background: var(--bg); color: var(--text);
}
.btn, .icon-btn, .op, .tile {
  font: inherit; cursor: pointer; border: 2px solid var(--border); background: var(--card); color: var(--text);
  border-radius: 14px; transition: transform .1s, background .15s;
}
.btn { padding: 10px 16px; font-weight: 700; }
.btn:hover:not(:disabled), .op:hover, .tile:hover, .icon-btn:hover { transform: translateY(-2px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.btn.accent { background: var(--accent); color: #2b2d42; border-color: var(--accent); }
.icon-btn { font-size: 1.4rem; width: 48px; height: 48px; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

.target { text-align: center; margin-bottom: 16px; }
.target .label { display: block; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .1em; font-size: .85rem; }
.target .value { font-size: 4.5rem; font-weight: 900; color: var(--accent); line-height: 1.1; display: inline-block; }
.target.win .value { animation: pop .6s ease 3; color: var(--good); }
@keyframes pop { 50% { transform: scale(1.3) rotate(-4deg); } }

.tiles { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; min-height: 72px; }
.tile { min-width: 72px; height: 72px; padding: 0 14px; font-size: 1.8rem; font-weight: 800; background: var(--tile); border-color: var(--tile-border); }
.tile.selected { background: var(--primary); color: var(--primary-text); border-color: var(--primary); transform: scale(1.1); }
.tile.new { animation: pop-in .3s ease; }
@keyframes pop-in { from { transform: scale(.3); opacity: 0; } }

.ops { display: flex; gap: 12px; justify-content: center; margin-top: 20px; }
.op { width: 64px; height: 64px; font-size: 2rem; font-weight: 800; }
.op.selected { background: var(--accent); border-color: var(--accent); color: #2b2d42; transform: scale(1.1); }
.used { display: flex; gap: 8px; justify-content: center; margin-top: 10px; min-height: 28px; }
.used span { padding: 2px 12px; border-radius: 999px; border: 2px dashed var(--border); color: var(--muted); font-weight: 800; }
.used span.done { border-style: solid; border-color: var(--good); color: var(--good); }

.message { text-align: center; font-weight: 700; min-height: 1.6em; margin: 16px 0 8px; }
.message.good { color: var(--good); } .message.bad { color: var(--bad); }
.steps { margin: 0 auto 12px; padding-left: 28px; max-width: 320px; color: var(--muted); font-weight: 700; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

.solution { border: 2px solid var(--border); border-radius: 14px; padding: 12px 16px; margin-top: 10px; }
.solution strong { display: block; margin-bottom: 4px; color: var(--primary); }
.solution ol { margin: 0; padding-left: 24px; }
.solution .final { margin-top: 6px; font-weight: 800; }
.site-footer { max-width: 760px; margin: 0 auto; padding: 20px 16px 28px; text-align: center; color: var(--muted); font-size: .9rem; border-top: 2px solid var(--border); }
.site-footer p { margin: 0 0 12px; }
.site-footer a { color: var(--primary); font-weight: 700; }
.share { display: flex; gap: 10px; justify-content: center; }
.share-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; border: 2px solid var(--border); background: var(--card); transition: transform .1s; }
.share-btn:hover { transform: translateY(-2px); }
.share-btn svg { width: 20px; height: 20px; fill: var(--text); }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media (max-width: 480px) { .target .value { font-size: 3.5rem; } .tile { min-width: 60px; height: 60px; font-size: 1.5rem; } }
