:root {
  --ws-bg: #ecfeff;
  --ws-surface: #ffffff;
  --ws-ink: #0f172a;
  --ws-ink-muted: #334155;
  --ws-accent: #0891b2;
  --ws-accent-dark: #0e7490;
  --ws-border: #cbd5e1;
  --ws-radius: 18px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif; color: var(--ws-ink); background: linear-gradient(160deg, #ecfeff 0%, #f0f9ff 50%, #e0f2fe 100%); min-height: 100dvh; overflow-x: hidden; }

.ws-app { max-width: 1080px; margin: 0 auto; padding: 12px 16px 28px; display: flex; flex-direction: column; gap: 14px; }

.ws-topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; background: rgba(255,255,255,0.92); border: 1.5px solid #bae6fd; border-radius: 16px; padding: 10px 14px; box-shadow: 0 4px 16px rgba(8,145,178,0.08); }
.ws-topbar-left, .ws-topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ws-brand-title { margin: 0; font-size: clamp(1.05rem, 2.4vw, 1.35rem); font-weight: 800; color: var(--ws-ink); letter-spacing: -0.02em; }

.ws-btn-ghost, .ws-btn-pill, .ws-btn-action { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 13px; border-radius: 999px; font-size: 0.92rem; font-weight: 700; text-decoration: none; cursor: pointer; border: 1.5px solid var(--ws-border); background: #ffffff; color: var(--ws-ink); transition: transform 0.14s ease, background 0.14s ease, border-color 0.14s ease; }
.ws-btn-ghost:hover, .ws-btn-pill:hover, .ws-btn-action:hover:not(:disabled) { background: #f0f9ff; border-color: var(--ws-accent); transform: translateY(-1px); }
.ws-btn-action:disabled { opacity: 0.48; cursor: not-allowed; }
.ws-btn-share { background: #0e7490; border-color: #0e7490; color: #ffffff; }
.ws-btn-share:hover { background: #155e75; border-color: #155e75; color: #ffffff; }

.ws-lobby-card { background: var(--ws-surface); border: 1.5px solid #bae6fd; border-radius: 24px; padding: 20px; box-shadow: 0 12px 32px rgba(8,145,178,0.10); display: flex; flex-direction: column; gap: 20px; }
.ws-hero-heading { margin: 0 0 8px; font-size: clamp(1.35rem, 3vw, 1.85rem); font-weight: 900; color: var(--ws-ink); line-height: 1.25; }

.ws-tier-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.ws-tier-tab { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 12px 10px; border-radius: 16px; border: 2px solid #cbd5e1; background: #f8fafc; color: var(--ws-ink); cursor: pointer; font-weight: 700; transition: all 0.15s ease; }
.ws-tier-tab strong { font-size: 0.98rem; }
.ws-tier-tab span { font-size: 0.8rem; color: var(--ws-ink-muted); font-weight: 600; }
.ws-tier-tab.is-active { background: #0891b2; border-color: #0e7490; color: #ffffff; box-shadow: 0 6px 16px rgba(8,145,178,0.22); }
.ws-tier-tab.is-active span { color: #e0f2fe; }

.ws-stage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.ws-stage-card { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 12px; border-radius: 16px; border: 2px solid #cbd5e1; background: #ffffff; color: var(--ws-ink); cursor: pointer; text-align: left; transition: all 0.14s ease; }
.ws-stage-card:hover { border-color: var(--ws-accent); background: #f0f9ff; }
.ws-stage-card.is-selected { border-color: #0891b2; background: #ecfeff; box-shadow: 0 0 0 3px rgba(8,145,178,0.2); }
.ws-stage-card.is-cleared { border-color: #059669; }
.ws-stage-num { font-size: 0.96rem; font-weight: 800; color: var(--ws-ink); }
.ws-stage-meta { font-size: 0.82rem; color: var(--ws-ink-muted); font-weight: 600; }

.ws-lobby-footer { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.ws-btn-primary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 28px; border-radius: 16px; border: none; background: #0e7490; color: #ffffff; font-size: 1.08rem; font-weight: 800; cursor: pointer; box-shadow: 0 8px 20px rgba(14,116,144,0.28); transition: transform 0.14s ease, background 0.14s ease; }
.ws-btn-primary:hover { background: #155e75; transform: translateY(-2px); }
.ws-btn-secondary { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 0 20px; border-radius: 14px; border: 2px solid #0e7490; background: #ffffff; color: #0e7490; font-size: 0.98rem; font-weight: 800; cursor: pointer; }
.ws-btn-ghost-dark { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 0 18px; border-radius: 14px; border: 1.5px solid #cbd5e1; background: #f8fafc; color: var(--ws-ink); font-size: 0.95rem; font-weight: 700; cursor: pointer; }
.ws-btn-full { width: 100%; }
.ws-lobby-tip { margin: 0; font-size: 0.9rem; font-weight: 700; color: var(--ws-ink-muted); }

/* PLAY SCREEN */
.ws-hud { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; background: #ffffff; border: 1.5px solid #bae6fd; border-radius: 18px; padding: 12px 16px; }
.ws-hud-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ws-hud-badge { padding: 4px 10px; border-radius: 999px; background: #0e7490; color: #ffffff; font-size: 0.875rem; font-weight: 800; }
.ws-hud-stats { display: flex; gap: 8px; }
.ws-stat-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 12px; background: #f0f9ff; border: 1.5px solid #bae6fd; font-size: 0.9rem; font-weight: 700; color: var(--ws-ink); }
.ws-stat-pill strong { color: #0e7490; font-size: 1.05rem; }
.ws-hud-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.ws-status-bar { background: #ffffff; border: 1.5px solid #67e8f9; border-radius: 14px; padding: 10px 16px; text-align: center; font-size: 0.98rem; font-weight: 700; color: #0f172a; }
.ws-status-bar.is-hint { background: #fef9c3; border-color: #eab308; color: #713f12; }
.ws-status-bar.is-error { background: #fee2e2; border-color: #ef4444; color: #991b1b; }

.ws-bench { background: linear-gradient(180deg, #ffffff 0%, #f0f9ff 100%); border: 2px solid #bae6fd; border-radius: 24px; padding: 30px 18px 26px; display: flex; flex-wrap: wrap; justify-content: center; gap: 26px 20px; min-height: 320px; align-items: flex-end; box-shadow: inset 0 -10px 24px rgba(8,145,178,0.06); }

.ws-tube-btn { position: relative; width: 76px; height: 224px; padding: 10px 7px 9px; border: 3.5px solid #475569; border-top: 2px solid #94a3b8; border-radius: 10px 10px 36px 36px; background: linear-gradient(90deg, rgba(255,255,255,0.9) 0%, rgba(241,245,249,0.55) 55%, rgba(255,255,255,0.9) 100%); display: flex; flex-direction: column-reverse; justify-content: flex-start; gap: 3px; cursor: pointer; transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease; box-shadow: 0 10px 18px rgba(15,23,42,0.10); }
.ws-tube-btn::before { content: ""; position: absolute; top: -10px; left: -6px; right: -6px; height: 10px; border: 3px solid #475569; border-radius: 8px; background: #f8fafc; }
.ws-tube-btn:hover { transform: translateY(-4px); border-color: #0891b2; }
.ws-tube-btn.is-selected { transform: translateY(-20px); border-color: #0891b2; box-shadow: 0 18px 28px rgba(8,145,178,0.32), 0 0 0 4px rgba(8,145,178,0.22); }
.ws-tube-btn.is-hint-src { border-color: #d97706; box-shadow: 0 0 0 4px rgba(245,158,11,0.35); transform: translateY(-10px); }
.ws-tube-btn.is-hint-dst { border-color: #059669; box-shadow: 0 0 0 4px rgba(16,185,129,0.35); }
.ws-tube-btn.is-complete { border-color: #059669; box-shadow: 0 10px 22px rgba(5,150,105,0.25); }
.ws-tube-btn.is-complete::after { content: "✓"; position: absolute; top: -28px; left: 50%; transform: translateX(-50%); width: 24px; height: 24px; border-radius: 999px; background: #059669; color: #ffffff; font-size: 0.85rem; font-weight: 900; display: grid; place-items: center; }

.ws-layer { width: 100%; height: 46px; border-radius: 8px; display: grid; place-items: center; font-size: 1rem; font-weight: 900; color: #ffffff; text-shadow: 0 1px 2px rgba(0,0,0,0.45); transition: transform 0.2s ease, opacity 0.2s ease; }
.ws-layer:first-child { border-radius: 8px 8px 26px 26px; }
.ws-color-coral { background: linear-gradient(180deg, #f87171, #dc2626); }
.ws-color-aqua { background: linear-gradient(180deg, #22d3ee, #0891b2); }
.ws-color-amber { background: linear-gradient(180deg, #fbbf24, #d97706); }
.ws-color-violet { background: linear-gradient(180deg, #a78bfa, #6d28d9); }
.ws-color-emerald { background: linear-gradient(180deg, #34d399, #059669); }
.ws-color-indigo { background: linear-gradient(180deg, #60a5fa, #1d4ed8); }

/* MODALS */
.ws-modal-card { width: 100%; max-width: 440px; background: #ffffff; border-radius: 22px; padding: 24px; box-shadow: 0 20px 50px rgba(15,23,42,0.28); color: var(--ws-ink); }
.ws-modal-card h2 { margin: 0 0 12px; font-size: 1.35rem; font-weight: 900; color: var(--ws-ink); }
.ws-result-card, .ws-qr-card { text-align: center; }
.ws-result-stars { font-size: 2.4rem; margin-bottom: 6px; }
.ws-result-sub, .ws-qr-desc { margin: 0 0 18px; color: var(--ws-ink-muted); font-size: 0.96rem; line-height: 1.5; font-weight: 600; }
.ws-result-actions, .ws-qr-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.ws-help-list { margin: 0 0 18px; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; line-height: 1.55; color: var(--ws-ink-muted); font-weight: 500; }
.ws-help-list strong { color: var(--ws-ink); }
.ws-qr-img { width: 220px; height: 220px; margin: 0 auto 16px; display: block; border-radius: 14px; border: 2px solid #bae6fd; background: #ffffff; }

@media (max-width: 780px) {
  .ws-hero { grid-template-columns: 1fr; }
  .ws-tube-btn { width: 64px; height: 196px; }
  .ws-layer { height: 40px; }
}
@media (max-width: 420px) {
  .ws-tier-tabs { grid-template-columns: 1fr; }
  .ws-tube-btn { width: 58px; height: 184px; }
  .ws-layer { height: 37px; font-size: 0.85rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* The six-tube opening aligns with the illustrated workbench at laptop ratio. */
.ws-play { display: grid; gap: clamp(12px, 1.6vw, 24px); }
.scene-game .ws-topbar,
.ws-hud {
  background: #f7feff;
  border: 2px solid #fff;
  border-radius: clamp(16px, 2.6vw, 38px);
  box-shadow: 0 6px 18px #124e602a;
}
.ws-play .ws-hud { min-height: clamp(60px, 5.3vw, 78px); padding-inline: clamp(12px, 1.6vw, 24px); }
.ws-play .ws-hud-title > strong { font-size: clamp(15px, 1.7vw, 25px); }
.ws-play .ws-stat-pill { border-radius: 999px; }
.ws-play .ws-stat-pill strong { font-size: clamp(16px, 1.85vw, 26px); }
.ws-play .ws-status-bar {
  width: min(100%, 750px);
  min-height: clamp(52px, 5.25vw, 76px);
  justify-self: center;
  display: grid;
  place-items: center;
  border: 3px solid #91ddff;
  border-radius: 999px;
  background: #e8f9ff;
  box-shadow: 0 4px 24px #56c8fc7a, inset 0 0 0 3px #ffffffba;
  font-size: clamp(15px, 1.8vw, 26px);
}
.ws-play .ws-status-bar.is-error { background: #fee2e2; border-color: #fca5a5; }
.ws-play .ws-status-bar.is-hint { background: #fef9c3; border-color: #eab308; }

.ws-play .ws-bench {
  gap: clamp(10px, 1.1vw, 18px);
  align-items: end;
  margin-top: clamp(3px, 2.4vw, 34px);
  margin-inline: auto;
  min-height: 0;
  width: min(84vw, 1130px);
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.ws-play .ws-bench[data-length="6"] { transform: translateX(3.7vw); }
.ws-play .ws-tube-btn {
  --tube-width: clamp(48px, 8.4vw, 126px);
  width: var(--tube-width);
  height: calc(var(--tube-width) * 3);
  padding: 14px 7% 8px;
  padding-inline: clamp(4px, .7vw, 10px);
  border: clamp(3px, .45vw, 7px) solid #fff;
  border-top: 0;
  border-radius: 8% 8% 40% 40% / 3% 3% 14% 14%;
  background: linear-gradient(90deg, #edfcff78, #ddf9fd29 22%, #34485b1c 75%, #fff9 93%);
  box-shadow: 0 2px 1px #ffefe5, inset 0 0 0 2px #689aa5, 0 12px 10px -6px #472f32ad;
}
.ws-play .ws-tube-btn::before {
  top: -5px;
  left: -7px;
  right: -7px;
  height: clamp(12px, 1.62vw, 24px);
  background: #bddce480;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px #638b99, 0 2px 1px #315765;
}
.ws-play .ws-tube-btn.is-selected { border-color: #086987; box-shadow: 0 0 0 4px #fff, 0 14px 18px #0e7490a1; }
.ws-play .ws-tube-btn.is-hint-src { border-color: #a74f00; }
.ws-play .ws-tube-btn.is-hint-dst,
.ws-play .ws-tube-btn.is-complete { border-color: #08744f; }
.ws-play .ws-layer {
  height: 21.5%;
  flex: none;
  border-radius: clamp(4px, 1vw, 15px);
  border: 1px solid #ffffff54;
  box-shadow: inset 2px 3px 2px #ffffff60, inset -2px -4px 2px #552c5c28;
  font-size: clamp(16px, 2.4vw, 34px);
  -webkit-text-stroke: .65px #243340;
}
.ws-play .ws-layer:first-child { border-radius: 14% 14% 38% 38% / 18% 18% 56% 56%; }

@media (min-width: 900px) {
  .ws-play .ws-bench[data-length="8"] { gap: 12px; }
  .ws-play .ws-bench[data-length="8"] .ws-tube-btn { --tube-width: clamp(65px, 7vw, 104px); }
}
@media (max-aspect-ratio: 5/4), (max-width: 899px) {
  .scene-game .ws-art { object-position: 31% bottom; }
  .ws-play .ws-bench,
  .ws-play .ws-bench[data-length="6"] {
    width: min(100%, 680px);
    padding: 20px 8px;
    margin-top: 0;
    transform: none;
    background: #124f58d9;
    border: 1px solid #c1f2ff;
    border-radius: 20px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    justify-items: center;
    gap: 24px 8px;
  }
  .ws-play .ws-tube-btn { --tube-width: min(16vw, 74px); height: calc(var(--tube-width) * 2.3); }
}
@media (max-width: 600px) {
  .ws-play .ws-bench {
    padding-block: 16px;
    row-gap: 18px;
  }
  .ws-play .ws-bench[data-length="6"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ws-play .ws-tube-btn { --tube-width: min(18vw, 62px); height: clamp(104px, 31vw, 138px); padding-top: 9px; }
  .ws-play .ws-tube-btn.is-selected { transform: translateY(-8px); }
  .ws-play .ws-tube-btn.is-complete::after { top: -16px; }
  .ws-play .ws-layer { height: 22%; }
}

.ws-brand-title { font-size: clamp(17px, 2.15vw, 31px); }
@media (min-width: 900px) {
  .ws-play .ws-bench[data-length="7"] .ws-tube-btn { --tube-width: clamp(58px, 7.3vw, 108px); }
  .ws-play .ws-bench[data-length="8"] .ws-tube-btn { --tube-width: clamp(52px, 6.3vw, 94px); }
  .ws-play .ws-bench[data-length="7"], .ws-play .ws-bench[data-length="8"] {
    min-height: min(25.2vw, 378px);
    transform: translateX(3.7vw);
  }
}

.ws-play .ws-tube-btn {
  isolation: isolate;
  height: auto;
  aspect-ratio: 1 / 3;
  border-color: transparent;
  background: none;
  box-shadow: none;
}
.ws-play .ws-tube-btn::before {
  inset: -3px -4px -4px;
  height: auto;
  z-index: -1;
  border: 0;
  background: url("../images/glass-tube.5a3ab97983c7.webp") center / contain no-repeat;
  border-radius: 0;
  box-shadow: none;
}
.ws-play .ws-tube-btn.is-selected { border-color: #08758f; }
.ws-play .ws-tube-btn.is-hint-src { border-color: #a74f00; }
.ws-play .ws-tube-btn.is-hint-dst, .ws-play .ws-tube-btn.is-complete { border-color: #08744f; }
.ws-play .ws-layer { height: 21%; flex: 0 0 21%; }
@media (max-aspect-ratio: 5/4), (max-width: 899px) {
  .ws-play .ws-tube-btn { --tube-width: min(13vw, 64px); }
}
@media (max-width: 600px) {
  .ws-play .ws-tube-btn { --tube-width: clamp(44px, 12vw, 51px); }
  .ws-play .ws-tube-btn:focus-visible { outline-offset: 1px; }
}

@media (min-width: 901px) and (min-aspect-ratio: 5/4) {
  .ws-play .ws-tube-btn { padding-inline: clamp(10px, 1vw, 15px); }
  .ws-play .ws-tube-btn::before { transform: scale(1.075); transform-origin: center bottom; }
  .ws-play .ws-hud-actions button, .ws-play .ws-stat-pill { font-size: 1rem; }
}
@media (prefers-reduced-motion: no-preference) {
  .ws-play .ws-tube-btn.is-selected { animation: ws-lift-in 160ms ease-out; }
  @keyframes ws-lift-in { from { transform: translateY(0); } }
}
