:root {
  --ink: #0c2d48;
  --ink-muted: #3b637c;
  --turquoise: #0e9aa7;
  --turquoise-dark: #0a7884;
  --cyan: #22d3ee;
  --gold: #f59e0b;
  --gold-soft: #fef3c7;
  --coral: #ef4444;
  --coral-soft: #fee2e2;
  --emerald: #10b981;
  --emerald-soft: #d1fae5;
  --glass: rgba(255, 255, 255, 0.82);
  --glass-strong: rgba(255, 255, 255, 0.93);
  --glass-border: rgba(255, 255, 255, 0.9);
  --shadow-float: 0 14px 36px rgba(9, 44, 66, 0.18), 0 3px 10px rgba(14, 154, 167, 0.12);
  --shadow-soft: 0 8px 20px rgba(9, 44, 66, 0.14);
}

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

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #1496ad;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
.brand-title,
.eyebrow,
.notation-chip,
.primary-btn,
.secondary-btn,
.pill-btn,
.dock-btn {
  font-family: "Outfit", "Plus Jakarta Sans", sans-serif;
}

button {
  font: inherit;
  cursor: pointer;
  border: 0;
  background: none;
  color: inherit;
}

button:focus-visible,
canvas:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

/* Tam ekran kıyı tuvali */
.stage-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  display: block;
  touch-action: none;
  user-select: none;
  z-index: 1;
}

/* Üst yüzen cam şerit */
.hud-top {
  position: fixed;
  top: 12px;
  left: 16px;
  right: 16px;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}

.glass-pill,
.top-actions {
  pointer-events: auto;
}

.glass-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1.5px solid var(--glass-border);
  box-shadow: var(--shadow-soft);
}

.brand-pill {
  padding: 5px 14px 5px 6px;
  flex-shrink: 0;
}

.brand-badge {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1rem;
  background: linear-gradient(135deg, #0e9aa7 0%, #0d5c75 100%);
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(13, 92, 117, 0.28);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.08;
}

.brand-title {
  font-weight: 800;
  font-size: 0.96rem;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--ink-muted);
}

/* 7 Şamandıra ilerleme hapı */
.progress-pill {
  gap: 5px;
  padding: 5px 8px;
}

.buoy {
  height: 30px;
  min-width: 30px;
  padding: 0 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: "Outfit", sans-serif;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--ink-muted);
  background: rgba(255, 255, 255, 0.72);
  border: 1.5px solid rgba(14, 154, 167, 0.22);
  transition: transform 0.16s ease, background-color 0.16s ease, color 0.16s ease;
}

.buoy:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--turquoise);
  color: var(--ink);
}

.buoy.done {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border-color: transparent;
  color: #ffffff;
}

.buoy.current {
  background: linear-gradient(135deg, #0e9aa7 0%, #0d5c75 100%);
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(14, 154, 167, 0.35);
  transform: scale(1.06);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

.pill-btn {
  height: 38px;
  padding: 0 13px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.82rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1.5px solid var(--glass-border);
  box-shadow: var(--shadow-soft);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.pill-btn:hover {
  transform: translateY(-1px);
  border-color: var(--turquoise);
}

#sandboxToggle[aria-pressed="true"] {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #ffffff;
  border-color: transparent;
}

.pill-btn.muted {
  opacity: 0.62;
  color: var(--ink-muted);
}

/* Sol üst telemetri hapı */
.stage-hud {
  position: fixed;
  top: 64px;
  left: 16px;
  z-index: 11;
  pointer-events: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border-radius: 999px;
  background: rgba(12, 45, 72, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #ffffff;
  font-family: "Outfit", sans-serif;
  font-size: 0.84rem;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(9, 44, 66, 0.25);
}

.hud-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.hud-badge.good {
  color: #6ee7b7;
}

.hud-badge.warn {
  color: #fcd34d;
}

.hud-sep {
  opacity: 0.4;
}

/* Yüzen araç çubuğu + birleşik görev kartı */
.bottom-float-stack {
  pointer-events: none;
}

.tool-dock {
  position: fixed;
  bottom: 16px;
  left: calc((100vw - 320px) / 2);
  transform: translateX(-50%);
  z-index: 12;
  pointer-events: auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  max-width: calc(100vw - 360px);
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1.5px solid var(--glass-border);
  box-shadow: var(--shadow-float);
}

.dock-btn {
  height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--ink);
  background: rgba(14, 154, 167, 0.12);
  border: 1px solid rgba(14, 154, 167, 0.22);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  transition: transform 0.15s ease, background-color 0.15s ease;
}

.dock-btn:hover {
  transform: translateY(-1px);
  background: rgba(14, 154, 167, 0.22);
}

.dock-btn.accent {
  background: linear-gradient(135deg, #0e9aa7 0%, #0d5c75 100%);
  color: #ffffff;
  border-color: transparent;
}

/* Sağ üst yüzen tek görev kartı */
.mission-float {
  position: fixed;
  top: 64px;
  right: 16px;
  width: 304px;
  max-height: calc(100dvh - 80px);
  overflow-y: auto;
  z-index: 12;
  pointer-events: auto;
  border-radius: 20px;
  padding: 12px 14px;
  background: var(--glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1.5px solid var(--glass-border);
  box-shadow: var(--shadow-float);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mission-float.collapsed {
  gap: 0;
}

.mission-float.collapsed .mission-body {
  display: none;
}

.mission-head {
  display: flex;
  align-items: center;
  gap: 9px;
}

.avatar-frame {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border-radius: 14px;
  background: linear-gradient(155deg, #fff8ea 0%, #d4f1f4 100%);
  border: 1.5px solid #ffffff;
  box-shadow: 0 4px 10px rgba(9, 44, 66, 0.12);
  display: grid;
  place-items: center;
  overflow: hidden;
}

#engineerImg {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.22s ease;
}

.mission-float.celebrate #engineerImg {
  transform: scale(1.07) translateY(-1px);
}

.speech-inline {
  flex: 1;
  min-width: 0;
  font-size: 0.79rem;
  line-height: 1.34;
  font-weight: 600;
  color: var(--ink);
}

.collapse-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--ink-muted);
  background: rgba(12, 45, 72, 0.08);
  transition: background-color 0.15s ease;
}

.collapse-btn:hover {
  background: rgba(14, 154, 167, 0.2);
  color: var(--ink);
}

.mission-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(12, 45, 72, 0.1);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.eyebrow {
  font-weight: 800;
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--turquoise-dark);
}

.notation-chip {
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(14, 154, 167, 0.15);
  color: var(--ink);
  font-weight: 800;
  font-size: 0.78rem;
}

.mission-body h1 {
  margin: 0;
  font-size: 1.14rem;
  font-weight: 900;
  line-height: 1.18;
  letter-spacing: -0.01em;
}

#instruction {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.42;
  color: var(--ink-muted);
}

.substeps {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 5px;
}

.substep {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.68);
  border: 1.5px solid rgba(12, 45, 72, 0.08);
  font-size: 0.79rem;
  font-weight: 600;
  color: var(--ink-muted);
}

.substep-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-family: "Outfit", sans-serif;
  font-weight: 800;
  font-size: 0.72rem;
  background: rgba(12, 45, 72, 0.1);
  color: var(--ink-muted);
}

.substep.active {
  background: rgba(255, 255, 255, 0.96);
  border-color: var(--turquoise);
  color: var(--ink);
}

.substep.active .substep-num {
  background: var(--turquoise);
  color: #ffffff;
}

.substep.done {
  background: var(--emerald-soft);
  border-color: rgba(16, 185, 129, 0.38);
  color: #065f46;
}

.substep.done .substep-num {
  background: var(--emerald);
  color: #ffffff;
}

.feedback {
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 0.81rem;
  font-weight: 600;
  line-height: 1.38;
}

.feedback.good {
  background: var(--emerald-soft);
  color: #065f46;
  border: 1.5px solid rgba(16, 185, 129, 0.45);
}

.feedback.bad {
  background: var(--coral-soft);
  color: #991b1b;
  border: 1.5px solid rgba(239, 68, 68, 0.4);
}

.feedback.info {
  background: var(--gold-soft);
  color: #92400e;
  border: 1.5px solid rgba(245, 158, 11, 0.4);
}

.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 2px;
}

.primary-btn {
  min-height: 40px;
  padding: 0 15px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 0.87rem;
  color: #ffffff;
  background: linear-gradient(135deg, #0e9aa7 0%, #0d5c75 100%);
  box-shadow: 0 6px 16px rgba(13, 92, 117, 0.28);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(13, 92, 117, 0.34);
}

.secondary-btn {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.86rem;
  color: var(--ink);
  background: rgba(14, 154, 167, 0.12);
  border: 1.5px solid rgba(14, 154, 167, 0.28);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.text-btn {
  min-height: 40px;
  padding: 0 11px;
  border-radius: 11px;
  font-family: "Outfit", sans-serif;
  font-weight: 700;
  font-size: 0.84rem;
  color: var(--turquoise-dark);
  background: rgba(14, 154, 167, 0.12);
}

.text-btn:hover {
  background: rgba(14, 154, 167, 0.2);
}

.hint-box {
  margin: 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--gold-soft);
  border: 1.5px dashed rgba(217, 119, 6, 0.45);
  color: #78350f;
  font-size: 0.8rem;
  line-height: 1.38;
  font-weight: 600;
}

/* Tam ekran karşılama & diploma katmanları */
.stage-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(9, 44, 66, 0.34);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}

.overlay-card {
  width: 100%;
  max-width: 450px;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 20px 22px;
  border-radius: 22px;
  background: var(--glass-strong);
  border: 2px solid #ffffff;
  box-shadow: 0 24px 54px rgba(9, 44, 66, 0.3);
  text-align: center;
}

.welcome-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.welcome-avatar {
  width: 104px;
  height: 104px;
  object-fit: contain;
  filter: drop-shadow(0 8px 14px rgba(12, 45, 72, 0.2));
}

.welcome-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: #92400e;
  font-family: "Outfit", sans-serif;
  font-weight: 800;
  font-size: 0.76rem;
}

.overlay-card h2 {
  margin: 0 0 8px;
  font-size: 1.42rem;
  font-weight: 900;
  color: var(--ink);
}

.overlay-desc {
  margin: 0 0 16px;
  font-size: 0.92rem;
  line-height: 1.48;
  color: var(--ink-muted);
}

.start-btn {
  min-height: 46px;
  padding: 0 24px;
  font-size: 0.98rem;
}

/* Kompakt bitiş diploması: 1280x800'de kaydırmasız tam sığar */
.finish-card {
  max-width: 500px;
  text-align: left;
  padding: 16px 20px;
}

.finish-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.finish-avatar {
  width: 60px;
  height: 60px;
  object-fit: contain;
  flex-shrink: 0;
}

.finish-kicker {
  display: inline-block;
  font-family: "Outfit", sans-serif;
  font-weight: 800;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--emerald);
}

.finish-header h2 {
  margin: 1px 0 0;
  font-size: 1.24rem;
}

.summary-diagram {
  margin-bottom: 10px;
  border-radius: 12px;
  overflow: hidden;
  border: 1.5px solid rgba(14, 154, 167, 0.25);
}

.summary-svg {
  display: block;
  width: 100%;
  max-height: 138px;
  height: auto;
}

.takeaway-list {
  margin: 0 0 12px;
  padding-left: 18px;
  display: grid;
  gap: 4px;
  font-size: 0.83rem;
  line-height: 1.38;
  color: var(--ink);
}

.finish-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

/* Mobil dikey düzen (<= 860px) */
@media (max-width: 860px) {
  .hud-top {
    top: 8px;
    left: 8px;
    right: 8px;
    flex-wrap: wrap;
    gap: 6px;
  }

  .brand-pill {
    padding: 4px 10px 4px 5px;
    gap: 6px;
  }

  .brand-badge {
    width: 28px;
    height: 28px;
    font-size: 0.85rem;
  }

  .brand-title {
    font-size: 0.84rem;
  }

  .brand-sub {
    display: none;
  }

  .pill-btn {
    height: 32px;
    padding: 0 9px;
    font-size: 0.75rem;
    gap: 4px;
  }

  #musicToggle .btn-label,
  #soundToggle .btn-label {
    display: none;
  }

  #musicToggle,
  #soundToggle {
    width: 32px;
    padding: 0;
    justify-content: center;
  }

  .progress-pill {
    order: 3;
    flex: 1 0 100%;
    justify-content: space-between;
    padding: 4px 6px;
    gap: 4px;
  }

  .buoy {
    flex: 1;
    min-width: 0;
    height: 26px;
    padding: 0 2px;
    font-size: 0.74rem;
  }

  .stage-hud {
    top: 96px;
    left: 10px;
    max-width: calc(100vw - 20px);
    padding: 5px 10px;
    font-size: 0.74rem;
  }

  .bottom-float-stack {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 10px;
    z-index: 12;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    pointer-events: none;
  }

  .tool-dock {
    position: static;
    transform: none;
    max-width: 100%;
    padding: 4px 7px;
    gap: 5px;
  }

  .dock-btn {
    height: 31px;
    padding: 0 9px;
    font-size: 0.75rem;
  }

  .mission-float {
    position: static;
    width: 100%;
    max-height: 36dvh;
    padding: 10px 12px;
    gap: 7px;
    border-radius: 18px;
  }

  .avatar-frame {
    width: 44px;
    height: 44px;
    border-radius: 12px;
  }

  .speech-inline {
    font-size: 0.76rem;
  }

  .mission-body {
    gap: 6px;
    padding-top: 6px;
  }

  .mission-body h1 {
    font-size: 1.02rem;
  }

  #instruction {
    font-size: 0.79rem;
    line-height: 1.35;
  }

  .substep {
    padding: 5px 8px;
    font-size: 0.74rem;
  }

  .primary-btn,
  .secondary-btn,
  .text-btn {
    min-height: 36px;
    font-size: 0.8rem;
  }

  .overlay-card {
    padding: 16px;
  }

  .welcome-avatar {
    width: 82px;
    height: 82px;
  }

  .overlay-card h2 {
    font-size: 1.2rem;
  }

  .takeaway-list {
    font-size: 0.78rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
