/*
 * TradeButtons TradingSchool — Games (Pattern Battle).
 *
 * Benutzt ausschließlich die Design-Token der Academy (--tba-*), damit der
 * Bereich sich nicht wie ein Fremdplugin anfühlt. Alle Klassen tragen das
 * Präfix .tba-, alles liegt unter .tba-root.
 */

.tba-root {
	--tba-game-glow: 0 0 0 1px rgba(45, 212, 191, .35), 0 8px 26px rgba(45, 212, 191, .18);
	--tba-card-h: 150px;
}

/* ---------------------------------------------------------------- Hub -- */

.tba-game-head-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }

.tba-game-kpis {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 12px;
	margin: 14px 0 4px;
}
.tba-game-kpi {
	background: var(--tba-panel-2);
	border: 1px solid var(--tba-line);
	border-radius: var(--tba-radius-sm);
	padding: 12px 14px;
	min-width: 0;
}
.tba-game-kpi .tba-kpi-value { font-size: 22px; }

.tba-daily { margin-top: 16px; }
.tba-daily-lab {
	display: flex; justify-content: space-between; align-items: center;
	font-size: 13px; color: var(--tba-muted); margin-bottom: 6px;
}
.tba-daily .tba-btn { margin-top: 10px; }

.tba-game-title { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.tba-game-ic { font-size: 30px; line-height: 1; }
.tba-game-title h3 { margin: 0; font-size: 18px; text-transform: none; letter-spacing: 0; color: var(--tba-text); }

/* Modus-Auswahl */
.tba-mode-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
	gap: 10px;
	margin-bottom: 14px;
}
.tba-mode {
	display: flex; flex-direction: column; gap: 4px;
	text-align: left;
	background: var(--tba-panel-2);
	border: 1px solid var(--tba-line);
	border-radius: var(--tba-radius-sm);
	padding: 12px 14px;
	color: var(--tba-text);
	cursor: pointer;
	transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
	min-height: 44px;
}
.tba-mode:hover { transform: translateY(-2px); }
.tba-mode.active { border-color: var(--tba-cyan); box-shadow: var(--tba-game-glow); }
.tba-mode .ic { font-size: 20px; }
.tba-mode .nm { font-weight: 700; }
.tba-mode .ds { font-size: 12px; color: var(--tba-muted); line-height: 1.35; }

/* Options-Zeilen */
.tba-opt-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.tba-opt-lab { font-size: 12px; color: var(--tba-muted); text-transform: uppercase; letter-spacing: .06em; margin-right: 4px; }
.tba-chip {
	background: var(--tba-panel-2);
	border: 1px solid var(--tba-line);
	border-radius: 999px;
	color: var(--tba-text);
	padding: 7px 14px;
	font-size: 13px;
	cursor: pointer;
	min-height: 36px;
}
.tba-chip.active { border-color: var(--tba-cyan); color: var(--tba-cyan); background: rgba(45, 212, 191, .10); }

/* Aktionen */
.tba-act-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.tba-act {
	display: flex; flex-direction: column; gap: 3px; text-align: left;
	background: linear-gradient(180deg, var(--tba-panel), var(--tba-panel-2));
	border: 1px solid var(--tba-line);
	border-radius: var(--tba-radius-sm);
	padding: 14px;
	color: var(--tba-text);
	cursor: pointer;
	min-height: 44px;
	transition: border-color .15s ease, transform .15s ease;
}
.tba-act:hover { border-color: var(--tba-cyan); transform: translateY(-2px); }
.tba-act .ic { font-size: 22px; }
.tba-act .nm { font-weight: 700; }
.tba-act .ds { font-size: 12px; color: var(--tba-muted); }
.tba-act-bot { cursor: default; }
.tba-act-bot:hover { transform: none; }
.tba-bot-levels { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tba-bot-levels .tba-chip { padding: 5px 11px; font-size: 12px; min-height: 32px; }

/* Verwechslungen */
.tba-conf-list { list-style: none; margin: 0 0 12px; padding: 0; }
.tba-conf-list li {
	display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
	padding: 9px 0; border-bottom: 1px solid var(--tba-line);
}
.tba-conf-list li:last-child { border-bottom: 0; }
.tba-conf-n { margin-left: auto; color: var(--tba-warn); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------- Pattern -- */

.tba-pat-svg { width: 100%; height: auto; display: block; }
.tba-pat-bg { fill: rgba(6, 14, 25, .92); }
.tba-pat-grid { stroke: rgba(148, 163, 184, .14); stroke-width: 1; }
.tba-pat-guide { stroke: rgba(148, 163, 184, .55); stroke-width: 1.6; stroke-dasharray: 5 4; }
.tba-pat-line { fill: none; stroke: var(--tba-blue); stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }
.tba-pat-wick { stroke-width: 2.5; }
.tba-pat-body { stroke-width: 2; }
.tba-pat-bull { stroke: var(--tba-good); }
.tba-pat-body.tba-pat-bull { fill: var(--tba-good); }
.tba-pat-bear { stroke: var(--tba-bad); }
.tba-pat-body.tba-pat-bear { fill: rgba(10, 18, 30, .95); }

/* Tendenz-Anzeige: Text trägt die Bedeutung, Farbe unterstützt nur. */
.tba-bias {
	display: inline-block;
	font-size: 11px; font-weight: 700;
	letter-spacing: .05em; text-transform: uppercase;
	padding: 4px 10px; border-radius: 999px;
	border: 1px solid var(--tba-line);
}
.tba-bias-bullish { color: var(--tba-good); border-color: rgba(52, 211, 153, .45); background: rgba(52, 211, 153, .10); }
.tba-bias-bearish { color: var(--tba-bad); border-color: rgba(248, 113, 113, .45); background: rgba(248, 113, 113, .10); }
.tba-bias-neutral { color: var(--tba-muted); }

/* ------------------------------------------------------------ VS-Kopf -- */

.tba-vs {
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: center;
	gap: 12px;
}
.tba-vs-player { text-align: center; min-width: 0; }
.tba-vs-player.opp { text-align: center; }
.tba-vs-av {
	width: 46px; height: 46px; margin: 0 auto 6px;
	border-radius: 50%;
	display: flex; align-items: center; justify-content: center;
	background: rgba(45, 212, 191, .12);
	border: 1px solid var(--tba-line);
	font-weight: 700; font-size: 18px;
}
.tba-vs-name { font-weight: 700; font-size: 14px; overflow-wrap: anywhere; }
.tba-vs-score { font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.tba-vs-prog { font-size: 11px; color: var(--tba-muted); }
.tba-vs-mid { text-align: center; }
.tba-vs-lab { font-size: 13px; font-weight: 800; letter-spacing: .12em; color: var(--tba-muted); }
.tba-vs-mode { font-size: 11px; color: var(--tba-muted); margin-top: 2px; }

/* -------------------------------------------------------------- Lobby -- */

.tba-code {
	text-align: center;
	background: var(--tba-panel-2);
	border: 1px dashed var(--tba-line);
	border-radius: var(--tba-radius-sm);
	padding: 16px; margin: 14px 0;
}
.tba-code-lab { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--tba-muted); }
.tba-code-val {
	font-size: 30px; font-weight: 800; letter-spacing: .16em;
	color: var(--tba-cyan); margin: 6px 0 10px;
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	overflow-wrap: anywhere;
}

/* -------------------------------------------------------------- Runde -- */

.tba-stage { min-height: 260px; }
.tba-round-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.tba-round-no { font-size: 12px; color: var(--tba-muted); text-transform: uppercase; letter-spacing: .08em; }
.tba-round-diff { font-size: 12px; color: var(--tba-muted); }
.tba-round-timer {
	margin-left: auto; font-variant-numeric: tabular-nums;
	font-weight: 700; color: var(--tba-cyan); min-width: 58px; text-align: right;
}
.tba-round-timer.urgent { color: var(--tba-bad); }
.tba-round-q { font-size: 19px; margin: 0 0 12px; }

.tba-round-visual {
	max-width: 460px; margin: 0 auto 16px;
	background: var(--tba-panel-2);
	border: 1px solid var(--tba-line);
	border-radius: var(--tba-radius);
	padding: 12px;
}
.tba-round-name { text-align: center; font-weight: 700; margin-top: 8px; }

.tba-answers { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.tba-answer {
	display: flex; align-items: center; gap: 10px; text-align: left;
	background: var(--tba-panel-2);
	border: 1px solid var(--tba-line);
	border-radius: var(--tba-radius-sm);
	padding: 14px 16px;
	color: var(--tba-text); font-size: 15px;
	cursor: pointer; min-height: 52px;
	transition: border-color .12s ease, background .12s ease;
}
.tba-answer:hover:not(:disabled) { border-color: var(--tba-cyan); }
.tba-answer:disabled { cursor: default; }
.tba-answer .k {
	flex: 0 0 26px; height: 26px; border-radius: 6px;
	display: flex; align-items: center; justify-content: center;
	background: rgba(148, 163, 184, .14); font-size: 12px; font-weight: 700;
}
.tba-answer .l { min-width: 0; overflow-wrap: anywhere; }
/* Richtig/falsch nie nur über Farbe: zusätzlich Rahmenstärke + Zeichen. */
.tba-answer.correct { border-color: var(--tba-good); border-width: 2px; background: rgba(52, 211, 153, .12); }
.tba-answer.correct .k::after { content: '✓'; }
.tba-answer.correct .k { color: var(--tba-good); }
.tba-answer.wrong { border-color: var(--tba-bad); border-width: 2px; background: rgba(248, 113, 113, .12); }
.tba-answer.wrong .k::after { content: '✕'; }
.tba-answer.chosen { outline: 2px solid rgba(56, 189, 248, .5); outline-offset: 1px; }
.tba-answer.correct .k, .tba-answer.wrong .k { font-size: 0; }
.tba-answer.correct .k::after, .tba-answer.wrong .k::after { font-size: 14px; }

/* Rückmeldung */
.tba-round-fb { margin-top: 16px; }
.tba-feedback {
	display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
	border-radius: var(--tba-radius-sm);
	padding: 12px 14px; font-weight: 600;
	border: 1px solid var(--tba-line);
}
.tba-feedback.ok { background: rgba(52, 211, 153, .12); border-color: rgba(52, 211, 153, .4); }
.tba-feedback.wrong { background: rgba(248, 113, 113, .12); border-color: rgba(248, 113, 113, .4); }
.tba-feedback .ic { font-size: 18px; }
.tba-fb-ms { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--tba-muted); font-weight: 400; }

/* Lern-Einblendung nach der Antwort */
.tba-reveal {
	margin-top: 14px; padding: 16px;
	background: var(--tba-panel-2);
	border: 1px solid var(--tba-line);
	border-radius: var(--tba-radius-sm);
}
.tba-reveal-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.tba-reveal-head h3 { margin: 0; font-size: 17px; color: var(--tba-text); text-transform: none; letter-spacing: 0; }
.tba-reveal-sec { margin-top: 12px; }
.tba-reveal-sec h4 {
	margin: 0 0 5px; font-size: 11px; text-transform: uppercase;
	letter-spacing: .1em; color: var(--tba-muted);
}
.tba-reveal-sec ul { margin: 0; padding-left: 18px; }
.tba-reveal-sec li { margin-bottom: 3px; }
.tba-reveal p { margin: 0; }
.tba-tip {
	display: flex; gap: 8px; margin-top: 14px; padding: 10px 12px;
	background: rgba(251, 191, 36, .10);
	border-left: 3px solid var(--tba-warn);
	border-radius: 0 var(--tba-radius-sm) var(--tba-radius-sm) 0;
}
.tba-note { margin-top: 12px; font-size: 12px; color: var(--tba-muted); font-style: italic; }

/* ------------------------------------------------------------- Memory -- */

.tba-memory {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
	gap: 12px;
	margin: 8px 0 4px;
}
.tba-mcard {
	position: relative;
	aspect-ratio: 4 / 3;
	min-height: 110px;
	padding: 0; border: 0; background: none;
	cursor: pointer;
	perspective: 900px;
	-webkit-tap-highlight-color: transparent;
}
.tba-mcard-in {
	position: absolute; inset: 0;
	transform-style: preserve-3d;
	transition: transform .45s cubic-bezier(.2, .7, .3, 1);
	border-radius: var(--tba-radius);
}
.tba-mcard.flipped .tba-mcard-in { transform: rotateY(180deg); }
.tba-mcard-back, .tba-mcard-front {
	position: absolute; inset: 0;
	backface-visibility: hidden;
	-webkit-backface-visibility: hidden;
	border-radius: var(--tba-radius);
	border: 1px solid var(--tba-line);
	display: flex; align-items: center; justify-content: center;
	overflow: hidden;
}
.tba-mcard-back {
	background:
		linear-gradient(135deg, rgba(45, 212, 191, .16), rgba(167, 139, 250, .16)),
		var(--tba-panel-solid);
}
.tba-mcard-logo {
	font-weight: 800; font-size: 22px; letter-spacing: .1em;
	color: var(--tba-cyan); opacity: .9;
}
.tba-mcard-front {
	transform: rotateY(180deg);
	background: var(--tba-panel-solid);
	padding: 6px;
}
.tba-mcard-front .tba-pat-svg { width: 100%; height: 100%; }
.tba-mcard-txt {
	font-size: 13px; line-height: 1.35; text-align: center; padding: 6px;
	overflow-wrap: anywhere;
}
.tba-mcard.matched .tba-mcard-front {
	border-color: var(--tba-good);
	box-shadow: 0 0 0 1px var(--tba-good), 0 0 18px rgba(52, 211, 153, .3);
}
.tba-mcard.matched { cursor: default; }
.tba-mcard.miss .tba-mcard-front { border-color: var(--tba-bad); }

/* ----------------------------------------------------------- Ergebnis -- */

.tba-result-title { text-align: center; letter-spacing: .06em; }
.tba-result-vs {
	display: grid; grid-template-columns: 1fr auto 1fr;
	align-items: center; gap: 12px; margin: 16px 0;
}
.tba-result-side { text-align: center; padding: 12px; border-radius: var(--tba-radius-sm); border: 1px solid transparent; }
.tba-result-side.winner { border-color: var(--tba-cyan); background: rgba(45, 212, 191, .08); }
.tba-result-score { font-size: 32px; font-weight: 800; font-variant-numeric: tabular-nums; }
.tba-result-grid {
	display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
	gap: 10px; margin: 16px 0;
}
.tba-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tba-tag {
	font-size: 12px; padding: 5px 10px; border-radius: 999px;
	border: 1px solid var(--tba-line); background: var(--tba-panel-2);
}
.tba-tag.ok { border-color: rgba(52, 211, 153, .4); color: var(--tba-good); }
.tba-tag.weak { border-color: rgba(251, 191, 36, .4); color: var(--tba-warn); }

/* ------------------------------------------------------------ Mastery -- */

.tba-mastery { display: flex; flex-direction: column; gap: 4px; }
.tba-mastery-row {
	display: grid;
	grid-template-columns: minmax(140px, 1.4fr) minmax(80px, 2fr) 60px auto;
	align-items: center; gap: 10px;
	padding: 8px 0; border-bottom: 1px solid var(--tba-line);
}
.tba-mastery-row:last-child { border-bottom: 0; }
.tba-mastery-nm { display: flex; flex-direction: column; min-width: 0; }
.tba-mastery-nm > span:first-child { overflow-wrap: anywhere; }
.tba-mastery-cat { font-size: 11px; color: var(--tba-muted); }
.tba-mastery-val { text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; }
.tba-mastery-act { display: flex; gap: 6px; }
.tba-mastery .tba-ov-track span.lvl-strong { background: var(--tba-good); }
.tba-mastery .tba-ov-track span.lvl-ok { background: var(--tba-cyan); }
.tba-mastery .tba-ov-track span.lvl-weak { background: var(--tba-bad); }
.tba-mastery .tba-ov-track span.lvl-learning { background: var(--tba-warn); }
.tba-mastery .tba-ov-track span.lvl-new { background: rgba(148, 163, 184, .35); }

/* -------------------------------------------------------- Bibliothek -- */

.tba-lib {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
	gap: 14px;
}
.tba-lib-tile {
	display: flex; flex-direction: column; gap: 8px; text-align: left;
	background: linear-gradient(180deg, var(--tba-panel), var(--tba-panel-2));
	border: 1px solid var(--tba-line);
	border-radius: var(--tba-radius);
	padding: 12px; color: var(--tba-text); cursor: pointer;
	transition: border-color .15s ease, transform .15s ease;
}
.tba-lib-tile:hover { border-color: var(--tba-cyan); transform: translateY(-2px); }
.tba-lib-meta h3 { margin: 6px 0 6px; font-size: 15px; color: var(--tba-text); text-transform: none; letter-spacing: 0; }
.tba-lib-meta p { margin: 8px 0 0; font-size: 13px; color: var(--tba-muted); line-height: 1.4; }

/* ------------------------------------------------------------- Dialog -- */

.tba-modal {
	position: fixed; inset: 0; z-index: 9999;
	background: rgba(2, 8, 23, .72);
	display: flex; align-items: center; justify-content: center;
	padding: 16px;
	overflow-y: auto;
}
.tba-modal-box {
	background: var(--tba-panel-solid);
	border: 1px solid var(--tba-line);
	border-radius: var(--tba-radius);
	padding: 20px;
	width: 100%; max-width: 420px;
	box-shadow: var(--tba-shadow);
	color: var(--tba-text);
	max-height: 92vh; overflow-y: auto;
}
.tba-modal-wide { max-width: 640px; }
.tba-modal-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.tba-input {
	width: 100%; padding: 12px 14px; margin: 10px 0;
	background: var(--tba-panel-2);
	border: 1px solid var(--tba-line);
	border-radius: var(--tba-radius-sm);
	color: var(--tba-text); font-size: 16px;
	letter-spacing: .1em; text-transform: uppercase;
}

/* -------------------------------------------------- Fokus & Bewegung -- */

.tba-root button:focus-visible,
.tba-root .tba-input:focus-visible,
.tba-modal button:focus-visible {
	outline: 2px solid var(--tba-cyan);
	outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
	.tba-mcard-in { transition: none; }
	.tba-mode, .tba-act, .tba-lib-tile { transition: none; }
	.tba-mode:hover, .tba-act:hover, .tba-lib-tile:hover { transform: none; }
}

/* ------------------------------------------------------------- Mobil -- */

@media (max-width: 980px) {
	.tba-game-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
	.tba-memory { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
	.tba-mcard { min-height: 96px; }
	.tba-answers { grid-template-columns: 1fr; }
	.tba-round-q { font-size: 17px; }
	.tba-vs { grid-template-columns: 1fr auto 1fr; gap: 6px; }
	.tba-vs-av { width: 38px; height: 38px; font-size: 15px; }
	.tba-vs-score { font-size: 22px; }
	.tba-vs-name { font-size: 12px; }
	.tba-code-val { font-size: 24px; }
	.tba-mastery-row { grid-template-columns: 1fr auto; grid-template-areas: 'nm val' 'track track' 'act act'; }
	.tba-mastery-nm { grid-area: nm; }
	.tba-mastery-val { grid-area: val; }
	.tba-mastery-row .tba-ov-track { grid-area: track; }
	.tba-mastery-act { grid-area: act; }
	.tba-result-vs { grid-template-columns: 1fr; }
	.tba-modal-actions .tba-btn { flex: 1 1 100%; }
}

/* Auf Touch-Geräten gibt es kein Schweben — Zustände hängen am Antippen. */
@media (hover: none) {
	.tba-mode:hover, .tba-act:hover, .tba-lib-tile:hover { transform: none; border-color: var(--tba-line); }
	.tba-answer:hover:not(:disabled) { border-color: var(--tba-line); }

	/* Ohne Maus muss jede Schaltfläche mit dem Finger sicher zu treffen sein.
	   Die kompakten Chips sind am Schreibtisch 36/32 px hoch — das ist für
	   einen Fingertipp zu wenig. */
	.tba-chip,
	.tba-bot-levels .tba-chip,
	.tba-btn-sm { min-height: 44px; padding-top: 10px; padding-bottom: 10px; }
}
