:root {
  color-scheme: light;
  --ink: #1d2735;
  --muted: #5d6681;
  --card: rgba(255, 255, 255, 0.88);
  --theme-main: #35c88a;
  --theme-accent: #87f5ca;
  --theme-paste: #d9fff1;
  --shadow: 0 18px 44px rgba(31, 61, 96, 0.2);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  overflow: hidden;
  padding: 14px;
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Comic Sans MS", system-ui, sans-serif;
  background:
    radial-gradient(circle at 13% 12%, rgba(255, 227, 105, 0.84) 0 118px, transparent 120px),
    radial-gradient(circle at 86% 18%, rgba(117, 224, 255, 0.62) 0 104px, transparent 106px),
    radial-gradient(circle at 85% 88%, rgba(255, 130, 179, 0.44) 0 134px, transparent 136px),
    linear-gradient(135deg, #98e8ff 0%, #fff2a7 43%, #ffc5df 100%);
}

button {
  border: 0;
  color: inherit;
  cursor: pointer;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.game-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 210px;
  gap: 16px;
  width: min(1190px, calc(100vw - 28px));
  height: min(820px, calc(100vh - 28px));
}

.stage {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-width: 0;
  overflow: hidden;
  border: 5px solid rgba(255, 255, 255, 0.86);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.34)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.28) 0 24px, rgba(255, 255, 255, 0.1) 24px 48px);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 16px;
  background: rgba(255, 255, 255, 0.66);
  backdrop-filter: blur(12px);
}

.eyebrow {
  margin: 0 0 2px;
  color: #33628c;
  font-size: 0.78rem;
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.8rem, 4vw, 3.8rem);
  line-height: 0.94;
  letter-spacing: 0;
}

.shine-meter {
  display: grid;
  grid-template-columns: auto 118px auto;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  font-weight: 950;
  white-space: nowrap;
}

.meter-track {
  width: 118px;
  height: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: #d7edf7;
  box-shadow: inset 0 2px 4px rgba(19, 36, 58, 0.15);
}

.meter-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--theme-main), var(--theme-accent), #fff07a);
  transition: width 160ms ease;
}

.message-row {
  min-height: 44px;
  padding: 9px 16px 10px;
  background: rgba(255, 255, 255, 0.48);
}

.message-row p {
  color: #5c3f87;
  font-size: 1rem;
  font-weight: 900;
  line-height: 1.35;
}

.play-area {
  position: relative;
  min-height: 0;
}

#brushCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: none;
  touch-action: none;
}

.controls {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 12px;
  min-width: 0;
}

.control-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 8px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.control-card h2 {
  font-size: 1.05rem;
  font-weight: 950;
}

.brush-sets {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
}

.set-button {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-width: 0;
  min-height: 54px;
  padding: 8px;
  border: 3px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: inset 0 -4px 0 rgba(24, 43, 66, 0.1), 0 4px 0 rgba(24, 43, 66, 0.12);
  font-weight: 950;
  text-align: left;
}

.set-button.is-active {
  color: #fff;
  background: var(--set-main);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.17), 0 2px 0 rgba(24, 43, 66, 0.14);
  transform: translateY(2px);
}

.set-preview {
  position: relative;
  display: block;
  width: 42px;
  height: 34px;
  border-radius: 8px;
  background: var(--set-main);
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.13);
}

.set-preview::before {
  position: absolute;
  right: -3px;
  bottom: 4px;
  width: 20px;
  height: 14px;
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  background: var(--set-paste);
  content: "";
}

.set-preview::after {
  position: absolute;
  top: 5px;
  left: 5px;
  width: 14px;
  height: 20px;
  border-radius: 5px;
  background: var(--set-accent);
  content: "";
}

.set-button span:last-child {
  overflow: hidden;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.actions {
  grid-template-columns: 1fr;
}

.action-button {
  min-height: 50px;
  border-radius: 8px;
  color: #fff;
  background: #624de3;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.17), 0 5px 0 rgba(24, 43, 66, 0.16);
  font-weight: 950;
}

.action-button:active {
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.17), 0 2px 0 rgba(24, 43, 66, 0.16);
  transform: translateY(3px);
}

.rinse {
  background: #249ad8;
}

.tip-card {
  align-content: start;
}

.tip-card p {
  color: var(--muted);
  font-size: 0.97rem;
  font-weight: 850;
  line-height: 1.35;
}

@media (max-width: 760px) {
  body {
    align-items: start;
    display: block;
    overflow: auto;
    overflow-x: hidden;
    padding: 10px;
  }

  .game-shell {
    grid-template-columns: 1fr;
    width: min(100%, calc(100vw - 20px));
    height: auto;
    margin: 0 auto;
  }

  .stage {
    min-height: 620px;
  }

  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .shine-meter {
    align-self: stretch;
    grid-template-columns: auto minmax(88px, 1fr) auto;
    width: auto;
  }

  .meter-track {
    width: auto;
    min-width: 0;
  }

  .controls {
    grid-template-rows: auto;
  }

  .brush-sets {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .actions {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 560px) {
  .stage {
    min-height: 560px;
  }

  .brush-sets,
  .actions {
    grid-template-columns: 1fr;
  }

  .set-button {
    min-height: 50px;
  }
}
