/* Hearts — Tisch, Karten, Overlays. Kartengrößen kommen als CSS-Variablen aus hearts.js
   (--kb Handkarte, --tk Stichkarte, --rb Rückseiten der Gegner). */

.hz-tisch {
	--kb: 64px;
	--tk: 70px;
	--rb: 24px;
	--ueb: .5;                /* sichtbarer Anteil einer überlappten Handkarte = 1 − ueb */
	position: relative;
	display: grid;
	/* feste Seitenspalten: wachsen sie mit den Punkte-Chips der Gegner, rutscht die Mitte samt Stich */
	grid-template-columns: 76px minmax(0, 1fr) 76px;
	grid-template-rows: auto 1fr auto auto auto;
	grid-template-areas:
		"oben oben oben"
		"links mitte rechts"
		"hinweis hinweis hinweis"
		"hand hand hand"
		"ich ich ich";
	height: clamp(560px, calc(100svh - 80px), 900px);
	max-width: 1080px;
	margin: 0 auto;
	padding: 8px 8px 6px;
	border-radius: 18px;
	background-color: #6B4423;
	background-size: cover;
	background-position: center;
	box-shadow: inset 0 0 0 6px rgba(60, 30, 10, .55), 0 10px 30px rgba(0, 0, 0, .25);
	color: #fff;
	overflow: hidden;
	user-select: none;
	-webkit-user-select: none;
	-webkit-tap-highlight-color: transparent;
}
/* grüner Filz in der Mitte des Holztisches */
.hz-tisch::before {
	content: '';
	position: absolute;
	inset: 14px;
	border-radius: 14px;
	background: radial-gradient(ellipse at 50% 45%, #2E8B57 0%, #1F6B42 60%, #155234 100%);
	box-shadow: inset 0 0 40px rgba(0, 0, 0, .45);
	pointer-events: none;
	z-index: 0;
}
.hz-tisch > * { position: relative; z-index: 1; }

/* ---------- Karten ---------- */
.hz-karte {
	display: inline-block;
	flex: 0 0 auto;
	width: var(--kb);
	height: calc(var(--kb) * 1.404);
	border-radius: calc(var(--kb) * .07);
	background-size: 100% 100%;
	background-color: #fff;
	box-shadow: 0 2px 5px rgba(0, 0, 0, .35);
	border: 0;
	padding: 0;
}
.hz-ruecken {
	background-color: #14532D;
	background-image:
		radial-gradient(circle at 50% 50%, rgba(255, 214, 0, .55) 0 18%, transparent 19%),
		repeating-linear-gradient(45deg, rgba(255, 214, 0, .22) 0 2px, transparent 2px 7px),
		repeating-linear-gradient(-45deg, rgba(255, 214, 0, .22) 0 2px, transparent 2px 7px);
	border: 2px solid #fff;
}

/* ---------- Plätze ---------- */
.hz-sitz { display: flex; align-items: center; gap: 4px; min-width: 0; }
.hz-oben { grid-area: oben; flex-direction: column; justify-content: flex-start; }
.hz-links { grid-area: links; flex-direction: column; justify-content: center; }
.hz-rechts { grid-area: rechts; flex-direction: column; justify-content: center; }
.hz-ich { grid-area: ich; flex-direction: row; justify-content: center; gap: 8px; min-height: 30px; }

.hz-person { display: flex; flex-direction: column; align-items: center; gap: 2px; position: relative; }
.hz-ich .hz-person { flex-direction: row; gap: 8px; }
.hz-avatar {
	width: 44px; height: 44px; border-radius: 50%;
	background: #FFF4CC center / cover no-repeat;
	border: 3px solid rgba(255, 255, 255, .85);
	display: flex; align-items: center; justify-content: center;
	font-size: 26px; line-height: 1;
	box-shadow: 0 2px 6px rgba(0, 0, 0, .35);
	position: relative;
}
.hz-ich .hz-avatar { width: 34px; height: 34px; font-size: 20px; }
.hz-sitz.dran .hz-avatar { border-color: #FFD60A; box-shadow: 0 0 0 4px rgba(255, 214, 10, .45), 0 2px 6px rgba(0, 0, 0, .35); }
.hz-name { font-weight: 700; font-size: .9rem; text-shadow: 0 1px 2px rgba(0, 0, 0, .7); max-width: 9.5em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hz-chips { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.hz-chip {
	font-size: .72rem; font-weight: 700; line-height: 1.2;
	padding: 1px 6px; border-radius: 999px;
	background: rgba(0, 0, 0, .45); color: #fff; white-space: nowrap;
}
.hz-chip.herz { background: #B3123B; }
.hz-chip.dame { background: #111; }
.hz-chip.uhr { background: #FFD60A; color: #3a2a00; }
.hz-chip.uhr.knapp { background: #E63946; color: #fff; }
.hz-chip.bereit { background: #2E7D32; }
.hz-bot-marke { position: absolute; right: -6px; bottom: -6px; font-size: 14px; }

/* Rückseiten der Gegner */
.hz-faecher { display: flex; justify-content: center; }
.hz-faecher .hz-karte { --kb: var(--rb); box-shadow: 0 1px 2px rgba(0, 0, 0, .4); border-width: 1px; }
.hz-oben .hz-faecher .hz-karte + .hz-karte { margin-left: calc(var(--rb) * -.68); }
/* Höhe auch ohne Karten halten: sonst wird die obere Zeile beim letzten Stich flacher und der Stich rutscht */
.hz-oben .hz-faecher { min-height: calc(var(--rb) * 1.404); }
.hz-links .hz-faecher, .hz-rechts .hz-faecher { flex-direction: column; }
.hz-links .hz-faecher .hz-karte, .hz-rechts .hz-faecher .hz-karte { width: calc(var(--rb) * 1.404); height: var(--rb); }
.hz-links .hz-faecher .hz-karte + .hz-karte, .hz-rechts .hz-faecher .hz-karte + .hz-karte { margin-top: calc(var(--rb) * -.72); }

.hz-platz-knopf { font-size: .78rem; padding: 3px 8px; border-radius: 999px; border: 0; background: #FFD60A; color: #3a2a00; font-weight: 700; cursor: pointer; }
.hz-blase {
	position: absolute; z-index: 30; left: 50%; top: -6px; transform: translate(-50%, -100%);
	background: #fff; color: #222; border-radius: 12px; padding: 4px 10px; font-size: .85rem; white-space: nowrap;
	box-shadow: 0 2px 8px rgba(0, 0, 0, .3); pointer-events: none; animation: hzBlase 4s forwards;
}
.hz-blase.emoji { background: none; box-shadow: none; font-size: 2.4rem; padding: 0; }
@keyframes hzBlase { 0%, 85% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- Mitte: Stich, Pfeil ---------- */
.hz-mitte { grid-area: mitte; position: relative; min-height: calc(var(--tk) * 2.4); }
.hz-slot { position: absolute; width: var(--tk); height: calc(var(--tk) * 1.404); }
.hz-slot .hz-karte { --kb: var(--tk); }
#hzSlot0 { left: calc(50% - var(--tk) / 2); top: calc(50% - var(--tk) * .2); }
#hzSlot2 { left: calc(50% - var(--tk) / 2); top: calc(50% - var(--tk) * 1.2); }
#hzSlot1 { left: calc(50% - var(--tk) * 1.45); top: calc(50% - var(--tk) * .7); }
#hzSlot3 { left: calc(50% + var(--tk) * .45); top: calc(50% - var(--tk) * .7); }
.hz-slot.sieger .hz-karte { box-shadow: 0 0 0 3px #FFD60A, 0 3px 8px rgba(0, 0, 0, .5); }

.hz-pfeil {
	position: absolute; left: 50%; top: 50%;
	width: min(150px, 40%); aspect-ratio: 1.2;
	transform: translate(-50%, -50%);
	background: none; border: 0; padding: 0; cursor: pointer;
	filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .45));
	transition: opacity .2s, transform .2s;
}
.hz-pfeil svg { width: 100%; height: 100%; display: block; transition: transform .25s; }
.hz-pfeil.rechts svg { transform: rotate(180deg); }
.hz-pfeil.gegenueber svg { transform: rotate(90deg); }
.hz-pfeil[disabled] { opacity: .45; cursor: default; }
.hz-pfeil:not([disabled]) { animation: hzPuls 1.2s ease-in-out infinite; }
@keyframes hzPuls { 50% { transform: translate(-50%, -50%) scale(1.07); } }
.hz-pfeil[hidden] { display: none; }
.hz-mitte-text {
	position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
	text-align: center; font-weight: 700; font-size: 1rem; max-width: 80%;
	background: rgba(0, 0, 0, .35); padding: 8px 14px; border-radius: 12px;
}
.hz-mitte-text[hidden] { display: none; }

/* ---------- Werkzeug-Leiste ---------- */
.hz-werkzeug { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; z-index: 5; }
.hz-wz {
	width: 36px; height: 36px; border-radius: 50%; border: 0; cursor: pointer;
	background: rgba(0, 0, 0, .35); color: #fff; font-size: 17px; line-height: 1;
	display: flex; align-items: center; justify-content: center;
}
.hz-wz:hover, .hz-wz:focus-visible { background: rgba(0, 0, 0, .55); }
.hz-wz[hidden] { display: none; }

/* ---------- Hinweis und Hand ---------- */
.hz-hinweis {
	grid-area: hinweis; justify-self: center;
	max-width: 560px; width: calc(100% - 16px);
	/* feste Höhe (zwei Zeilen): ändert sich der Text, darf die Mitte nicht rutschen */
	box-sizing: border-box; height: calc(2.6em + 10px); overflow: hidden;
	margin: 4px 0 2px; padding: 5px 12px; border-radius: 8px;
	background: #FFF3A6; color: #3a2a00; font-size: .92rem; line-height: 1.3;
	display: flex; align-items: center; justify-content: center; text-align: center;
	box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
}
.hz-hinweis:empty { visibility: hidden; }
.hz-hand {
	grid-area: hand;
	display: flex; justify-content: center; align-items: flex-end;
	padding-top: calc(var(--kb) * .3);
	min-height: calc(var(--kb) * 1.73);
	touch-action: manipulation;
}
/* Alle Handkarten auf DERSELBEN Ebene: Sonst malt der Browser jede Karte mit filter/transform (Hover,
   abgedunkelt, gewählt) über ihre rechten Nachbarn — sie „springt nach vorn“ (Meldung des Users 2026-11-20). */
.hz-hand .hz-karte { position: relative; z-index: 1; cursor: default; transition: transform .14s ease, filter .14s; }
.hz-hand .hz-karte + .hz-karte { margin-left: calc(var(--kb) * var(--ueb) * -1); }
.hz-hand .hz-karte.waehlbar { cursor: pointer; }
.hz-hand.zug .hz-karte:not(.waehlbar) { filter: brightness(.62) saturate(.7); }
.hz-hand .hz-karte.gewaehlt { transform: translateY(calc(var(--kb) * -.28)); box-shadow: 0 0 0 3px #FFD60A, 0 4px 10px rgba(0, 0, 0, .45); }
.hz-hand .hz-karte.neu { box-shadow: 0 0 0 3px #7BD3FF, 0 2px 6px rgba(0, 0, 0, .35); }
.hz-hand .hz-karte.weg { visibility: hidden; }
@media (hover: hover) {
	/* Überfahren: an Ort und Stelle hervorheben, nicht anheben (Wunsch des Users 2026-11-20 — das Springen wirkte unruhig) */
	.hz-hand .hz-karte.waehlbar:hover { box-shadow: 0 0 0 2px #FFD60A, 0 2px 5px rgba(0, 0, 0, .35); filter: brightness(1.05); }
	.hz-hand .hz-karte.waehlbar.gewaehlt:hover { box-shadow: 0 0 0 3px #FFD60A, 0 4px 10px rgba(0, 0, 0, .45); }
}
.hz-hand .hz-zuschauer-hinweis { align-self: center; opacity: .85; font-size: .9rem; }

/* fliegende Karten (hängen am Tisch, damit sie auch im Vollbild sichtbar sind) */
.hz-flug { position: absolute; z-index: 25; pointer-events: none; transition: transform .32s cubic-bezier(.3, .7, .3, 1), opacity .32s; }
.hz-flug .hz-karte { --kb: var(--tk); }

/* ---------- Meldungen ---------- */
.hz-meldung {
	position: absolute; left: 50%; top: 40%; transform: translateX(-50%); z-index: 35;
	background: rgba(20, 20, 20, .88); color: #fff; padding: 8px 14px; border-radius: 10px;
	font-size: .92rem; max-width: 86%; text-align: center; pointer-events: none;
}
.hz-meldung.fehler { background: #B3123B; }
.hz-meldung[hidden] { display: none; }
.hz-mp-anfrage {
	position: absolute; left: 50%; top: 56px; transform: translateX(-50%); z-index: 36;
	background: #fff; color: #222; padding: 8px 12px; border-radius: 12px; box-shadow: 0 4px 14px rgba(0, 0, 0, .35);
	display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center; max-width: 92%;
}
.hz-mp-anfrage[hidden] { display: none; }

/* ---------- Overlays ---------- */
.hz-overlay {
	position: absolute; inset: 0; z-index: 40;
	background: rgba(0, 0, 0, .45);
	display: flex; align-items: center; justify-content: center;
	padding: 10px;
}
.hz-popup { z-index: 60; }
.hz-overlay[hidden] { display: none !important; }
.hz-blatt {
	background: #FFFDF5; color: #2b2b2b;
	border-radius: 16px; padding: 16px 18px;
	width: min(460px, 100%); max-height: 100%; overflow: auto;
	box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
}
.hz-blatt-breit { width: min(620px, 100%); }
.hz-blatt h2 { margin: 0 0 8px; font-size: 1.3rem; }
.hz-blatt p { margin: 6px 0; }
.hz-klein { font-size: .85rem; opacity: .85; }
.hz-knoepfe { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.hz-knoepfe .btn[hidden] { display: none !important; }
.hz-wahl { border: 1px solid #e3dcc4; border-radius: 10px; margin: 8px 0; padding: 6px 10px; }
.hz-wahl legend { font-weight: 700; font-size: .9rem; padding: 0 4px; }
.hz-wahl label { display: block; padding: 3px 0; cursor: pointer; }
.hz-wahl[hidden] { display: none; }
.hz-farbwahl { margin: 4px 0 8px; padding: 6px 10px; border: 1px solid #e3dcc4; border-radius: 10px; }
.hz-farbwahl label { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }

.hz-tabelle { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: .92rem; }
.hz-tabelle th, .hz-tabelle td { padding: 4px 6px; border-bottom: 1px solid #ece4c8; text-align: right; }
.hz-tabelle th:first-child, .hz-tabelle td:first-child { text-align: left; }
.hz-tabelle tr.ich td { font-weight: 700; background: #FFF6CC; }
.hz-tabelle tr.summe td { font-weight: 700; border-top: 2px solid #c9bd92; }
.hz-tabelle .mond { color: #6a4fc9; }
.hz-ende-bananas { font-size: 1.15rem; font-weight: 700; color: #7A5300; }
.hz-ende-zeile { font-size: 1rem; }

.hz-reiter { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.hz-reiter button { border: 1px solid #d9cfae; background: #fff; border-radius: 999px; padding: 3px 10px; cursor: pointer; font-size: .85rem; }
.hz-reiter button.aktiv { background: #FFD60A; border-color: #d4ab00; font-weight: 700; }
.hz-liste-avatar { width: 22px; height: 22px; border-radius: 50%; vertical-align: middle; margin-right: 6px; object-fit: cover; }

.hz-chatliste { list-style: none; margin: 0 0 8px; padding: 0; max-height: 180px; overflow: auto; font-size: .9rem; }
.hz-chatliste li { padding: 2px 0; }
.hz-chatliste li.sys { opacity: .7; font-style: italic; }
.hz-chatliste .gross { font-size: 1.6rem; }
.hz-floskeln, .hz-emojis { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.hz-floskeln button, .hz-emojis button { border: 1px solid #d9cfae; background: #fff; border-radius: 999px; padding: 4px 10px; cursor: pointer; }
.hz-emojis button { font-size: 1.3rem; padding: 2px 8px; }

.hz-sitzliste { list-style: none; padding: 0; margin: 8px 0; }
.hz-sitzliste li { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px solid #ece4c8; }
.hz-sitzliste li > span:nth-child(2) { flex: 1; }

/* ---------- Mehrspieler: Leiste und Tischliste ---------- */
.hz-mp-leiste {
	display: flex; align-items: center; justify-content: space-between; gap: 8px;
	max-width: 1080px; margin: 0 auto 8px; padding: 6px 12px; border-radius: 12px;
	background: #FFF3A6; color: #3a2a00; font-weight: 700;
}
.hz-mp-leiste[hidden] { display: none; }
.hz-tische { max-width: 1080px; margin: 18px auto 0; }
.hz-tische-kopf { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.hz-tische-kopf h2 { margin: 0; }
.hz-tische-raster { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin-top: 10px; }
.hz-tischkarte { background: var(--card-bg, #fff); border-radius: 14px; padding: 10px 12px; box-shadow: 0 2px 8px rgba(0, 0, 0, .12); }
.hz-tischkarte.mein { outline: 3px solid #FFD60A; }
.hz-tischkarte h3 { margin: 0 0 6px; font-size: 1rem; }
.hz-tischkarte .hz-plaetze { display: flex; gap: 6px; font-size: 1.3rem; }
.hz-tischkarte .hz-knoepfe { margin-top: 8px; }

.hz-nur-mp[hidden] { display: none; }
.hz-zurueck { margin-left: 6px; }

/* Chat-Knopf neben dem eigenen Namen (Mehrspieler) */
.hz-chat-knopf {
	position: relative; flex: 0 0 auto;
	width: 34px; height: 34px; border-radius: 50%; border: 0; cursor: pointer;
	background: rgba(0, 0, 0, .4); color: #fff; font-size: 17px; line-height: 1;
	display: flex; align-items: center; justify-content: center;
	box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
}
.hz-chat-knopf:hover, .hz-chat-knopf:focus-visible { background: rgba(0, 0, 0, .6); }
.hz-chat-neu {
	position: absolute; top: -4px; right: -4px; min-width: 17px; height: 17px; padding: 0 4px;
	border-radius: 999px; background: #E63946; color: #fff; font-size: .68rem; font-weight: 700;
	display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 2px #fff;
}

/* ---------- Größen ---------- */
@media (min-width: 700px) {
	.hz-tisch { --rb: 34px; padding: 12px 14px 8px; grid-template-columns: 170px minmax(0, 1fr) 170px; }
	.hz-avatar { width: 56px; height: 56px; font-size: 32px; }
	.hz-ich .hz-avatar { width: 40px; height: 40px; font-size: 24px; }
	.hz-name { font-size: 1rem; }
	.hz-links, .hz-rechts { flex-direction: row; gap: 10px; }
	.hz-rechts { flex-direction: row-reverse; }
}
/* Handy hochkant: Gegner seitlich schmaler, damit die Mitte Platz hat */
@media (max-width: 480px) {
	.hz-tisch { grid-template-columns: 54px minmax(0, 1fr) 54px; padding: 6px 4px 4px; border-radius: 12px; margin: 0 -10px; }
	.hz-tisch::before { inset: 8px; }
	.hz-avatar { width: 38px; height: 38px; font-size: 22px; }
	.hz-name { font-size: .8rem; max-width: 6.5em; }
	.hz-chip { font-size: .66rem; padding: 1px 5px; }
	.hz-hinweis { font-size: .85rem; }
	.hz-werkzeug { top: 6px; right: 6px; gap: 4px; }
	.hz-wz { width: 32px; height: 32px; font-size: 15px; }
}
/* Handy quer: Gegner neben die Mitte, alles niedriger */
@media (orientation: landscape) and (max-height: 520px) {
	.hz-tisch { height: calc(100svh - 10px); min-height: 300px; grid-template-rows: auto 1fr auto auto 0; padding: 4px 8px; }
	/* eigene Namenszeile samt 💬 in die freie Ecke oben links (unten ist kein Platz) */
	/* grid-area: auto, sonst richtet sich „absolute“ im Grid an der untersten Zeile statt am Tisch aus */
	.hz-tisch > .hz-ich { position: absolute; grid-area: auto; left: 12px; top: 8px; z-index: 5; }
	.hz-ich .hz-avatar { width: 28px; height: 28px; font-size: 16px; }
	.hz-chat-knopf { width: 30px; height: 30px; font-size: 15px; }
	.hz-avatar { width: 32px; height: 32px; font-size: 18px; }
	.hz-oben { flex-direction: row; justify-content: center; gap: 8px; }
	.hz-oben .hz-person { flex-direction: row; }
	.hz-faecher { display: none; }
	.hz-hinweis { height: calc(1.3em + 4px); font-size: .82rem; padding: 2px 10px; white-space: nowrap; text-overflow: ellipsis; display: block; }
}

/* ---------- Vollbild ---------- */
.hz-tisch.hz-fs { height: 100vh; height: 100dvh; max-width: none; width: 100%; border-radius: 0; }
.hz-tisch.hz-pseudo-fs { position: fixed; inset: 0; z-index: 9999; margin: 0; }
body.hz-noscroll { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
	.hz-flug, .hz-hand .hz-karte, .hz-pfeil svg { transition: none; }
	.hz-pfeil:not([disabled]) { animation: none; }
}
