:root {
	--wall: #2b1d24;
	--wall-2: #35232c;
	--ink: #f7efd8;
	--muted: #c9b9a6;
	--gold: #ffd35c;
	--coral: #ff7a59;
	--teal: #2fa39a;
	--card: #fff7e6;
	--card-ink: #2a1d17;
	--wood: #7a4b2c;
	--wood-dark: #4f2f1a;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
	min-height: 100vh;
	color: var(--ink);
	font-family: "Fredoka", "Trebuchet MS", sans-serif;
	background-color: var(--wall);
	background-image:
		radial-gradient(circle at 20px 20px, rgba(255, 211, 92, 0.07) 3px, transparent 4px),
		radial-gradient(circle at 60px 60px, rgba(255, 122, 89, 0.06) 3px, transparent 4px),
		linear-gradient(90deg, rgba(0, 0, 0, 0.12) 50%, transparent 50%);
	background-size: 80px 80px, 80px 80px, 80px 80px;
}

.hidden { display: none !important; }

.top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 14px 24px;
	max-width: 1500px;
	margin: 0 auto;
}
.logo {
	font-family: "Bungee", "Arial Black", sans-serif;
	font-size: clamp(20px, 3vw, 30px);
	color: var(--gold);
	text-shadow: 3px 3px 0 #4a1f2e;
	letter-spacing: 0.5px;
}
.logo .the { font-size: 0.55em; color: var(--coral); margin-right: 8px; vertical-align: 0.35em; }
.meta { display: flex; align-items: center; gap: 12px; }
.badge {
	font-weight: 700;
	font-size: 14px;
	padding: 5px 12px;
	border-radius: 999px;
	background: #4b3a44;
	color: #e8dccb;
	letter-spacing: 1px;
}
.badge.live { background: #d93434; color: #fff; box-shadow: 0 0 0 0 rgba(217, 52, 52, 0.6); animation: pulse 1.8s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(217, 52, 52, 0.55); } 70% { box-shadow: 0 0 0 10px rgba(217, 52, 52, 0); } 100% { box-shadow: 0 0 0 0 rgba(217, 52, 52, 0); } }
.viewers { color: var(--muted); font-size: 15px; }

.layout {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 340px;
	gap: 24px;
	max-width: 1500px;
	margin: 0 auto;
	padding: 0 24px 32px;
	align-items: start;
}

/* the TV set */
.tv {
	background: linear-gradient(160deg, #8a5634, var(--wood) 40%, var(--wood-dark));
	border-radius: 28px;
	padding: 22px 22px 14px;
	box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45), inset 0 2px 0 rgba(255, 255, 255, 0.15);
	transition: box-shadow 0.4s;
}
.tv.directing { box-shadow: 0 0 0 4px var(--gold), 0 18px 40px rgba(0, 0, 0, 0.45); }
.screen {
	position: relative;
	border-radius: 18px;
	overflow: hidden;
	background: #000;
	box-shadow: inset 0 0 0 6px #1b1210, 0 0 0 3px #2f1c12;
	aspect-ratio: 16 / 9;
}
.screen canvas { display: block; width: 100%; height: 100%; }
.screen::after {
	content: '';
	position: absolute;
	inset: 0;
	pointer-events: none;
	background: radial-gradient(ellipse at center, transparent 60%, rgba(0, 0, 0, 0.35));
	border-radius: 18px;
}
.tv:fullscreen { border-radius: 0; padding: 0; background: #000; display: flex; flex-direction: column; justify-content: center; }
.tv:fullscreen .screen { border-radius: 0; max-height: 100vh; }
.tv:fullscreen .tv-controls { display: none; }

.tv-controls { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 10px; padding-top: 12px; }
.knobs { display: flex; gap: 10px; margin-right: auto; }
.knobs i { width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #d9c8a8, #6d5a40); box-shadow: 0 2px 3px rgba(0, 0, 0, 0.4); }

.tune {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	background: rgba(20, 12, 24, 0.82);
	backdrop-filter: blur(4px);
	padding: 16px;
}
.tune-card { text-align: center; max-width: 520px; }
.tune-logo { font-family: "Bungee", sans-serif; font-size: clamp(26px, 5vw, 54px); color: var(--gold); text-shadow: 4px 4px 0 #4a1f2e; line-height: 1.05; }
.tune-logo span { display: block; font-size: 0.42em; color: var(--coral); }
.tune-card p { font-size: clamp(14px, 1.6vw, 18px); line-height: 1.45; color: var(--ink); margin: 12px auto 18px; }

/* buttons and fields */
.btn {
	font-family: inherit;
	font-weight: 600;
	font-size: 16px;
	border: 0;
	border-radius: 12px;
	padding: 10px 18px;
	cursor: pointer;
	color: #2a1606;
	background: var(--gold);
	box-shadow: 0 4px 0 #b88a1d;
	transition: transform 0.08s, box-shadow 0.08s;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #b88a1d; }
.btn.big { font-size: 22px; padding: 14px 34px; border-radius: 16px; }
.btn.small { font-size: 14px; padding: 7px 12px; }
.btn.ghost { background: rgba(255, 255, 255, 0.12); color: var(--ink); box-shadow: none; }
.btn.ghost:active { transform: translateY(1px); }

input[type="text"], textarea {
	width: 100%;
	font-family: inherit;
	font-size: 16px;
	border: 2px solid #d9c9a8;
	border-radius: 10px;
	padding: 9px 11px;
	background: #fffdf6;
	color: var(--card-ink);
	resize: none;
}
input[type="text"]:focus, textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(47, 163, 154, 0.25); }

/* side cards */
.side { display: flex; flex-direction: column; gap: 18px; }
.card {
	background: var(--card);
	color: var(--card-ink);
	border-radius: 16px;
	padding: 16px 18px 18px;
	box-shadow: 0 10px 24px rgba(0, 0, 0, 0.3);
}
.card-label { font-size: 12px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: #9b6b3a; }
.story-title { font-family: "Bungee", sans-serif; font-size: 22px; line-height: 1.15; margin: 6px 0 4px; color: #4a1f2e; }
.beat { font-weight: 600; color: var(--teal); min-height: 1.2em; }
.mode-text { margin-top: 8px; font-size: 14px; color: #6d5a4a; line-height: 1.4; }

.chair { padding-top: 0; overflow: hidden; }
.clapper {
	margin: 0 -18px 14px;
	padding: 12px 18px;
	background: repeating-linear-gradient(-45deg, #1f1a1f 0 18px, #f7efd8 18px 36px);
	position: relative;
}
.clapper span {
	display: inline-block;
	font-family: "Bungee", sans-serif;
	font-size: 16px;
	background: #1f1a1f;
	color: var(--gold);
	padding: 4px 10px;
	border-radius: 6px;
}
.chair-status { margin: 0 0 10px; font-size: 15px; line-height: 1.4; }
.pending-twist { margin: -4px 0 12px; padding: 8px 10px; border-left: 4px solid var(--gold); background: #fff0c4; border-radius: 6px; font-style: italic; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: #7a5a3a; margin-bottom: 6px; }
#joinArea .btn { width: 100%; margin-top: 10px; }
.queue-pos { font-size: 18px; font-weight: 600; margin: 0 0 10px; }
#queueArea .btn.ghost, .card .btn.ghost { background: #efe2c8; color: var(--card-ink); }

.turn-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.turn-head strong { font-size: 16px; line-height: 1.25; }
.countdown { font-weight: 700; font-size: 18px; background: var(--teal); color: #fff; border-radius: 999px; padding: 3px 10px; min-width: 52px; text-align: center; }
.countdown.low { background: #d93434; }
.turn-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.char-count { font-size: 13px; color: #8a7460; }
.examples { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip {
	font-family: inherit;
	font-size: 13px;
	border: 1.5px dashed #c9a87a;
	background: transparent;
	color: #6d4a2a;
	border-radius: 999px;
	padding: 4px 10px;
	cursor: pointer;
	text-align: left;
}
.chip:hover { background: #fff0c4; }
.busy { font-weight: 600; }
.dots::after { content: '...'; animation: dots 1.2s steps(4) infinite; display: inline-block; overflow: hidden; vertical-align: bottom; width: 0; }
@keyframes dots { to { width: 1.2em; } }
.good-note { margin: 0 0 6px; font-weight: 600; color: var(--teal); }
.your-twist { margin: 0; font-style: italic; }

.fine-print { font-size: 13px; color: var(--muted); line-height: 1.45; margin: 0 4px; }

/* toasts */
.set-name { font-size: 14px; color: #7a5a3a; margin-top: 2px; }
.set-name:empty { display: none; }
.how { margin: 0 0 14px; padding: 0; list-style: none; counter-reset: how; }
.how li { counter-increment: how; position: relative; padding: 0 0 10px 36px; font-size: 14px; line-height: 1.4; }
.how li::before { content: counter(how); position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%; background: #1f1a1f; color: var(--gold); font-weight: 700; font-size: 13px; display: grid; place-items: center; }
.how li b { display: block; font-size: 15px; }
.plan-status { margin: 0 0 12px; padding: 8px 10px; border-radius: 8px; background: #efe2c8; font-size: 14px; font-weight: 600; }
.plan-status.go { background: #d9f2ee; color: #145e57; }
.step-label { font-size: 14px; font-weight: 700; margin: 12px 0 6px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.step-label b { width: 22px; height: 22px; border-radius: 50%; background: var(--teal); color: #fff; display: grid; place-items: center; font-size: 12px; }
.hint { font-weight: 500; font-size: 12px; color: #8a7460; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pick {
	font-family: inherit;
	font-size: 13px;
	font-weight: 600;
	border: 2px solid #d9c9a8;
	background: #fffdf6;
	color: var(--card-ink);
	border-radius: 999px;
	padding: 5px 11px;
	cursor: pointer;
}
.pick:hover { border-color: var(--teal); }
.pick.on { background: var(--teal); border-color: var(--teal); color: #fff; }
.pick.new { border-style: dashed; }
.new-place { margin-top: 8px; }
.new-place .hint { margin-top: 4px; }
.examples-label { font-size: 12px; color: #8a7460; margin-top: 10px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: 0 4px 0 #b88a1d; }
.rules { margin: 14px 0 10px; font-size: 13px; }
.rules summary { cursor: pointer; font-weight: 700; color: #6d4a2a; }
.rules-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.rules ul { margin: 0; padding-left: 16px; line-height: 1.4; }
.rules-head { font-weight: 700; margin-bottom: 4px; }
.rules-head.ok { color: #1f8c84; }
.rules-head.no { color: #c0392b; }
.rules-note { margin: 8px 0 0; font-style: italic; color: #6d5a4a; }
.editor-note { margin: 8px 0 0; font-size: 13px; color: #6d5a4a; }
.editor-note:empty { display: none; }
@media (max-width: 420px) { .rules-cols { grid-template-columns: 1fr; } }

.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; z-index: 10; pointer-events: none; width: min(92vw, 520px); }
.toast {
	background: #1f1a1f;
	color: var(--ink);
	padding: 10px 16px;
	border-radius: 12px;
	box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
	border-left: 5px solid var(--teal);
	font-size: 15px;
	animation: rise 0.25s ease-out;
	transition: opacity 0.5s, transform 0.5s;
}
.toast.warn { border-left-color: var(--coral); }
.toast.good { border-left-color: var(--gold); }
.toast.out { opacity: 0; transform: translateY(8px); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

@media (max-width: 1000px) {
	.layout { grid-template-columns: 1fr; padding: 0 16px 24px; }
	.top { padding: 12px 16px; }
	.tv { padding: 12px 12px 10px; border-radius: 20px; }
	.screen { border-radius: 12px; }
}
@media (max-width: 520px) {
	.knobs { display: none; }
	.viewers { display: none; }
}
