/* Travle game (native). Scoped under #travle-app / .tg so the legacy page CSS does not leak in. */
#travle-app { max-width: 1180px; margin: 6px auto 18px; padding: 0 10px; min-height: 760px; }
#travle-app.is-ready { min-height: 0; }
@media (min-width: 900px) { #travle-app { min-height: 620px; } }

.tg {
  --ink: #13141c; --muted: #5a6072; --bg: #ffffff; --soft: #f4f6fb; --line: #e3e7ef; --accent: #ffbf5a; --accent-ink: #13141c;
  --sea: #dbeafe; --land: #eef0f4; --land-line: #b9c0cf; --s: #2563eb; --e: #7c3aed;
  --g: #16a34a; --y: #f59e0b; --r: #ef4444; --best: #86efac; --shadow: 0 10px 30px rgba(19, 20, 28, .10);
  position: relative; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow); font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; text-align: left;
}
.tg *, .tg *::before, .tg *::after { box-sizing: border-box; }
.tg [hidden] { display: none !important; }
.tg :where(ul, ol, li) { list-style: none; margin: 0; padding: 0; display: block; }
.tg :where(h2, h3, p) { margin: 0; text-align: left; color: inherit; }
/* main.min.css (legacy) hides every select and some inputs with opacity:0 */
.tg select, .tg input { opacity: 1; }
.tg button, .tg select, .tg input { font: inherit; color: inherit; }
.tg button { cursor: pointer; }
.tg button:disabled { cursor: default; opacity: .45; }
.tg svg { display: block; }
.tg.tg-cb { --g: #2563eb; --y: #f97316; --r: #6b7280; --best: #93c5fd; --s: #0891b2; --e: #9333ea; }
.tg[data-theme="dark"] { --ink: #eef1f8; --muted: #a3abc0; --bg: #151824; --soft: #1e2232; --line: #2c3245; --sea: #0f2742; --land: #2a3044; --land-line: #4a5370; --best: #166534; --shadow: 0 10px 30px rgba(0,0,0,.4); }
@media (prefers-color-scheme: dark) {
  .tg[data-theme="auto"] { --ink: #eef1f8; --muted: #a3abc0; --bg: #151824; --soft: #1e2232; --line: #2c3245; --sea: #0f2742; --land: #2a3044; --land-line: #4a5370; --best: #166534; --shadow: 0 10px 30px rgba(0,0,0,.4); }
}

/* Top bar */
.tg-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.tg-tabs { display: flex; gap: 4px; background: var(--soft); padding: 4px; border-radius: 12px; }
.tg-tab { position: relative; border: 0; background: transparent; padding: 8px 14px; border-radius: 9px; font-weight: 700; font-size: 14px; color: var(--muted); white-space: nowrap; }
.tg-tab.is-on { background: var(--bg); color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.tg-tab.tg-dotnew::after { content: ""; position: absolute; top: 6px; right: 5px; width: 7px; height: 7px; border-radius: 50%; background: var(--r); }
.tg-tools { display: flex; gap: 2px; }
.tg-icon { position: relative; display: inline-grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--ink); font-size: 26px; line-height: 1; }
.tg-icon:hover { background: var(--soft); }
.tg-icon svg { width: 22px; height: 22px; }
.tg-streak-badge { position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 800; line-height: 18px; text-align: center; }
.tg-streak-badge::before { content: "🔥"; font-size: 9px; margin-right: 1px; }
.tg-pulse { animation: tg-pulse 1.6s ease-in-out 4; }
@keyframes tg-pulse { 50% { background: var(--accent); } }

/* Layout */
.tg-body { display: flex; flex-direction: column; }
.tg-panel { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.tg-mapwrap { position: relative; order: 0; margin: 0 12px 12px; border-radius: 14px; overflow: hidden; background: var(--sea); border: 1px solid var(--line); height: 56vw; min-height: 240px; max-height: 420px; touch-action: none; }
@media (max-width: 899px) {
  .tg-panel { display: contents; }
  .tg-route { order: 1; margin: 12px 12px 0; } .tg-meta { order: 2; margin: 0 12px; } .tg-meter { order: 3; margin: 0 12px; }
  .tg-unl { order: 4; margin: 0 12px; } .tg-form { order: 5; margin: 0 12px; } .tg-msg { order: 6; margin: 0 12px; }
  .tg-result { order: 7; margin: 0 12px; } .tg-mapwrap { order: 8; margin-bottom: 0; } .tg-actions { order: 9; margin: 0 12px; } .tg-guesses { order: 10; margin: 0 12px 12px; }
  .tg-body { gap: 10px; }
}
@media (min-width: 900px) {
  .tg-body { flex-direction: row; align-items: stretch; }
  .tg-panel { width: 380px; flex: 0 0 380px; border-right: 1px solid var(--line); padding: 14px; }
  .tg-mapwrap { flex: 1; margin: 12px; height: auto; min-height: 560px; max-height: none; }
}

/* Route header */
.tg-route { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 6px; }
.tg-end { background: var(--soft); border-radius: 12px; padding: 8px 10px; border-left: 4px solid var(--s); min-width: 0; }
.tg-end-e { border-left-color: var(--e); }
.tg-end-label { display: block; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.tg-end-main { display: flex; align-items: center; gap: 7px; min-width: 0; }
.tg-end-main b { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tg-route-arrow { color: var(--muted); } .tg-route-arrow svg { width: 22px; height: 22px; }
.tg-flag { width: 30px; height: 20px; flex: 0 0 auto; border-radius: 3px; object-fit: cover; box-shadow: 0 0 0 1px rgba(0,0,0,.12); background: var(--land); }
.tg-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }
.tg-left { font-weight: 700; color: var(--ink); white-space: nowrap; }
.tg-meter { display: flex; gap: 4px; }
.tg-meter i { flex: 1; height: 7px; border-radius: 4px; background: var(--line); }
.tg-meter i.is-opt { background: color-mix(in srgb, var(--g) 25%, var(--line)); }
.tg-meter i.q-g { background: var(--g); } .tg-meter i.q-y { background: var(--y); } .tg-meter i.q-r { background: var(--r); }

/* Unlimited options */
.tg-unl { display: none; gap: 8px; align-items: end; flex-wrap: wrap; }
.tg.is-unl .tg-unl { display: grid; grid-template-columns: 1fr 1fr auto auto; }
.tg-unl .tg-route-share { height: 38px; padding: 0 10px; }
.tg-unl .tg-new { height: 38px; padding: 0 12px; }
@media (max-width: 480px) { .tg-unl .tg-new span { display: none; } }
.tg-unl label { display: flex; flex-direction: column; gap: 2px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); min-width: 0; }
.tg select { appearance: auto; height: 38px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); padding: 0 8px; font-size: 14px; text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--ink); }

/* Form */
.tg-form { display: flex; gap: 8px; }
.tg-combo { position: relative; flex: 1; }
.tg-input { width: 100%; height: 50px; border: 2px solid var(--line); border-radius: 12px; padding: 0 14px; font-size: 17px; background: var(--bg); color: var(--ink); outline: none; }
.tg-input:focus { border-color: var(--s); box-shadow: 0 0 0 4px color-mix(in srgb, var(--s) 18%, transparent); }
.tg-sugg { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; right: 0; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.tg-sugg li { display: flex !important; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; font-size: 16px; }
.tg-sugg li[aria-selected="true"], .tg-sugg li:hover { background: var(--soft); }
.tg-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 42px; padding: 0 16px; border: 0; border-radius: 12px; background: var(--ink); color: var(--bg) !important; font-weight: 800; font-size: 15px; text-decoration: none; }
.tg-btn svg { width: 18px; height: 18px; }
.tg-btn-go { height: 50px; min-width: 64px; background: var(--accent); color: var(--accent-ink) !important; font-size: 17px; }
.tg-btn-alt { background: var(--s); color: #fff !important; }
.tg-btn-ghost { background: var(--soft); color: var(--ink) !important; font-weight: 700; }
.tg-btn:not(:disabled):hover { filter: brightness(1.06); }
.tg-actions { display: flex; gap: 8px; }
.tg-actions .tg-btn { flex: 1; }
.tg-hint-n { min-width: 20px; height: 20px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-size: 12px; line-height: 20px; }
.tg-shake { animation: tg-shake .35s; }
@keyframes tg-shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* Message */
.tg-msg { min-height: 20px; font-size: 14px; font-weight: 600; color: var(--muted); opacity: 0; transition: opacity .2s; }
.tg-msg.is-on { opacity: 1; } .tg-msg.is-bad { color: var(--r); }

/* Guesses */
.tg-guesses { display: flex !important; flex-direction: column; gap: 6px; }
.tg-guess { display: flex !important; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 4px 10px 10px 4px; background: var(--soft); border-left: 4px solid var(--line); font-weight: 600; animation: tg-in .3s ease-out; }
.tg-guess.q-g { border-left-color: var(--g); } .tg-guess.q-y { border-left-color: var(--y); } .tg-guess.q-r { border-left-color: var(--r); }
.tg-guess > span:nth-child(3) { flex: 1; }
.tg-guess-n { width: 18px; color: var(--muted); font-size: 12px; text-align: right; }
@keyframes tg-in { from { opacity: 0; transform: translateY(-6px); } }
.tg-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--line); flex: 0 0 auto; vertical-align: -1px; }
.tg-dot.q-g { background: var(--g); } .tg-dot.q-y { background: var(--y); } .tg-dot.q-r { background: var(--r); }

/* Result */
.tg-result { background: var(--soft); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 10px; animation: tg-in .35s ease-out; }
.tg-result-head { display: flex; flex-direction: column; gap: 2px; }
.tg-result-head strong { font-size: 22px; font-weight: 900; }
.tg-result-head.is-won strong { color: var(--g); } .tg-result-head.is-lost strong { color: var(--r); }
.tg-result-head span { font-size: 14px; color: var(--muted); }
.tg-pts { color: var(--ink); }
.tg-emoji { font-size: 20px; letter-spacing: 2px; line-height: 1.2; word-break: break-all; }
.tg-best { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 13px; }
.tg-best > span:first-child { width: 100%; color: var(--muted); font-weight: 700; }
.tg-chip { display: inline-flex; align-items: center; gap: 5px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px 2px 3px; font-weight: 600; }
a.tg-chip { color: var(--ink); text-decoration: none; }
a.tg-chip:hover { border-color: var(--s); }
.tg-chip .tg-flag { width: 21px; height: 14px; border-radius: 999px; }
.tg-sep { color: var(--muted); font-style: normal; }
.tg-result-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.tg-result-actions .tg-btn { flex: 1 1 auto; }
.tg-next { font-size: 14px; color: var(--muted); } .tg-cd { color: var(--ink); font-variant-numeric: tabular-nums; }
.tg.is-over .tg-form, .tg.is-over .tg-actions { display: none; }

/* Map */
.tg-map { width: 100%; height: 100%; cursor: grab; user-select: none; -webkit-user-select: none; }
.tg-map:active { cursor: grabbing; }
.tg-c { fill: var(--land); stroke: var(--land-line); stroke-width: .7; vector-effect: non-scaling-stroke; stroke-linejoin: round; transition: fill .35s; }
.tg-bg { fill: var(--land); }
.tg-c.is-s { fill: var(--s); stroke: #fff; }
.tg-c.is-e { fill: var(--e); stroke: #fff; }
.tg-c.q-g { fill: var(--g); } .tg-c.q-y { fill: var(--y); } .tg-c.q-r { fill: var(--r); }
.tg-c.is-best { fill: var(--best); }
.tg-c.is-hint { fill: color-mix(in srgb, var(--accent) 60%, var(--land)); stroke: var(--ink); stroke-width: 2; stroke-dasharray: 4 3; animation: tg-hint 1.2s ease-in-out infinite; }
@keyframes tg-hint { 50% { fill: var(--accent); } }
.tg-labels { pointer-events: none; }
.tg-pin { stroke: #fff; stroke-width: 2; vector-effect: non-scaling-stroke; }
.tg-pin-s { fill: var(--s); } .tg-pin-e { fill: var(--e); }
.tg-lbl { font-weight: 700; fill: var(--ink); stroke: var(--bg); stroke-width: .18em; paint-order: stroke; stroke-linejoin: round; text-anchor: middle; dominant-baseline: middle; font-size: .72em; }
.tg-lbl-end { font-size: 1em; font-weight: 900; }
.tg-routeline { fill: none; stroke: var(--ink); stroke-dasharray: 1.5 1; stroke-linecap: round; stroke-linejoin: round; opacity: .8; pointer-events: none; }
.tg-zoom { position: absolute; right: 8px; top: 8px; display: flex; flex-direction: column; gap: 4px; }
.tg-zoom button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); display: grid; place-items: center; box-shadow: 0 2px 6px rgba(0,0,0,.1); }
.tg-zoom svg { width: 18px; height: 18px; }
.tg-legend { position: absolute; left: 8px; bottom: 8px; display: flex; flex-wrap: wrap; gap: 4px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent); border-radius: 10px; padding: 5px 9px; font-size: 12px; font-weight: 600; pointer-events: none; }
.tg-legend span { display: inline-flex; align-items: center; gap: 5px; }
.tg-legend .tg-dot { width: 10px; height: 10px; }

/* Modal */
.tg-modal { position: fixed; inset: 0; margin: auto; height: fit-content; border: 0; padding: 0; background: transparent; max-width: min(520px, calc(100vw - 24px)); width: 100%; color: var(--ink); }
.tg-modal::backdrop { background: rgba(10, 12, 20, .55); }
.tg-modal[open] { animation: tg-in .2s ease-out; }
.tg-modal-box { background: var(--bg); border-radius: 18px; box-shadow: var(--shadow); max-height: calc(100vh - 40px); overflow: auto; }
.tg-modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 6px; position: sticky; top: 0; background: var(--bg); }
.tg-modal-head h2 { font-size: 20px; font-weight: 900; }
.tg-modal-x { font-size: 30px !important; color: var(--ink) !important; }
.tg-modal-body { padding: 4px 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.tg-help p { margin: 0 0 10px; color: var(--ink); font-size: 15px; line-height: 1.5; text-align: left; }
.tg-help ul { margin: 0 0 10px; display: flex !important; flex-direction: column; gap: 6px; }
.tg-help li { display: flex !important; align-items: center; gap: 8px; }
.tg-stat-sec h3 { font-size: 15px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 8px; }
.tg-stat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; text-align: center; }
.tg-stat-grid b { display: block; font-size: 24px; font-weight: 900; line-height: 1.1; }
.tg-stat-grid span { font-size: 11px; color: var(--muted); }
.tg-stat-sub { font-size: 12px; font-weight: 700; color: var(--muted); margin: 10px 0 4px; }
.tg-bars { display: flex; flex-direction: column; gap: 3px; }
.tg-bar { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.tg-bar span { width: 22px; text-align: right; color: var(--muted); font-weight: 700; }
.tg-bar i { display: block; background: var(--g); color: #fff; font-style: normal; font-weight: 800; text-align: right; padding: 1px 6px; border-radius: 4px; min-width: 22px; }
.tg-bar-x i { background: var(--r); }
.tg-ach { display: grid !important; grid-template-columns: 1fr 1fr; gap: 6px; }
.tg-ach li { display: flex !important; gap: 6px; align-items: center; font-size: 13px; padding: 6px 8px; border-radius: 10px; background: var(--soft); color: var(--muted); }
.tg-ach li.is-on { color: var(--ink); font-weight: 700; }
.tg-settings { display: flex; flex-direction: column; gap: 12px; }
.tg-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-weight: 600; }
.tg-row input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--s); }

/* Toast + confetti */
.tg-toast { position: fixed; left: 50%; top: 76px; transform: translate(-50%, -10px); z-index: 2000; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 700; box-shadow: var(--shadow); opacity: 0; transition: opacity .25s, transform .25s; max-width: calc(100vw - 24px); }
.tg-toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.tg-confetti { position: fixed; inset: 0; pointer-events: none; z-index: 2001; }
@media (max-width: 420px) {
  .tg-tab { padding: 8px 10px; font-size: 13px; }
  .tg-icon { width: 36px; height: 36px; }
  .tg-end-main b { font-size: 14px; }
  .tg-stat-grid b { font-size: 20px; }
}

/* Progress backup (Settings) */
.tg-backup { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.tg-backup h3 { font-size: 14px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.tg-backup p { font-size: 14px; color: var(--ink); line-height: 1.45; }
.tg-backup .tg-lastbk { font-size: 12px; color: var(--muted); }
.tg-backup-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.tg-backup-btns .tg-btn { flex: 1 1 auto; height: 40px; font-size: 14px; padding: 0 12px; cursor: pointer; }
.tg-bk-input { width: 100%; min-height: 56px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font: 13px/1.4 ui-monospace, Consolas, monospace; background: var(--bg); color: var(--ink); resize: vertical; opacity: 1; }
.tg-protect { border: 1px dashed var(--accent); background: color-mix(in srgb, var(--accent) 18%, var(--bg)); color: var(--ink); border-radius: 12px; padding: 10px 12px; font-weight: 700; font-size: 14px; text-align: left; cursor: pointer; }
