:root { --bg:#fbf7f2; --ink:#2d2a26; --accent:#c2573a; --muted:#8a8178; --card:#fff; --line:#e7dfd5; }
* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh; padding: 24px 16px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink);
}
#app { max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; }
h1 { font-weight: 600; font-size: 1.6rem; margin: 0 0 4px; text-align: center; }
.sub { margin: 0 0 20px; color: var(--muted); font-size: .95rem; text-align: center; }
.card { width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; margin: 12px 0; }
button, select, input[type=text], .btn {
  font: inherit; padding: 9px 14px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
}
input[type=text] { cursor: text; min-width: 0; flex: 1; }
.btn.primary, button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
input[type=file] { display: none; }
.field { display: flex; flex-direction: column; gap: 6px; width: 100%; margin-top: 10px; color: var(--muted); font-size: .9rem; }
.field input, .field select { color: var(--ink); }
.stats { display: flex; gap: 18px; color: var(--muted); margin: 12px 0; font-variant-numeric: tabular-nums; flex-wrap: wrap; justify-content: center; }
.stats b { color: var(--ink); font-weight: 600; }
#board {
  width: min(92vw, 520px); aspect-ratio: 1; display: grid; gap: 3px;
  padding: 3px; background: var(--line); border-radius: 12px;
  touch-action: none; user-select: none;
}
.tile {
  position: relative; border-radius: 6px; cursor: grab;
  background-color: #ddd; background-image: var(--img);
  background-repeat: no-repeat;
  background-size: calc(var(--n) * 100%) calc(var(--n) * 100%);
  transition: transform .12s, box-shadow .12s;
}
.tile.lift { transform: scale(1.04); box-shadow: 0 8px 20px rgba(0,0,0,.25); z-index: 2; cursor: grabbing; }
.tile.selected { outline: 3px solid var(--accent); outline-offset: -3px; }
.msg { min-height: 1.6em; margin: 14px 0 0; font-weight: 600; color: var(--accent); text-align: center; }
.error { color: #a22; }
.link-box { display: flex; gap: 8px; width: 100%; }
.link-box input { font-size: .85rem; }
#preview { width: min(92vw, 520px); border-radius: 12px; margin-top: 12px; display: none; }
.hint { font-size: .85rem; color: var(--muted); margin-top: 10px; text-align: center; }
.loading { color: var(--muted); }
