:root{
  --bg:#0b0f14;
  --panel:#0f1620;
  --panel2:#121b27;
  --text:rgba(255,255,255,.92);
  --muted:rgba(255,255,255,.66);
  --line:rgba(210,225,240,.92);
  --accent:rgba(255,190,120,.92);
  --danger:rgba(255,95,95,.92);
  --ok:rgba(120,255,175,.92);
  --shadow: 0 14px 34px rgba(0,0,0,.45);
  --radius:18px;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  background: radial-gradient(1200px 800px at 60% 10%, #121b27 0%, var(--bg) 55%, #06080c 100%);
  color:var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
}

.topbar{
  display:flex;
  gap:14px;
  padding:14px;
  align-items:stretch;
  border-bottom:1px solid rgba(255,255,255,.08);
  background: linear-gradient(180deg, rgba(20,30,44,.94) 0%, rgba(10,14,20,.92) 100%);
}

.topbar__left{flex: 1 1 auto; min-width: 340px}
.topbar__right{flex: 0 0 420px; max-width: 520px; width: 420px}

.level{
  background: linear-gradient(180deg, rgba(16,26,38,.92) 0%, rgba(12,18,26,.86) 100%);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
}
.level__badge{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.10);
  color: var(--text);
  font-weight: 800;
  letter-spacing: .2px;
  width: fit-content;
}
.level__title{margin:10px 0 4px 0; font-size: 16px; font-weight: 900;}
.level__desc{margin:0; color:var(--muted); font-size: 13px; line-height: 1.35;}

.given{
  margin-top:12px;
  background: linear-gradient(180deg, rgba(16,26,38,.92) 0%, rgba(12,18,26,.86) 100%);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
}
.given__title{font-weight: 900; font-size: 13px; margin-bottom: 10px; color: rgba(255,255,255,.88);}
.given__grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:8px 12px;
}
.given__item{
  display:flex;
  justify-content: space-between;
  gap:10px;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
}
.given__item span:first-child{color: var(--muted); font-weight: 800; font-size: 12px;}
.given__item span:last-child{font-weight: 900; font-variant-numeric: tabular-nums;}
.given__note{
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.inputs{
  height:100%;
  background: linear-gradient(180deg, rgba(16,26,38,.92) 0%, rgba(12,18,26,.86) 100%);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
}
.inputs__title{font-weight: 900; font-size: 13px; margin-bottom: 10px; color: rgba(255,255,255,.88);}

.field{margin: 10px 0}
label{display:block; font-weight: 800; font-size: 13px; margin-bottom: 6px;}
.field__row{display:flex; gap:10px; align-items:center; flex-wrap:wrap}
input[type="number"]{
  width: 140px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12);
  color: var(--text);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  outline: none;
}
input[type="number"]:focus{
  border-color: rgba(255,190,120,.50);
  box-shadow: 0 0 0 3px rgba(255,190,120,.14);
}
.hint{color: var(--muted); font-size: 12px; line-height: 1.35;}

.buttons{display:flex; gap:10px; margin-top: 10px; flex-wrap:wrap}
.btn{
  appearance:none;
  border:none;
  border-radius: 14px;
  padding: 10px 14px;
  background: rgba(255,255,255,.08);
  color: var(--text);
  font-weight: 900;
  cursor:pointer;
  border: 1px solid rgba(255,255,255,.12);
  transition: transform .06s ease, background .12s ease, border-color .12s ease;
}
.btn:hover{background: rgba(255,255,255,.10); border-color: rgba(255,255,255,.18);}
.btn:active{transform: translateY(1px);}
.btn--primary{
  background: rgba(255,190,120,.16);
  border-color: rgba(255,190,120,.30);
}
.btn--primary:hover{background: rgba(255,190,120,.20); border-color: rgba(255,190,120,.42);}

.status{
  margin-top: 12px;
  padding: 10px 10px;
  border-radius: 14px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
}
.status__row{
  display:flex;
  justify-content: space-between;
  gap:10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.status__row .mono{color: rgba(255,255,255,.86); font-weight: 900;}

.mono{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-variant-numeric: tabular-nums;
}

.stage{
  height: calc(100vh - 236px);
  min-height: 420px;
  padding: 14px;
}
.stage__frame{
  position:relative;
  height:100%;
  border-radius: 22px;
  overflow:hidden;
  border: 1px solid rgba(255,255,255,.08);
  box-shadow: var(--shadow);
  background:
    radial-gradient(1000px 700px at 60% 15%, rgba(18,28,40,.55) 0%, rgba(0,0,0,0) 65%),
    rgba(8,12,18,.55);
}

.ropeSvg{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
}
#ropeWhole, #ropeLeft, #ropeRight{
  fill: none;
  stroke: var(--line);
  stroke-width: 8;
  stroke-linecap: round;
  filter: drop-shadow(0 8px 14px rgba(0,0,0,.35));
}
#ropeWhole.broken, #ropeLeft.broken, #ropeRight.broken{
  stroke: rgba(255,95,95,.90);
  stroke-dasharray: 10 12;
}
#leftAnchor,#rightAnchor{
  fill: rgba(255,255,255,.40);
  opacity: .85;
}

.ball{
  position:absolute;
  left: 50%;
  top: 0;
  width: 64px;
  height: 64px;
  transform: translate(-50%, 0);
  border-radius: 999px;
  background: radial-gradient(circle at 30% 25%, rgba(255,255,255,.90) 0%, rgba(255,210,170,.88) 20%, rgba(210,120,60,.95) 70%, rgba(150,70,30,.95) 100%);
  box-shadow: 0 18px 38px rgba(0,0,0,.45);
}

.star{
  position:absolute;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 34px;
  filter: drop-shadow(0 10px 18px rgba(0,0,0,.50));
  user-select:none;
}

.legend{
  position:absolute;
  left: 14px;
  bottom: 14px;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(8,12,18,.55);
  border: 1px solid rgba(255,255,255,.10);
  color: var(--muted);
  font-size: 12px;
  display:flex;
  gap:14px;
  flex-wrap:wrap;
}
.legend__item{display:flex; align-items:center; gap:8px;}
.swatch{width: 14px; height: 6px; border-radius: 999px; display:inline-block;}
.swatch--rope{background: var(--line);}
.swatch--ball{background: rgba(210,120,60,.95); height: 10px; width: 10px; border-radius: 999px;}
.swatch--star{background: rgba(255,220,120,.92); height: 10px; width: 10px; border-radius: 6px;}

@media (max-width: 980px){
  .topbar{flex-direction:column}
  .topbar__right{flex: 1 1 auto; width:100%; max-width:none}
  .stage{height: calc(100vh - 520px)}
}


.ropeSvg[data-state="intact"] #ropeLeft,
.ropeSvg[data-state="intact"] #ropeRight{ display:none; }

.ropeSvg[data-state="broken"] #ropeWhole{ display:none; }

.ropeSvg[data-state="broken"] #ropeLeft,
.ropeSvg[data-state="broken"] #ropeRight{
  stroke: rgba(255,95,95,.92);
  stroke-width: 8;
  stroke-linecap: round;
  filter: drop-shadow(0 8px 14px rgba(0,0,0,.35));
}

@keyframes snapFlash{
  0%{ filter: drop-shadow(0 0 0 rgba(255,95,95,0)); }
  20%{ filter: drop-shadow(0 0 22px rgba(255,95,95,.55)); }
  100%{ filter: drop-shadow(0 0 0 rgba(255,95,95,0)); }
}
.ropeSvg[data-state="broken"]{ animation: snapFlash .45s ease-out 1; }
