:root {
  --ink: #273431;
  --muted: #6d7771;
  --cream: #f7f0e6;
  --paper: #fffaf3;
  --green: #466d65;
  --green-dark: #345850;
  --coral: #dd7058;
  --gold: #d8a44e;
  --line: rgba(39, 52, 49, .16);
  --shadow: 0 24px 70px rgba(62, 48, 35, .14);
  --progress: 0%;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--cream); color: var(--ink); }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  font-family: "DM Sans", system-ui, sans-serif;
  background:
    radial-gradient(circle at 86% 14%, rgba(216, 164, 78, .13), transparent 22rem),
    radial-gradient(circle at 8% 76%, rgba(70, 109, 101, .09), transparent 24rem),
    var(--cream);
}

button, input { font: inherit; }
button { color: inherit; }

.paper-noise {
  position: fixed;
  inset: 0;
  opacity: .24;
  pointer-events: none;
  z-index: 20;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.07'/%3E%3C/svg%3E");
}

.site-header {
  position: relative;
  z-index: 25;
  max-width: 1280px;
  height: 96px;
  margin: 0 auto;
  padding: 0 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  font-family: "DM Serif Display", Georgia, serif;
  font-size: 22px;
  letter-spacing: -.01em;
}

.brand-mark {
  display: grid;
  grid-template-columns: repeat(2, 10px);
  grid-template-rows: repeat(2, 10px);
  gap: 2px;
  transform: rotate(-4deg);
}

.brand-mark i { display: block; background: var(--green); }
.brand-mark i:nth-child(1) { border-radius: 4px 1px 1px; }
.brand-mark i:nth-child(2) { border-radius: 1px 5px 1px 1px; background: var(--coral); }
.brand-mark i:nth-child(3) { border-radius: 1px 1px 1px 5px; background: var(--gold); }
.brand-mark i:nth-child(4) { border-radius: 1px 1px 5px; }

.text-button {
  border: 0;
  border-bottom: 1px solid currentColor;
  padding: 5px 0;
  background: none;
  cursor: pointer;
  color: var(--muted);
}

.home-view {
  max-width: 1280px;
  margin: 0 auto;
  padding: 70px 48px 50px;
  display: grid;
  grid-template-columns: .95fr 1.05fr;
  gap: 60px;
  align-items: center;
}

.hero-copy { padding: 8px 0 30px; position: relative; z-index: 2; }

.eyebrow {
  margin: 0 0 18px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--coral);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.eyebrow > span {
  display: block;
  width: 26px;
  height: 1px;
  background: currentColor;
}

.eyebrow.compact { margin-bottom: 7px; }

.hero-copy h1, .game-toolbar h1 {
  margin: 0;
  font-family: "DM Serif Display", Georgia, serif;
  font-weight: 400;
  letter-spacing: -.045em;
  line-height: .99;
}

.hero-copy h1 { max-width: 620px; font-size: clamp(55px, 6vw, 84px); }
.hero-copy h1 em { color: var(--green); font-weight: 400; }

.intro {
  max-width: 510px;
  margin: 28px 0 32px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.65;
}

.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }

.button {
  min-height: 52px;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 0 23px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

.button:hover:not(:disabled) { transform: translateY(-2px); }
.button:disabled { opacity: .65; cursor: wait; }
.button-primary { color: white; background: var(--green); box-shadow: 0 10px 24px rgba(70, 109, 101, .18); }
.button-primary:hover:not(:disabled) { background: var(--green-dark); box-shadow: 0 13px 28px rgba(70, 109, 101, .25); }
.button-secondary { border-color: var(--line); background: rgba(255, 250, 243, .55); }
.button-secondary:hover { background: var(--paper); }
.button.full { width: 100%; }

.privacy-note { margin: 23px 0 0; color: #89908c; font-size: 12px; }
.privacy-note span { margin-right: 7px; color: var(--gold); }

.hero-art { position: relative; min-height: 510px; }
.sun { position: absolute; width: 260px; height: 260px; top: 20px; right: 70px; border-radius: 50%; background: #efd6a3; opacity: .7; }

.photo-card {
  position: absolute;
  padding: 13px 13px 16px;
  background: #fffdf8;
  box-shadow: var(--shadow);
}

.photo-card p { margin: 12px 4px 0; font-family: "DM Serif Display", Georgia, serif; color: #68716b; font-style: italic; }
.card-front { width: 355px; left: 70px; top: 56px; transform: rotate(-4deg); }
.card-back { width: 280px; right: 10px; top: 190px; transform: rotate(8deg); }
.abstract-photo { position: relative; height: 285px; overflow: hidden; background: #88a3a5; }
.photo-two { height: 220px; background: linear-gradient(160deg, #c48768 0 38%, #d5b474 39% 55%, #637b72 56%); }
.photo-one { background: linear-gradient(#90afb5 0 47%, #e6c583 47% 63%, #607f71 63%); }
.hill { position: absolute; bottom: 0; display: block; border-radius: 50% 50% 0 0; }
.hill-a { width: 270px; height: 115px; left: -30px; background: #486b61; transform: rotate(7deg); }
.hill-b { width: 250px; height: 90px; right: -60px; background: #304f4a; transform: rotate(-7deg); }
.moon { position: absolute; width: 30px; height: 30px; top: 42px; right: 46px; border-radius: 50%; background: #f5dfb7; }

.loose-piece { position: absolute; width: 74px; height: 74px; filter: drop-shadow(0 14px 10px rgba(55, 44, 34, .18)); }
.loose-piece::before { content: ""; position: absolute; inset: 0; border-radius: 7px; background: var(--coral); clip-path: polygon(0 0, 38% 0, 38% 10%, 46% 17%, 55% 17%, 63% 10%, 63% 0, 100% 0, 100% 37%, 89% 37%, 82% 45%, 82% 55%, 89% 63%, 100% 63%, 100% 100%, 0 100%); }
.piece-a { right: 33px; top: 75px; transform: rotate(20deg); }
.piece-b { left: 5px; bottom: 42px; transform: rotate(-13deg) scale(.8); }
.piece-b::before { background: var(--gold); }

.doodle { position: absolute; width: 140px; right: 55px; bottom: 10px; overflow: visible; fill: none; stroke: var(--coral); stroke-width: 2; stroke-linecap: round; opacity: .75; }

.steps {
  grid-column: 1 / -1;
  margin-top: 68px;
  padding-top: 35px;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 50px;
}

.steps article { display: flex; gap: 18px; }
.steps article > span { color: var(--coral); font-family: "DM Serif Display", Georgia, serif; font-size: 16px; font-style: italic; }
.steps h2 { margin: 0 0 7px; font-family: "DM Serif Display", Georgia, serif; font-size: 21px; font-weight: 400; }
.steps p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }

.dialog-card {
  width: min(520px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  overflow: auto;
  border: 0;
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 35px 100px rgba(31, 39, 36, .3);
}
.dialog-card::backdrop { background: rgba(35, 45, 42, .52); backdrop-filter: blur(4px); }
.dialog-card form { position: relative; padding: 43px 45px 45px; }
.dialog-card h2 { margin: 0 0 28px; font: 400 39px/1 "DM Serif Display", Georgia, serif; letter-spacing: -.03em; }
.small-dialog { width: min(460px, calc(100vw - 28px)); }
.dialog-close { position: absolute; top: 15px; right: 18px; border: 0; background: transparent; color: #78817c; font: 300 30px/1 sans-serif; cursor: pointer; }

.field { display: block; margin: 0 0 18px; }
.field > span, .difficulty legend { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 700; }
.field small { color: #929994; font-weight: 400; }
.field input {
  width: 100%;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 13px;
  outline: none;
  color: var(--ink);
  background: white;
  transition: border .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(70, 109, 101, .11); }
.field .code-input { text-transform: uppercase; letter-spacing: .28em; font-size: 21px; font-weight: 700; }

.upload-field {
  min-height: 112px;
  margin: 4px 0 19px;
  border: 1px dashed rgba(70, 109, 101, .45);
  border-radius: 6px;
  padding: 18px;
  display: grid;
  grid-template-columns: 45px 1fr;
  grid-template-rows: 1fr 1fr;
  align-items: center;
  column-gap: 13px;
  cursor: pointer;
  background: rgba(70, 109, 101, .035);
}
.upload-field:hover, .upload-field.has-file { border-color: var(--green); background: rgba(70, 109, 101, .07); }
.upload-field input { position: absolute; opacity: 0; pointer-events: none; }
.upload-icon { grid-row: 1 / 3; display: grid; place-items: center; width: 43px; height: 43px; border-radius: 50%; background: var(--green); color: white; font-size: 22px; }
.upload-field strong { align-self: end; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.upload-field small { align-self: start; color: #8b938e; font-size: 11px; }

.difficulty { border: 0; margin: 0 0 20px; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.difficulty legend { grid-column: 1 / -1; }
.difficulty input { position: absolute; opacity: 0; }
.difficulty label span { height: 60px; border: 1px solid var(--line); border-radius: 4px; display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; background: white; }
.difficulty label b { font-family: "DM Serif Display", Georgia, serif; font-size: 21px; font-weight: 400; }
.difficulty label small { color: var(--muted); }
.difficulty input:checked + span { border-color: var(--green); outline: 2px solid rgba(70, 109, 101, .13); color: var(--green); }
.form-error { min-height: 18px; margin: -5px 0 10px; color: #b64f3a; font-size: 12px; }
.spinner { width: 17px; height: 17px; border: 2px solid rgba(255,255,255,.45); border-top-color: white; border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.game-view { max-width: 1440px; margin: 0 auto; padding: 30px 42px 70px; }
.game-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 35px; max-width: 1220px; margin: 0 auto 13px; }
.game-toolbar h1 { font-size: clamp(33px, 4vw, 50px); }
.room-actions { display: flex; gap: 35px; align-items: center; }
.new-puzzle-button { align-self: center; border: 0; border-bottom: 1px solid rgba(70,109,101,.35); padding: 5px 0; display: flex; align-items: center; gap: 7px; color: var(--green); background: none; font-size: 12px; font-weight: 700; cursor: pointer; }
.new-puzzle-button span { color: var(--coral); font-size: 16px; }
.room-actions small { display: block; margin-bottom: 5px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; }
.room-code { border: 1px solid var(--line); border-radius: 4px; padding: 8px 11px; display: flex; gap: 11px; background: var(--paper); cursor: pointer; }
.room-code b { letter-spacing: .18em; }
.room-code span { color: var(--coral); }
.progress-wrap { min-width: 85px; }
.progress-wrap::after { content: ""; display: block; width: 85px; height: 3px; margin-top: 7px; border-radius: 5px; background: linear-gradient(to right, var(--coral) var(--progress), rgba(39,52,49,.12) var(--progress)); }

.players-row { max-width: 1220px; margin: 0 auto 14px; min-height: 34px; display: flex; justify-content: space-between; align-items: center; }
.avatars { display: flex; align-items: center; }
.avatar { position: relative; width: 32px; height: 32px; margin-left: -5px; border: 2px solid var(--cream); border-radius: 50%; display: grid; place-items: center; background: var(--avatar-color); color: white; font-size: 10px; font-weight: 700; }
.avatar:first-child { margin-left: 0; }
.player-caption { margin-left: 9px; color: var(--muted); font-size: 12px; }
.table-preferences { display: flex; align-items: center; gap: 20px; }
.guide-control { height: 30px; border: 1px solid var(--line); border-radius: 4px; padding: 3px; display: flex; align-items: center; gap: 2px; background: rgba(255,250,243,.66); }
.guide-control > span { margin: 0 6px; color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.guide-control button { height: 22px; border: 0; border-radius: 3px; padding: 0 8px; color: var(--muted); background: transparent; font-size: 9px; cursor: pointer; transition: color .15s, background .15s; }
.guide-control button:hover { color: var(--ink); }
.guide-control button.active { color: white; background: var(--green); }
#connectionStatus { color: var(--muted); font-size: 11px; }
.live-dot { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: #4a936a; box-shadow: 0 0 0 3px rgba(74,147,106,.12); }
#connectionStatus.offline .live-dot { background: var(--gold); box-shadow: 0 0 0 3px rgba(216,164,78,.15); }
.reference-card { max-width: 1220px; min-height: 128px; margin: 0 auto 14px; border: 1px solid var(--line); border-radius: 7px; padding: 13px 18px; display: flex; align-items: center; justify-content: center; gap: 20px; background: rgba(255,250,243,.72); box-shadow: 0 10px 30px rgba(62,48,35,.06); }
.reference-card > div { max-width: 130px; display: flex; flex-direction: column; }
.reference-card small { color: var(--coral); font-size: 9px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.reference-card strong { margin-top: 5px; font: 400 17px/1.15 "DM Serif Display", Georgia, serif; }
.reference-card img { width: min(280px, 45vw); height: 104px; border-radius: 3px; object-fit: contain; background: rgba(39,52,49,.05); box-shadow: 0 5px 16px rgba(39,52,49,.12); }

.stage-shell { max-width: 1280px; margin: 0 auto; padding: 16px; border: 1px solid rgba(39, 52, 49, .11); border-radius: 10px; background: rgba(255, 250, 243, .6); box-shadow: 0 16px 55px rgba(62, 48, 35, .08); }
.setup-room { min-height: 610px; padding: clamp(30px, 5vw, 68px); display: grid; grid-template-columns: .75fr 1.25fr; gap: clamp(40px, 7vw, 100px); border-radius: 5px; background: linear-gradient(135deg, rgba(255,255,255,.56), rgba(240,225,201,.3)); }
.setup-intro { padding-top: 22px; }
.setup-intro h2, .waiting-room h2 { margin: 0; font: 400 clamp(43px, 5vw, 65px)/1.03 "DM Serif Display", Georgia, serif; letter-spacing: -.04em; }
.setup-intro h2 em, .waiting-room h2 em { color: var(--green); font-weight: 400; }
.setup-intro > p:not(.eyebrow) { max-width: 410px; margin: 25px 0; color: var(--muted); line-height: 1.65; }
.setup-code-card { max-width: 300px; margin-top: 38px; padding: 20px; border: 1px solid var(--line); border-radius: 5px; display: grid; grid-template-columns: 1fr auto; background: var(--paper); box-shadow: 0 12px 35px rgba(62,48,35,.08); }
.setup-code-card small { grid-column: 1 / -1; color: var(--muted); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; }
.setup-code-card strong { margin-top: 7px; color: var(--green); font: 400 28px "DM Serif Display", Georgia, serif; letter-spacing: .18em; }
.setup-code-card button { align-self: end; border: 0; border-bottom: 1px solid currentColor; padding: 2px 0; color: var(--coral); background: none; font-size: 11px; cursor: pointer; }
.setup-form { max-width: 650px; padding: 34px; border-radius: 6px; background: var(--paper); box-shadow: 0 18px 55px rgba(62,48,35,.1); }
.setup-form-heading { margin-bottom: 18px; display: flex; gap: 14px; align-items: start; }
.setup-form-heading > span { color: var(--coral); font: italic 15px "DM Serif Display", Georgia, serif; }
.setup-form-heading h3 { margin: 0 0 2px; font: 400 23px "DM Serif Display", Georgia, serif; }
.setup-form-heading p { margin: 0; color: var(--muted); font-size: 11px; }
.setting-heading { margin-top: 12px; }
.setup-upload { position: relative; min-height: 128px; margin-bottom: 18px; border: 1px dashed rgba(70,109,101,.45); border-radius: 5px; padding: 20px; display: flex; align-items: center; gap: 15px; overflow: hidden; cursor: pointer; background: rgba(70,109,101,.035); }
.setup-upload:hover, .setup-upload.has-file { border-color: var(--green); background: rgba(70,109,101,.07); }
.setup-upload input { position: absolute; opacity: 0; pointer-events: none; }
.setup-upload > span:nth-of-type(2) { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.setup-upload strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.setup-upload small { color: var(--muted); font-size: 10px; }
.setup-upload img { width: 105px; height: 86px; margin-left: auto; border-radius: 3px; object-fit: cover; box-shadow: 0 5px 15px rgba(39,52,49,.15); }
.setup-upload img:not([src]) { display: none; }
.setup-two-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.piece-count-control { margin-bottom: 21px; }
.piece-count-control > div:first-child { display: flex; justify-content: space-between; align-items: baseline; }
.piece-count-control label, .piece-styles legend { font-size: 12px; font-weight: 700; }
.piece-count-control output { color: var(--green); font: 400 20px "DM Serif Display", Georgia, serif; }
.piece-count-control input[type="range"] { width: 100%; height: 4px; margin: 17px 0 9px; border-radius: 4px; appearance: none; background: linear-gradient(to right, var(--coral) var(--range-value, 25%), rgba(39,52,49,.14) var(--range-value, 25%)); cursor: pointer; }
.piece-count-control input[type="range"]::-webkit-slider-thumb { width: 20px; height: 20px; border: 4px solid var(--paper); border-radius: 50%; appearance: none; background: var(--coral); box-shadow: 0 1px 6px rgba(39,52,49,.3); }
.piece-count-control input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border: 4px solid var(--paper); border-radius: 50%; background: var(--coral); box-shadow: 0 1px 6px rgba(39,52,49,.3); }
.range-notes { display: flex; justify-content: space-between; color: #909791; font-size: 9px; }
.piece-styles { margin: 0 0 17px; padding: 0; border: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.piece-styles legend { margin-bottom: 8px; }
.piece-styles input { position: absolute; opacity: 0; }
.style-choice { min-height: 88px; border: 1px solid var(--line); border-radius: 4px; padding: 10px 8px; display: grid; grid-template-columns: 34px 1fr; grid-template-rows: 1fr 1fr; column-gap: 7px; align-items: center; cursor: pointer; background: white; }
.piece-styles input:checked + .style-choice { border-color: var(--green); outline: 2px solid rgba(70,109,101,.12); background: rgba(70,109,101,.035); }
.style-icon { grid-row: 1 / 3; display: block; width: 31px; height: 31px; background: var(--green); }
.classic-icon { clip-path: polygon(0 0,35% 0,35% 12%,44% 22%,56% 22%,65% 12%,65% 0,100% 0,100% 35%,88% 35%,78% 44%,78% 56%,88% 65%,100% 65%,100% 100%,0 100%); }
.rounded-icon { border-radius: 9px; background: var(--gold); }
.square-icon { border-radius: 1px; background: var(--coral); }
.style-choice b { align-self: end; font-size: 12px; }
.style-choice small { align-self: start; color: var(--muted); font-size: 9px; }
.rotation-setting { margin-bottom: 18px; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 11px; cursor: pointer; }
.rotation-setting input { position: absolute; opacity: 0; }
.toggle { position: relative; flex: 0 0 auto; width: 36px; height: 20px; border-radius: 20px; background: #c7ccc8; transition: background .2s; }
.toggle::after { content: ""; position: absolute; width: 14px; height: 14px; left: 3px; top: 3px; border-radius: 50%; background: white; transition: transform .2s; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.rotation-setting input:checked + .toggle { background: var(--green); }
.rotation-setting input:checked + .toggle::after { transform: translateX(16px); }
.rotation-setting > span:last-child { display: flex; flex-direction: column; }
.rotation-setting b { font-size: 11px; }
.rotation-setting small { color: var(--muted); font-size: 9px; }
.setup-actions { display: flex; gap: 10px; }
.setup-actions .button { flex: 1; }
.waiting-room { min-height: 610px; padding: 70px 25px; border-radius: 5px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; background: linear-gradient(135deg, rgba(255,255,255,.5), rgba(240,225,201,.3)); }
.waiting-room > p:not(.eyebrow) { max-width: 470px; margin: 23px auto; color: var(--muted); line-height: 1.65; }
.waiting-art { position: relative; width: 155px; height: 88px; margin-bottom: 30px; }
.waiting-art i { position: absolute; display: block; width: 55px; height: 55px; background: var(--green); clip-path: polygon(0 0,35% 0,35% 12%,44% 22%,56% 22%,65% 12%,65% 0,100% 0,100% 100%,0 100%); filter: drop-shadow(0 8px 7px rgba(39,52,49,.15)); }
.waiting-art i:nth-child(1) { left: 0; top: 23px; transform: rotate(-15deg); background: var(--gold); }
.waiting-art i:nth-child(2) { left: 54px; top: 0; transform: rotate(5deg); background: var(--green); }
.waiting-art i:nth-child(3) { right: 0; top: 28px; transform: rotate(19deg); background: var(--coral); }
.waiting-pulse { margin-top: 8px; padding: 10px 16px; border-radius: 30px; color: var(--green); background: rgba(70,109,101,.08); font-size: 11px; font-weight: 700; }
.waiting-pulse span { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--green); animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; transform: scale(.8); } }
.puzzle-stage { position: relative; width: 100%; aspect-ratio: 12 / 7; overflow: hidden; border-radius: 5px; touch-action: none; background-color: #dfe4dc; background-image: radial-gradient(rgba(62, 80, 72, .11) .7px, transparent .7px), linear-gradient(135deg, rgba(255,255,255,.42), transparent); background-size: 11px 11px, 100% 100%; }
.puzzle-stage::before { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 70px rgba(68, 78, 70, .09); pointer-events: none; z-index: 5; }
.board { position: absolute; z-index: 1; background: #cad1c9; box-shadow: 0 14px 30px rgba(50, 63, 57, .15), 0 0 0 7px rgba(255,255,255,.3); }
.board img { width: 100%; height: 100%; display: block; object-fit: fill; opacity: .16; filter: saturate(.6); pointer-events: none; transition: opacity .18s ease; }
.puzzle-stage.guide-hidden .board img { opacity: 0; }
.board::after { content: ""; position: absolute; inset: 0; border: 1px solid rgba(39,52,49,.2); pointer-events: none; }
.piece-layer { position: absolute; inset: 0; z-index: 3; }
.puzzle-piece { position: absolute; z-index: 6; margin: 0; padding: 0; border: 0; border-radius: 2px; background-repeat: no-repeat; cursor: grab; box-shadow: 0 5px 12px rgba(34, 46, 42, .27), inset 0 0 0 1px rgba(255,255,255,.42); transition: box-shadow .15s, filter .15s; touch-action: none; }
.puzzle-piece.style-classic { border-radius: 0; mask-repeat: no-repeat; mask-size: 100% 100%; -webkit-mask-repeat: no-repeat; -webkit-mask-size: 100% 100%; filter: drop-shadow(0 5px 4px rgba(34,46,42,.3)); box-shadow: none; }
.puzzle-piece.style-rounded { border-radius: 13%; }
.puzzle-piece.style-square { border-radius: 1px; }
.puzzle-piece:hover { z-index: 20; filter: brightness(1.04); box-shadow: 0 8px 16px rgba(34,46,42,.34), inset 0 0 0 1px rgba(255,255,255,.58); }
.puzzle-piece.dragging { z-index: 50; cursor: grabbing; box-shadow: 0 14px 24px rgba(34,46,42,.4); }
.puzzle-piece.held:not(.snapped) { outline: 3px solid var(--holder-color); outline-offset: 2px; }
.puzzle-piece.held-by-other { cursor: not-allowed; }
.puzzle-piece.snapped { z-index: 4; cursor: default; border-radius: 0; box-shadow: inset 0 0 0 .5px rgba(255,255,255,.17); }
.tray-label { position: absolute; z-index: 0; top: 15px; margin: 0; color: rgba(54, 70, 64, .42); font: italic 14px "DM Serif Display", Georgia, serif; }
.tray-left { left: 25px; }
.tray-right { right: 25px; }
.rotation-hint { position: absolute; z-index: 8; left: 50%; bottom: 11px; margin: 0; padding: 7px 12px; border-radius: 30px; transform: translateX(-50%); color: rgba(39,52,49,.68); background: rgba(255,250,243,.72); font-size: 10px; pointer-events: none; }
.rotation-hint kbd { border: 1px solid rgba(39,52,49,.25); border-radius: 3px; padding: 1px 4px; background: white; font: inherit; font-weight: 700; }
.mobile-hint { display: none; text-align: center; color: var(--muted); font-size: 11px; }

.celebration { position: fixed; z-index: 100; inset: 0; padding: 25px; display: grid; place-items: center; background: rgba(36, 48, 44, .65); backdrop-filter: blur(7px); }
.celebration-card { width: min(470px, 100%); padding: 35px; border-radius: 8px; text-align: center; background: var(--paper); box-shadow: var(--shadow); animation: arrive .45s cubic-bezier(.2,.9,.2,1); }
.celebration-card .eyebrow { justify-content: center; }
.celebration-card h2 { margin: 0 0 7px; font: 400 47px "DM Serif Display", Georgia, serif; }
.celebration-card > p:not(.eyebrow) { margin: 0 0 20px; color: var(--muted); }
.celebration-card img { width: 100%; max-height: 280px; margin-bottom: 22px; object-fit: contain; box-shadow: 0 10px 25px rgba(36,48,44,.13); }
.confetti { margin-bottom: 10px; color: var(--gold); font-size: 23px; letter-spacing: .14em; }
@keyframes arrive { from { opacity: 0; transform: translateY(16px) scale(.96); } }

.toast { position: fixed; z-index: 200; left: 50%; bottom: 25px; padding: 11px 18px; border-radius: 50px; transform: translate(-50%, 20px); opacity: 0; color: white; background: var(--ink); box-shadow: 0 10px 30px rgba(0,0,0,.2); pointer-events: none; transition: opacity .2s, transform .2s; font-size: 13px; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.hidden { display: none !important; }

@media (max-width: 900px) {
  .site-header { height: 78px; padding: 0 24px; }
  .home-view { padding: 35px 24px 45px; grid-template-columns: 1fr; gap: 15px; }
  .hero-copy { text-align: center; }
  .hero-copy .eyebrow, .hero-actions { justify-content: center; }
  .hero-copy .intro { margin-left: auto; margin-right: auto; }
  .hero-art { width: min(600px, 100%); margin: 0 auto; }
  .steps { margin-top: 20px; gap: 24px; }
  .game-view { padding: 18px 15px 50px; }
  .stage-shell { padding: 8px; }
  .setup-room { grid-template-columns: 1fr; }
  .setup-intro { text-align: center; }
  .setup-intro .eyebrow { justify-content: center; }
  .setup-intro > p:not(.eyebrow), .setup-code-card { margin-left: auto; margin-right: auto; }
  .setup-form { margin: 0 auto; width: 100%; }
}

@media (max-width: 650px) {
  .brand { font-size: 19px; }
  .home-view { padding-top: 22px; }
  .hero-copy h1 { font-size: 50px; }
  .intro { font-size: 16px; }
  .hero-actions .button { width: 100%; }
  .hero-art { min-height: 370px; transform: scale(.88); transform-origin: top center; margin-bottom: -45px; }
  .card-front { width: 280px; left: calc(50% - 170px); }
  .card-back { width: 220px; right: calc(50% - 185px); top: 150px; }
  .abstract-photo { height: 220px; }
  .photo-two { height: 170px; }
  .sun { width: 210px; height: 210px; right: calc(50% - 175px); }
  .steps { grid-template-columns: 1fr; }
  .steps article { padding-bottom: 20px; border-bottom: 1px solid var(--line); }
  .dialog-card form { padding: 39px 23px 27px; }
  .game-toolbar { display: block; }
  .game-toolbar h1 { margin-bottom: 18px; }
  .room-actions { justify-content: space-between; }
  #newPuzzleButton { position: absolute; right: 24px; top: 78px; }
  #gatherPiecesButton { position: absolute; right: 24px; top: 112px; }
  .players-row { margin-top: 18px; }
  .players-row { align-items: flex-start; gap: 10px; }
  .table-preferences { margin-left: auto; }
  .guide-control > span, #connectionStatus { display: none; }
  .guide-control button { padding: 0 6px; }
  .reference-card { margin-left: 0; margin-right: 0; padding: 10px; gap: 10px; }
  .reference-card > div { max-width: 95px; }
  .reference-card img { width: min(220px, 58vw); height: 92px; }
  .stage-shell { margin-left: -15px; margin-right: -15px; border-radius: 0; border-left: 0; border-right: 0; }
  .setup-room { padding: 32px 19px; gap: 35px; }
  .setup-form { padding: 24px 18px; }
  .setup-two-fields { grid-template-columns: 1fr; gap: 0; }
  .style-choice { grid-template-columns: 1fr; grid-template-rows: auto auto auto; justify-items: center; text-align: center; }
  .style-icon { grid-row: auto; }
  .style-choice b { align-self: auto; }
  .style-choice small { align-self: auto; }
  .setup-actions { flex-direction: column-reverse; }
  .puzzle-stage { min-width: 750px; }
  .stage-shell { overflow-x: auto; }
  .mobile-hint { display: block; }
  .celebration-card { padding: 25px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
