:root {
  --phet-cream: #faf5e4;
  --phet-cream-dark: #ede5cc;
  --phet-border: #5c5749;
  --phet-ink: #111111;
  --phet-muted: #444444;

  --color-fb: #0077cc;
  --color-fg: #d93025;
  --color-fn: #8e24aa;
  --color-fnet: #2e9e44;

  --phet-yellow: #ffe100;
  --font-phet: Arial, Helvetica, "Trebuchet MS", sans-serif;
  --font-mono: "Lucida Console", "Consolas", "Courier New", monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-phet);
  color: var(--phet-ink);
  background: #000000;
  user-select: none;
  -webkit-user-select: none;
}

.hidden {
  display: none !important;
}

.app-shell {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
}

/* Full-Bleed PhET Play Area */
.play-area {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #e6f2fa;
}

#sim-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: default;
}

/* Top-Center Compact PhET Instruction Strip */
.stage-banner {
  position: absolute;
  top: 6px;
  left: 234px;
  right: 482px;
  margin: 0 auto;
  width: fit-content;
  max-width: calc(100% - 716px);
  background: rgba(250, 245, 228, 0.95);
  border: 1.5px solid var(--phet-border);
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--phet-ink);
  pointer-events: none;
  text-align: center;
  z-index: 8;
}

/* PhET Cream Floating Panels (Sun Panel style) */
.phet-panel {
  background: var(--phet-cream);
  border: 1.5px solid var(--phet-border);
  border-radius: 8px;
  padding: 8px 10px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.14);
}

.fbd-card {
  position: absolute;
  top: 12px;
  left: 14px;
  width: 214px;
  height: 244px;
  min-width: 195px;
  min-height: 225px;
  display: flex;
  flex-direction: column;
  z-index: 20;
}

.motion-card {
  position: absolute;
  top: 12px;
  right: 274px;
  width: 196px;
  z-index: 10;
}

.phet-right-stack {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 248px;
  max-height: calc(100% - 76px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
}

.phet-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1.5px solid #c9c0a8;
}

.phet-panel-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--phet-ink);
}

.phet-panel-heading {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--phet-ink);
  margin-bottom: 7px;
  padding-bottom: 4px;
  border-bottom: 1.5px solid #c9c0a8;
}

.phet-tag {
  font-size: 11px;
  font-weight: 700;
  color: #222222;
  background: #ffffff;
  border: 1px solid #666666;
  padding: 1px 6px;
  border-radius: 4px;
}

#fbd-svg {
  display: block;
  flex: 1;
  min-height: 150px;
  width: 100%;
  height: 100%;
  background: #ffffff;
  border: 1.5px solid #555555;
  border-radius: 4px;
}

.fbd-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.fbd-zoom-btn {
  width: 22px;
  height: 20px;
  padding: 0;
  border-radius: 4px;
  border: 1.2px solid #444444;
  background: linear-gradient(180deg, #ffffff 0%, #dcdcdc 100%);
  color: #111111;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.fbd-zoom-btn:hover {
  background: linear-gradient(180deg, #fffdf4 0%, #e5dcc1 100%);
}

.fbd-mini-summary {
  margin-top: 5px;
  padding-right: 16px;
  font-size: 11px;
  color: #222222;
  text-align: center;
  min-height: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.fbd-resize-handle {
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  touch-action: none;
  opacity: 0.8;
}

.fbd-resize-handle:hover {
  opacity: 1;
}

.fbd-resize-handle svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* Status Pill inside Motion Card */
.status-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 4px;
  border: 1.5px solid #333333;
  white-space: nowrap;
}

.status-neutral {
  background: #ffffff;
  color: #222222;
}

.status-eq {
  background: #c8f7c5;
  color: #0b5a1e;
  border-color: #166534;
}

.status-rising {
  background: #cdeafd;
  color: #004c82;
  border-color: #0077cc;
}

.status-falling {
  background: #fde0dd;
  color: #8f160d;
  border-color: #d93025;
}

.status-tethered {
  background: #f0daf7;
  color: #5a126e;
  border-color: #8e24aa;
}

/* Motion Readout Rows (PhET crisp white recessed boxes) */
.readout-grid {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.readout-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
}

.readout-label {
  color: var(--phet-ink);
  font-weight: 700;
}

.readout-val {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12.5px;
  color: var(--phet-ink);
  background: #ffffff;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1.5px solid #555555;
  min-width: 78px;
  text-align: right;
}

/* Authentic PhET Square Black-Bordered Checkboxes */
.checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.phet-checkbox-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--phet-ink);
  cursor: pointer;
}

.phet-check-input {
  appearance: none;
  -webkit-appearance: none;
  width: 17px;
  height: 17px;
  background: #ffffff;
  border: 2px solid #111111;
  border-radius: 3px;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}

.phet-check-input:checked::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 0px;
  width: 5px;
  height: 10px;
  border: solid #111111;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(42deg);
}

.force-swatch {
  display: inline-block;
  width: 12px;
  height: 10px;
  border: 1px solid #111111;
  border-radius: 2px;
  flex-shrink: 0;
}

.swatch-fb { background: var(--color-fb); }
.swatch-fg { background: var(--color-fg); }
.swatch-fn { background: var(--color-fn); }
.swatch-net { background: var(--color-fnet); }

.force-legend {
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid #c9c0a8;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 6px;
  font-size: 11px;
  font-weight: 700;
  color: #222222;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Beveled Tactile PhET Push Buttons (Sun RectangularPushButton) */
.phet-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 10px;
  font-family: var(--font-phet);
  font-size: 12.5px;
  font-weight: 700;
  color: #111111;
  background: linear-gradient(180deg, #ffffff 0%, #dcdcdc 100%);
  border: 1.5px solid #333333;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 2px 0 rgba(0, 0, 0, 0.25);
  transition: filter 0.08s ease, transform 0.06s ease;
}

.phet-btn:hover:not(:disabled) {
  filter: brightness(1.04);
}

.phet-btn:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
}

.phet-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.phet-btn-sm {
  padding: 5px 8px;
  font-size: 12px;
}

.phet-btn-xs {
  padding: 4px 6px;
  font-size: 11.5px;
}

.phet-btn-compact {
  padding: 5px 8px;
  font-size: 12px;
}

.phet-btn-full {
  width: 100%;
  margin-top: 6px;
}

.phet-btn-blue {
  color: #ffffff;
  background: linear-gradient(180deg, #4db3f0 0%, #1c7ec7 100%);
  border-color: #0b4a78;
}

.phet-btn-green {
  color: #ffffff;
  background: linear-gradient(180deg, #5cc762 0%, #278f2e 100%);
  border-color: #135418;
  min-width: 142px;
}

.phet-btn-green.paused-state {
  color: #111111;
  background: linear-gradient(180deg, #ffe066 0%, #eab308 100%);
  border-color: #854d0e;
}

.phet-btn-cream {
  background: linear-gradient(180deg, #fffdf4 0%, #e5dcc1 100%);
}

.tool-btn-scissors.active {
  background: linear-gradient(180deg, #fde68a 0%, #f59e0b 100%);
  border-color: #78350f;
  color: #111111;
}

.phet-btn.attached {
  background: linear-gradient(180deg, #dcfce7 0%, #86efac 100%);
  border-color: #166534;
  color: #052e16;
}

.btn-icon {
  width: 15px;
  height: 15px;
}

/* Controls inside Right Stack */
.control-block {
  margin-bottom: 9px;
}

.control-block:last-child {
  margin-bottom: 0;
}

.control-label {
  font-size: 12px;
  font-weight: 700;
  color: #222222;
  margin-bottom: 5px;
}

.balloon-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}

.balloon-btn {
  flex-direction: column;
  gap: 3px;
  padding: 5px 3px;
  font-size: 11px;
}

.balloon-btn.active {
  background: linear-gradient(180deg, #e0f2fe 0%, #bae6fd 100%);
  border-color: #005c9e;
  box-shadow: inset 0 0 0 1px #0077cc;
}

.balloon-swatch {
  width: 16px;
  height: 20px;
  border-radius: 50% 50% 48% 48%;
  border: 1.5px solid #111111;
}

.swatch-blue { background: radial-gradient(circle at 35% 30%, #93c5fd, #0077cc); }
.swatch-red { background: radial-gradient(circle at 35% 30%, #fca5a5, #d93025); }
.swatch-yellow { background: radial-gradient(circle at 35% 30%, #fef08a, #eab308); }

.quick-attach-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.hint-text {
  margin-top: 5px;
  font-size: 11px;
  color: #333333;
  line-height: 1.3;
}

/* Classic Scientific OHAUS-style LCD Mirror */
.balance-mirror-block {
  background: #efe9d4;
  border: 1.5px solid #7d7767;
  border-radius: 6px;
  padding: 7px;
}

.balance-mirror-lcd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #c5d6b2;
  color: #182614;
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 700;
  padding: 5px 8px;
  border-radius: 4px;
  border: 2px solid #444444;
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.22);
  margin-bottom: 5px;
}

.tare-badge {
  font-family: var(--font-phet);
  font-size: 10px;
  font-weight: 700;
  background: #182614;
  color: #c5d6b2;
  padding: 1px 4px;
  border-radius: 2px;
}

.pan-contents-tag {
  font-size: 11px;
  font-weight: 700;
  color: #222222;
  margin-bottom: 5px;
}

.balance-btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

/* House Controls + Authentic PhET Teal HSlider */
.house-mass-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff9db;
  border: 1.5px solid #8a6d1b;
  border-radius: 5px;
  padding: 5px 8px;
  font-size: 12.5px;
  margin-bottom: 8px;
}

.balloon-count-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.balloon-count-header .control-label {
  margin-bottom: 0;
}

.count-readout {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: #111111;
  background: #ffffff;
  border: 1.5px solid #444444;
  border-radius: 4px;
  padding: 1px 6px;
}

.phet-slider-wrap {
  margin: 4px 0 7px;
}

.phet-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 7px;
  background: #ffffff;
  border: 1.5px solid #222222;
  border-radius: 4px;
  outline: none;
  cursor: pointer;
}

.phet-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 24px;
  border-radius: 4px;
  border: 1.5px solid #111111;
  background: linear-gradient(90deg, #88d8ff 0%, #31a7e6 50%, #238ec7 100%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

.phet-slider::-moz-range-thumb {
  width: 16px;
  height: 24px;
  border-radius: 4px;
  border: 1.5px solid #111111;
  background: linear-gradient(90deg, #88d8ff 0%, #31a7e6 50%, #238ec7 100%);
  cursor: pointer;
}

.phet-slider-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  font-weight: 700;
  color: #333333;
  margin-top: 3px;
  padding: 0 2px;
}

.exact-input-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 6px;
}

.phet-number-input {
  flex: 1;
  min-width: 0;
  padding: 4px 7px;
  border: 1.5px solid #333333;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
  color: #111111;
  background: #ffffff;
}

.phet-number-input:focus {
  outline: none;
  border-color: #0077cc;
}

.stepper-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.sync-card {
  background: #efe9d4;
  border: 1.5px solid #7d7767;
  border-radius: 6px;
  padding: 7px;
}

.sync-info-text {
  font-size: 11.5px;
  font-weight: 700;
  color: #111111;
  background: #ffffff;
  border: 1.5px solid #666666;
  border-radius: 4px;
  padding: 4px 6px;
  margin-bottom: 6px;
}

.custom-lift-toggle {
  font-size: 11.5px;
  margin-bottom: 5px;
}

.unit-suffix {
  font-weight: 700;
  font-size: 12.5px;
}

/* Bottom-Center Floating PhET Action Tools Tray */
.phet-bottom-tools {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 140px);
  background: var(--phet-cream);
  border: 1.5px solid var(--phet-border);
  border-radius: 8px;
  padding: 5px 9px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.22);
  z-index: 12;
}

.toolbar-group {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 5px;
}

.toolbar-divider {
  width: 1.5px;
  height: 22px;
  background: #b8af96;
  margin: 0 2px;
}

.trim-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Iconic Bottom-Right Play Area Orange PhET Reset All Button */
.phet-reset-btn {
  position: absolute;
  right: 16px;
  bottom: 12px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid #7a3200;
  background: linear-gradient(180deg, #ffbe42 0%, #ef6c00 100%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.5), 0 3px 0 #7a3200;
  z-index: 12;
}

.phet-reset-btn:hover {
  filter: brightness(1.06);
}

.phet-reset-btn:active {
  transform: translateY(1px);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25), 0 1px 0 #7a3200;
}

.phet-reset-btn svg {
  width: 22px;
  height: 22px;
}

/* Pure Black PhET Joist Bottom Navigation Bar */
.phet-navbar {
  height: 54px;
  flex-shrink: 0;
  background: #000000;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  border-top: 2px solid #262626;
  gap: 10px;
}

.nav-left {
  display: flex;
  align-items: center;
  min-width: 170px;
}

.nav-title {
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
}

.nav-screens {
  display: flex;
  align-items: center;
  gap: 18px;
  height: 100%;
}

.joist-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  color: #9ca3af;
  font-family: var(--font-phet);
}

.joist-thumb {
  display: block;
  width: 54px;
  height: 30px;
  border: 2px solid #555555;
  border-radius: 3px;
  overflow: hidden;
  opacity: 0.72;
  transition: opacity 0.1s ease, border-color 0.1s ease;
}

.joist-thumb svg {
  display: block;
  width: 100%;
  height: 100%;
}

.joist-label {
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.joist-tab:hover .joist-thumb {
  opacity: 0.95;
  border-color: #aaaaaa;
}

.joist-tab.active {
  color: var(--phet-yellow);
}

.joist-tab.active .joist-thumb {
  opacity: 1;
  border: 2.5px solid var(--phet-yellow);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 7px;
}

.g-selector-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #171717;
  border: 1px solid #444444;
  border-radius: 4px;
  padding: 2px 6px;
}

.g-label {
  font-size: 12px;
  font-weight: 700;
  color: #e5e5e5;
}

.g-select {
  background: #000000;
  color: #ffffff;
  border: 1px solid #555555;
  border-radius: 3px;
  padding: 2px 4px;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-mono);
  cursor: pointer;
}

.joist-util-btn {
  height: 30px;
  padding: 0 9px;
  border-radius: 4px;
  border: 1px solid #444444;
  background: #171717;
  color: #ffffff;
  font-family: var(--font-phet);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.joist-util-btn:hover {
  background: #2b2b2b;
  border-color: #777777;
}

.joist-link-btn {
  text-decoration: none;
  white-space: nowrap;
}

.joist-icon-btn {
  width: 32px;
  padding: 0;
}

.util-svg {
  width: 17px;
  height: 17px;
}

@media (max-width: 1120px) {
  .motion-card {
    right: auto;
    left: 14px;
    top: 268px;
    width: 210px;
  }
  .stage-banner {
    right: 274px;
    max-width: calc(100% - 508px);
    font-size: 11px;
    padding: 2px 8px;
  }
}
