:root {
  color-scheme: light;
  font-family: "Arial Rounded MT Bold", "Hiragino Maru Gothic ProN", "Yu Gothic", system-ui, sans-serif;
  color: #302841;
  background: #efe9dc;
  font-synthesis: none;
  --ink: #302841;
  --coral: #ed6b69;
  --gold: #f2bd4f;
  --blue: #63afc4;
  --paper: #fffaf0;
  --paper-deep: #f4eddf;
  --green: #4e9b79;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: #efe9dc;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 14% 4%, rgba(242, 189, 79, 0.26), transparent 26rem),
    radial-gradient(circle at 90% 34%, rgba(99, 175, 196, 0.18), transparent 30rem),
    repeating-linear-gradient(0deg, rgba(48, 40, 65, 0.018) 0 1px, transparent 1px 5px),
    #efe9dc;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

button:focus-visible,
a:focus-visible,
canvas:focus-visible {
  outline: 4px solid rgba(99, 175, 196, 0.62);
  outline-offset: 3px;
}

.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 42px;
  border-bottom: 2px solid rgba(48, 40, 65, 0.16);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-decoration: none;
}

.brand-crayon {
  position: relative;
  width: 30px;
  height: 9px;
  border: 2px solid var(--ink);
  border-radius: 3px 7px 7px 3px;
  background: var(--coral);
  transform: rotate(-8deg);
}

.brand-crayon::after {
  position: absolute;
  top: 1px;
  right: -7px;
  width: 0;
  height: 0;
  border-top: 3px solid transparent;
  border-bottom: 3px solid transparent;
  border-left: 7px solid var(--ink);
  content: "";
}

.challenge-number {
  color: rgba(48, 40, 65, 0.62);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.game-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 36px;
  padding: 34px 0 24px;
}

.eyebrow,
.overlay-kicker {
  margin: 0 0 8px;
  color: var(--coral);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.18em;
}

h1,
h2,
p,
dl,
dd {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(2.6rem, 7vw, 5.6rem);
  line-height: 0.9;
  letter-spacing: -0.08em;
}

.tagline {
  margin-bottom: 0;
  color: rgba(48, 40, 65, 0.72);
  font-size: 0.94rem;
  font-weight: 700;
}

.meters {
  display: grid;
  grid-template-columns: repeat(3, minmax(72px, 1fr));
  min-width: min(340px, 42vw);
  margin-bottom: 0;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: var(--paper);
  box-shadow: 5px 5px 0 rgba(48, 40, 65, 0.16);
}

.meters div {
  padding: 10px 14px;
  border-right: 1px dashed rgba(48, 40, 65, 0.3);
}

.meters div:last-child {
  border-right: 0;
}

.meters dt {
  margin-bottom: 3px;
  color: rgba(48, 40, 65, 0.55);
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.13em;
}

.meters dd {
  margin-bottom: 0;
  font-size: clamp(1.1rem, 2.2vw, 1.65rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.floating-play-hud {
  position: fixed;
  z-index: 100;
  top: 12px;
  right: max(12px, calc((100vw - 1180px) / 2));
  display: grid;
  grid-template-columns: 76px minmax(82px, 1fr);
  gap: 9px;
  width: 178px;
  padding: 8px;
  border: 2px solid var(--ink);
  border-radius: 15px;
  background: rgba(255, 250, 240, 0.96);
  box-shadow: 5px 6px 0 rgba(48, 40, 65, 0.24);
  pointer-events: none;
}

.floating-play-hud.is-hidden {
  display: none;
}

#floating-target-canvas {
  display: block;
  width: 76px;
  height: 76px;
  border: 1px dashed rgba(48, 40, 65, 0.34);
  border-radius: 9px;
  background: var(--paper);
}

.floating-time-block {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  line-height: 1;
}

.floating-label,
.floating-cat-name {
  overflow: hidden;
  color: rgba(48, 40, 65, 0.6);
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.floating-time-block strong {
  display: flex;
  align-items: baseline;
  gap: 2px;
  margin: 3px 0 5px;
  font-size: 2rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.08em;
}

.floating-time-block small {
  font-size: 0.66rem;
  letter-spacing: 0;
}

.floating-play-hud.is-urgent {
  border-color: var(--coral);
  background: rgba(255, 240, 228, 0.98);
}

.floating-play-hud.is-urgent .floating-time-block strong {
  color: var(--coral);
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(240px, 0.54fr) minmax(450px, 1fr);
  align-items: start;
  gap: 18px;
}

.reference-panel,
.drawing-panel {
  min-width: 0;
}

.reference-panel {
  padding: 18px;
  border: 2px solid var(--ink);
  border-radius: 18px;
  background: rgba(255, 250, 240, 0.82);
  box-shadow: 6px 7px 0 rgba(48, 40, 65, 0.14);
}

.panel-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.step-label,
.tool-label {
  display: block;
  margin-bottom: 4px;
  color: rgba(48, 40, 65, 0.54);
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.panel-heading h2 {
  margin-bottom: 0;
  font-size: 1.35rem;
}

.target-note {
  color: var(--coral);
  font-size: 0.68rem;
  font-weight: 900;
}

#target-canvas {
  display: block;
  width: 100%;
  height: auto;
  border: 2px dashed rgba(48, 40, 65, 0.24);
  border-radius: 14px;
  background: var(--paper);
}

.score-guide {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.score-guide span {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 7px;
  padding: 10px;
  border-radius: 10px;
  background: var(--paper-deep);
  font-size: 0.74rem;
  font-weight: 900;
}

.score-guide b {
  font-size: 1.25rem;
}

.drawing-panel {
  display: grid;
  gap: 10px;
}

.canvas-shell {
  position: relative;
  width: 100%;
  overflow: hidden;
  border: 3px solid var(--ink);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: 8px 9px 0 rgba(48, 40, 65, 0.16);
}

#drawing-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  cursor: pointer;
  touch-action: none;
  user-select: none;
}

.canvas-shell.is-painted {
  animation: paint-pop 180ms ease-out;
}

@keyframes paint-pop {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(0.996); }
}

.canvas-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(255, 250, 240, 0.86);
  backdrop-filter: blur(3px);
}

.canvas-overlay.is-hidden {
  display: none;
}

.overlay-card {
  width: min(430px, 92%);
  padding: clamp(18px, 4vw, 30px);
  border: 2px solid var(--ink);
  border-radius: 17px 20px 14px 22px;
  background: var(--paper);
  box-shadow: 8px 9px 0 rgba(48, 40, 65, 0.2);
  text-align: center;
  transform: rotate(-0.45deg);
}

.overlay-card h2 {
  margin-bottom: 14px;
  font-size: clamp(1.65rem, 5vw, 2.7rem);
  line-height: 1.05;
  letter-spacing: -0.05em;
}

.intro-instructions {
  display: grid;
  gap: 6px;
  margin-bottom: 17px;
  text-align: left;
}

.intro-instructions p {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 0;
  font-size: 0.83rem;
  font-weight: 800;
}

.intro-instructions span {
  display: grid;
  width: 27px;
  height: 27px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: var(--paper);
  background: var(--ink);
  font-size: 0.62rem;
}

.primary-button {
  min-width: min(250px, 100%);
  min-height: 48px;
  padding: 12px 24px;
  border: 2px solid var(--ink);
  border-radius: 11px;
  color: var(--ink);
  background: var(--gold);
  box-shadow: 4px 5px 0 var(--ink);
  font-weight: 900;
  cursor: pointer;
  transition: transform 110ms ease, box-shadow 110ms ease;
}

.primary-button:hover {
  transform: translate(-1px, -1px);
  box-shadow: 6px 7px 0 var(--ink);
}

.primary-button:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 2px 0 var(--ink);
}

.small-note {
  margin: 13px 0 0;
  color: rgba(48, 40, 65, 0.62);
  font-size: 0.69rem;
  line-height: 1.5;
}

.result-message {
  min-height: 2.7em;
  margin-bottom: 14px;
  color: rgba(48, 40, 65, 0.72);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.5;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 18px;
}

.result-grid div {
  padding: 8px 4px;
  border-radius: 9px;
  background: var(--paper-deep);
}

.result-grid dt {
  color: rgba(48, 40, 65, 0.54);
  font-size: 0.58rem;
  font-weight: 900;
}

.result-grid dd {
  margin-bottom: 0;
  font-size: 1.25rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.bucket-box {
  padding: 11px;
  border: 2px solid var(--ink);
  border-radius: 15px;
  background: rgba(255, 250, 240, 0.84);
}

.bucket-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.bucket-heading .tool-label {
  margin-bottom: 2px;
}

.bucket-heading h2 {
  margin-bottom: 0;
  font-size: 1rem;
}

.bucket-note {
  color: rgba(48, 40, 65, 0.62);
  font-size: 0.64rem;
  font-weight: 900;
}

.bucket-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.bucket-button {
  display: flex;
  min-width: 0;
  min-height: 56px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 7px 8px;
  border: 2px solid transparent;
  border-radius: 11px;
  color: var(--ink);
  background: var(--paper-deep);
  font-size: 0.72rem;
  font-weight: 900;
  cursor: pointer;
}

.bucket-button.is-selected {
  border-color: var(--ink);
  background: var(--paper);
  box-shadow: 3px 4px 0 rgba(48, 40, 65, 0.25);
  transform: translateY(-1px);
}

.bucket-swatch {
  position: relative;
  display: block;
  width: 31px;
  height: 25px;
  flex: 0 0 auto;
  border: 2px solid var(--ink);
  border-radius: 3px 3px 8px 8px;
}

.bucket-swatch::before {
  position: absolute;
  left: 4px;
  top: -9px;
  width: 19px;
  height: 13px;
  border: 2px solid var(--ink);
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
  content: "";
}

.bucket-button[data-bucket="red"] .bucket-swatch { background: #ed6b69; }
.bucket-button[data-bucket="yellow"] .bucket-swatch { background: #f2bd4f; }
.bucket-button[data-bucket="blue"] .bucket-swatch { background: #63afc4; }
.bucket-button[data-bucket="water"] .bucket-swatch {
  background: repeating-linear-gradient(-45deg, #d7eef1 0 6px, #fffaf0 6px 11px);
}

.mix-recipes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 9px;
}

.mix-recipes span {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 7px 4px;
  border-radius: 8px;
  background: var(--paper-deep);
  font-size: 0.61rem;
}

.mix-recipes b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recipe-dot {
  display: inline-block;
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  border: 1px solid rgba(48, 40, 65, 0.35);
  border-radius: 50%;
}

.recipe-dot.is-red { background: #ed6b69; }
.recipe-dot.is-yellow { background: #f2bd4f; }
.recipe-dot.is-blue { background: #63afc4; }
.recipe-dot.is-orange { background: #ed954f; }
.recipe-dot.is-green { background: #70a978; }
.recipe-dot.is-purple { background: #9277b5; }

.status-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 34px;
  padding: 2px 4px;
}

.status-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(78, 155, 121, 0.16);
}

.status-row p {
  margin-bottom: 0;
  color: rgba(48, 40, 65, 0.76);
  font-size: 0.73rem;
  font-weight: 700;
}

.game-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 2px 0;
  color: rgba(48, 40, 65, 0.54);
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

@media (max-width: 860px) {
  .game-heading {
    align-items: stretch;
  }

  .game-layout {
    grid-template-columns: 1fr;
  }

  .reference-panel {
    display: grid;
    grid-template-columns: minmax(130px, 190px) 1fr;
    align-items: center;
    gap: 14px;
  }

  .reference-panel .panel-heading {
    align-self: end;
    margin-bottom: 0;
  }

  .reference-panel #target-canvas {
    grid-row: 1 / span 2;
  }

  .reference-panel .score-guide {
    align-self: start;
    margin-top: 0;
  }
}

@media (max-width: 620px) {
  .page-shell {
    width: min(100% - 20px, 560px);
    padding-top: 14px;
  }

  .topbar {
    min-height: 36px;
  }

  .brand {
    font-size: 0.62rem;
    letter-spacing: 0.09em;
  }

  .challenge-number {
    font-size: 0.56rem;
  }

  .game-heading {
    display: grid;
    gap: 16px;
    padding: 24px 0 18px;
  }

  h1 {
    font-size: clamp(2.75rem, 15vw, 4.4rem);
  }

  .meters {
    width: 100%;
    min-width: 0;
  }

  .meters div {
    padding: 8px 12px;
  }

  .reference-panel {
    grid-template-columns: 112px 1fr;
    padding: 12px;
  }

  .panel-heading {
    display: block;
  }

  .target-note {
    display: block;
    margin-top: 6px;
  }

  .score-guide {
    gap: 5px;
  }

  .score-guide span {
    padding: 7px 4px;
    font-size: 0.62rem;
  }

  .score-guide b {
    font-size: 1rem;
  }

  .floating-play-hud {
    top: 8px;
    right: 8px;
    grid-template-columns: 62px minmax(68px, 1fr);
    gap: 7px;
    width: 150px;
    padding: 6px;
    border-radius: 12px;
    box-shadow: 3px 4px 0 rgba(48, 40, 65, 0.22);
  }

  #floating-target-canvas {
    width: 62px;
    height: 62px;
    border-radius: 7px;
  }

  .floating-time-block strong {
    margin: 2px 0 3px;
    font-size: 1.6rem;
  }

  .floating-label,
  .floating-cat-name {
    font-size: 0.5rem;
  }

  .canvas-shell {
    border-radius: 14px;
    box-shadow: 5px 6px 0 rgba(48, 40, 65, 0.16);
  }

  .canvas-overlay {
    padding: 10px;
  }

  .overlay-card {
    width: min(94%, 360px);
    padding: 15px 14px;
    box-shadow: 5px 6px 0 rgba(48, 40, 65, 0.2);
  }

  .overlay-card h2 {
    margin-bottom: 9px;
    font-size: clamp(1.35rem, 7vw, 2rem);
  }

  .overlay-kicker {
    margin-bottom: 5px;
    font-size: 0.51rem;
  }

  .intro-instructions {
    gap: 3px;
    margin-bottom: 10px;
  }

  .intro-instructions p {
    gap: 7px;
    font-size: 0.69rem;
  }

  .intro-instructions span {
    width: 22px;
    height: 22px;
    font-size: 0.52rem;
  }

  .primary-button {
    min-height: 44px;
    padding: 9px 16px;
    font-size: 0.8rem;
  }

  .small-note {
    margin-top: 8px;
    font-size: 0.58rem;
  }

  .result-message {
    min-height: 0;
    margin-bottom: 8px;
    font-size: 0.68rem;
  }

  .result-grid {
    margin-bottom: 10px;
  }

  .result-grid div {
    padding: 5px 2px;
  }

  .result-grid dd {
    font-size: 1rem;
  }

  .bucket-box {
    padding: 8px;
  }

  .bucket-heading {
    margin-bottom: 7px;
  }

  .bucket-heading h2 {
    font-size: 0.85rem;
  }

  .bucket-note {
    font-size: 0.54rem;
  }

  .bucket-row {
    gap: 5px;
  }

  .bucket-button {
    min-height: 54px;
    flex-direction: column;
    gap: 3px;
    padding: 5px 2px;
    font-size: 0.62rem;
  }

  .bucket-swatch {
    width: 27px;
    height: 21px;
  }

  .bucket-swatch::before {
    left: 3px;
    width: 17px;
  }

  .mix-recipes {
    gap: 4px;
    margin-top: 7px;
  }

  .mix-recipes span {
    gap: 2px;
    padding: 6px 2px;
    font-size: 0.5rem;
  }

  .recipe-dot {
    width: 10px;
    height: 10px;
  }

  .game-footer {
    display: grid;
    gap: 5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
