/* Tooth Time Coder — Chrome 96+ safe CSS */

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1a4a6e;
  font-family: Arial, Helvetica, sans-serif;
  color: #1b2a38;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

button {
  font-family: inherit;
  cursor: pointer;
}

#app {
  --z: 1;
  position: relative;
  width: calc(100% / var(--z));
  height: calc(100vh / var(--z));
  transform: scale(var(--z));
  transform-origin: 0 0;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #c8ecff 0%, #e8f7ff 45%, #d7f0c8 100%);
  overflow: hidden;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  min-height: 64px;
  background: rgba(255, 255, 255, 0.72);
  border-bottom: 3px solid #7eb8de;
  flex-shrink: 0;
}

.titles h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
  color: #0d4f7a;
}

.credit {
  margin: 2px 0 0;
  font-size: 14px;
  color: #35586f;
}

.level-badge {
  padding: 10px 18px;
  border-radius: 999px;
  background: #ffd86b;
  border: 3px solid #e0a800;
  font-size: 20px;
  font-weight: bold;
  min-width: 110px;
  text-align: center;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.zoom-label {
  font-size: 14px;
  font-weight: bold;
  color: #35586f;
  margin-right: 4px;
}

.zoom-btn {
  min-width: 44px;
  min-height: 40px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 2px solid #7eb8de;
  background: #fff;
  font-size: 14px;
  font-weight: bold;
  color: #0d4f7a;
}

.zoom-btn.is-active {
  background: #0d4f7a;
  color: #fff;
  border-color: #0d4f7a;
}

.stage {
  flex: 1;
  display: flex;
  min-height: 0;
  padding: 8px 14px 44px;
  gap: 12px;
}

.scene-panel {
  flex: 1.15;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.scene {
  position: relative;
  flex: 1;
  min-height: 0;
  border-radius: 22px;
  border: 4px solid #6aa8cf;
  background: #9ed6f5;
  overflow: hidden;
  box-shadow: inset 0 -18px 0 #8bc4e8;
}

.wall {
  position: absolute;
  inset: 0 0 28% 0;
  background: repeating-linear-gradient(
    90deg,
    #b7e4fa,
    #b7e4fa 48px,
    #aedcf4 48px,
    #aedcf4 96px
  );
}

.mirror {
  position: absolute;
  top: 8%;
  left: 50%;
  width: 34%;
  height: 28%;
  margin-left: -17%;
  border-radius: 16px;
  border: 6px solid #d9eef9;
  background: linear-gradient(145deg, #eef9ff, #c5e5f7);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.08);
}

.sink {
  position: absolute;
  left: 50%;
  bottom: 18%;
  width: 42%;
  height: 22%;
  margin-left: -21%;
  z-index: 2;
}

.basin {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 70%;
  border-radius: 18px 18px 28px 28px;
  background: #f4fbff;
  border: 4px solid #c7dbe8;
  box-shadow: inset 0 10px 16px rgba(120, 180, 210, 0.35);
}

.faucet {
  position: absolute;
  left: 50%;
  top: 0;
  width: 18px;
  height: 36%;
  margin-left: -9px;
  background: #9eb4c4;
  border-radius: 8px;
}

.faucet::before {
  content: "";
  position: absolute;
  top: -10px;
  left: -14px;
  width: 46px;
  height: 16px;
  background: #9eb4c4;
  border-radius: 10px;
}

.water {
  position: absolute;
  left: 50%;
  top: 34%;
  width: 8px;
  height: 0;
  margin-left: -4px;
  background: #6ec8ff;
  border-radius: 4px;
  opacity: 0;
  transition: height 0.25s ease, opacity 0.25s ease;
}

.scene.is-rinsing .water {
  height: 42%;
  opacity: 1;
}

.counter {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 18%;
  background: #8f6a49;
  border-top: 8px solid #a67b55;
  z-index: 1;
}

.toothpaste-tube {
  position: absolute;
  right: 18%;
  bottom: 20%;
  width: 28px;
  height: 56px;
  background: #ff6b8a;
  border-radius: 6px 6px 4px 4px;
  z-index: 3;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.1);
}

.toothpaste-tube::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 8px;
  width: 12px;
  height: 12px;
  background: #ffd86b;
  border-radius: 3px;
}

.toothpaste-tube.is-used {
  transform: rotate(-25deg);
}

.character {
  position: absolute;
  left: 50%;
  bottom: 16%;
  width: 140px;
  height: 220px;
  margin-left: -70px;
  z-index: 4;
  transition: transform 0.25s ease;
}

.char-body {
  position: relative;
  width: 100%;
  height: 100%;
}

.char-head {
  position: absolute;
  left: 50%;
  top: 0;
  width: 78px;
  height: 78px;
  margin-left: -39px;
  z-index: 3;
}

.char-hair {
  position: absolute;
  left: 6px;
  right: 6px;
  top: -6px;
  height: 28px;
  background: #5a3a1e;
  border-radius: 40px 40px 8px 8px;
}

.char-face {
  position: absolute;
  inset: 8px 4px 0;
  background: #ffd3ad;
  border-radius: 50%;
  border: 3px solid #e8b888;
}

.eye {
  position: absolute;
  top: 28px;
  width: 10px;
  height: 12px;
  background: #2a2a2a;
  border-radius: 50%;
}

.eye.left {
  left: 18px;
}

.eye.right {
  right: 18px;
}

.mouth {
  position: absolute;
  left: 50%;
  bottom: 16px;
  width: 22px;
  height: 10px;
  margin-left: -11px;
  border: 3px solid #c45d6a;
  border-top: none;
  border-radius: 0 0 14px 14px;
  background: transparent;
}

.character[data-pose="celebrating"] .mouth {
  width: 28px;
  height: 16px;
  margin-left: -14px;
  background: #c45d6a;
  border-radius: 0 0 16px 16px;
}

.blush {
  position: absolute;
  top: 40px;
  width: 12px;
  height: 8px;
  background: rgba(255, 120, 140, 0.45);
  border-radius: 50%;
}

.blush.left {
  left: 8px;
}

.blush.right {
  right: 8px;
}

.char-torso {
  position: absolute;
  left: 50%;
  top: 72px;
  width: 70px;
  height: 78px;
  margin-left: -35px;
  background: #4ec3ff;
  border-radius: 18px 18px 12px 12px;
  border: 3px solid #2ea0d8;
  z-index: 2;
}

.char-arm {
  position: absolute;
  top: 80px;
  width: 18px;
  height: 56px;
  background: #ffd3ad;
  border-radius: 10px;
  border: 2px solid #e8b888;
  transform-origin: top center;
  z-index: 1;
}

.left-arm {
  left: 18px;
  transform: rotate(12deg);
}

.right-arm {
  right: 18px;
  transform: rotate(-12deg);
  z-index: 5;
}

.brush {
  position: absolute;
  left: 50%;
  top: 22px;
  width: 12px;
  height: 22px;
  margin-left: -6px;
  background: #6ad18b;
  border-radius: 4px;
  opacity: 0;
  transform-origin: top center;
}

.brush::before {
  content: "";
  position: absolute;
  bottom: -10px;
  left: -6px;
  width: 24px;
  height: 12px;
  background: #fff;
  border: 2px solid #cfd8df;
  border-radius: 4px;
}

.character[data-pose="holding"] .brush,
.character[data-pose="brushing"] .brush,
.character[data-pose="rinsing"] .brush,
.character[data-pose="celebrating"] .brush {
  opacity: 1;
}

.character[data-pose="holding"] .right-arm,
.character[data-pose="brushing"] .right-arm {
  top: 20px;
  right: auto;
  left: 48px;
  height: 46px;
  z-index: 7;
}

.character[data-pose="holding"] .right-arm {
  transform: rotate(-24deg);
}

.character[data-pose="brushing"] .right-arm {
  animation: brushMove 0.28s ease-in-out infinite alternate;
}

.character[data-pose="brushing"][data-spot="top"] .right-arm {
  animation-name: brushTop;
}

.character[data-pose="brushing"][data-spot="bottom"] .right-arm {
  animation-name: brushBottom;
}

.character[data-pose="rinsing"] .right-arm {
  top: 18px;
  right: auto;
  left: 36px;
  transform: rotate(18deg);
}

.character[data-pose="rinsing"] .brush {
  opacity: 0;
}

.character[data-pose="celebrating"] {
  animation: celebrateBounce 0.5s ease-in-out infinite alternate;
}

.character[data-pose="celebrating"] .left-arm {
  transform: rotate(-40deg);
}

.character[data-pose="celebrating"] .right-arm {
  transform: rotate(40deg);
}

@keyframes brushMove {
  from {
    transform: rotate(-32deg);
  }
  to {
    transform: rotate(8deg);
  }
}

@keyframes brushTop {
  from {
    transform: rotate(-48deg);
  }
  to {
    transform: rotate(-16deg);
  }
}

@keyframes brushBottom {
  from {
    transform: rotate(-8deg);
  }
  to {
    transform: rotate(22deg);
  }
}

@keyframes celebrateBounce {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-10px);
  }
}

.char-legs {
  position: absolute;
  left: 50%;
  top: 148px;
  width: 60px;
  margin-left: -30px;
  display: flex;
  justify-content: space-between;
}

.leg {
  width: 18px;
  height: 48px;
  background: #35586f;
  border-radius: 8px;
}

.bubbles {
  position: absolute;
  left: 22px;
  top: 42px;
  width: 70px;
  height: 48px;
  pointer-events: none;
  opacity: 0;
  z-index: 6;
}

.scene.is-brushing .bubbles {
  opacity: 1;
}

.bubbles::before,
.bubbles::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  border: 2px solid #cfefff;
  animation: floatBubble 1s ease-in-out infinite;
}

.bubbles::after {
  left: 28px;
  top: 10px;
  width: 12px;
  height: 12px;
  animation-delay: 0.25s;
}

@keyframes floatBubble {
  from {
    transform: translateY(8px);
    opacity: 0.4;
  }
  to {
    transform: translateY(-12px);
    opacity: 1;
  }
}

.spoken {
  margin: 8px 0 0;
  min-height: 28px;
  padding: 6px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.8);
  border: 2px solid #7eb8de;
  font-size: 18px;
  font-weight: bold;
  color: #0d4f7a;
  text-align: center;
}

.code-panel {
  flex: 0 0 42%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 360px;
  min-height: 0;
  overflow: hidden;
}

.panel-block {
  background: rgba(255, 255, 255, 0.88);
  border: 3px solid #7eb8de;
  border-radius: 18px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.look-block {
  flex: 1.1;
  overflow: hidden;
}

.list-block {
  flex: 1;
  overflow: hidden;
}

.panel-block h2 {
  margin: 0 0 4px;
  font-size: 20px;
  color: #0d4f7a;
}

.hint {
  margin: 0 0 8px;
  font-size: 13px;
  color: #35586f;
}

.bar-tray,
.program-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  min-height: 0;
  flex: 1;
  padding: 4px;
}

.program-list {
  border: 3px dashed #9ec7e3;
  border-radius: 14px;
  background: #f3faff;
  min-height: 64px;
}

.program-list.is-drag-over {
  background: #dff3ff;
  border-color: #0d4f7a;
}

.program-list:empty::before {
  content: "Drop bars here";
  display: block;
  padding: 28px 12px;
  text-align: center;
  color: #7a97ab;
  font-size: 16px;
}

.code-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 3px solid #2ea0d8;
  background: #4ec3ff;
  color: #083552;
  font-size: 18px;
  font-weight: bold;
  text-align: left;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  box-shadow: 0 3px 0 #2a89ba;
}

.code-bar:focus {
  outline: 3px solid #ffd86b;
  outline-offset: 2px;
}

button.code-bar.is-glow {
  background: #ffe14a;
  border-color: #e09000;
  color: #083552;
  box-shadow: 0 0 0 4px #fff7c2, 0 0 0 9px #ffb703, 0 0 22px 6px #ffd86b;
  animation: barGlow 0.45s ease-in-out 2 alternate;
}

@keyframes barGlow {
  0% {
    box-shadow: 0 0 0 0 #ffd86b, 0 3px 0 #2a89ba;
  }
  40% {
    box-shadow: 0 0 0 6px #ffd86b, 0 0 22px #ffe08a, 0 3px 0 #2a89ba;
  }
  100% {
    box-shadow: 0 0 0 0 #ffd86b, 0 3px 0 #2a89ba;
  }
}

.code-bar[data-kind="grab"] {
  background: #7ed957;
  border-color: #4aa832;
  box-shadow: 0 3px 0 #3f922b;
}

.code-bar[data-kind="paste"] {
  background: #ff9ec4;
  border-color: #e26a98;
  box-shadow: 0 3px 0 #c95580;
}

.code-bar[data-kind="brush"] {
  background: #4ec3ff;
  border-color: #2ea0d8;
}

.code-bar[data-kind="rinse"] {
  background: #8fd3ff;
  border-color: #4aa6d8;
}

.code-bar[data-kind="extra"] {
  background: #d7c3ff;
  border-color: #9d7fd6;
  box-shadow: 0 3px 0 #8666bf;
}

.bar-remove {
  min-width: 36px;
  min-height: 36px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.7);
  color: #083552;
  font-size: 20px;
  font-weight: bold;
  line-height: 1;
}

.list-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  flex-shrink: 0;
}

.btn {
  flex: 1;
  min-height: 52px;
  border-radius: 16px;
  border: 3px solid transparent;
  font-size: 22px;
  font-weight: bold;
  padding: 8px 12px;
}

.btn-go {
  background: #31c46b;
  border-color: #1f9a4f;
  color: #fff;
  box-shadow: 0 4px 0 #187a3e;
}

.btn-go:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #187a3e;
}

.btn-go:disabled,
.btn-clear:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn-clear {
  background: #fff;
  border-color: #9eb4c4;
  color: #35586f;
}

.mistake-star {
  position: absolute;
  top: 78px;
  right: 24px;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 4px solid #e0a800;
  background: #ffd86b;
  color: #c47a00;
  font-size: 40px;
  line-height: 1;
  z-index: 20;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.12);
  animation: starPop 0.35s ease;
}

.mistake-star[hidden] {
  display: none;
}

@keyframes starPop {
  from {
    transform: scale(0.4);
  }
  to {
    transform: scale(1);
  }
}

.cheer {
  position: absolute;
  inset: 0;
  background: rgba(13, 79, 122, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
}

.cheer[hidden] {
  display: none;
}

.cheer-card {
  width: min(460px, 90%);
  padding: 28px 24px;
  border-radius: 24px;
  background: #fff;
  border: 4px solid #ffd86b;
  text-align: center;
  box-shadow: 0 12px 0 rgba(0, 0, 0, 0.12);
}

.cheer-title {
  margin: 0 0 8px;
  font-size: 36px;
  color: #0d4f7a;
}

.cheer-body {
  margin: 0 0 18px;
  font-size: 20px;
  color: #35586f;
}

.cheer-card .btn {
  width: 100%;
}

.feedback-dock {
  position: absolute;
  right: 8px;
  bottom: 6px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.feedback-open,
.feedback-close,
.feedback-send {
  font-family: Arial, Helvetica, sans-serif;
  font-weight: bold;
  border-radius: 10px;
  min-height: 32px;
  padding: 4px 12px;
  cursor: pointer;
}

.feedback-open {
  border: 2px solid #0d4f7a;
  background: #fff;
  color: #0d4f7a;
  font-size: 14px;
}

.feedback-panel {
  width: 240px;
  margin: 0 0 6px;
  padding: 8px;
  background: #fff;
  border: 3px solid #0d4f7a;
  border-radius: 12px;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.12);
}

.feedback-panel[hidden] {
  display: none;
}

.feedback-field {
  display: block;
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: bold;
  color: #0d4f7a;
}

.feedback-field input,
.feedback-field select,
.feedback-field textarea {
  display: block;
  width: 100%;
  margin-top: 2px;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  font-weight: normal;
  color: #1b2a38;
  border: 2px solid #7eb8de;
  border-radius: 8px;
  padding: 4px 6px;
  background: #fff;
}

.feedback-field input,
.feedback-field select {
  height: 28px;
}

.feedback-field textarea {
  height: 44px;
  resize: none;
}

.feedback-note,
.feedback-thanks {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: bold;
  line-height: 1.2;
}

.feedback-note {
  color: #9a3412;
}

.feedback-thanks {
  color: #187a3e;
}

.feedback-note[hidden],
.feedback-thanks[hidden] {
  display: none;
}

.feedback-actions {
  display: flex;
  gap: 6px;
}

.feedback-close,
.feedback-send {
  flex: 1;
  font-size: 14px;
}

.feedback-close {
  border: 2px solid #9eb4c4;
  background: #fff;
  color: #35586f;
}

.feedback-send {
  border: 2px solid #1f9a4f;
  background: #31c46b;
  color: #fff;
}

.feedback-send:disabled {
  opacity: 0.55;
  cursor: default;
}

.feedback-frame {
  position: absolute;
  width: 0;
  height: 0;
  border: 0;
  left: 0;
  top: 0;
  visibility: hidden;
}

@media (max-height: 700px) {
  .titles h1 {
    font-size: 24px;
  }

  .spoken {
    font-size: 16px;
    min-height: 24px;
  }

  .code-bar {
    min-height: 44px;
    font-size: 16px;
  }

  .btn {
    min-height: 48px;
    font-size: 20px;
  }
}
