/* Quack Attack: a bar on top, the game filling the space below, and the level maker's tools under it */
.quack-attack {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  background: #bfe6ff;
  color: #f4f1e8;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

.quack-attack [hidden] {
  display: none !important;
}

/* The bar */
.qa-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: #1f2a44;
  font: 600 0.95rem/1.2 system-ui, sans-serif;
}

.qa-name {
  font-weight: 800;
}

.qa-counts {
  color: #c3cbe0;
  font-variant-numeric: tabular-nums;
}

.qa-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-left: auto;
}

.qa-button {
  padding: 0.4rem 0.7rem;
  border: 1px solid #3c4a6b;
  border-radius: 8px;
  background: #2a3757;
  color: #f4f1e8;
  font: 600 0.9rem/1.1 system-ui, sans-serif;
  cursor: pointer;
}

.qa-button:hover {
  background: #344368;
}

.qa-button:disabled {
  opacity: 0.45;
  cursor: default;
}

.qa-sound.is-off {
  text-decoration: line-through;
  opacity: 0.6;
}

.qa-level-name {
  min-width: 10rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid #3c4a6b;
  border-radius: 8px;
  background: #141c30;
  color: #f4f1e8;
  font: 600 0.95rem/1.2 system-ui, sans-serif;
}

/* The game */
.qa-area {
  position: relative;
  flex: 1;
  min-height: 200px;
  overflow: hidden;
}

.qa-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}

.qa-editing .qa-canvas {
  cursor: crosshair;
}

.qa-status {
  position: absolute;
  bottom: 0.5rem;
  left: 50%;
  max-width: calc(100% - 1rem);
  margin: 0;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  background: rgb(31 42 68 / 0.78);
  color: #fff;
  font: 600 0.92rem/1.3 system-ui, sans-serif;
  text-align: center;
  pointer-events: none;
  transform: translateX(-50%);
  transition: opacity 0.3s;
}

.qa-status:empty {
  opacity: 0;
}

/* The level maker's tools */
.qa-tools {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem calc(0.6rem + env(safe-area-inset-bottom, 0px));
  background: #1f2a44;
}

.qa-tool-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
}

.qa-tool {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  align-items: center;
  min-width: 3.6rem;
  padding: 0.3rem 0.4rem;
  border: 2px solid #3c4a6b;
  border-radius: 10px;
  background: #2a3757;
  color: #f4f1e8;
  font: 600 0.75rem/1.1 system-ui, sans-serif;
  cursor: pointer;
}

.qa-tool canvas {
  width: 2.2rem;
  height: 1.6rem;
}

.qa-tool[aria-pressed="true"] {
  border-color: #ffc93c;
  background: #4a4227;
}

.qa-tool:disabled {
  opacity: 0.35;
  cursor: default;
}

@media (hover: none) and (pointer: coarse) {
  .qa-bar .qa-button span {
    display: none;
  }
}

/* Short screens (like sideways phones): all the tools in one strip that scrolls sideways */
@media (max-height: 560px) {
  .qa-tools {
    flex-direction: row;
    padding-top: 0.35rem;
    padding-bottom: calc(0.35rem + env(safe-area-inset-bottom, 0px));
    overflow-x: auto;
    scrollbar-width: none;
  }

  .qa-tool-row {
    flex: none;
    flex-wrap: nowrap;
  }

  .qa-tool {
    flex: none;
    min-width: 3.2rem;
    padding: 0.2rem 0.35rem;
    font-size: 0.68rem;
  }

  .qa-tool canvas {
    width: 1.8rem;
    height: 1.1rem;
  }

  .qa-actions .qa-button {
    align-self: center;
    white-space: nowrap;
  }
}

/* Narrow screens: each row of tools scrolls sideways */
@media (max-width: 560px) {
  .qa-tool-row {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .qa-tool {
    flex: none;
  }

  .qa-tool canvas {
    width: 1.8rem;
    height: 1.2rem;
  }
}

/* Screens over the game */
.qa-screen {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  padding: 1rem;
  overflow: auto;
  background: rgb(20 30 52 / 0.45);
}

.qa-panel {
  box-sizing: border-box;
  width: min(100%, 30rem);
  margin: auto; /* centred, but a tall panel scrolls from its top */
  padding: 1.3rem 1.6rem;
  border-radius: 16px;
  background: #fffaf0;
  color: #27304a;
  text-align: center;
  box-shadow: 0 10px 34px rgb(0 0 0 / 0.35);
  font: 400 1rem/1.45 system-ui, sans-serif;
}

.qa-panel-wide {
  width: min(100%, 40rem);
}

.qa-panel p {
  margin: 0.6em 0;
}

.quack-attack .qa-title {
  margin: 0 0 0.4em;
  color: #d9730d;
  font: 900 2rem/1.1 "Trebuchet MS", system-ui, sans-serif;
}

.quack-attack .qa-subtitle {
  margin: 1.2em 0 0.4em;
  color: #d9730d;
  font: 800 1.15rem/1.2 system-ui, sans-serif;
  text-align: left;
}

.quack-attack .qa-logo {
  margin: 0 0 0.3em;
  color: #f2b300;
  font: 900 3.2rem/1 "Trebuchet MS", system-ui, sans-serif;
  letter-spacing: -0.02em;
  text-shadow: 0 3px 0 #c97a00;
}

.qa-logo span {
  color: #2f7fd1;
  text-shadow: 0 3px 0 #1d5592;
}

.qa-tagline {
  color: #4f5872;
}

.qa-home-buttons,
.qa-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
  margin-top: 0.8rem;
}

.qa-home-buttons .btn {
  min-width: 8rem;
  justify-content: center;
  font-size: 1.1rem;
}

.qa-secondary {
  padding: 0.6em 1.1em;
  border: 2px solid #d9730d;
  border-radius: 999px;
  background: #fff;
  color: #b35c06;
  font: 700 0.95rem/1.2 system-ui, sans-serif;
  cursor: pointer;
}

.qa-secondary:hover {
  background: #fff1df;
}

.qa-link {
  padding: 0;
  border: 0;
  background: none;
  color: #b35c06;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.qa-progress {
  color: #4f5872;
  font-size: 0.92em;
}

/* Stars */
.qa-stars {
  display: flex;
  gap: 0.3rem;
  justify-content: center;
  font-size: 2.6rem;
  line-height: 1;
}

.qa-star {
  color: #d9d4c7;
}

.qa-star.is-on {
  color: #ffbf1f;
  text-shadow: 0 2px 0 #c98a00;
  animation: qa-star-pop 0.45s backwards;
}

.qa-star:nth-child(2) { animation-delay: 0.2s; }
.qa-star:nth-child(3) { animation-delay: 0.4s; }

@keyframes qa-star-pop {
  from {
    transform: scale(0.2) rotate(-40deg);
    opacity: 0;
  }
  70% {
    transform: scale(1.25);
  }
}

/* Choosing a level */
.qa-level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(5.4rem, 1fr));
  gap: 0.5rem;
}

.qa-level {
  position: relative;
  padding: 0.5rem 0.3rem 0.4rem;
  border: 2px solid #eadfc6;
  border-radius: 12px;
  background: #fff;
  color: #27304a;
  font: 800 1.2rem/1.1 system-ui, sans-serif;
  cursor: pointer;
}

.qa-level small {
  display: block;
  margin-top: 0.15rem;
  overflow: hidden;
  color: #7a8096;
  font-size: 0.66rem;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.qa-level .qa-level-stars {
  display: block;
  margin-top: 0.15rem;
  color: #d9d4c7;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
}

.qa-level .qa-level-stars b {
  color: #ffb000;
  font-weight: inherit;
}

.qa-level.is-done {
  border-color: #f2c14e;
  background: #fff8e3;
}

.qa-level.is-next {
  border-color: #2f7fd1;
  box-shadow: 0 0 0 2px #9cc8f2;
}

.qa-mine {
  display: grid;
  gap: 0.4rem;
  text-align: left;
}

.qa-mine-empty {
  color: #7a8096;
  font-size: 0.92em;
}

.qa-mine-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  padding: 0.45rem 0.6rem;
  border: 1px solid #eadfc6;
  border-radius: 10px;
  background: #fff;
}

.qa-mine-row strong {
  flex: 1;
  min-width: 8rem;
}

.qa-mine-row small {
  display: block;
  color: #7a8096;
  font-weight: 400;
}

.qa-mine-row button {
  padding: 0.3rem 0.65rem;
  border: 1px solid #e0d2b4;
  border-radius: 8px;
  background: #fffaf0;
  color: #27304a;
  font: 600 0.85rem/1.1 system-ui, sans-serif;
  cursor: pointer;
}

/* Choosing what to fling */
.qa-shot-list {
  display: grid;
  gap: 0.4rem;
  text-align: left;
}

.qa-shot-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  padding: 0.4rem 0.6rem;
  border: 1px solid #eadfc6;
  border-radius: 10px;
  background: #fff;
}

.qa-shot-row canvas {
  flex: none;
  width: 2rem;
  height: 2rem;
}

.qa-shot-row div {
  flex: 1;
}

.qa-shot-row small {
  display: block;
  color: #7a8096;
  font-size: 0.82em;
}

.qa-shot-row output {
  min-width: 1.4rem;
  font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.qa-step {
  width: 2rem;
  height: 2rem;
  border: 1px solid #e0d2b4;
  border-radius: 8px;
  background: #fffaf0;
  color: #27304a;
  font: 700 1.1rem/1 system-ui, sans-serif;
  cursor: pointer;
}

/* The order shots are flung in */
.qa-order {
  display: grid;
  gap: 0.3rem;
  margin: 0;
  padding: 0;
  list-style: none;
  text-align: left;
}

.qa-order li {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.3rem 0.5rem;
  border: 1px solid #eadfc6;
  border-radius: 10px;
  background: #fff;
}

.qa-order-n {
  min-width: 1.3rem;
  color: #7a8096;
  font-weight: 800;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.qa-order canvas {
  flex: none;
  width: 1.6rem;
  height: 1.6rem;
}

.qa-order strong {
  flex: 1;
}

.qa-order .qa-step {
  width: 1.8rem;
  height: 1.8rem;
  font-size: 0.95rem;
}

.qa-order .qa-step:disabled {
  opacity: 0.3;
  cursor: default;
}

.qa-order-empty {
  color: #7a8096;
  font-size: 0.92em;
}

/* Sharing */
.qa-share-link {
  width: 100%;
  box-sizing: border-box;
  padding: 0.55rem 0.7rem;
  border: 1px solid #e0d2b4;
  border-radius: 8px;
  background: #fff;
  color: #27304a;
  font: 0.85rem/1.4 ui-monospace, Menlo, Consolas, monospace;
}

.qa-copied {
  min-height: 1.2em;
  color: #2f8a4c;
  font-size: 0.9em;
}

.qa-how {
  margin: 0.6em 0 1em;
  padding: 0;
  list-style: none;
  text-align: left;
}

.qa-how li {
  margin: 0.45em 0;
}

.quack-attack kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0.05em 0.35em;
  border: 1px solid #d3c7ab;
  border-bottom-width: 2px;
  border-radius: 5px;
  background: #fff;
  color: #27304a;
  font: 600 0.82em/1.4 system-ui, sans-serif;
  text-align: center;
}

/* The levels screen's tabs and lists */
.qa-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  justify-content: center;
  margin-bottom: 0.8rem;
}

.qa-tab-button {
  padding: 0.45em 0.95em;
  border: 2px solid #eadfc6;
  border-radius: 999px;
  background: #fff;
  color: #4f5872;
  font: 700 0.92rem/1.2 system-ui, sans-serif;
  cursor: pointer;
}

.qa-tab-button[aria-selected="true"] {
  border-color: #d9730d;
  background: #d9730d;
  color: #fff;
}

.qa-list {
  display: grid;
  gap: 0.4rem;
  text-align: left;
}

.qa-search,
.qa-wide-input {
  box-sizing: border-box;
  width: 100%;
  margin-bottom: 0.6rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid #e0d2b4;
  border-radius: 10px;
  background: #fff;
  color: #27304a;
  font: 1rem/1.3 system-ui, sans-serif;
}

.qa-pager {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  justify-content: center;
  margin-top: 0.6rem;
  color: #7a8096;
  font-size: 0.9em;
}

.qa-subtitle small {
  margin-left: 0.4em;
  color: #7a8096;
  font-size: 0.8em;
  font-weight: 600;
}

.qa-note,
.qa-help {
  margin: 0.2em 0 0.6em;
  color: #4f5872;
  font-size: 0.92em;
  text-align: left;
}

.qa-note {
  padding: 0.6rem 0.8rem;
  border-radius: 10px;
  background: #fff1df;
}

.qa-note a {
  color: #b35c06;
  font-weight: 700;
}

.quack-attack .qa-error {
  min-height: 1.2em;
  color: #b23b2e;
  font-size: 0.92em;
}
