/* Shared engine styles: board overlay, pen marks, UI widgets. */
:root {
  --pen: #14161a;
  --pen-alpha: 0.9;
  --hl: #7df24a;
  --accent: #7df24a;
  --accent-2: #42c6ff;
  --danger: #ff5c5c;
  --bg: #0f141c;
  --bg-2: #171e2a;
  --bg-3: #212b3a;
  --line: #2d3a4d;
  --text: #e8eef5;
  --muted: #9aa8ba;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[data-pen="blue"] { --pen: #1d3fb3; }
[data-pen="red"] { --pen: #c6232b; }
[data-pen="green"] { --pen: #11823b; }

.rw-board { position: relative; display: inline-block; line-height: 0; user-select: none; -webkit-user-select: none; }
.rw-board img { display: block; width: 100%; height: auto; pointer-events: none; }
.rw-overlay { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: pan-x pan-y pinch-zoom; overflow: visible; }
.rw-hit { fill: rgba(255,255,255,0); stroke: none; cursor: pointer; transition: fill .12s; }
.rw-cell:hover .rw-hit { fill: rgba(125,242,74,0.18); }
.rw-cell.rw-hl .rw-hit { fill: rgba(125,242,74,0.35); stroke: var(--hl); stroke-width: 6; animation: rw-pulse 1.2s ease-in-out infinite; }
.rw-cell.rw-hl-2 .rw-hit { fill: rgba(66,198,255,0.35); stroke: var(--accent-2); stroke-width: 6; }
.rw-cell.rw-hl-bad .rw-hit { fill: rgba(255,92,92,0.35); stroke: var(--danger); stroke-width: 6; }
.rw-cell.rw-disabled .rw-hit { cursor: not-allowed; }
.rw-cell.rw-disabled:hover .rw-hit { fill: rgba(255,92,92,0.15); }
@keyframes rw-pulse { 0%,100% { stroke-opacity: 1; } 50% { stroke-opacity: .35; } }
.rw-mark { pointer-events: none; }
.rw-mark .pen { stroke: var(--pen); stroke-opacity: var(--pen-alpha); stroke-linecap: round; stroke-linejoin: round; fill: none; }
.rw-mark .pen-text { fill: var(--pen); fill-opacity: var(--pen-alpha); font-family: "Segoe Print", "Bradley Hand", "Marker Felt", "Comic Sans MS", "Chalkboard", cursive; font-weight: 700; }

/* Toasts */
.ui-toasts { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 1000; pointer-events: none; max-width: min(92vw, 520px); }
.ui-toast { background: var(--bg-3); color: var(--text); border: 1px solid var(--line); border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.4); opacity: 0; transform: translateY(8px); transition: all .25s; font-size: 14px; }
.ui-toast.show { opacity: 1; transform: none; }
.ui-toast.warn { border-left-color: #ffb347; }
.ui-toast.bad { border-left-color: var(--danger); }

/* Modals */
.ui-overlay { position: fixed; inset: 0; background: rgba(5,8,12,.72); display: flex; align-items: center; justify-content: center; z-index: 900; padding: 16px; }
.ui-overlay-light { background: rgba(5,8,12,.45); }
.ui-modal { background: var(--bg-2); color: var(--text); border: 1px solid var(--line); border-radius: 14px; width: min(100%, 460px); max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.ui-modal.wide { width: min(100%, 860px); }
.ui-modal h2 { margin: 0; padding: 14px 18px; font-size: 17px; border-bottom: 1px solid var(--line); }
.ui-modal-body { padding: 14px 18px; overflow: auto; font-size: 14px; line-height: 1.45; }
.ui-modal-body p { margin: 0 0 10px; }
.ui-modal-buttons { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line); }
.ui-input { width: 100%; box-sizing: border-box; font-size: 16px; padding: 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.ui-choices { display: flex; flex-direction: column; gap: 6px; }
.ui-choice { text-align: left; background: var(--bg-3); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; font: inherit; }
.ui-choice:hover:not(:disabled) { border-color: var(--accent); }
.ui-choice:disabled { opacity: .45; cursor: not-allowed; }
.ui-choice.good { border-color: var(--accent); }
.ui-choice-label { font-weight: 600; }
.ui-choice-detail { color: var(--muted); font-size: 12.5px; }

/* Buttons */
.btn { font: inherit; font-size: 14px; background: var(--bg-3); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; cursor: pointer; line-height: 1.2; }
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #0b1a07; border-color: var(--accent); font-weight: 700; }
.btn.danger { border-color: var(--danger); color: #ffb3b3; }
.btn.small { padding: 5px 9px; font-size: 13px; }
.btn.big { padding: 12px 16px; font-size: 16px; }

/* Number pad */
.ui-numpad { background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; padding: 12px; width: 240px; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.ui-numpad-title { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.ui-numpad-display { font-size: 30px; font-weight: 700; text-align: center; background: var(--bg); border-radius: 8px; padding: 6px; margin-bottom: 8px; min-height: 40px; }
.ui-numpad-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.ui-numpad-keys .key { font-size: 20px; padding: 10px 0; background: var(--bg-3); color: var(--text); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.ui-numpad-keys .key.primary { background: var(--accent); color: #0b1a07; font-weight: 700; }
.ui-numpad-keys .key.soft { color: var(--muted); }
.ui-numpad-extra { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.ui-numpad-extra .btn { flex: 1; }
.muted { color: var(--muted); }
