*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --font-ui: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", system-ui, -apple-system, sans-serif;
  --font-round: "Hiragino Maru Gothic ProN", "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  --ink: #23384d;
  --ink-soft: #5a6e82;
  --accent: #2f86c6;
  --warm: #d4561c;
  --bg: #9fb4c8;
  --round-bg: rgba(46, 74, 102, 0.72);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
}

body {
  font-family: var(--font-ui);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

p,
h1 {
  margin: 0;
}

button {
  font: inherit;
}

.app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.sky {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

/* Round buttons in the top corners. */
.home-link {
  position: absolute;
  top: calc(var(--safe-top) + 12px);
  left: calc(var(--safe-left) + 12px);
  z-index: 18;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(35, 56, 77, 0.15);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  color: #2b4c6b;
  box-shadow: 0 3px 10px rgba(20, 40, 60, 0.16);
  text-decoration: none;
  touch-action: manipulation;
}

.home-link svg {
  width: 24px;
  height: 24px;
  pointer-events: none;
}

.weather-button,
.help-toggle,
.sound-toggle {
  position: absolute;
  top: calc(var(--safe-top) + 12px);
  z-index: 18;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--round-bg);
  color: #fff;
  cursor: pointer;
  touch-action: manipulation;
}

.weather-button {
  left: calc(var(--safe-left) + 64px);
  color: #e8f3ff;
}

.weather-button svg,
.sound-toggle svg {
  width: 24px;
  height: 24px;
}

.weather-button svg {
  display: none;
}

.weather-button[data-weather="drizzle"] .icon-drizzle,
.weather-button[data-weather="heavy"] .icon-heavy,
.weather-button[data-weather="sunny"] .icon-sunny,
.weather-button[data-weather="night"] .icon-night {
  display: block;
}

.weather-button[data-weather="sunny"] {
  background: rgba(232, 140, 30, 0.85);
  color: #fff6c4;
}

.weather-button[data-weather="night"] {
  background: rgba(40, 52, 96, 0.85);
  color: #fff3b0;
}

.help-toggle {
  right: calc(var(--safe-right) + 64px);
  font-family: var(--font-round);
  font-size: 22px;
  font-weight: 900;
}

.sound-toggle {
  right: calc(var(--safe-right) + 12px);
}

.sound-toggle .icon-off,
.sound-toggle[aria-pressed="false"] .icon-on {
  display: none;
}

.sound-toggle[aria-pressed="false"] .icon-off {
  display: block;
}

/* Title and the weather, between the round buttons at the top. */
.head {
  position: absolute;
  top: calc(var(--safe-top) + 12px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 232px);
  text-align: center;
  color: #1e3a56;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
  pointer-events: none;
}

.title {
  font-family: var(--font-round);
  font-size: 19px;
  font-weight: 900;
  line-height: 1.2;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.weather-name {
  margin-top: 2px;
  font-size: 13px;
  font-weight: 800;
}

.is-night .head {
  color: #f1f5ff;
  text-shadow: 0 1px 0 rgba(10, 20, 50, 0.8);
}

.toast {
  position: absolute;
  top: calc(var(--safe-top) + 76px);
  left: 50%;
  z-index: 8;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.5;
  text-align: center;
  word-break: keep-all;
  overflow-wrap: anywhere;
  box-shadow: 0 6px 18px rgba(20, 40, 60, 0.2);
  opacity: 0;
  transform: translate(-50%, -6px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Pens and tools along the bottom. */
.toolbar {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 10px);
  z-index: 10;
  display: flex;
  gap: 10px;
  align-items: center;
  max-width: calc(100% - 16px);
  padding: 6px 8px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.93);
  box-shadow: 0 6px 20px rgba(20, 40, 60, 0.22);
  transform: translateX(-50%);
}

.tool-group {
  display: flex;
  gap: 2px;
}

.tool {
  display: grid;
  grid-template-rows: 26px auto;
  place-items: center;
  min-width: 44px;
  height: 52px;
  padding: 3px 2px 4px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  touch-action: manipulation;
}

.tool svg {
  width: 26px;
  height: 26px;
}

.tool span {
  font-size: 11px;
  font-weight: 800;
  line-height: 1.1;
  white-space: nowrap;
}

.tool[aria-pressed="true"] {
  background: #dcecf7;
  color: #0d5c95;
  box-shadow: inset 0 0 0 2px #7fb6de;
}

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

/* Sheets */
.sheet {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--safe-top) + 16px) calc(var(--safe-right) + 16px) calc(var(--safe-bottom) + 16px) calc(var(--safe-left) + 16px);
  background: rgba(16, 32, 52, 0.55);
}

.sheet[hidden] {
  display: none;
}

.panel {
  width: min(100%, 380px);
  max-height: 100%;
  overflow-y: auto;
  padding: 20px 18px 16px;
  border-radius: 22px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  touch-action: pan-y;
}

.sheet-title {
  font-family: var(--font-round);
  font-size: 21px;
  font-weight: 900;
  text-align: center;
}

.sheet-note {
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.slot-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.slot {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 6px 4px 6px;
  border: 2px solid #d5e4ee;
  border-radius: 14px;
  background: #f4f9fc;
  color: var(--ink);
  font-family: var(--font-round);
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  touch-action: manipulation;
}

.slot canvas {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
}

.slot[aria-pressed="true"] {
  border-color: var(--accent);
  background: #e4f3fc;
  color: #0d5c95;
}

.sheet-actions,
.confirm-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 14px;
}

.sheet-actions[hidden] {
  display: none;
}

.clear-confirm {
  margin-top: 14px;
  padding: 12px;
  border-radius: 16px;
  background: #fff1e8;
  text-align: center;
}

.clear-confirm[hidden] {
  display: none;
}

.confirm-text {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.5;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.confirm-actions {
  margin-top: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 46px;
  padding: 10px 18px;
  border: 0;
  border-radius: 999px;
  font-family: var(--font-round);
  font-size: 16px;
  font-weight: 900;
  line-height: 1.3;
  cursor: pointer;
  touch-action: manipulation;
}

.btn svg {
  width: 22px;
  height: 22px;
}

.btn:active {
  transform: translateY(2px);
}

.btn-sub {
  background: #dfe9f0;
  color: var(--ink);
}

.btn-warm {
  background: #f08a4b;
  color: #fff;
  box-shadow: 0 4px 0 #c9652a;
}

.help-steps {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.help-steps li {
  position: relative;
  margin-top: 10px;
  padding-left: 34px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.6;
  counter-increment: step;
  /* Break at the spaces between words, so a short word is never split across lines. */
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.help-steps li::before {
  content: counter(step);
  position: absolute;
  top: 1px;
  left: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-round);
  font-size: 14px;
  font-weight: 900;
  line-height: 24px;
  text-align: center;
}

.help-steps strong {
  color: var(--warm);
}

.sheet-close {
  display: block;
  margin: 16px auto 0;
  padding: 10px 34px;
  border: 0;
  border-radius: 999px;
  background: #ffd84d;
  color: #5a3b00;
  font-family: var(--font-round);
  font-size: 16px;
  font-weight: 900;
  box-shadow: 0 4px 0 #d9a300;
  cursor: pointer;
}

/* Narrow phones: the seven tools still fit in one row. */
@media (max-width: 360px) {
  .toolbar {
    gap: 4px;
    padding: 5px 4px;
  }

  .tool {
    min-width: 40px;
  }

  .title {
    font-size: 16px;
  }
}

/* Short screens (phones held sideways): a smaller toolbar leaves room for the garden. */
@media (max-height: 520px) {
  .toolbar {
    bottom: calc(var(--safe-bottom) + 6px);
    padding: 3px 6px;
  }

  .tool {
    grid-template-rows: 24px;
    height: 40px;
  }

  /* The names stay readable to screen readers. */
  .tool span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .weather-name {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    transition: none;
  }
}

/* Focus outlines are turned off across the site. */
*:focus,
*:focus-visible,
*:focus-within {
  outline: none !important;
}
