/* Create By Asking: falling sand game (projects/falling-sand-game.html).
   Loaded after style.css, tools.css and advanced.css; reuses .adv-shell, .chip-dark and .icon-btn. */

.sd { gap: 12px; }
.sd kbd { font: 600 0.68rem/1 var(--mono); background: rgba(255, 255, 255, 0.1); border-radius: 4px; padding: 2px 5px; color: #E9E2FF; }

/* scenes */
.sd-scenes { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.sd-scene { border: 0; cursor: pointer; border-radius: 999px; padding: 8px 13px; background: rgba(255, 255, 255, 0.08); color: #E2DAFA; font: 600 var(--step--1)/1 var(--body); white-space: nowrap; transition: background 0.15s, transform 0.1s; }
.sd-scene:hover { background: rgba(255, 255, 255, 0.16); }
.sd-scene:active { transform: scale(0.97); }
.sd-scene[aria-pressed="true"] { background: #FFC93C; color: #1C0F3F; }
.sd-scene.is-challenge::after { content: "Challenge"; margin-left: 6px; font: 700 0.6rem/1 var(--mono); letter-spacing: 0.05em; text-transform: uppercase; background: #FF2E7E; color: #fff; padding: 2px 5px; border-radius: 4px; vertical-align: 1px; }

/* the play area: picture on the left, materials on the right */
.sd-play { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 14px; align-items: start; }
.sd-left { display: grid; gap: 12px; min-width: 0; }
.sd-stage { position: relative; border-radius: 14px; overflow: hidden; background: #1B1533; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 18px 40px -18px rgba(0, 0, 0, 0.7); display: grid; place-items: center; touch-action: none; user-select: none; -webkit-user-select: none; }
.sd-stage canvas { display: block; width: 100%; height: 100%; cursor: crosshair; touch-action: none; -webkit-tap-highlight-color: transparent; outline: none; }
.sd-stage canvas:focus-visible { box-shadow: inset 0 0 0 3px #FFC93C; }
.sd-stage:fullscreen { background: #000; border-radius: 0; aspect-ratio: auto !important; width: 100vw; height: 100vh; }
.sd-stage:-webkit-full-screen { background: #000; border-radius: 0; width: 100vw; height: 100vh; }

.sd-hint { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); font: 700 0.9rem/1 var(--body); color: #fff; background: rgba(12, 6, 30, 0.72); padding: 10px 16px; border-radius: 99px; pointer-events: none; white-space: nowrap; box-shadow: 0 6px 20px -8px #000; animation: sd-bob 2.2s ease-in-out infinite; }
.sd-hint[hidden] { display: none; }
@keyframes sd-bob { 50% { transform: translate(-50%, -5px); } }
.sd-count { position: absolute; left: 10px; bottom: 9px; font: 600 0.7rem/1 var(--mono); color: rgba(255, 255, 255, 0.55); pointer-events: none; text-shadow: 0 1px 2px #000; }
.sd-float { position: absolute; right: 10px; top: 10px; display: flex; gap: 6px; }
.sd-float .icon-btn { background: rgba(12, 6, 30, 0.6); backdrop-filter: blur(6px); }
.sd-float .icon-btn:hover { background: rgba(12, 6, 30, 0.85); }

.sd-banner { position: absolute; left: 10px; right: 96px; top: 10px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: rgba(12, 6, 30, 0.78); backdrop-filter: blur(8px); color: #F2ECFF; border-radius: 12px; padding: 9px 12px; font: 500 0.88rem/1.35 var(--body); box-shadow: 0 8px 24px -12px #000; }
.sd-banner[hidden] { display: none; }
.sd-banner p { flex: 1 1 220px; margin: 0; }
.sd-act { border: 0; cursor: pointer; border-radius: 999px; padding: 7px 14px; background: #FFC93C; color: #1C0F3F; font: 800 0.88rem/1 var(--body); white-space: nowrap; }
.sd-act:hover { background: #FFD766; }
.sd-x { border: 0; background: none; color: #A597CC; font-size: 1.2rem; line-height: 1; cursor: pointer; padding: 2px 4px; }
.sd-x:hover { color: #fff; }

.sd-toast { position: absolute; left: 50%; bottom: 40px; transform: translate(-50%, 8px); max-width: calc(100% - 24px); background: #FFC93C; color: #1C0F3F; font: 700 0.85rem/1.3 var(--body); padding: 9px 14px; border-radius: 10px; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; text-align: center; }
.sd-toast.on { opacity: 1; transform: translate(-50%, 0); }

.sd-help { position: absolute; inset: 10px; overflow: auto; background: rgba(12, 6, 30, 0.93); backdrop-filter: blur(8px); border-radius: 12px; padding: 16px 18px; color: #E2DAFA; font-size: 0.88rem; }
.sd-help[hidden] { display: none; }
.sd-help h3 { font: 800 1.1rem/1.1 var(--display); color: #FFC93C; margin-bottom: 10px; }
.sd-help dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px 18px; margin: 0; }
.sd-help dl div { display: flex; gap: 8px; align-items: baseline; }
.sd-help dt { min-width: 64px; }
.sd-help dd { margin: 0; color: #CBBFE8; }
.sd-help .sd-x { position: absolute; right: 10px; top: 8px; }

/* materials */
.sd-side { display: grid; gap: 10px; }
.sd-mats { display: grid; gap: 8px; }
.sd-grp { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.sd-gl { grid-column: 1 / -1; font: 600 0.64rem/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: #A597CC; padding: 2px 0 1px; }
.sd-mat { position: relative; display: flex; align-items: center; gap: 6px; min-width: 0; border: 0; cursor: pointer; border-radius: 8px; padding: 5px 6px; background: rgba(255, 255, 255, 0.06); color: #E2DAFA; font: 600 0.74rem/1.1 var(--body); text-align: left; transition: background 0.12s; }
.sd-mat:hover { background: rgba(255, 255, 255, 0.13); }
.sd-mat[aria-pressed="true"] { background: rgba(255, 201, 60, 0.18); color: #fff; box-shadow: inset 0 0 0 2px #FFC93C; }
.sd-sw { flex: none; width: 18px; height: 18px; border-radius: 5px; background-size: cover; image-rendering: pixelated; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18); }
.sd-nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sd-mat kbd { position: absolute; right: 3px; top: 2px; font-size: 0.55rem; padding: 1px 3px; opacity: 0.6; }
.sd-info { margin: 0; min-height: 3.6em; font-size: 0.84rem; line-height: 1.4; color: #CBBFE8; background: rgba(255, 255, 255, 0.05); border-radius: 10px; padding: 8px 10px; }
.sd-info b { color: #FFC93C; margin-right: 4px; }

/* control bars */
.sd-bars { display: grid; gap: 10px; }
.sd-bar { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.sd-bar .adv-group { gap: 5px; }
.sd .chip-dark { padding: 7px 11px; white-space: nowrap; }
.sd .chip-dark:disabled { opacity: 0.4; cursor: default; }
.sd .chip-dark:not(:disabled):hover { background: rgba(255, 255, 255, 0.16); }
.sd .chip-dark[aria-pressed="true"]:hover { background: #FFD766; }
.sd .adv-range input { width: 100px; }
.sd .adv-range output { min-width: 2.6em; }
.sd-sep { width: 1px; align-self: stretch; background: rgba(255, 255, 255, 0.1); }
.sd-note { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; justify-content: space-between; }
.sd-check { display: inline-flex; align-items: center; gap: 7px; font-size: var(--step--1); color: #CBBFE8; cursor: pointer; }
.sd-check input { accent-color: #FFC93C; width: 16px; height: 16px; }

@media (max-width: 860px) {
  .sd-play { grid-template-columns: minmax(0, 1fr); }
  .sd-left { display: contents; }
  .sd-stage { order: 1; }
  .sd-side { order: 2; }
  .sd-bars { order: 3; }
  .sd-mats { display: flex; gap: 10px; overflow-x: auto; overscroll-behavior-x: contain; padding-bottom: 6px; scroll-snap-type: x proximity; scrollbar-width: thin; }
  .sd-grp { display: flex; gap: 4px; flex: none; align-items: stretch; }
  .sd-gl { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 0.58rem; padding: 0 2px; text-align: center; }
  .sd-mat { flex-direction: column; justify-content: center; width: 66px; padding: 7px 3px 6px; gap: 5px; text-align: center; scroll-snap-align: start; font-size: 0.68rem; }
  .sd-sw { width: 28px; height: 28px; border-radius: 7px; }
  .sd-nm { white-space: normal; line-height: 1.05; max-width: 100%; }
  .sd-mat kbd { display: none; }
  .sd-info { min-height: 0; }
}
@media (max-width: 560px) {
  .sd-scenes { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .sd-scenes::-webkit-scrollbar { display: none; }
  .sd-scenes .adv-label { display: none; }
  .sd-banner { right: 10px; top: 52px; font-size: 0.8rem; padding: 7px 10px; }
  .sd-bar { gap: 8px 10px; }
  .sd .adv-range input { width: 84px; }
  .sd-sep { display: none; }
  .sd-hint { font-size: 0.8rem; }
}
@media (hover: none) { .sd-mat kbd, [data-keys-only] { display: none !important; } }
