/* The Coding Sandbox (tools/coding-sandbox/): its own stylesheet, apart from Turtle Coding's. */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; background: #f1f5f9; min-height: 100vh; user-select: none; -webkit-user-select: none; }
[hidden] { display: none !important; }

/* ===== Site Header (the classic page; the purple skin draws its own) ===== */
.site-header { background: white; border-bottom: 1px solid #e5e7eb; height: 64px; position: sticky; top: 0; z-index: 100; }
.header-inner { max-width: 100%; height: 100%; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; }
.site-logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.site-logo-img { height: 44px; width: auto; display: block; }
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-links a { font-size: 14px; font-weight: 600; color: #64748b; text-decoration: none; padding: 8px 14px; border-radius: 8px; }
.nav-links a:hover { background: #f1f5f9; color: #1a1a2e; }
.nav-links a.active { background: #fef3c7; color: #92400e; }
.hamburger-btn { display: none; background: none; border: none; cursor: pointer; padding: 8px; z-index: 200; }
.hamburger-btn span { display: block; width: 24px; height: 2.5px; background: #64748b; border-radius: 2px; margin: 5px 0; }
@media (max-width: 768px) {
  .hamburger-btn { display: block; }
  .nav-links { display: none; position: absolute; top: 64px; left: 0; right: 0; background: white; flex-direction: column; padding: 8px 16px 16px; border-bottom: 1px solid #e5e7eb; gap: 2px; }
  .nav-links.open { display: flex; }
}

/* ===== Layout: no side panel; the workspace holds the start screen or the game ===== */
.main-container.solo { display: grid; grid-template-columns: minmax(0, 1fr); }

/* ===== The start screen: a new game, the example games, the games saved ===== */
.picker { flex: 1 1 auto; min-height: 0; overflow-y: auto; margin: -12px -18px -18px; padding: 26px 24px 44px; }
.pk-defs { position: absolute; width: 0; height: 0; overflow: hidden; }   /* the drawings' gradients while the start screen shows */
.pk-in { max-width: 1160px; margin: 0 auto; font-family: 'DM Sans', -apple-system, sans-serif; color: #341e60; }
.pk-crumb { font: 700 12.5px 'DM Sans', sans-serif; color: #634bf5; text-decoration: none; }
.pk-crumb:hover { text-decoration: underline; }
.picker h1 { font: 600 34px/1.1 'Fredoka', 'DM Sans', sans-serif; color: #341e60; margin: 12px 0 6px; }
.pk-sub { font: 500 16px/1.5 'DM Sans', sans-serif; color: #6b5f8a; max-width: 640px; margin-bottom: 28px; }
.pk-h { display: flex; align-items: center; gap: 12px; font: 600 20px 'Fredoka', 'DM Sans', sans-serif; color: #341e60; margin: 0 0 12px; }
.pk-h::after { content: ''; flex: 1; height: 2px; border-radius: 2px; background: #ece6f6; }
.pk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 14px; margin-bottom: 34px; }
.pk-card { display: flex; flex-direction: column; align-items: stretch; padding: 0; text-align: left; border: 2px solid #ece6f6; border-radius: 22px; background: #fff; cursor: pointer; overflow: hidden; font-family: 'DM Sans', sans-serif; color: #341e60; box-shadow: 0 4px 14px rgba(52,30,96,.06); transition: transform .15s, box-shadow .15s, border-color .15s; }
.pk-card:hover { border-color: #634bf5; transform: translateY(-2px); box-shadow: 0 10px 24px rgba(52,30,96,.12); }
.pk-card:focus-visible { outline: 3px solid #b9a9ff; outline-offset: 2px; }
.pk-card .pk-pic { height: 118px; display: grid; place-items: center; background: #f4f0fb; }
.pk-card .pk-pic svg { width: 92px; height: 92px; overflow: visible; }
.pk-w { display: grid; gap: 4px; padding: 12px 16px 16px; }
.pk-w b { font: 600 18px 'Fredoka', 'DM Sans', sans-serif; }
.pk-w span { font-size: 14px; line-height: 1.4; color: #6b5f8a; }
.pk-new { border-style: dashed; border-color: #ffc896; }
.pk-new:hover { border-color: #ff7800; }
.pk-new .pk-pic { background: #fff4e8; color: #ff7800; }
.pk-new .pk-pic svg { width: 54px; height: 54px; }
.pk-msg { font: 600 14px 'DM Sans', sans-serif; color: #4a3f6b; margin: -4px 2px 8px; }
.pk-msg:empty { display: none; }
.pk-msg.good { color: #15803d; }
.pk-msg.bad { color: #b91c1c; }
.pk-list { display: grid; gap: 10px; }
.pk-empty { padding: 22px; text-align: center; border: 2px dashed #e3dcf2; border-radius: 18px; color: #8a7fa8; font: 500 15px 'DM Sans', sans-serif; }
.pk-row { display: flex; align-items: center; gap: 14px; padding: 10px 12px 10px 10px; background: #fff; border: 2px solid #ece6f6; border-radius: 18px; }
.pk-row.new { border-color: #86d4a9; background: #f3fbf6; }
.pk-pic.sm { flex: none; width: 56px; height: 56px; border-radius: 14px; display: grid; place-items: center; background: #f4f0fb; }
.pk-pic.sm svg { width: 46px; height: 46px; overflow: visible; }
.pk-t { flex: 1 1 0; min-width: 0; display: grid; gap: 2px; }
.pk-t b { font: 600 17px 'Fredoka', 'DM Sans', sans-serif; color: #341e60; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pk-t span { font: 500 13.5px/1.35 'DM Sans', sans-serif; color: #8a7fa8; }
.pk-acts { flex: none; display: flex; align-items: center; gap: 8px; }
.pk-open { min-height: 40px; padding: 0 20px; border: 0; border-radius: 999px; background: #634bf5; color: #fff; font: 600 16px 'Fredoka', 'DM Sans', sans-serif; cursor: pointer; }
.pk-open:hover { background: #5236e8; }
.pk-dup { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px 0 11px; border: 2px solid #e2dcf5; border-radius: 999px; background: #fff; color: #341e60; font: 700 14px 'DM Sans', sans-serif; cursor: pointer; }
.pk-dup:hover { border-color: #634bf5; color: #634bf5; }
.pk-dup svg { width: 18px; height: 18px; }
.pk-open:disabled, .pk-dup:disabled { opacity: .55; cursor: default; }
.pk-del { display: grid; min-width: 40px; height: 40px; padding: 0 10px; border: 0; border-radius: 999px; background: none; color: #a99fc6; cursor: pointer; font: 700 14px 'DM Sans', sans-serif; }
.pk-del > * { grid-area: 1 / 1; place-self: center; }
.pk-del svg { width: 19px; height: 19px; }
.pk-del .q { visibility: hidden; color: #fff; }
.pk-del:hover { background: #fff0f0; color: #dc2626; }
.pk-del.sure { background: #dc2626; }
.pk-del.sure svg { visibility: hidden; }
.pk-del.sure .q { visibility: visible; }
.pk-where { margin: 14px 2px 0; font: 500 14px/1.5 'DM Sans', sans-serif; color: #6b5f8a; }
.pk-where a, .pk-more a { color: #634bf5; font-weight: 700; }
.pk-more { margin-top: 26px; font: 500 14px 'DM Sans', sans-serif; color: #8a7fa8; }
@media (max-width: 600px) {
  .picker h1 { font-size: 28px; }
  .pk-grid { gap: 10px; margin-bottom: 28px; }
  .pk-card { flex-direction: row; }
  .pk-card .pk-pic { flex: none; width: 92px; height: auto; min-height: 92px; }
  .pk-card .pk-pic svg { width: 70px; height: 70px; }
  .pk-new .pk-pic svg { width: 40px; height: 40px; }
  .pk-w { align-content: center; padding: 10px 14px; }
  .pk-row { flex-wrap: wrap; }
  .pk-acts { width: 100%; justify-content: flex-end; }
}

/* the question at Close, when the game has changed */
.close-ask { position: fixed; inset: 0; z-index: 3000; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(32,18,64,.42); }
.ca-box { width: min(520px, 100%); padding: 22px 22px 18px; background: #fff; border-radius: 22px; box-shadow: 0 18px 50px rgba(32,18,64,.28); font-family: 'DM Sans', sans-serif; color: #341e60; }
.ca-box h2 { font: 600 22px/1.2 'Fredoka', 'DM Sans', sans-serif; margin-bottom: 8px; overflow-wrap: anywhere; }
.ca-box p { font: 500 15px/1.45 'DM Sans', sans-serif; color: #4a3f6b; margin-bottom: 18px; }
.ca-b { display: flex; flex-wrap: wrap; gap: 8px; }
.ca-b button { min-height: 42px; padding: 0 16px; border: 2px solid #e2dcf5; border-radius: 999px; background: #fff; color: #341e60; font: 700 14.5px 'DM Sans', sans-serif; cursor: pointer; }
.ca-b button:hover { border-color: #634bf5; color: #634bf5; }
.ca-b button.go { background: #634bf5; border-color: #634bf5; color: #fff; }
.ca-b button.go:hover { background: #5236e8; border-color: #5236e8; color: #fff; }
.ca-b #caCancel { margin-left: auto; border-color: transparent; color: #6b5f8a; }

/* ===== Workspace: the status line, then the map and the code ===== */
.workspace { display: flex; flex-direction: column; align-items: stretch; padding: 12px 18px 18px; overflow: hidden; height: calc(100vh - 64px); position: relative; min-width: 0; background: #fbf8f2; }
.game { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }

/* the game bar: the game's name (and rename), what is happening, Save, Close, sound, full screen */
.game-bar { flex: none; display: flex; align-items: center; gap: 12px; min-height: 46px; margin-bottom: 8px; }
.gb-name { flex: 0 0 auto; min-width: 0; max-width: 36%; display: flex; align-items: center; gap: 2px; }
.gb-title { min-width: 0; font: 600 22px/1.25 'Fredoka', 'DM Sans', sans-serif; color: #341e60; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gb-input { min-width: 0; width: 300px; max-width: 100%; padding: 4px 10px; font: 600 20px 'Fredoka', 'DM Sans', sans-serif; color: #341e60; border: 2px solid #b9a9ff; border-radius: 12px; background: #fff; outline: none; user-select: text; -webkit-user-select: text; }
.gb-icon { flex: none; width: 36px; height: 36px; border: 0; border-radius: 50%; background: none; color: #8a7fa8; cursor: pointer; display: grid; place-items: center; }
.gb-icon:hover { background: #ece8ff; color: #634bf5; }
.gb-icon svg { width: 19px; height: 19px; }
.readout { flex: 1 1 auto; min-width: 0; min-height: 40px; display: flex; align-items: center; justify-content: center; text-align: center; }
.gb-acts { flex: none; display: flex; align-items: center; gap: 8px; }
.gb-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 16px 0 12px; border: 2px solid #e2dcf5; border-radius: 999px; background: #fff; color: #341e60; font: 700 14.5px 'DM Sans', sans-serif; cursor: pointer; }
.gb-btn svg { width: 18px; height: 18px; }
.gb-btn:hover:not(:disabled) { border-color: #634bf5; color: #634bf5; }
.gb-btn.save { background: #634bf5; border-color: #634bf5; color: #fff; }
.gb-btn.save:hover:not(:disabled) { background: #5236e8; border-color: #5236e8; color: #fff; }
.gb-btn:disabled { opacity: .45; cursor: default; }
.fullscreen-btn, .sound-btn { flex: none; width: 40px; height: 40px; padding: 0; border: 2px solid #e2dcf5; border-radius: 50%; background: #fff; color: #6b5f8a; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.fullscreen-btn:hover, .sound-btn:hover { color: #634bf5; border-color: #634bf5; }
.fullscreen-btn svg, .sound-btn svg { width: 19px; height: 19px; }
.sound-btn .snd-off, .sound-btn.off .snd-on { display: none; }
.sound-btn.off .snd-off { display: block; }
.status { font: 600 16px/1.3 'DM Sans', -apple-system, sans-serif; color: #4a3f6b; }
.status.good { color: #15803d; }
.status.bad { color: #c2410c; }

.play { flex: 1 1 auto; min-height: 0; display: flex; gap: 16px; }
.play.stacked { flex-direction: column; gap: 12px; }
.stage-wrap { flex: 1 1 auto; min-width: 0; min-height: 0; position: relative; display: flex; flex-direction: column; }

/* the tools over the map */
.stage-bar { flex: none; align-self: center; max-width: 100%; margin: 0 0 8px; z-index: 5; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; align-items: center; padding: 5px 8px; background: rgba(255,255,255,.94); border: 2px solid #ece6f6; border-radius: 26px; box-shadow: 0 4px 14px rgba(52,30,96,.10); }
.stage-bar.off { opacity: .45; pointer-events: none; }
.tb-tools, .tb-items { display: flex; gap: 5px; align-items: center; }
.tb-set { display: flex; align-items: center; gap: 6px; padding: 0 4px 0 10px; border-left: 2px solid #ece6f6; border-right: 2px solid #ece6f6; margin: 0 2px; font: 600 13px 'DM Sans', sans-serif; color: #6b5f8a; }
.tb-set select { font: 600 14px 'Fredoka', 'DM Sans', sans-serif; color: #341e60; border: 2px solid #e2dcf5; border-radius: 999px; padding: 6px 10px; background: #fff; cursor: pointer; max-width: 150px; }
.tool { width: 46px; height: 46px; border-radius: 50%; border: 2px solid transparent; background: #f7f5fc; cursor: pointer; display: grid; place-items: center; padding: 0; }
.tool svg { width: 36px; height: 36px; overflow: visible; }
.tool[data-tool="select"] svg, .tool[data-tool="hand"] svg, .tool[data-tool="erase"] svg { width: 26px; height: 26px; }
.tool:hover { border-color: #d9d0f5; }
.tool.on { border-color: #634bf5; background: #ece8ff; box-shadow: 0 0 0 3px rgba(99,75,245,.18); }

/* the maps of the game, a tab each */
.map-tabs { flex: none; display: flex; gap: 5px; align-items: center; margin: 0 2px 6px; overflow-x: auto; scrollbar-width: thin; padding: 2px; }
.map-tab, .map-add { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 4px 13px 4px 9px; border: 2px solid #ece6f6; border-radius: 999px; background: #fff; color: #4a3f6b; font: 600 14px 'Fredoka', 'DM Sans', sans-serif; cursor: pointer; white-space: nowrap; }
.map-tab:hover, .map-add:hover { border-color: #c9bcfd; }
.map-tab.on { border-color: #634bf5; background: #ece8ff; color: #341e60; }
.map-tab.on.sel { background: #634bf5; color: #fff; }
.map-tab.on.sel .mt-dot { border-color: rgba(255,255,255,.75); }
.mt-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(52,30,96,.25); }
.mt-n { max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.mt-star { width: 15px; height: 15px; fill: #f5b301; margin-left: -1px; }
.map-add { padding: 4px 12px; color: #634bf5; border-style: dashed; border-color: #c9bcfd; }
.map-tabs.running .map-tab:not(.on), .map-tabs.running .map-add { opacity: .5; cursor: default; }
.stage-wrap.max .map-tabs { display: none; }

/* the map: drawn once and slid about (a CSS transform) to follow the hero */
.stage-box { flex: 1 1 auto; min-height: 0; position: relative; overflow: hidden; border-radius: 22px; background: #efe9dd; cursor: grab; touch-action: none; outline: none; }
.stage-box:focus-visible { box-shadow: 0 0 0 3px #b9a9ff; }
.stage-box.tool-on { cursor: crosshair; }
.stage-box.panning { cursor: grabbing; }
#stage { position: absolute; left: 0; top: 0; display: block; transform-origin: 0 0; will-change: transform; overflow: hidden; }
.stage-btns { position: absolute; right: 8px; top: 8px; z-index: 6; display: flex; gap: 6px; align-items: center; max-width: calc(100% - 16px); flex-wrap: wrap; justify-content: flex-end; }
.cam-btn, .board-fs { position: relative; display: flex; align-items: center; gap: 7px; padding: 7px 12px 7px 10px; border: 2px solid #ece6f6; border-radius: 999px; background: rgba(255,255,255,.94); color: #341e60; font: 600 14px 'Fredoka', 'DM Sans', sans-serif; cursor: pointer; box-shadow: 0 4px 12px rgba(52,30,96,.14); }
.cam-btn svg, .board-fs svg { width: 18px; height: 18px; }
.cam-btn:hover, .board-fs:hover { border-color: #634bf5; color: #634bf5; }
.cam-btn[hidden], .board-fs[hidden] { display: none; }
.cam-btn.on { background: #634bf5; border-color: #634bf5; color: #fff; }
.board-fs { align-items: center; justify-content: center; gap: 0; width: 42px; height: 42px; padding: 0; border: 2px solid #ffd2a8; border-radius: 999px; background: rgba(255,255,255,.94); color: #c2410c; font: 600 14px 'Fredoka', 'DM Sans', sans-serif; cursor: pointer; box-shadow: 0 4px 12px rgba(52,30,96,.14); }
.board-fs:hover { border-color: #ff7800; color: #ff7800; }
.board-fs.on { background: #fff; border-color: #ece6f6; color: #341e60; }
/* the hero's bag, over the map */
.bag-strip { position: absolute; left: 8px; top: 8px; z-index: 6; display: flex; align-items: center; gap: 4px; padding: 3px 12px 3px 3px; border: 2px solid #f2dfa3; border-radius: 999px; background: rgba(255,255,255,.95); box-shadow: 0 4px 12px rgba(52,30,96,.14); font: 700 15px 'DM Sans', sans-serif; color: #7c4a03; pointer-events: none; max-width: calc(100% - 16px); flex-wrap: wrap; }
.bag-strip svg { width: 32px; height: 32px; overflow: visible; }
.bs-who { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: #fff6d8; margin-right: 2px; }
.bs-it { display: inline-flex; align-items: center; gap: 1px; padding-right: 3px; }
/* the board full screen: the map fills the screen, Pause and Stop at the bottom left */
.stage-wrap.max { position: fixed; inset: 0; z-index: 2000; margin: 0; background: #1c1233; }
.stage-wrap.max .stage-bar { display: none; }
.stage-wrap.max .stage-box { border-radius: 0; }
.stage-wrap.max .bag-strip { left: 12px; top: 12px; }
.fs-bar { position: absolute; left: 12px; bottom: 12px; z-index: 7; display: flex; gap: 8px; }
.fs-b { width: 54px; height: 54px; border-radius: 50%; border: 3px solid #fff; background: #341e60; color: #fff; display: grid; place-items: center; cursor: pointer; box-shadow: 0 6px 16px rgba(0,0,0,.28); }
.fs-b svg { width: 22px; height: 22px; }
.fs-b.go { background: #ff7800; }
.fs-b.go.paused { background: #634bf5; }
.fs-status { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); z-index: 6; max-width: min(640px, calc(100% - 340px)); padding: 9px 18px; border-radius: 18px; background: rgba(52,30,96,.88); color: #fff; font: 600 16px/1.3 'DM Sans', sans-serif; text-align: center; pointer-events: none; }
.fs-status.bad { background: rgba(194,65,12,.92); }
.fs-status.good { background: rgba(21,128,61,.92); }
@media (max-width: 700px) { .fs-status { top: auto; bottom: 78px; max-width: calc(100% - 24px); } }
@media (max-width: 420px) { .cam-btn span { display: none; } .cam-btn { padding: 8px; } }
body.sb-running .th.marker { opacity: .3; }
.key-hint { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 6; padding: 8px 16px; border-radius: 999px; background: #341e60; color: #fff; font: 600 15px 'Fredoka', 'DM Sans', sans-serif; pointer-events: none; box-shadow: 0 6px 16px rgba(52,30,96,.3); }

/* the keys as buttons on a touch screen, while a game that reads keys runs */
.pad { position: absolute; right: 10px; bottom: 10px; z-index: 6; display: grid; grid-template-columns: repeat(3, 48px); grid-template-rows: repeat(2, 48px) 38px; gap: 5px; touch-action: none; opacity: .88; }
.pad button { border: 0; border-radius: 16px; background: rgba(52,30,96,.78); color: #fff; display: grid; place-items: center; cursor: pointer; touch-action: none; box-shadow: 0 4px 12px rgba(0,0,0,.2); }
.pad button svg { width: 26px; height: 26px; fill: currentColor; }
.pad button.down { background: #ff7800; }
.pad .pk-up { grid-column: 2; grid-row: 1; }
.pad .pk-left { grid-column: 1; grid-row: 2; }
.pad .pk-down { grid-column: 2; grid-row: 2; }
.pad .pk-right { grid-column: 3; grid-row: 2; }
.pad .pk-space { grid-column: 1 / -1; grid-row: 3; font: 700 15px 'DM Sans', sans-serif; letter-spacing: .04em; }

/* the you-won card over the map */
.win { position: absolute; left: 50%; bottom: 14px; transform: translate(-50%, 0) scale(.9); z-index: 7; min-width: 280px; max-width: calc(100% - 32px); padding: 18px 24px 16px; text-align: center; background: #fff; border-radius: 24px; box-shadow: 0 20px 50px rgba(52,30,96,.28); opacity: 0; pointer-events: none; transition: opacity .25s, transform .3s cubic-bezier(.2,1.4,.4,1); }
.win.show { opacity: 1; transform: translate(-50%, 0) scale(1); pointer-events: auto; }
.win h2 { font: 600 30px/1.1 'Fredoka', sans-serif; color: #341e60; margin-bottom: 6px; }
.win p { font: 600 17px/1.4 'DM Sans', sans-serif; color: #4a3f6b; margin-bottom: 16px; }
.win .row-b { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.win button { min-height: 44px; padding: 0 20px; border-radius: 999px; font: 700 15px 'DM Sans', sans-serif; cursor: pointer; border: 2px solid #e2dcf5; background: #fff; color: #341e60; }
.win button.go { background: #ff7800; border-color: #ff7800; color: #fff; }
.note { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); max-width: calc(100% - 24px); padding: 9px 16px; border-radius: 10px; background: #2d3748; color: white; font: 600 14px 'DM Sans', -apple-system, sans-serif; text-align: center; opacity: 0; transition: opacity 0.2s; pointer-events: none; z-index: 8; }
.note.show { opacity: 1; }

/* ===== The code panel: the picked thing and its Python ===== */
.code { flex: 0 0 clamp(390px, 36%, 500px); min-height: 0; display: flex; flex-direction: column; background: #fff; border: 2px solid #ebe5f5; border-radius: 22px; box-shadow: 0 4px 20px rgba(52,30,96,.06); overflow: hidden; position: relative; }
.play.stacked .code { flex: 0 0 52%; min-height: 300px; }
.code-head { flex: none; display: flex; align-items: center; gap: 8px; padding: 12px 12px 6px; }
.thing-pic { flex: none; width: 46px; height: 46px; border-radius: 14px; background: #f7f5fc; display: grid; place-items: center; }
.thing-pic svg { width: 40px; height: 40px; overflow: visible; }
.thing-name { flex: 1 1 auto; min-width: 0; font: 600 19px 'Fredoka', 'DM Sans', sans-serif; color: #341e60; border: 2px solid transparent; border-radius: 10px; padding: 5px 8px; background: none; }
.thing-name:hover { border-color: #ece6f6; }
.thing-name:focus { outline: none; border-color: #b9a9ff; background: #fbfaff; }
.hero-btn { flex: none; display: inline-flex; align-items: center; gap: 5px; min-height: 36px; padding: 0 12px 0 9px; border-radius: 999px; border: 2px solid #f2dfa3; background: #fff; color: #8a6a00; font: 700 13px 'DM Sans', sans-serif; cursor: pointer; }
.hero-btn svg { width: 17px; height: 17px; fill: none; stroke: #e0a800; stroke-width: 2; stroke-linejoin: round; }
.hero-btn.on { background: #f5b301; border-color: #f5b301; color: #fff; }
.hero-btn.on svg { fill: #fff; stroke: #fff; }
.icon-btn { flex: none; width: 36px; height: 36px; border-radius: 50%; border: 0; background: #f3f0fb; color: #6b5f8a; cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover { background: #fdecea; color: #c0392b; }
.icon-btn svg { width: 19px; height: 19px; }
.code-pick { flex: none; padding: 0 12px 6px; }
.code-pick select, .code-tools select { width: 100%; font: 600 14px 'DM Sans', sans-serif; color: #341e60; border: 2px solid #ece6f6; border-radius: 10px; padding: 7px 10px; background: #fff; cursor: pointer; }
.code-tools { flex: none; position: relative; display: flex; align-items: center; gap: 8px; padding: 0 12px 8px; }
.code-tools select { flex: 1 1 auto; width: auto; min-width: 0; background: #fff7ef; border-color: #ffd8b3; color: #9a3412; }
.small-btn { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: 10px; border: 2px solid #ece6f6; background: #fff; color: #341e60; font: 700 13px 'DM Sans', sans-serif; cursor: pointer; }
.small-btn:hover { border-color: #634bf5; color: #634bf5; }
.small-btn svg { width: 16px; height: 16px; }
.line-count { flex: none; font: 600 12.5px 'DM Sans', sans-serif; color: #8a7fa8; white-space: nowrap; }
.code.none .gate-row, .code.none .bag-row, .code.none .portal-row, .code.none .code-head:not(.map-head),
.code.none .code-tools, .code.none .pal-fold, .code.none .palette, .code.none .pyed, .code.none .pyerr, .code.none .vars { display: none !important; }
.no-thing { display: none; }
/* nothing picked, or a map's tab: the map's name and controls in place of the code */
.map-panel { display: none; flex: none; }
.code.none .map-panel { display: block; }
.map-body { padding: 4px 14px 8px; display: grid; gap: 8px; }
.mp-l { font: 700 12px 'DM Sans', sans-serif; color: #8a7fa8; text-transform: uppercase; letter-spacing: .04em; margin-top: 2px; }
.map-body select { width: 100%; font: 600 14px 'DM Sans', sans-serif; color: #341e60; border: 2px solid #ece6f6; border-radius: 10px; padding: 8px 10px; background: #fff; cursor: pointer; }
.mp-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mp-row .small-btn { justify-content: center; min-height: 40px; }
.map-body :disabled, .map-head :disabled { opacity: .55; cursor: default; }
.mp-info { margin: 2px 0 0; font: 500 14px/1.45 'DM Sans', sans-serif; color: #6b5f8a; }
#delMap.armed { background: #c0392b; color: #fff; }

/* following, a gate's state, a thing's bag */
.follow-btn:hover { background: #e6eeff; color: #2563eb; }
.follow-btn.on { background: #2563eb; color: #fff; }
.gate-row { flex: none; display: flex; margin: 0 12px 8px; border: 2px solid #ece6f6; border-radius: 12px; overflow: hidden; }
.gate-row button { flex: 1 1 0; min-height: 36px; border: 0; border-right: 2px solid #ece6f6; background: #fff; font: 700 13.5px 'DM Sans', sans-serif; color: #4a3f6b; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.gate-row button:last-child { border-right: 0; }
.gate-row button svg { width: 15px; height: 15px; }
.gate-row button.on { background: #634bf5; color: #fff; }
.gate-row button:disabled { cursor: default; }
.gate-row button:disabled:not(.on) { color: #b3a9cc; }
.bag-row { flex: none; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 0 12px 8px; padding: 4px 6px 4px 10px; min-height: 44px; background: #fffaf0; border: 2px solid #f6e3bd; border-radius: 12px; }
.bag-t { font: 700 12px 'DM Sans', sans-serif; color: #9a6a12; text-transform: uppercase; letter-spacing: .04em; }
.bag-items { flex: 1 1 auto; display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.bag-it { display: inline-flex; align-items: center; gap: 2px; padding: 1px 8px 1px 2px; border: 2px solid #f2dfa3; border-radius: 999px; background: #fff; cursor: pointer; font: 700 13px 'DM Sans', sans-serif; color: #7c4a03; }
.bag-it svg { width: 28px; height: 28px; overflow: visible; }
.bag-it:hover:not(:disabled) { border-color: #ef4444; }
.bag-it:disabled { cursor: default; }
.bag-none { font: 500 13px 'DM Sans', sans-serif; color: #b3a9cc; }
.portal-row { flex: none; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 0 12px 8px; padding: 4px 6px 4px 10px; min-height: 44px; background: #f5f3ff; border: 2px solid #ddd6fe; border-radius: 12px; }
.portal-row .bag-t { color: #5b21b6; }
.portal-row select { flex: 1 1 140px; min-width: 0; font: 600 13.5px 'DM Sans', sans-serif; color: #341e60; border: 2px solid #ddd6fe; border-radius: 999px; padding: 5px 10px; background: #fff; cursor: pointer; }
.portal-row select:disabled { cursor: default; color: #6b5f8a; }
.portal-row .small-btn { min-height: 32px; border-color: #ddd6fe; }
.portal-row .go-there { width: 34px; padding: 0; justify-content: center; }
.bag-row select { flex: none; font: 600 13px 'DM Sans', sans-serif; color: #7c4a03; border: 2px solid #f2dfa3; border-radius: 999px; padding: 4px 8px; background: #fff; cursor: pointer; max-width: 120px; }

/* the sounds list */
.sounds-pop { position: absolute; left: 12px; right: 12px; top: 42px; z-index: 30; max-height: 330px; overflow-y: auto; padding: 10px 12px 12px; background: #fff; border: 2px solid #ece6f6; border-radius: 16px; box-shadow: 0 16px 40px rgba(52,30,96,.22); }
.sp-t { font: 700 12px 'DM Sans', sans-serif; color: #8a7fa8; text-transform: uppercase; letter-spacing: .04em; margin: 6px 0 6px; }
.sp-b { display: flex; flex-wrap: wrap; gap: 6px; }
.snd { display: inline-flex; align-items: stretch; border: 2px solid #e6e0f7; border-radius: 999px; overflow: hidden; }
.snd button { border: 0; background: #fff; cursor: pointer; font: 600 14px 'Fredoka', 'DM Sans', sans-serif; color: #341e60; }
.snd .snd-play { width: 32px; display: grid; place-items: center; background: #f1edff; color: #634bf5; }
.snd .snd-play svg { width: 14px; height: 14px; }
.snd .snd-put { padding: 5px 11px 5px 8px; }
.snd button:hover { background: #ece8ff; }
.sp-n { margin-top: 10px; font: 500 12.5px 'DM Sans', sans-serif; color: #8a7fa8; }

/* the picked thing's variables while it runs */
.vars { flex: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 8px; }
.vchip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; background: #fff; border: 2px solid #f2cf68; border-radius: 10px; font: 600 13.5px ui-monospace, 'Cascadia Mono', Consolas, monospace; color: #7c4a03; }
.vchip i { font-style: normal; font-weight: 700; background: #fff6d8; border-radius: 7px; padding: 2px 7px; color: #341e60; }

/* the code buttons, folded away until opened */
.pal-fold { flex: none; display: flex; align-items: center; gap: 6px; margin: 0 12px 6px; padding: 6px 10px 6px 6px; border: 0; border-radius: 10px; background: #f6f2ff; color: #4a3f6b; font: 600 15px 'Fredoka', 'DM Sans', sans-serif; cursor: pointer; text-align: left; }
.pal-fold:hover { background: #ede6ff; color: #634bf5; }
.pal-fold svg { width: 18px; height: 18px; flex: none; transition: transform .15s; }
.pal-fold[aria-expanded="true"] svg { transform: rotate(90deg); }
.palette { flex: none; max-height: 42%; overflow-y: auto; padding: 0 12px 8px; border-bottom: 2px dashed #ece6f6; margin-bottom: 4px; }
.code.folded .palette { display: none; }
.pg-t { font: 700 11.5px 'DM Sans', sans-serif; color: #8a7fa8; text-transform: uppercase; letter-spacing: .04em; margin: 6px 0 5px; }
.pg-b { display: flex; flex-wrap: wrap; gap: 5px; }
.pal { border: 2px solid; border-radius: 10px; padding: 5px 9px; font: 600 13.5px ui-monospace, 'Cascadia Mono', Consolas, monospace; cursor: pointer; white-space: nowrap; }
.pal:hover { transform: translateY(-1px); box-shadow: 0 3px 8px rgba(52,30,96,.12); }
.k-mv { background: #eaf1ff; border-color: #b4cbfb; color: #1e3a8a; }
.k-lg { background: #f1edff; border-color: #cbbffd; color: #4b35d6; }
.k-ck { background: #e3f8f3; border-color: #94dccb; color: #115e52; }
.k-sd { background: #ffeef4; border-color: #f9b8cf; color: #9d174d; }
.k-vr { background: #fff6d8; border-color: #f2cf68; color: #7c4a03; }
.k-it { background: #fff4e6; border-color: #fdc790; color: #9a3412; }
.k-mk { background: #fcefff; border-color: #e7b5f4; color: #86198f; }
.k-gt { background: #eef8e8; border-color: #b4dc9b; color: #3f6212; }
.k-mp { background: #e8f6fb; border-color: #9fd6ea; color: #0e5a73; }
body.sb-running .palette, body.sb-running .code-tools select, body.sb-running .hero-btn, body.sb-running #delThing { opacity: .45; pointer-events: none; }

/* the editor: a text box over its own coloured copy */
.program { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; padding: 2px 8px 8px; overflow: hidden; }
.pyed { position: relative; flex: 1 1 auto; min-height: 0; display: flex; overflow: hidden; background: #fbfaff; border: 2px solid #ece6f6; border-radius: 12px; font: 500 15px/28px ui-monospace, 'Cascadia Mono', Consolas, 'Courier New', monospace; }
.pyed:focus-within { border-color: #b9a9ff; }
body.sb-running .pyed { background: #f7f5fc; }
.pyg { flex: none; width: 34px; padding: 10px 6px 10px 0; text-align: right; color: #b3a9cc; user-select: none; font-size: 12.5px; overflow: hidden; }
.pyg div { height: 28px; }
.pyg .err { color: #ef4444; font-weight: 700; }
.pyw { position: relative; flex: 1 1 auto; min-width: 0; overflow: hidden; }
.pyh, .pyt { margin: 0; padding: 10px 12px; font: inherit; letter-spacing: 0; white-space: pre; tab-size: 4; box-sizing: border-box; }
.pyh { position: absolute; left: 0; top: 0; min-width: 100%; color: #341e60; pointer-events: none; }
.pyt { position: absolute; inset: 0; width: 100%; height: 100%; resize: none; border: 0; outline: none; background: transparent; color: transparent; caret-color: #341e60; overflow: auto; -webkit-text-fill-color: transparent; user-select: text; -webkit-user-select: text; }
.pyt::placeholder { color: #b3a9cc; -webkit-text-fill-color: #b3a9cc; }
.pyt::selection { background: rgba(99,75,245,.25); }
.pyh .pl { position: relative; height: 28px; border-radius: 6px; }
.pyh .pl.run { background: #fff2c2; box-shadow: inset 4px 0 #f5b301; }
.pyh .pl.err { background: #ffe8e8; box-shadow: inset 4px 0 #ef4444; }
.pyh i { font-style: normal; }
.pyh .k { color: #7c3aed; font-weight: 700; }
.pyh .f { color: #1d4ed8; }
.pyh .n { color: #c2410c; }
.pyh .v { color: #7c4a03; background: #fff3c4; border-radius: 4px; }
.pyh .s { color: #15803d; }
.pyh .m { color: #9a92b5; font-style: italic; }
.pyerr { flex: none; margin: 8px 2px 0; padding: 8px 12px; border-radius: 10px; background: #fff1f1; border: 2px solid #fca5a5; color: #b91c1c; font: 600 14px/1.35 'DM Sans', -apple-system, sans-serif; user-select: text; }

.transport { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px 12px; border-top: 2px solid #f3f0fb; background: #fdfcff; }
.tbtn { min-height: 46px; padding: 0 14px; border-radius: 999px; border: 2px solid #e2dcf5; background: #fff; color: #341e60; font: 700 15px 'DM Sans', sans-serif; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; }
.tbtn:hover { border-color: #c9bcfd; }
.tbtn:disabled { opacity: .4; cursor: default; }
.tbtn svg { width: 18px; height: 18px; }
.tbtn.go { background: #ff7800; border-color: #ff7800; color: #fff; padding: 0 18px; }
.tbtn.go:hover { background: #ea6a00; border-color: #ea6a00; }
.tbtn.go.paused { background: #634bf5; border-color: #634bf5; }
.tbtn.speed { width: 46px; padding: 0; justify-content: center; margin-left: auto; }
.tbtn.speed svg { width: 24px; height: 24px; }
.tbtn.help { width: 46px; padding: 0; justify-content: center; color: #634bf5; }
.tbtn.help svg { width: 24px; height: 24px; }
.speed .sp { display: none; }
.speed[data-speed="slow"] .sp[data-speed="slow"], .speed[data-speed="medium"] .sp[data-speed="medium"], .speed[data-speed="fast"] .sp[data-speed="fast"] { display: inline-flex; }

@media (prefers-reduced-motion: reduce) { .win, .pal { transition: none !important; } }

/* ===== Fullscreen ===== */
body.is-fullscreen .site-header { display: none; }
body.is-fullscreen .workspace { height: 100vh; padding: 14px 22px 18px; }

/* ===== Phones: the game bar, the map, then the code ===== */
@media (max-width: 768px) {
  .workspace { height: auto; padding: 10px 8px 12px; }
  .picker { margin: -10px -8px -12px; padding: 18px 14px 28px; overflow: visible; }
  .game-bar { flex-wrap: wrap; gap: 4px 8px; }
  .gb-name { flex: 1 1 auto; max-width: none; }
  .gb-title { font-size: 20px; }
  .readout { order: 3; flex: 1 1 100%; min-height: 0; padding: 2px 4px 4px; justify-content: flex-start; text-align: left; }
  .status { font-size: 14px; }
  .play, .play.stacked { flex-direction: column; flex: none; }
  .stage-wrap { flex: none; height: min(118vw, 70vh); }
  .play.stacked .code, .code { flex: none; height: 560px; min-height: 0; }
  .play.stacked .code.none, .code.none { height: auto; }   /* the map's panel: as tall as it is */
  .tool { width: 40px; height: 40px; }
  .tool svg { width: 31px; height: 31px; }
  .tb-set { border: 0; padding: 0; }
}
@media (max-width: 480px) {
  .gb-btn { width: 40px; padding: 0; justify-content: center; }
  .gb-btn span { display: none; }
}
@media (max-width: 760px) {
  body.pv-tool #mainContainer { display: block !important; }
  body.pv-tool #workspace { height: auto !important; max-height: none !important; overflow: visible !important; }
}
