/* assets/css/trace.css - Noos Trace 2.0 */
:root { --accent: #88b04b; --accent-d: #6f9239; --bg: #f8fafc; --dark: #1e293b; --text-light: #64748b; --grid-bg: #475569; --tr-card: #ffffff; --tr-line: #e2e8f0; }
[hidden] { display: none !important; }

.tr-body { display: flex; flex-direction: column; min-height: 100vh; margin: 0; font-family: 'Quicksand', sans-serif; background: var(--bg); color: var(--dark); overflow-x: hidden; }

.tr-page { width: 100%; flex-grow: 1; box-sizing: border-box; padding: 10px 16px calc(24px + env(safe-area-inset-bottom)); display: flex; justify-content: center; }
.tr-card { position: relative; width: 100%; max-width: 450px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; }
.tr-left, .tr-right { width: 100%; display: flex; flex-direction: column; align-items: center; }

/* mode tabs */
.tr-modes { display: inline-flex; gap: 4px; padding: 4px; border-radius: 999px; background: #e8edf3; margin-top: 6px; }
.tr-mode { font: inherit; font-weight: 700; font-size: 13px; letter-spacing: .5px; border: 0; background: transparent; color: var(--text-light); padding: 8px 18px; border-radius: 999px; cursor: pointer; white-space: nowrap; -webkit-tap-highlight-color: transparent; }
.tr-mode.on { background: var(--dark); color: #fff; box-shadow: 0 2px 6px rgba(15,23,42,.25); }
.tr-mode:disabled { opacity: .45; cursor: default; }
.tr-note { font-size: 12px; font-weight: 700; color: var(--text-light); margin: 8px 0 2px; min-height: 16px; }

/* hud */
.stats-bar { color: #64748b; margin: 6px 0 4px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; font-size: 12px; }
.status-area { display: flex; flex-direction: column; justify-content: center; align-items: center; margin-bottom: 8px; }
#score-val { font-size: 3rem; font-weight: 700; color: var(--accent); margin: 0; line-height: 1; font-variant-numeric: tabular-nums; }
.tr-score-l { font-size: 11px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: #94a3b8; margin-top: 2px; }

/* board: sized from width AND height so it never forces a page scroll on short screens */
.tr-board-wrap { position: relative; width: min(100%, 420px, calc(100dvh - 432px)); min-width: 180px; margin: 0 auto; }
.trace-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(8px, 3.4%, 15px); background: var(--grid-bg); padding: clamp(10px, 4.4%, 20px); border-radius: clamp(22px, 8%, 35px); box-shadow: 0 10px 25px rgba(0,0,0,.15); touch-action: manipulation; }
.dot { --c: var(--accent); position: relative; width: 100%; aspect-ratio: 1 / 1; padding: 0; border: 0; border-radius: 50%; background: #ffffff; cursor: pointer; display: flex; align-items: center; justify-content: center; color: #94a3b8; font: inherit; font-weight: 700; font-size: clamp(14px, 4.5vw, 22px);
    transition: transform .08s, background .08s, box-shadow .08s; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.dot-n { opacity: 0; transition: opacity .15s; pointer-events: none; }
.show-nums .dot-n { opacity: 1; }
.dot.active { background: var(--c) !important; box-shadow: 0 0 30px var(--c); transform: scale(1.08); color: #fff; }
.dot:active { transform: scale(.94); }
.dot:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.dot.wrong { background: #ef4444 !important; box-shadow: 0 0 30px #ef4444; color: #fff; animation: trShake .3s ease; }
.dot.reveal { animation: trReveal .55s ease 2; box-shadow: 0 0 0 4px #fff, 0 0 26px var(--c); }
.trace-grid.locked .dot { cursor: default; }
.trace-grid.shake { animation: trShake .3s ease; }
@keyframes trShake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-9px); } 75% { transform: translateX(9px); } }
@keyframes trReveal { 0%, 100% { transform: scale(1); background: #fff; } 50% { transform: scale(1.1); background: var(--c); } }

/* 3-2-1 resume */
.tr-count { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; border-radius: 30px; background: rgba(15,23,42,.72); color: #fff; font-size: clamp(64px, 22vw, 110px); font-weight: 700; z-index: 5; }

/* progress + status */
.tr-prog { width: min(100%, 420px); height: 6px; border-radius: 6px; background: #e2e8f0; margin: 14px auto 0; overflow: hidden; }
.tr-prog i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .12s; }
#status-msg { font-weight: 700; font-size: 1.1rem; color: var(--text-light); margin-top: 10px; min-height: 1.5rem; }

/* actions */
.tr-actions { display: flex; justify-content: center; min-height: 58px; align-items: center; }
.btn-start { margin-top: 12px; padding: 14px 40px; background: var(--accent); color: #fff; border: 0; border-radius: 50px; font: inherit; font-weight: 700; font-size: 1rem; cursor: pointer; box-shadow: 0 8px 15px rgba(136,176,75,.25); white-space: nowrap; }
.btn-start:disabled { opacity: 0; pointer-events: none; }
.btn-start:active { transform: scale(.98); }
.tr-chips { display: flex; justify-content: center; gap: 8px; margin-top: 12px; flex-wrap: nowrap; }
.tr-chip { font: inherit; font-weight: 700; font-size: 13px; border: 1px solid var(--tr-line); background: #fff; color: var(--dark); border-radius: 999px; padding: 8px 14px; cursor: pointer; white-space: nowrap; }
.tr-chip:active { transform: scale(.97); }

/* overlays: opaque, scrollable, never centred with justify-content:center */
.tr-overlay { position: fixed; inset: 0; z-index: 8000; background: #ffffff; display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 10px; padding: calc(16px + env(safe-area-inset-top)) 20px calc(20px + env(safe-area-inset-bottom)); overflow-y: auto; -webkit-overflow-scrolling: touch; box-sizing: border-box; text-align: left; }
.tr-overlay > :first-child { margin-top: auto; }
.tr-overlay > :last-child { margin-bottom: auto; }
.tr-overlay > * { width: 100%; max-width: 420px; margin-left: auto; margin-right: auto; box-sizing: border-box; flex-shrink: 0; }
.tr-ov-h { margin: 0 0 4px; font-size: 1.4rem; text-align: center; }
.tr-pause { text-align: center; align-items: center; }
.tr-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-radius: 14px; background: var(--bg); font-weight: 700; font-size: 14px; }
.tr-row-col { flex-direction: column; align-items: stretch; }
.tr-tog { font: inherit; font-weight: 700; font-size: 12px; letter-spacing: .5px; border: 0; border-radius: 10px; padding: 7px 14px; background: var(--dark); color: #fff; cursor: pointer; white-space: nowrap; }
.tr-tog[aria-pressed="false"] { background: #cbd5e1; color: #334155; }
.tr-wide { width: 100%; padding: 12px; font-size: 14px; }
.tr-danger { background: #fee2e2; color: #b91c1c; }
.tr-hint { color: var(--text-light); font-weight: 600; font-size: 12px; }
.tr-back { align-self: center; width: auto; margin-top: 8px; }
.tr-skins { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.tr-skin { display: flex; flex-direction: column; align-items: center; gap: 4px; font: inherit; font-size: 11px; font-weight: 700; color: var(--text-light); background: #fff; border: 2px solid var(--tr-line); border-radius: 12px; padding: 6px 8px; cursor: pointer; }
.tr-skin.on { border-color: var(--dark); color: var(--dark); }
.tr-skin.lock { opacity: .5; }
.tr-sw { display: grid; grid-template-columns: repeat(3, 8px); gap: 2px; }
.tr-sw i { width: 8px; height: 8px; border-radius: 50%; display: block; }
#trophy-list { max-height: 46vh; overflow-y: auto; padding: 4px; -webkit-overflow-scrolling: touch; }

/* short landscape: board left, controls right */
@media (max-height: 520px) and (orientation: landscape) {
    .tr-page { padding-top: 4px; }
    .tr-card { max-width: 860px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 300px); align-items: center; column-gap: 20px; }
    .tr-right { grid-column: 1; grid-row: 1; }
    .tr-left { grid-column: 2; grid-row: 1; }
    .tr-board-wrap { width: min(100%, calc(100dvh - 130px)); min-width: 190px; }
    #score-val { font-size: 2.2rem; }
    .tr-prog { margin-top: 8px; }
    #status-msg { margin-top: 4px; font-size: 1rem; }
    .btn-start { margin-top: 6px; padding: 10px 30px; }
    .tr-actions { min-height: 48px; }
    .tr-chips { margin-top: 6px; }
}
@media (max-width: 360px) { .tr-mode { padding: 8px 13px; } .tr-chip { padding: 8px 10px; font-size: 12px; } }
@media (prefers-reduced-motion: reduce) {
    .dot, .tr-prog i { transition: none; }
    .dot.active { transform: none; }
    .dot.wrong, .trace-grid.shake, .dot.reveal { animation: none; }
}

/* toast */
.tr-toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: #0f172a; color: #fff; font-weight: 700; font-size: 13px; padding: 10px 16px; border-radius: 12px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 20000; max-width: 90vw; text-align: center; }
.tr-toast.on { opacity: 1; transform: translate(-50%, 0); }