:root {
  --cream: #f4e6c8;
  --gold: #e2b257;
  --gold-bright: #ffd978;
  --paper: #ead8b2;
  --paper-deep: #d8ba86;
  --ink: #4d3121;
  --wood: #6f3d22;
  --dark: #190c08;
  --shadow: rgba(0,0,0,.34);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  color: var(--cream);
  font-family: Georgia, 'Times New Roman', serif;
  background:
    radial-gradient(circle at 50% 40%, rgba(255,211,126,.12), transparent 32%),
    linear-gradient(180deg, rgba(20,9,5,.22), rgba(12,5,3,.62)),
    url('assets/craft-station-bg-nocandle.png') center/cover no-repeat;
}
button { font: inherit; }
.app-shell {
  width: min(1620px, calc(100vw - 24px));
  height: min(930px, calc(100vh - 18px));
  margin: 9px auto;
  display: grid;
  grid-template-columns: 282px minmax(560px, 1fr) 268px;
  gap: 16px;
  padding: 14px;
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(30,14,8,.10), rgba(18,8,5,.16));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 24px 54px rgba(0,0,0,.35);
}
.side-panel {
  position: relative;
  z-index: 4;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.title-plaque { width: 100%; filter: drop-shadow(0 12px 20px rgba(0,0,0,.34)); }
.leather-card, .parchment-card {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  border: 2px solid rgba(188,136,72,.84);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.16), 0 10px 20px rgba(0,0,0,.22);
}
.leather-card {
  padding: 14px 16px;
  background:
    radial-gradient(circle at 18% 10%, rgba(255,219,171,.15), transparent 23%),
    linear-gradient(180deg, rgba(91,52,31,.97), rgba(39,22,15,.98));
}
.parchment-card {
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255,255,255,.23), transparent 18%),
    linear-gradient(180deg, #eddcb9, #dfc69a);
}
.label {
  display: block;
  font-size: .78rem;
  color: #d6ad6b;
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-bottom: 7px;
}
.stat-card strong, .timer-card strong {
  display: block;
  font-size: clamp(2rem, 4vw, 3.1rem);
  line-height: .95;
  color: #fff0ce;
  text-shadow: 0 2px 0 rgba(0,0,0,.25);
}
.objective-card { padding: 14px 16px; }
.design-row { display: flex; gap: 12px; align-items: center; }
.design-icon {
  width: 62px; height: 62px; border-radius: 18px;
  display: grid; place-items: center;
  font-size: 2.15rem;
  background: radial-gradient(circle at 40% 32%, #fff4bf, #e7b851 55%, #8b5624 100%);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.42), 0 8px 14px rgba(0,0,0,.16);
}
.design-row strong { display: block; font-size: 1.65rem; line-height: 1; color: #5e3d22; }
.design-row small { display: block; color: #785532; margin-top: 5px; font-size: .95rem; }
.center-stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border-radius: 26px;
  background: radial-gradient(circle at 50% 46%, rgba(255,210,131,.045), transparent 35%);
}
.hoop-wrap {
  position: absolute;
  inset: 20px 26px 96px;
  display: grid;
  place-items: center;
}
.hoop-wrap::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background:
    radial-gradient(circle, transparent 57%, rgba(210,155,83,.92) 58%, rgba(94,49,24,.98) 67%, transparent 68%),
    repeating-conic-gradient(from 8deg, rgba(255,255,255,.06) 0deg 5deg, rgba(0,0,0,.04) 5deg 10deg);
  filter: drop-shadow(0 24px 40px rgba(0,0,0,.36));
}
#game {
  position: relative;
  z-index: 1;
  width: min(100%, 880px);
  height: min(100%, 760px);
  aspect-ratio: 1.08 / 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 45%, rgba(255,224,163,.22), transparent 42%),
    linear-gradient(180deg, rgba(92,55,40,.88), rgba(35,22,16,.96));
  border: 2px solid rgba(255,226,174,.22);
  box-shadow: inset 0 0 0 8px rgba(70,37,20,.32), inset 0 0 46px rgba(0,0,0,.42);
  touch-action: none;
  user-select: none;
}
.top-controls {
  position: absolute; right: 10px; top: 10px; z-index: 8;
  display: flex; gap: 8px;
}
.round-btn {
  width: 48px; height: 48px; border-radius: 50%; border: 2px solid #95693b;
  color: #f6e5bd; font-weight: 900; font-size: 1.35rem;
  background: linear-gradient(180deg, #875f35, #5c381d);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.13), 0 8px 14px rgba(0,0,0,.24);
}
.bottom-banner {
  position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%);
  width: min(92%, 780px); min-height: 68px; z-index: 6;
  display: grid; grid-template-columns: 40px 1fr 40px; gap: 10px; align-items: center;
  padding: 10px 16px;
}
.bottom-banner p { margin: 0; text-align: center; font-size: 1.08rem; line-height: 1.14; color: #684321; }
.banner-dot {
  width: 24px; height: 24px; border-radius: 50%; justify-self: center;
  border: 2px solid #c99e57;
  background: radial-gradient(circle, rgba(255,227,156,.9), rgba(255,227,156,.12));
}
.timer-card { padding: 14px 16px; }
.meter { height: 10px; border-radius: 999px; background: rgba(255,255,255,.12); overflow: hidden; margin-top: 12px; }
.meter span { display: block; width: 0%; height: 100%; background: linear-gradient(90deg, #ffd86e, #7ee6ff); border-radius: inherit; transition: width .18s ease; }
.tool-card {
  width: 100%; min-height: 92px; padding: 14px;
  display: grid; grid-template-columns: 54px 1fr; align-items: center; gap: 12px;
  border: 2px solid #bd8f56; text-align: left;
}
.tool-card .tool-icon {
  width: 54px; height: 54px; display: grid; place-items: center; border-radius: 15px;
  background: linear-gradient(180deg, rgba(255,255,255,.22), rgba(255,255,255,.08));
  font-size: 1.85rem;
}
.tool-card strong { display: block; color: #563820; font-size: 1.28rem; line-height: 1; }
.tool-card small { display: block; color: #735032; margin-top: 5px; font-size: .9rem; }
.decor-spool, .decor-shears, .decor-candle { position: absolute; pointer-events: none; z-index: 0; filter: drop-shadow(0 12px 20px rgba(0,0,0,.30)); }
.spool-purple { width: 86px; left: 34px; top: 4px; transform: rotate(10deg); }
.spool-teal { width: 90px; left: -10px; top: 174px; transform: rotate(-12deg); }
.spool-rust { width: 100px; right: 16px; bottom: 108px; transform: rotate(8deg); }
.spool-magenta { width: 86px; right: 98px; bottom: 20px; transform: rotate(-14deg); }
.decor-shears { width: 104px; left: 12px; bottom: 48px; transform: rotate(-12deg); }
.candle-cluster { position: absolute; top: -4px; right: 112px; z-index: 2; pointer-events: none; }
.decor-candle { position: relative; width: 130px; }
.candle-flame {
  position: absolute; left: 62px; top: 5px; width: 17px; height: 32px;
  background: radial-gradient(circle at 50% 68%, rgba(255,255,255,.95), rgba(255,255,255,.1) 24%, transparent 44%), radial-gradient(ellipse at 50% 55%, rgba(255,229,130,.95), rgba(255,190,80,.9) 42%, rgba(255,113,16,.62) 70%, transparent 78%);
  clip-path: polygon(50% 0, 78% 24%, 92% 54%, 68% 100%, 32% 100%, 8% 54%, 24% 24%);
  filter: drop-shadow(0 0 9px rgba(255,193,80,.8)) drop-shadow(0 0 18px rgba(255,140,20,.55));
  animation: flame 1.7s ease-in-out infinite;
}
@keyframes flame { 0%,100%{transform:rotate(-2deg) scale(1)} 50%{transform:rotate(3deg) scale(1.08,.96)} }
.toast {
  position: absolute; left: 50%; top: 20px; transform: translateX(-50%) translateY(-8px);
  z-index: 12; opacity: 0; pointer-events: none; text-align: center;
  min-width: 240px; max-width: min(560px, 82%); padding: 11px 16px; border-radius: 999px;
  color: #fff0c9; border: 1px solid rgba(245,198,96,.38);
  background: linear-gradient(180deg, rgba(62,28,15,.95), rgba(35,17,10,.98));
  box-shadow: 0 16px 30px rgba(0,0,0,.26), inset 0 1px 0 rgba(255,255,255,.16);
  transition: opacity .18s ease, transform .18s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.modal-card { border: none; padding: 0; background: transparent; max-width: min(560px, calc(100vw - 24px)); }
.modal-card::backdrop { background: rgba(14,7,4,.68); backdrop-filter: blur(3px); }
.modal-inner { padding: 22px; border-radius: 22px; text-align: center; }
.modal-inner h1, .modal-inner h2 { margin: 0 0 10px; color: #57381f; font-size: clamp(2rem, 6vw, 3.2rem); line-height: .95; }
.modal-inner p, .modal-inner li { color: #654423; font-size: 1.05rem; line-height: 1.35; }
.modal-inner ul { text-align: left; padding-left: 1.2rem; }
.primary-btn {
  border: 0; border-radius: 999px; padding: 13px 20px; min-height: 48px;
  background: linear-gradient(180deg, #ffd872, #c88728); color: #4d2f13;
  font-weight: 900; box-shadow: inset 0 1px 0 rgba(255,255,255,.42), 0 8px 18px rgba(0,0,0,.18);
}
.result-icon {
  width: 86px; height: 86px; border-radius: 50%; margin: 0 auto 10px;
  display: grid; place-items: center; font-size: 3.1rem;
  background: radial-gradient(circle at 35% 30%, #fff2ba, #e3b653 55%, #885322 100%);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.42), 0 0 24px rgba(255,206,103,.25);
}
.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
.result-grid div { padding: 10px; border-radius: 14px; background: rgba(100,61,28,.12); }
.result-grid span { display: block; color: #855f36; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; }
.result-grid strong { display: block; color: #51331c; font-size: 1.35rem; margin-top: 4px; }
.final-score { font-size: 3rem !important; font-weight: 900; color: #51331c !important; margin: 8px 0 !important; }

@media (max-width: 1120px) {
  .app-shell { grid-template-columns: 250px minmax(420px, 1fr) 244px; gap: 12px; }
  .tool-card { grid-template-columns: 48px 1fr; }
  .tool-card .tool-icon { width: 48px; height: 48px; }
}
@media (max-width: 860px), (orientation: portrait) and (max-width: 960px) {
  body { overflow-y: auto; }
  .app-shell {
    width: 100%; min-height: 100%; height: auto; margin: 0; padding: 8px;
    display: flex; flex-direction: column; gap: 8px; border-radius: 0;
  }
  .center-stage { order: 1; height: 70svh; min-height: 520px; border-radius: 22px; }
  .left-panel { order: 2; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .right-panel { order: 3; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .title-plaque { display: none; }
  .objective-card { grid-column: 1 / -1; }
  .hoop-wrap { inset: 6px 2px 68px; }
  .hoop-wrap::before { inset: 10px 8px; }
  #game { width: min(104vw, 640px); max-width: none; height: auto; }
  .bottom-banner { width: calc(100% - 8px); bottom: 2px; min-height: 56px; padding: 8px 12px; grid-template-columns: 26px 1fr 26px; }
  .bottom-banner p { font-size: .9rem; }
  .banner-dot { width: 18px; height: 18px; }
  .decor-spool, .decor-shears, .candle-cluster { display: none; }
  .top-controls { right: 6px; top: 6px; gap: 6px; }
  .round-btn { width: 40px; height: 40px; font-size: 1.1rem; }
  .stat-card, .timer-card, .objective-card { padding: 10px 12px; }
  .stat-card strong, .timer-card strong { font-size: 2rem; }
  .label { font-size: .68rem; margin-bottom: 4px; }
  .design-icon { width: 50px; height: 50px; font-size: 1.8rem; }
  .design-row strong { font-size: 1.3rem; }
  .design-row small { font-size: .82rem; }
  .tool-card { min-height: 88px; grid-template-columns: 1fr; grid-template-rows: auto auto; justify-items: center; text-align: center; padding: 9px 6px; gap: 4px; }
  .tool-card .tool-icon { width: 42px; height: 42px; font-size: 1.45rem; }
  .tool-card strong { font-size: .92rem; }
  .tool-card small { display: none; }
  .toast { top: 8px; max-width: calc(100% - 92px); min-width: 0; font-size: .86rem; }
}
@media (max-width: 430px) {
  .center-stage { height: 68svh; min-height: 500px; }
  .result-grid { grid-template-columns: 1fr; }
  .modal-inner { padding: 18px; }
}


/* --- embroidery remake polish pass: cleaner mobile, no score button --- */
.primary-btn {
  max-width: 100%;
  white-space: normal;
  line-height: 1.12;
  text-wrap: balance;
}
.modal-card {
  width: min(560px, calc(100vw - 18px));
}
.modal-inner {
  max-width: 100%;
}
.result-grid strong {
  word-break: keep-all;
}
.center-stage {
  isolation: isolate;
}
.hoop-wrap::after {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  pointer-events: none;
  box-shadow: inset 0 0 40px rgba(255, 214, 127, .08), inset 0 0 0 1px rgba(255, 230, 166, .10);
}
.tool-card {
  transition: transform .16s ease, filter .16s ease, box-shadow .16s ease;
}
.tool-card:active {
  transform: scale(.985);
}
.toast {
  z-index: 12;
  font-weight: 800;
}
@media (max-width: 860px), (orientation: portrait) and (max-width: 960px) {
  .center-stage {
    height: 72svh;
    min-height: 560px;
  }
  .right-panel {
    grid-template-columns: 1fr 1fr 1fr;
    align-items: stretch;
  }
  .tool-card {
    min-height: 86px;
    grid-template-columns: 42px 1fr;
    padding: 10px;
  }
  .tool-card .tool-icon {
    width: 42px;
    height: 42px;
    font-size: 1.35rem;
  }
  .tool-card strong {
    font-size: 1.05rem;
  }
  .tool-card small {
    font-size: .78rem;
  }
  .timer-card, .stat-card {
    min-height: 86px;
  }
  .hoop-wrap {
    inset: 4px 0 62px;
  }
  #game {
    width: min(112vw, 720px);
  }
  .bottom-banner {
    min-height: 54px;
    padding: 7px 10px;
  }
  .bottom-banner p {
    font-size: .86rem;
    line-height: 1.16;
  }
  .modal-inner {
    padding: 18px 14px;
  }
  .modal-inner ul {
    padding-left: 1.0rem;
  }
  .result-grid {
    grid-template-columns: 1fr;
    gap: 7px;
  }
}
@media (max-width: 480px) {
  .center-stage {
    height: 70svh;
    min-height: 540px;
  }
  .left-panel {
    grid-template-columns: 1fr 1fr;
  }
  .right-panel {
    grid-template-columns: 1fr 1fr 1fr;
  }
  .timer-card strong, .stat-card strong {
    font-size: 1.65rem;
  }
  .tool-card {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    gap: 4px;
    padding: 8px 6px;
  }
  .tool-card small {
    display: none;
  }
  .label {
    font-size: .64rem;
  }
  .modal-inner h1, .modal-inner h2 {
    font-size: clamp(1.55rem, 9vw, 2.35rem);
  }
  .modal-inner p, .modal-inner li {
    font-size: .93rem;
  }
  .primary-btn {
    width: 100%;
  }
}
