/* Wortwerk – Legespiel mit Buchstabensteinen.
   Alle Regeln sind auf .wrw gescoped, damit kein Theme-CSS kollidiert. */

.wrw {
	--wrw-paper:  #f4f1e8;   /* Grund hinter dem Brett */
	--wrw-frame:  #2c4a44;   /* Brettrahmen */
	--wrw-cell:   #e8e3d5;   /* leeres Feld */
	--wrw-grid:   #cdc6b4;   /* Fugen */
	--wrw-ink:    #23312e;
	--wrw-muted:  #6c7b76;
	--wrw-line:   #d8d2c2;

	/* Prämienfelder – eigene Farbwelt, an den Rahmen angelehnt. */
	--wrw-w3:     #1f6f63;   /* Wort dreifach */
	--wrw-w2:     #7fb3a8;   /* Wort doppelt */
	--wrw-l3:     #c9762f;   /* Buchstabe dreifach */
	--wrw-l2:     #e6c489;   /* Buchstabe doppelt */
	--wrw-start:  #c9a227;   /* Startfeld */

	--wrw-tile:   #fbf6e8;   /* Stein */
	--wrw-tile2:  #eadfc4;
	--wrw-fresh:  #1f6f63;   /* frisch gelegt */
	--wrw-joker:  #8d6fb0;   /* Joker */

	--wrw-sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	--wrw-mono: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

	container-type: inline-size;
	container-name: wrw;

	background: var(--wrw-paper);
	color: var(--wrw-ink);
	font-family: var(--wrw-sans);
	border: 1px solid var(--wrw-line);
	border-radius: 12px;
	max-width: 760px;
	margin: 0 auto;
	box-sizing: border-box;
}

.wrw *,
.wrw *::before,
.wrw *::after { box-sizing: border-box; }

.wrw__inner { padding: clamp(14px, 4cqi, 26px); }

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

.wrw__head { margin-bottom: 12px; }

.wrw__eyebrow {
	font-family: var(--wrw-mono);
	font-size: 11px;
	letter-spacing: 0.32em;
	text-transform: uppercase;
	color: var(--wrw-muted);
	margin: 0 0 4px;
}

.wrw__title {
	font-size: clamp(21px, 6cqi, 32px);
	font-weight: 800;
	line-height: 1.05;
	margin: 0;
	color: var(--wrw-ink);
}

.wrw__missing {
	margin: 0;
	padding: 14px;
	border: 1px dashed var(--wrw-line);
	border-radius: 10px;
	color: var(--wrw-muted);
	font-size: 14px;
}

/* ---------- Spielerzahl vor dem Raum ---------- */

.wrw__setup {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	margin-bottom: 12px;
}

.wrw__setupLabel {
	font-family: var(--wrw-mono);
	font-size: 11px;
	letter-spacing: 0.18em;
	text-transform: uppercase;
	color: var(--wrw-muted);
}

/* ---------- Punktestand ---------- */

.wrw__scores {
	display: flex;
	flex-wrap: wrap;
	gap: 6px 10px;
	margin-bottom: 12px;
}

.wrw__player {
	display: flex;
	align-items: baseline;
	gap: 7px;
	padding: 6px 11px;
	border: 1px solid var(--wrw-line);
	border-radius: 999px;
	background: #fff;
	font-size: 13px;
	line-height: 1;
}

.wrw__player.is-turn {
	border-color: var(--wrw-w3);
	box-shadow: 0 0 0 2px rgba(31, 111, 99, 0.16);
}

.wrw__player.is-you .wrw__pname { font-weight: 700; }

.wrw__pname { color: var(--wrw-ink); }

.wrw__pscore {
	font-family: var(--wrw-mono);
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	color: var(--wrw-w3);
}

.wrw__ptiles {
	font-family: var(--wrw-mono);
	font-size: 11px;
	color: var(--wrw-muted);
}

/* ---------- Brett ---------- */

.wrw__boardWrap {
	background: var(--wrw-frame);
	border-radius: 10px;
	padding: clamp(6px, 1.6cqi, 12px);
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 2px 6px rgba(0, 0, 0, 0.18);
}

.wrw__board {
	display: grid;
	/* minmax(0, 1fr): ohne die 0 wachsen die Spuren auf ihren min-content-Wert
	   und das Brett läuft aus einer schmalen Spalte heraus. */
	grid-template-columns: repeat(13, minmax(0, 1fr));
	gap: clamp(1px, 0.3cqi, 3px);
	aspect-ratio: 1 / 1;
}

.wrw__cell {
	position: relative;
	min-width: 0;
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: clamp(1px, 0.5cqi, 3px);
	background: var(--wrw-cell);
	color: var(--wrw-ink);
	font: inherit;
	line-height: 1;
	cursor: default;
	display: grid;
	place-items: center;
	overflow: hidden;
	-webkit-tap-highlight-color: transparent;
}

.wrw__cell--w3 { background: var(--wrw-w3); }
.wrw__cell--w2 { background: var(--wrw-w2); }
.wrw__cell--l3 { background: var(--wrw-l3); }
.wrw__cell--l2 { background: var(--wrw-l2); }
.wrw__cell--st { background: var(--wrw-start); }

/* Feldbeschriftung – verschwindet, sobald ein Stein daraufliegt. */
.wrw__mark {
	font-family: var(--wrw-mono);
	font-size: clamp(4px, 1.15cqi, 9px);
	font-weight: 700;
	letter-spacing: -0.02em;
	color: rgba(255, 255, 255, 0.92);
	pointer-events: none;
	user-select: none;
}

.wrw__cell--l2 .wrw__mark,
.wrw__cell--st .wrw__mark { color: rgba(0, 0, 0, 0.5); }

.wrw__cell.is-open { cursor: pointer; }
.wrw__cell.is-open:hover { outline: 2px solid var(--wrw-w3); outline-offset: -2px; }

.wrw__cell:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }

/* Stein auf dem Brett */
.wrw__tile {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	background: linear-gradient(180deg, var(--wrw-tile), var(--wrw-tile2));
	border-radius: clamp(1px, 0.5cqi, 3px);
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 1px 1px rgba(0, 0, 0, 0.22);
	font-weight: 800;
	font-size: clamp(7px, 2.5cqi, 19px);
	color: var(--wrw-ink);
	line-height: 1;
}

.wrw__tile sub {
	position: absolute;
	right: 6%;
	bottom: 4%;
	font-size: 0.5em;
	font-weight: 700;
	color: var(--wrw-muted);
	line-height: 1;
}

.wrw__tile.is-joker { color: var(--wrw-joker); }

/* zuletzt vom Gegner gelegt */
.wrw__cell.is-last .wrw__tile { box-shadow: 0 0 0 2px var(--wrw-fresh), 0 1px 1px rgba(0, 0, 0, 0.22); }

/* eigener, noch nicht abgeschickter Stein */
.wrw__cell.is-pending .wrw__tile {
	background: linear-gradient(180deg, #fff9e2, #f0e6c6);
	box-shadow: 0 0 0 2px var(--wrw-start), 0 1px 1px rgba(0, 0, 0, 0.22);
	cursor: pointer;
}

/* ---------- Bank ---------- */

.wrw__rackWrap {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	margin-top: 12px;
}

.wrw__rack {
	display: flex;
	gap: clamp(3px, 1cqi, 7px);
	padding: clamp(4px, 1.2cqi, 8px);
	background: var(--wrw-frame);
	border-radius: 8px;
	min-height: 44px;
}

.wrw__slot {
	width: clamp(28px, 8cqi, 46px);
	aspect-ratio: 1 / 1;
	padding: 0;
	border: 0;
	border-radius: 4px;
	background: rgba(255, 255, 255, 0.09);
	position: relative;
	display: grid;
	place-items: center;
	font: inherit;
	font-weight: 800;
	font-size: clamp(13px, 4cqi, 22px);
	color: var(--wrw-ink);
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

.wrw__slot.is-filled {
	background: linear-gradient(180deg, var(--wrw-tile), var(--wrw-tile2));
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 1px 2px rgba(0, 0, 0, 0.3);
}

.wrw__slot.is-used { opacity: 0.28; cursor: default; }

.wrw__slot.is-sel { outline: 3px solid var(--wrw-start); outline-offset: -3px; }

.wrw__slot.is-swap { outline: 3px solid var(--wrw-l3); outline-offset: -3px; }

.wrw__slot sub {
	position: absolute;
	right: 9%;
	bottom: 4%;
	font-size: 0.45em;
	font-weight: 700;
	color: var(--wrw-muted);
	line-height: 1;
}

.wrw__slot.is-joker { color: var(--wrw-joker); }

.wrw__bag {
	font-family: var(--wrw-mono);
	font-size: 12px;
	color: var(--wrw-muted);
	white-space: nowrap;
}

/* ---------- Status, Knöpfe, Verlauf ---------- */

.wrw__status {
	margin: 12px 0 0;
	font-size: clamp(13px, 3.4cqi, 15px);
	line-height: 1.45;
	min-height: 1.45em;
	color: var(--wrw-ink);
}

.wrw__status.is-win  { color: var(--wrw-w3); font-weight: 700; }
.wrw__status.is-lose { color: #b4472f; font-weight: 700; }
.wrw__status.is-warn { color: #b4472f; }

.wrw__actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	margin-top: 12px;
}

.wrw__btn {
	font: inherit;
	font-size: 13px;
	font-weight: 600;
	line-height: 1;
	padding: 10px 15px;
	border-radius: 8px;
	border: 1px solid transparent;
	background: var(--wrw-frame);
	color: var(--wrw-paper);
	cursor: pointer;
	transition: background-color 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.wrw__btn:hover { background: #3a615a; }

.wrw__btn:focus-visible { outline: 2px solid var(--wrw-w3); outline-offset: 2px; }

.wrw__btn[disabled] { opacity: 0.4; cursor: default; }
.wrw__btn[disabled]:hover { background: var(--wrw-frame); }

.wrw__btn--ghost {
	background: transparent;
	color: var(--wrw-ink);
	border-color: var(--wrw-line);
}

.wrw__btn--ghost:hover { background: rgba(0, 0, 0, 0.05); }
.wrw__btn--ghost[disabled]:hover { background: transparent; }

.wrw__btn--chip {
	background: transparent;
	color: var(--wrw-muted);
	border-color: var(--wrw-line);
	padding: 7px 12px;
	font-size: 12px;
}

.wrw__btn--chip.is-on {
	background: var(--wrw-frame);
	color: var(--wrw-paper);
	border-color: var(--wrw-frame);
}

.wrw__logBox {
	margin-top: 12px;
	font-size: 13px;
	color: var(--wrw-muted);
}

.wrw__logBox summary { cursor: pointer; }

.wrw__log {
	margin: 8px 0 0;
	padding-left: 20px;
	max-height: 180px;
	overflow-y: auto;
}

.wrw__log li { margin-bottom: 3px; line-height: 1.4; }

.wrw__logPts {
	font-family: var(--wrw-mono);
	font-weight: 700;
	color: var(--wrw-w3);
}

.wrw__hint {
	margin: 12px 0 0;
	font-size: 12px;
	line-height: 1.6;
	color: var(--wrw-muted);
}

/* ---------- Joker-Auswahl ---------- */

.wrw__pick {
	position: fixed;
	inset: 0;
	background: rgba(20, 28, 26, 0.55);
	display: grid;
	place-items: center;
	padding: 16px;
	z-index: 99999;
}

.wrw__pickBox {
	background: var(--wrw-paper);
	border-radius: 12px;
	padding: 18px;
	max-width: 420px;
	width: 100%;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}

.wrw__pickTitle {
	margin: 0 0 12px;
	font-size: 15px;
	font-weight: 700;
}

.wrw__pickGrid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
	gap: 6px;
	margin-bottom: 12px;
}

.wrw__pickBtn {
	aspect-ratio: 1 / 1;
	border: 1px solid var(--wrw-line);
	border-radius: 6px;
	background: linear-gradient(180deg, var(--wrw-tile), var(--wrw-tile2));
	font: inherit;
	font-weight: 800;
	font-size: 16px;
	color: var(--wrw-ink);
	cursor: pointer;
}

.wrw__pickBtn:hover { border-color: var(--wrw-w3); }

/* ---------- Enge Spalten ---------- */

@container wrw (max-width: 420px) {
	.wrw__inner { padding: 12px; }
	.wrw__hint { display: none; }
	.wrw__setupLabel { display: none; }
	.wrw__mark { display: none; }
}

/* ---------- Einrichtung: Modus, Spielerzahl, Stärke ---------- */

.wrw__setup { flex-direction: column; align-items: stretch; gap: 8px; }

.wrw__setupRow {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
}

.wrw__setupRow[hidden] { display: none; }
