:root {
	color-scheme: light;
	--paper: #efe8d5;
	--paper-deep: #e3d9bf;
	--ink: #26372e;
	--ink-soft: #5c6457;
	--walnut: #5a3d27;
	--walnut-deep: #3a271a;
	--velvet: #23382d;
	--velvet-deep: #172820;
	--brass: #c9ab6a;
	--brass-deep: #8c7349;
	--rose: #a9696d;
	--glow: #f3d98f;
}

* { box-sizing: border-box; }

body {
	margin: 0;
	min-height: 100svh;
	padding: 18px 16px 104px;
	color: var(--ink);
	background:
		url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='180' viewBox='0 0 120 180'%3E%3Cpath d='M60 0C28 30 92 60 60 90S28 150 60 180' fill='none' stroke='%23b9b08c' stroke-width='1.1' opacity='.55'/%3E%3Cpath d='M60 90C40 80 34 60 42 48C56 56 62 72 60 90ZM60 90C80 100 86 120 78 132C64 124 58 108 60 90Z' fill='%23c9c09a' opacity='.45'/%3E%3Ccircle cx='60' cy='45' r='3' fill='%23c4a9a0' opacity='.5'/%3E%3C/svg%3E") 0 0 / 120px 180px,
		radial-gradient(ellipse at 50% 0, #f7f1e0, transparent 70%),
		var(--paper);
	font-family: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
	font-size: 18px;
	line-height: 1.4;
	-webkit-font-smoothing: antialiased;
}
body.house-room { padding-bottom: 104px; }
button, input { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--brass-deep); outline-offset: 3px; }
.v-defs { position: absolute; width: 0; height: 0; }
[hidden] { display: none !important; }
.v-fallback { display: none; }
body:not(.house-room) .v-fallback { display: inline-block; position: fixed; left: 16px; bottom: 16px; color: var(--ink); }

.v-room { max-width: 1080px; margin: 0 auto; }
.v-head { text-align: center; margin: 4px 0 18px; }
.v-head h1 { margin: 0; font: 400 clamp(34px, 6vw, 52px)/1 Federo, Georgia, serif; letter-spacing: 6px; text-transform: uppercase; color: var(--ink); }
.v-tagline { margin: 6px 0 0; font-style: italic; color: var(--ink-soft); }

.v-table { display: grid; grid-template-columns: minmax(0, 560px) minmax(280px, 380px); justify-content: center; gap: 28px; align-items: start; }

/* The cabinet: a walnut case with an arched cornice and sixteen velvet niches. */
.v-cabinet-wrap { position: relative; justify-self: end; width: min(100%, max(320px, calc((100svh - 210px) / 1.4))); filter: drop-shadow(0 14px 22px #2a1d1240); }
.v-cornice svg { display: block; width: 100%; height: clamp(34px, 7vw, 52px); }
.v-cabinet {
	position: relative;
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: clamp(5px, 1.4vw, 10px);
	padding: clamp(8px, 2vw, 16px);
	background:
		repeating-linear-gradient(90deg, #ffffff08 0 1px, transparent 1px 7px),
		linear-gradient(180deg, var(--walnut), var(--walnut-deep));
	border-left: 3px solid #2b1c12;
	border-right: 3px solid #2b1c12;
	box-shadow: inset 0 0 0 1px #c9ab6a80, inset 0 0 0 5px #4a3220, inset 0 0 0 6px #c9ab6a55;
}
.v-plinth { height: 18px; margin: 0 -8px; background: linear-gradient(180deg, #4a3220, #2b1c12); border-radius: 0 0 6px 6px; box-shadow: inset 0 2px 0 #c9ab6a77; }
.v-niche {
	position: relative;
	aspect-ratio: 5 / 7;
	display: flex;
	align-items: flex-end;
	justify-content: center;
	padding: 0 0 6%;
	border: 0;
	border-radius: 50% 50% 4px 4px / 26% 26% 4px 4px;
	background:
		linear-gradient(180deg, transparent 0 91%, #6b4a30 91% 93%, #c9ab6a 93% 94%, #4a3220 94%),
		radial-gradient(ellipse at 50% 30%, #335042, var(--velvet) 60%, var(--velvet-deep));
	box-shadow: inset 0 0 0 1.5px #c9ab6a99, inset 0 6px 14px #0b140f99;
	cursor: default;
	overflow: hidden;
}
.v-niche::before {
	/* glass front */
	content: '';
	position: absolute; inset: 0;
	background: linear-gradient(115deg, #ffffff14 0 18%, transparent 18% 40%, #ffffff0a 40% 46%, transparent 46%);
	pointer-events: none;
	z-index: 2;
}
.v-niche.is-open { cursor: pointer; }
.v-niche.is-open:hover, .v-niche.is-chosen { box-shadow: inset 0 0 0 2px var(--glow), inset 0 6px 14px #0b140f99, 0 0 16px #f3d98f55; }
.v-niche.is-last { box-shadow: inset 0 0 0 2px #e2c98a, inset 0 6px 14px #0b140f99; }
.v-niche.is-win { box-shadow: inset 0 0 0 3px var(--glow), inset 0 0 26px #f3d98f88, 0 0 18px #f3d98f99; }
.v-niche.is-danger::after { content: ''; position: absolute; top: 8%; left: 50%; width: 9px; height: 9px; margin-left: -4.5px; border-radius: 50%; background: var(--rose); box-shadow: 0 0 0 2px #f6e9e0aa; z-index: 3; }
.v-niche .v-vase { width: 86%; height: auto; }
.v-niche .is-ghost { opacity: .45; }
.v-winline { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; overflow: visible; }
.v-winline path { fill: none; stroke: var(--glow); stroke-width: 5; stroke-linecap: round; filter: drop-shadow(0 0 5px #f3d98f); stroke-dasharray: 600; stroke-dashoffset: 600; animation: v-draw .7s .25s ease-out forwards; }
@keyframes v-draw { to { stroke-dashoffset: 0; } }

.v-vase { display: block; overflow: visible; }
.v-drop { animation: v-drop .42s cubic-bezier(.2, .9, .3, 1.15); }
@keyframes v-drop { from { transform: translateY(-26%); opacity: 0; } to { transform: none; opacity: 1; } }

/* The side panel. */
.v-side { display: flex; flex-direction: column; gap: 14px; }
.v-play { display: flex; flex-direction: column; gap: 14px; }
.v-score { display: flex; justify-content: space-between; gap: 10px; padding: 8px 14px; border: 1px solid var(--brass-deep); border-radius: 18px 18px 4px 4px; background: #f7f1e1; font: 15px/1.3 Federo, Georgia, serif; letter-spacing: .6px; }
.v-score:empty { display: none; }
.v-score .is-turn { color: var(--rose); }
.v-score .is-turn::before { content: '❧ '; }
.v-score b { font-weight: 400; font-size: 18px; margin: 0 4px; }
.v-status { margin: 0; min-height: 2.8em; font-size: 21px; line-height: 1.3; }
.v-status em { color: var(--rose); }
.v-label { display: block; font: 12px/1.3 Federo, Georgia, serif; letter-spacing: 1.4px; text-transform: uppercase; color: var(--brass-deep); }

.v-hand { display: flex; align-items: center; gap: 14px; padding: 10px 14px; min-height: 104px; border-radius: 14px; background: linear-gradient(180deg, #2e4a3c, var(--velvet)); color: #efe2c3; box-shadow: inset 0 0 0 1px #c9ab6a99, 0 6px 16px #2a1d1230; }
.v-hand .v-label { color: var(--brass); }
.v-hand-vase { flex: none; width: 58px; }
.v-hand-vase .v-vase { width: 100%; height: auto; }
.v-hand-vase:empty::before { content: ''; display: block; width: 46px; height: 64px; margin: 0 auto; border: 1.5px dashed #c9ab6a77; border-radius: 50% 50% 6px 6px / 30% 30% 6px 6px; }
.v-hand-text { display: flex; flex-direction: column; gap: 2px; font-size: 18px; }
.v-hand.is-new .v-hand-vase { animation: v-hand .5s ease-out; }
@keyframes v-hand { from { transform: translateX(40px) rotate(8deg); opacity: 0; } }

.v-shelf { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; margin-top: 6px; padding: 6px; border-radius: 8px; background: linear-gradient(180deg, #e7dcc0, #d8cba9); box-shadow: inset 0 0 0 1px #b5a37a, inset 0 -5px 0 #b59d6c66; }
.v-slot { position: relative; min-width: 0; aspect-ratio: 5 / 7; display: flex; align-items: flex-end; justify-content: center; padding: 0 0 4px; border: 0; border-radius: 8px 8px 3px 3px; background: transparent; cursor: default; border-bottom: 2px solid #a8916088; }
.v-slot .v-vase { width: 92%; height: auto; transition: transform .15s; }
.v-slot.is-open { cursor: pointer; }
.v-slot.is-open:hover .v-vase { transform: translateY(-4px); }
.v-slot.is-chosen { background: #f3d98f66; box-shadow: 0 0 0 2px var(--brass-deep); }
.v-slot.is-chosen .v-vase { transform: translateY(-6px); }
.v-slot.is-gone::before { content: ''; width: 50%; height: 30%; margin-bottom: 4px; border: 1px dashed #a8916088; border-radius: 50% 50% 3px 3px; }
.v-slot.is-danger::after { content: ''; position: absolute; top: 3px; right: 3px; width: 8px; height: 8px; border-radius: 50%; background: var(--rose); }

.v-actions { display: flex; gap: 10px; }
.v-actions:has(> [hidden]:only-child) { display: none; }
.v-after { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.v-btn { min-height: 44px; padding: 8px 18px; border: 1px solid var(--brass-deep); border-radius: 22px 22px 6px 6px; background: #f7f1e1; color: var(--ink); font: 15px/1.2 Federo, Georgia, serif; letter-spacing: .8px; cursor: pointer; transition: background .15s, transform .1s; }
.v-btn:hover { background: #fffaf0; }
.v-btn:active { transform: translateY(1px); }
.v-btn-primary { background: var(--ink); color: #f3e9cf; border-color: #1a2620; box-shadow: inset 0 0 0 2px var(--ink), inset 0 0 0 3px #c9ab6a88; }
.v-btn-primary:hover { background: #31473b; }
.v-btn-quiet { border-color: transparent; background: transparent; text-decoration: underline; text-decoration-color: #8c734966; text-underline-offset: 4px; }
#confirm { flex: 1; }
.v-toggle { display: inline-flex; align-items: baseline; gap: 8px; font-size: 16px; color: var(--ink-soft); cursor: pointer; }
.v-toggle input { accent-color: var(--ink); width: 16px; height: 16px; align-self: center; }
.v-toggle small { font-size: 14px; font-style: italic; }

.v-setup { display: flex; flex-direction: column; gap: 12px; }
.v-choice { margin: 0; padding: 10px 14px 14px; border: 1px solid #b5a37a; border-radius: 14px 14px 4px 4px; background: #f7f1e1cc; }
.v-choice legend { padding: 0 6px; font: 14px/1.3 Federo, Georgia, serif; letter-spacing: 1.2px; text-transform: uppercase; color: var(--brass-deep); }
.v-row { display: flex; flex-wrap: wrap; gap: 8px; }
.v-row > .v-btn { flex: 1 1 auto; }
.v-join { display: flex; gap: 6px; flex: 1 1 150px; }
.v-join input { width: 6.5ch; min-width: 0; flex: 1; min-height: 44px; padding: 6px 10px; border: 1px solid var(--brass-deep); border-radius: 8px; background: #fffaf0; font: 18px/1 Federo, Georgia, serif; letter-spacing: 4px; text-transform: uppercase; text-align: center; }
.v-online { margin-top: 10px; }
.v-online-status { margin: 0 0 8px; font-style: italic; }
.v-invite { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.v-code { align-self: center; padding: 4px 18px; font: 34px/1.2 Federo, Georgia, serif; letter-spacing: 10px; border-bottom: 2px solid var(--brass); }

.v-rules { padding: 10px 14px; border-top: 1px solid #b5a37a88; font-size: 17px; }
.v-rules summary { cursor: pointer; font: 14px/1.3 Federo, Georgia, serif; letter-spacing: 1.2px; text-transform: uppercase; color: var(--brass-deep); }
.v-rules p { margin: 10px 0; }
.v-key { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.v-key li { display: grid; grid-template-columns: 30px 1fr 30px 1fr; align-items: end; gap: 6px; }
.v-key .v-vase { width: 30px; height: auto; }

@media (prefers-reduced-motion: reduce) {
	.v-drop, .v-hand.is-new .v-hand-vase, .v-winline path { animation: none; stroke-dashoffset: 0; }
}

@media (max-width: 820px) {
	/* On a phone the score and the instruction sit above the cabinet, and the
	   cabinet shrinks so the shelf stays in view below it. */
	.v-table { display: flex; flex-direction: column; align-items: stretch; gap: 12px; max-width: 520px; margin: 0 auto; }
	.v-side { display: contents; }
	.v-score { order: 1; }
	.v-status { order: 2; min-height: 0; font-size: 19px; text-align: center; }
	.v-cabinet-wrap { order: 3; align-self: center; width: min(100%, max(240px, calc((100svh - 400px) / 1.32))); }
	.v-play, .v-setup { order: 4; }
	.v-rules { order: 5; }
	.v-head { margin-bottom: 10px; }
	body.is-playing .v-tagline { display: none; }
	.v-hand { min-height: 70px; padding: 6px 12px; }
	.v-hand-vase { width: 40px; }
	.v-hand-vase:empty::before { width: 32px; height: 46px; }
	.v-play { display: flex; flex-direction: column; gap: 10px; }
}
