:root {
  color-scheme: light;
  --ink: #21406f;
  --soft-ink: #697f8a;
  --paper: #fffefe;
  --panel: rgba(255, 255, 255, 0.82);
  --line: #d8e6dc;
  --leaf: #72ad62;
  --leaf-dark: #337b55;
  --carrot: #f28a3d;
  --rose: #f49aa0;
  --sky: #dff2ed;
  --sun: #f6cf6a;
  --blue-line: #255ab0;
  --shadow: 0 18px 44px rgba(76, 92, 88, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100svh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 16% 92%, rgba(244, 154, 160, 0.18), transparent 26%),
    radial-gradient(circle at 88% 18%, rgba(246, 207, 106, 0.22), transparent 28%),
    linear-gradient(180deg, rgba(223, 242, 237, 0.9), rgba(255, 254, 254, 0.98) 52%),
    var(--paper);
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.app {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: start center;
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}

.timer-shell {
  width: min(760px, 100%);
  display: grid;
  gap: 12px;
}

.title-screen {
  width: min(100%, calc((100svh - 16px) * 1158 / 1444));
  min-height: calc(100vh - 16px);
  min-height: calc(100svh - 16px);
  align-content: center;
}

.play-screen {
  align-content: start;
}

.topbar,
.controls,
.play-actions {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.topbar {
  position: relative;
  min-height: 0;
  aspect-ratio: 1042 / 774;
  padding: 0;
  display: block;
  overflow: hidden;
  border-color: rgba(231, 147, 154, 0.42);
  background: url("assets/header2.png") center / cover no-repeat;
}

.title-topbar {
  aspect-ratio: 1158 / 1444;
  background-image: url("assets/TOP.png");
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--soft-ink);
  font-size: 0.92rem;
  font-weight: 800;
}

h1 {
  margin: 0;
  line-height: 1;
  font-size: clamp(2rem, 5vw, 4rem);
  letter-spacing: 0;
}

.title-copy {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.time-display {
  position: absolute;
  left: 12.5%;
  right: 12.5%;
  bottom: 9.6%;
  min-width: 0;
  min-height: 0;
  height: 30%;
  padding: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  row-gap: 2%;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.time-display span {
  color: var(--blue-line);
  font-size: clamp(1.2rem, 4vw, 2.8rem);
  font-weight: 1000;
  line-height: 1;
}

.time-display strong {
  font-size: clamp(4.2rem, 16vw, 9.2rem);
  line-height: 0.86;
  color: var(--blue-line);
}

.scene-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border: 1px solid rgba(36, 54, 64, 0.12);
  border-radius: 8px;
  background: var(--sky);
  box-shadow: var(--shadow);
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.carrot-button {
  position: absolute;
  left: 50%;
  bottom: 18px;
  width: min(330px, 70%);
  aspect-ratio: 1066 / 628;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: url("assets/ninjin-ageru.png") center / contain no-repeat;
  cursor: pointer;
  filter: drop-shadow(0 10px 16px rgba(138, 86, 38, 0.2));
  transform: translateX(-50%);
}

.carrot-button span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.carrot-button:active {
  transform: translateX(-50%) translateY(1px);
}

.carrot-button:disabled {
  cursor: default;
  opacity: 0.82;
}

.controls {
  padding: 14px;
  display: grid;
  gap: 14px;
  align-items: stretch;
}

.title-controls {
  padding: 14px;
}

.play-actions {
  padding: 10px;
  display: grid;
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 10px;
  color: var(--soft-ink);
  font-size: 0.9rem;
  font-weight: 900;
}

.duration-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 4.8% 5.2%;
}

.title-duration-grid {
  position: absolute;
  left: 12.8%;
  right: 12.8%;
  top: 44.8%;
  height: 28.6%;
}

.duration-button {
  min-width: 0;
  min-height: 0;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0);
  color: transparent;
  font-size: 0;
  cursor: pointer;
}

.duration-button:focus-visible {
  outline: 4px solid rgba(37, 90, 176, 0.45);
  outline-offset: -4px;
}

.duration-button:active {
  background: rgba(255, 255, 255, 0.16);
}

.duration-button:disabled {
  cursor: default;
}

.start-button {
  width: 100%;
  min-height: 60px;
  font-size: 1.2rem;
}

.action-row {
  display: flex;
  gap: 8px;
}

.primary-button,
.secondary-button {
  min-width: 118px;
  min-height: 52px;
  padding: 0 18px;
  border-radius: 8px;
  font-weight: 1000;
  cursor: pointer;
}

.primary-button {
  border: 0;
  color: #ffffff;
  background: var(--blue-line);
}

.secondary-button {
  color: var(--blue-line);
  background: #ffffff;
  border: 2px solid rgba(37, 90, 176, 0.22);
}

button:active {
  transform: translateY(1px);
}

[hidden] {
  display: none !important;
}

@media (max-width: 719px) {
  .timer-shell {
    gap: 8px;
  }

  .play-screen {
    width: min(100%, 560px);
  }

  .play-topbar {
    border-radius: 6px;
  }

  .time-display {
    bottom: 8.4%;
    height: 31%;
  }

  .time-display span {
    font-size: clamp(0.95rem, 5vw, 1.4rem);
  }

  .time-display strong {
    font-size: clamp(3.2rem, 18vw, 5.8rem);
  }

  .scene-wrap {
    border-radius: 6px;
  }

  .carrot-button {
    bottom: max(10px, env(safe-area-inset-bottom));
    width: min(300px, 72%);
  }

  .play-actions {
    padding: 6px;
  }

  .secondary-button {
    min-height: 44px;
    font-size: 0.95rem;
  }
}

@media (max-width: 380px) {
  .app {
    padding: 6px;
  }

  .timer-shell {
    gap: 6px;
  }

  .secondary-button {
    min-height: 40px;
  }
}

@media (min-width: 720px) {
  .app {
    padding: 18px;
  }

  .timer-shell {
    gap: 14px;
  }
}
