:root{
  --bg: #14181b;                /* charcoal blue */
  --bg2: #161412;               /* brown-charcoal hint */
  --fg: #f1f1f1;
  --muted: rgba(241,241,241,0.62);
  --line: rgba(241,241,241,0.08);

  --accent: #a3321d;            /* deep red-orange */
  --accent-soft: rgba(163,50,29,0.22);
  --ring-soft: rgba(163,50,29,0.16);
  --link: #ff6b3d;
}

*{ box-sizing:border-box; }
html, body{
  height:100%;
  overscroll-behavior: none;
}

body{
  margin:0;
  overflow-x: hidden;
  color:var(--fg);
  background: var(--bg);
  font-family: "Courier New", Courier, monospace;

  /* Prevent iOS rubber-band scroll during interaction */
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

.wrap{
  max-width: 900px;
  margin: 0 auto;
  padding: 28px 18px 28px;
}

.top{
  border-bottom:1px solid var(--line);
  padding-bottom:14px;
  margin-bottom:22px;
}

h1{ font-size:22px; margin:0; letter-spacing:0.2px; }
.sub{ margin:6px 0 0; color:var(--muted); font-size:13px; }

.stage{
  display:grid;
  justify-items:center;
}

.operator{
  width:100%;
  max-width:520px;
  display:block;
  animation: slowRotate 170s linear infinite;
  transform-origin: 50% 50%;

  /* Critical: prevents Safari from scrolling page while dragging */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

@keyframes slowRotate{
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.field-fill{
  fill: rgba(163,50,29,0.05);
}

.field-ring{
  fill:none;
  pointer-events:none;
}

.field-ring.subtle{
  stroke: var(--ring-soft);
  stroke-width: 1;
}

.field-ring.outer{
  stroke: rgba(163,50,29,0.28);
  stroke-width: 1.2;
  shape-rendering: geometricPrecision;
  vector-effect: non-scaling-stroke;
}

.field-core{
  fill: rgba(163,50,29,0.12);
  stroke: rgba(163,50,29,0.42);
  stroke-width: 1;
  cursor: pointer;
  transition: fill 200ms ease, stroke 200ms ease;
}

.field-core:hover{
  fill: rgba(163,50,29,0.22);
}

.stress-sheen{
  fill: rgba(255, 107, 61, 0.22);
  opacity: 0;
  pointer-events:none;
  transition: opacity 120ms linear;
}

.stateReadout{
  margin: 8px 0 4px;
  font-size: 12px;
  letter-spacing: 1px;
  color: rgba(255,107,61,0.9);
  text-align:center;
  text-transform: uppercase;
}

.controlStrip{
  width:100%;
  max-width:420px;
  display:grid;
  gap:10px;
}

.status{
  text-align:center;
  font-size:12px;
  letter-spacing:1px;
  color: var(--muted);
  padding: 6px 0 2px;
}

/* Subtle blink + dots while loading */
.status.loading{
  color: rgba(255,107,61,0.9);
  animation: statusPulse 1.15s ease-in-out infinite;
}
.status.loading::after{
  content:"";
  display:inline-block;
  width:1.5em;
  margin-left:0.25em;
  text-align:left;
  animation: statusDots 1.1s steps(4, end) infinite;
  opacity:0.9;
}
@keyframes statusPulse{
  0%,100%{ opacity:0.55; }
  50%{ opacity:1; }
}
@keyframes statusDots{
  0%{ content:""; }
  25%{ content:"."; }
  50%{ content:".."; }
  75%{ content:"..."; }
  100%{ content:""; }
}

button{
  border:1px solid var(--line);
  border-radius:12px;
  padding:10px 12px;
  background: rgba(255,255,255,0.03);
  color: var(--fg);
  cursor:pointer;
  font-size:14px;
}
button:disabled{ opacity:0.5; cursor:not-allowed; }

.primary{
  background: rgba(255,255,255,0.06);
  font-weight:600;
}

.hint{
  margin-top:6px;
  color: var(--muted);
  font-size:13px;
  line-height:1.4;
  text-align:center;
}

.inlineControls{
  width: 100%;
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#playPauseMount{
  margin-left: auto;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.foot{
  margin-top:18px;
  border-top:1px solid var(--line);
  padding-top:12px;
}

.small{ font-size:12px; color: var(--muted); }
.mono{ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }

.spec{
  margin-top:6px;
  font-size:11px;
  letter-spacing:1px;
  color: rgba(255,107,61,0.45);
}

.spec .la5{
  color: var(--link);
  text-decoration:none;
  font-weight:600;
  transition: color 180ms ease, text-shadow 180ms ease;
}
.spec .la5:hover{
  color:#ff845f;
  text-shadow:0 0 10px rgba(255,107,61,0.18);
  text-decoration: underline;
}

/* ===== START GATE OVERLAY ===== */

.overlay{
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0,0,0,0.88);
  backdrop-filter: blur(2px);
  z-index: 60;
}

.overlay.hidden{
  display: none;
}

.panel{
  width: min(420px, calc(100% - 40px));
  border: 1px solid rgba(241,241,241,0.14);
  border-radius: 14px;
  background: rgba(20,20,20,0.88);
  box-shadow: 0 18px 60px rgba(0,0,0,0.45);
  padding: 22px 18px;
  text-align: center;
}

.titleText{
  font-size: 14px;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.msg{
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
}

#playPauseMount{
  margin-left: auto;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.terminalBack{
  display: inline-block;
  padding: 6px 10px;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 8px;
  background: rgba(242,242,242,0.03);
  color: rgba(236,232,225,0.65);
  text-decoration: none;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.terminalBack:hover{
  color: rgba(236,232,225,0.85);
  background: rgba(255,255,255,0.05);
}
