/* Shape Match. Tokens only (tokens.css); no hex here. */
.sm-root { margin: 0; background: var(--paper-200); color: var(--ink); font-family: var(--font-body); font-size: var(--fs-16); line-height: var(--lh-body); -webkit-font-smoothing: antialiased; }
.sm-root * { box-sizing: border-box; }
.sm-wrap { max-width: 1000px; margin: 0 auto; padding: var(--sp-4) var(--sp-4) var(--sp-7); padding-left: max(var(--sp-4), env(safe-area-inset-left, 0px)); padding-right: max(var(--sp-4), env(safe-area-inset-right, 0px)); }
.sm-ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* header */
.sm-top { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-4); }
.sm-top h1 { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: var(--fs-28); letter-spacing: -0.02em; line-height: var(--lh-tight); }
.sm-back { display: inline-flex; align-items: center; gap: var(--sp-2); min-height: 36px; padding: 0 var(--sp-3) 0 var(--sp-2); border: 1px solid var(--paper-300); border-radius: var(--r-pill); background: var(--paper-100); color: var(--ink); font: 700 var(--fs-14) var(--font-body); text-decoration: none; transition: border-color var(--t-fast) var(--ease); }
.sm-back:hover { border-color: var(--ink); }
.sm-back:focus-visible, .sm-btn:focus-visible, #smCv:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; box-shadow: 0 0 0 2px var(--accent); }

/* status bar: three cells, small caps label over a strong value */
.sm-hud { display: grid; grid-template-columns: 1fr 1fr 1fr; margin-bottom: var(--sp-4); background: var(--paper-100); border: 1px solid var(--paper-300); border-radius: var(--r-md); overflow: hidden; }
.sm-cell { display: flex; flex-direction: column; gap: 2px; padding: var(--sp-3) var(--sp-4); min-width: 0; }
.sm-cell + .sm-cell { border-left: 1px solid var(--paper-300); }
.sm-k { font-size: var(--fs-12); font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.sm-v { display: flex; align-items: center; min-height: 32px; font-family: var(--font-num); font-size: var(--fs-28); font-weight: 700; line-height: 1; }
.sm-of { font-size: var(--fs-16); color: var(--ink-3); margin-left: 2px; }
.sm-cell.sm-score { background: var(--accent); border-left-color: var(--ink); }
.sm-score .sm-k { color: var(--ink); }
.sm-prog { display: flex; gap: 3px; margin-top: var(--sp-2); }
.sm-prog i { flex: 1; height: 4px; border-radius: 2px; background: var(--paper-300); }
.sm-prog i.done { background: var(--ink); }
.sm-prog i.now { background: var(--accent); box-shadow: inset 0 0 0 1px var(--ink); }
.sm-pips { display: inline-flex; gap: var(--sp-2); }
.sm-pip { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--ink); background: var(--accent); transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
.sm-pip.used { background: transparent; border-color: var(--paper-300); transform: scale(.82); }

/* map (the canvas draws its own frame and the tray under it) */
.sm-map { position: relative; min-height: 240px; filter: drop-shadow(0 8px 14px rgba(20,35,46,.10)); }
#smCv { display: block; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#smCv.drag { cursor: grabbing; }
.sm-load { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; border: 1px solid var(--paper-300); border-radius: var(--r-md); background: var(--paper-100); color: var(--ink-2); font-weight: 700; }
.sm-load[hidden] { display: none; }

/* EXPERIMENT: direction wash. A soft green gradient over the half of the map the shape should move toward. Delete this block, #smWash and washHint() to revert. */
.sm-wash { position: absolute; left: 0; top: 0; width: 100%; z-index: 1; border-radius: var(--r-md); pointer-events: none; opacity: 0; --wash: color-mix(in srgb, var(--correct-fill) 42%, transparent); }
.sm-wash.show { animation: sm-wash var(--wash-ms, 3000ms) ease-in-out forwards; }
.sm-wash.west  { background: linear-gradient(to right,  var(--wash), transparent 55%); }
.sm-wash.east  { background: linear-gradient(to left,   var(--wash), transparent 55%); }
.sm-wash.north { background: linear-gradient(to bottom, var(--wash), transparent 55%); }
.sm-wash.south { background: linear-gradient(to top,    var(--wash), transparent 55%); }
@keyframes sm-wash { 0% { opacity: 0; } 30% { opacity: 1; } 65% { opacity: 1; } 100% { opacity: 0; } }

/* wrong-drop banner */
.sm-toast { position: absolute; top: var(--sp-4); left: 50%; transform: translateX(-50%); z-index: 2; display: flex; align-items: center; gap: var(--sp-4); max-width: calc(100% - var(--sp-5)); padding: var(--sp-3) var(--sp-5) var(--sp-3) var(--sp-4); background: var(--paper-100); border: 2px solid var(--ink); border-radius: var(--r-md); box-shadow: 0 2px 0 var(--ink), 0 14px 26px -10px rgba(20,35,46,.45); pointer-events: none; animation: sm-toast-in var(--t-med) var(--ease); }
.sm-toast[hidden] { display: none; }
.sm-toast-arrow { display: grid; place-items: center; flex: none; width: 52px; height: 52px; border-radius: 50%; background: var(--wrong-fill); border: 2px solid var(--ink); color: var(--paper-100); font: 700 var(--fs-28) var(--font-display); line-height: 1; }
.sm-toast b { display: block; font-family: var(--font-display); font-size: var(--fs-28); line-height: var(--lh-tight); text-transform: uppercase; letter-spacing: .02em; }
.sm-toast small { display: block; margin-top: var(--sp-1); font-family: var(--font-num); font-size: var(--fs-14); font-weight: 700; color: var(--ink-2); }
@keyframes sm-toast-in { from { opacity: 0; transform: translate(-50%, -10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* message + actions */
.sm-dock { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); margin-top: var(--sp-4); padding: var(--sp-3) var(--sp-4); background: var(--paper-100); border: 1px solid var(--paper-300); border-radius: var(--r-md); }
.sm-dock[hidden] { display: none; }
.sm-msg { flex: 1; min-width: 0; min-height: 3em; margin: 0; display: flex; flex-direction: column; justify-content: center; font-family: var(--font-display); font-size: var(--fs-20); font-weight: 700; line-height: var(--lh-tight); }
.sm-msg small { display: block; margin-top: var(--sp-1); color: var(--ink-2); font-family: var(--font-body); font-weight: 600; font-size: var(--fs-14); }
.sm-msg.good b { color: var(--correct); }
.sm-msg.bad b { color: var(--wrong); }
.sm-bar { display: flex; gap: var(--sp-2); flex: none; }
.sm-btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); min-height: var(--touch); padding: 0 var(--sp-5); border: 1px solid var(--ink); border-radius: var(--r-pill); background: transparent; color: var(--ink); font: 700 var(--fs-14) var(--font-body); cursor: pointer; transition: transform var(--t-press) var(--ease), background var(--t-fast) var(--ease); }
.sm-btn:hover:not(:disabled) { background: var(--paper-200); }
.sm-btn:active:not(:disabled) { transform: scale(.97); }
.sm-btn:disabled { color: var(--ink-3); border-color: var(--paper-300); cursor: default; }
.sm-primary, .sm-primary:hover:not(:disabled) { background: var(--accent); }
.sm-primary { box-shadow: 0 2px 0 var(--ink); }
.sm-primary:active:not(:disabled) { box-shadow: 0 0 0 var(--ink); transform: translateY(2px); }
.sm-btn[hidden] { display: none; }
.sm-wide { width: 100%; }
.sm-end .sm-btn + .sm-btn { margin-top: var(--sp-2); }

/* end screen */
.sm-end { margin: var(--sp-5) auto 0; padding: var(--sp-5); background: var(--paper-100); border: 1px solid var(--ink); border-radius: var(--r-md); box-shadow: 0 2px 0 var(--ink); max-width: 560px; text-align: center; }
.sm-end[hidden] { display: none; }
.sm-eyebrow { margin: 0 0 var(--sp-1); font-size: var(--fs-12); font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.sm-total { margin: 0; display: flex; align-items: baseline; justify-content: center; gap: var(--sp-2); color: var(--ink-3); }
.sm-total b { font-family: var(--font-num); font-size: 64px; line-height: 1; color: var(--ink); letter-spacing: -0.03em; }
.sm-meter { display: block; height: 8px; margin: var(--sp-3) 0 var(--sp-4); border-radius: 4px; background: var(--paper-300); overflow: hidden; }
.sm-meter i { display: block; height: 100%; width: 0; background: var(--accent); box-shadow: inset 0 0 0 1px var(--ink); border-radius: 4px; transition: width var(--t-reward) var(--ease); }
.sm-rows { width: 100%; border-collapse: collapse; margin-bottom: var(--sp-5); font-size: var(--fs-14); text-align: left; }
.sm-rows th { font-size: var(--fs-12); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.sm-rows th, .sm-rows td { padding: var(--sp-2) var(--sp-2) var(--sp-2) 0; border-bottom: 1px solid var(--paper-300); }
.sm-rows td:first-child { font-weight: 700; }
.sm-rows td:first-child::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: var(--sp-2); border-radius: 50%; background: var(--correct-fill); border: 1px solid var(--ink); }
.sm-rows .miss td:first-child::before { background: var(--wrong-fill); }
.sm-rows td:nth-child(n+2), .sm-rows th:nth-child(n+2) { text-align: right; padding-right: 0; font-family: var(--font-num); }
.sm-rows th:nth-child(2), .sm-rows td:nth-child(2) { padding-right: var(--sp-4); }
.sm-note { margin: var(--sp-5) auto 0; color: var(--ink-3); font-size: var(--fs-14); text-align: center; max-width: 60ch; }

@media (max-width: 560px) {
  .sm-top h1 { font-size: var(--fs-20); }
  .sm-cell { padding: var(--sp-2) var(--sp-3); }
  .sm-v { font-size: var(--fs-20); min-height: 26px; }
  .sm-pip { width: 14px; height: 14px; }
  .sm-dock { flex-direction: column; align-items: stretch; }
  .sm-bar .sm-btn { flex: 1; }
  .sm-msg { font-size: var(--fs-16); }
  .sm-toast b { font-size: var(--fs-20); }
  .sm-toast-arrow { width: 40px; height: 40px; font-size: var(--fs-20); }
  .sm-total b { font-size: var(--fs-48); }
}
@media (prefers-reduced-motion: reduce) { .sm-btn, .sm-pip, .sm-meter i, .sm-back { transition: none; } .sm-toast { animation: none; } .sm-wash.show { animation-duration: 1ms; } }
