:root {
  color-scheme: light;
  --ink: #15365f;
  --ink-soft: #5b6f84;
  --paper: #fffefa;
  --yellow: #ffd84d;
  --grid: #7bd9f3;
  --button-shadow: 4px 4px 0 rgba(21, 54, 95, 0.94);
  --panel-shadow: 5px 5px 0 rgba(21, 54, 95, 0.9), 0 16px 36px rgba(21, 54, 95, 0.2);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  min-height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: #fff;
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  color: inherit;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  position: relative;
  width: 100vw;
  min-height: 100dvh;
  overflow: hidden;
}

#exerciseCanvas {
  position: fixed;
  inset: 0;
  display: block;
  width: 100vw;
  height: 100dvh;
  cursor: default;
  touch-action: none;
  user-select: none;
}

#exerciseCanvas:focus-visible,
button:focus-visible {
  outline: 3px solid #217fd3;
  outline-offset: 3px;
}

.floating-tools {
  position: fixed;
  left: clamp(14px, 2.2vw, 30px);
  bottom: clamp(14px, 2.4vw, 26px);
  z-index: 20;
  display: flex;
  max-width: calc(100vw - 28px);
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.tool-button,
.icon-button,
.pen-swatch {
  min-height: 48px;
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--button-shadow);
  cursor: pointer;
  font-weight: 1000;
  transition: transform 150ms ease, box-shadow 150ms ease, opacity 150ms ease;
}

.tool-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  font-size: 16px;
}

.icon-button {
  display: grid;
  width: 50px;
  height: 48px;
  place-items: center;
}

.tool-button:hover,
.icon-button:hover {
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 rgba(21, 54, 95, 0.94);
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
  transform: none;
}

.icon-button[aria-pressed="true"] {
  background: var(--yellow);
}

.icon-button svg {
  display: block;
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.25;
}

.reset-button {
  background: #ffe8e0;
}

.pen-cluster {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 48px;
  padding: 4px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--button-shadow);
}

.pen-cluster .icon-button,
.pen-cluster .pen-swatch {
  box-shadow: none;
}

.pen-cluster .icon-button:hover,
.pen-cluster .pen-swatch:hover {
  box-shadow: none;
}

.pen-swatch {
  width: 30px;
  height: 30px;
  min-height: 0;
  flex: 0 0 auto;
  padding: 0;
  border-radius: 50%;
}

.pen-swatch.red {
  background: #e84855;
}

.pen-swatch.green {
  background: #25a95f;
}

.pen-swatch.blue {
  background: #247ce8;
}

.pen-swatch.black {
  background: #202933;
}

.pen-swatch.is-selected {
  outline: 3px solid var(--yellow);
  outline-offset: 3px;
}

.help-button span {
  display: block;
  font-size: 25px;
  font-weight: 1000;
  line-height: 1;
}

.help-bubble {
  position: fixed;
  left: clamp(14px, 2.2vw, 30px);
  bottom: clamp(78px, 10vw, 92px);
  z-index: 30;
  width: min(390px, calc(100vw - 28px));
  padding: 16px 18px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--panel-shadow);
}

.pen-name-bubble {
  position: fixed;
  z-index: 31;
  padding: 9px 12px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--panel-shadow);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 1000;
  white-space: nowrap;
}

.help-bubble h1,
.help-bubble p {
  margin: 0;
}

.help-bubble h1 {
  margin-bottom: 10px;
  font-size: 18px;
  font-weight: 1000;
}

.help-bubble p {
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.65;
}

.help-bubble p + p {
  margin-top: 7px;
}

@media (max-width: 560px) {
  .floating-tools {
    gap: 8px;
  }

  .tool-button {
    min-height: 43px;
    padding: 0 14px;
    font-size: 14px;
  }

  .icon-button {
    width: 44px;
    height: 43px;
    min-height: 43px;
  }

  .pen-cluster {
    min-height: 43px;
    gap: 5px;
  }

  .pen-swatch {
    width: 26px;
    height: 26px;
  }
}
