﻿:root {
  --bg: #edf3fb;
  --ink: #112132;
  --muted: #4f6478;
  --card: #ffffff;
  --line: #c8d7e8;
  --accent: #1f6feb;
  --accent-strong: #0f4fc3;
  --month-active: #f97316;
  --month-active-border: #9a3412;
  --month-active-ring: rgba(249, 115, 22, 0.28);
  --shadow: 0 12px 30px rgba(24, 45, 74, 0.12);
  --scene-bg: linear-gradient(90deg, #0f4fc3, #1f6feb);
  --scene-ink: #ffffff;
}

html[data-theme='dark'] {
  --bg: #0b1324;
  --ink: #dbe7ff;
  --muted: #9cb0d1;
  --card: #111b2e;
  --line: #273853;
  --accent: #5b9bff;
  --accent-strong: #3d7ee7;
  --month-active: #fb923c;
  --month-active-border: #fdba74;
  --month-active-ring: rgba(251, 146, 60, 0.35);
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
  --scene-bg: linear-gradient(90deg, #2563eb, #3b82f6);
  --scene-ink: #f8fbff;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: 'Segoe UI', 'Inter', Arial, sans-serif;
  color: var(--ink);
  min-height: 100dvh;
  overscroll-behavior: none;
  background:
    radial-gradient(circle at 12% 12%, rgba(89, 141, 232, 0.2) 0%, transparent 40%),
    radial-gradient(circle at 88% 20%, rgba(111, 169, 245, 0.18) 0%, transparent 45%),
    var(--bg);
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: clamp(12px, 2.4vw, 24px);
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.panel,
.preview {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

h1 {
  margin: 0;
  font-size: 30px;
}

.mds-trigger {
  display: inline-block;
  padding: 0 5px;
  border-radius: 9px;
  cursor: pointer;
  user-select: none;
  transition: transform 120ms ease, background-color 120ms ease;
}

.mds-trigger:hover {
  background: color-mix(in srgb, var(--accent) 17%, transparent);
}

.mds-trigger:active {
  transform: scale(0.94);
}

h2 {
  margin: 0 0 10px;
}

form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 700;
}

input {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 16px;
  color: var(--ink);
  background: transparent;
}

input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 24%, transparent);
}

.name-input-wrap {
  position: relative;
}

.name-input-wrap input {
  width: 100%;
  padding-right: 34px;
}

.dog-runner {
  position: absolute;
  left: 8px;
  top: 64%;
  transform: translateY(-50%);
  font-size: 16px;
  line-height: 1;
  pointer-events: none;
  opacity: 0;
  user-select: none;
}

.dog-runner.run {
  animation: dog-run-once 4.2s linear 1;
}

.bolt-rain {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  display: none;
  z-index: 9999;
}

.bolt-rain.active {
  display: block;
}

.bolt-particle {
  position: absolute;
  top: -40px;
  left: 0;
  width: 24px;
  height: 24px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  will-change: transform, opacity;
  filter: drop-shadow(0 5px 4px rgba(0, 0, 0, 0.26));
  animation-name: bolt-fall;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

.bolt-particle.is-bolt {
  width: 18px;
  height: 74px;
}

.bolt-particle.is-bolt::before,
.bolt-particle.is-bolt::after {
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.bolt-particle.is-bolt::before {
  top: 0;
  width: 22px;
  height: 12px;
  clip-path: polygon(20% 0, 80% 0, 100% 50%, 80% 100%, 20% 100%, 0 50%);
  background: linear-gradient(90deg, #7b8795, #d2d8df 48%, #7b8795);
}

.bolt-particle.is-bolt::after {
  top: 8px;
  width: 8px;
  height: 64px;
  border-radius: 6px;
  background:
    repeating-linear-gradient(
      to bottom,
      #cdd4dc 0 2px,
      #8894a1 2px 4px
    );
}

.bolt-particle.is-nut {
  width: 28px;
  height: 28px;
  border: 6px solid #c4ccd5;
  border-radius: 4px;
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
  background: rgba(255, 255, 255, 0.08);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.35),
    inset 0 0 10px rgba(0, 0, 0, 0.2);
}

.bolt-particle.is-hammer {
  width: 96px;
  height: 96px;
}

@keyframes bolt-fall {
  0% {
    transform: translate3d(0, -24px, 0) rotate(0deg);
    opacity: 0;
  }

  8% {
    opacity: 1;
  }

  100% {
    transform: translate3d(var(--drift, 0px), 110vh, 0) rotate(var(--spin, 540deg));
    opacity: 0.95;
  }
}

@keyframes dog-run-once {
  0% {
    left: 10px;
    transform: translateY(-50%) scaleX(1);
    opacity: 0;
  }

  12% {
    opacity: 0.95;
  }

  48% {
    left: calc(100% - 32px);
    transform: translateY(-50%) scaleX(1);
    opacity: 0.95;
  }

  52% {
    left: calc(100% - 32px);
    transform: translateY(-50%) scaleX(-1);
    opacity: 0.95;
  }

  90% {
    opacity: 0.95;
  }

  100% {
    left: 10px;
    transform: translateY(-50%) scaleX(-1);
    opacity: 0;
  }
}

.scene-button {
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  text-align: center;
  font-size: 15px;
  font-weight: 800;
  text-decoration: none;
  color: var(--scene-ink);
  background: var(--scene-bg);
  box-shadow: 0 8px 18px rgba(27, 92, 196, 0.35);
}

.scene-button,
.theme-toggle,
.sheet-btn,
button,
input {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.theme-toggle {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
}

.theme-toggle:hover {
  border-color: var(--accent);
}

.sheet-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.sheet-btn {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 10px 14px;
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
}

.sheet-btn:hover {
  border-color: var(--accent);
}

.sheet-btn.active {
  border-color: var(--month-active-border);
  background: var(--month-active);
  color: #fff;
  box-shadow: 0 0 0 3px var(--month-active-ring);
}

button[type='submit'],
.save-button {
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
}

button[type='submit']:disabled,
.save-button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.status {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
}

.status.error {
  color: #dc2626;
}

#calendarImage {
  width: 100%;
  display: block;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--card) 82%, #9bb8e9 18%);
  min-height: 260px;
  object-fit: contain;
}

@media (max-width: 920px) {
  html,
  body {
    overflow: hidden;
  }

  body {
    overscroll-behavior: none;
  }

  .page {
    max-width: none;
    height: 100dvh;
    min-height: 100dvh;
    padding:
      calc(8px + env(safe-area-inset-top))
      calc(8px + env(safe-area-inset-right))
      calc(8px + env(safe-area-inset-bottom))
      calc(8px + env(safe-area-inset-left));
    gap: 8px;
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    overflow: hidden;
  }

  .panel,
  .preview {
    min-height: 0;
    padding: 12px;
    border-radius: 14px;
  }

  .panel {
    display: flex;
    flex-direction: column;
  }

  .preview {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  h1 {
    font-size: 24px;
  }

  h2 {
    font-size: 18px;
    margin: 0;
  }

  form {
    gap: 8px;
  }

  label {
    gap: 4px;
    font-size: 14px;
  }

  input {
    padding: 9px 10px;
    font-size: 16px;
  }

  .sheet-buttons {
    gap: 6px;
  }

  .sheet-btn {
    padding: 8px 10px;
    font-size: 14px;
  }

  button[type='submit'],
  .save-button {
    padding: 10px 12px;
    font-size: 14px;
  }

  .status {
    min-height: 16px;
    font-size: 13px;
  }

  #calendarImage {
    flex: 1;
    min-height: 0;
  }
}

@media (max-height: 620px) and (orientation: landscape) {
  html,
  body {
    overflow: hidden;
  }

  .page {
    max-width: none;
    height: 100dvh;
    min-height: 100dvh;
    padding:
      calc(8px + env(safe-area-inset-top))
      calc(8px + env(safe-area-inset-right))
      calc(8px + env(safe-area-inset-bottom))
      calc(8px + env(safe-area-inset-left));
    gap: 8px;
    grid-template-columns: minmax(320px, 0.95fr) minmax(360px, 1.05fr);
    overflow: hidden;
  }

  .panel,
  .preview {
    min-height: 0;
    padding: 10px;
    border-radius: 14px;
  }

  .preview {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .panel-head {
    margin-bottom: 6px;
  }

  h1 {
    font-size: 22px;
  }

  h2 {
    font-size: 17px;
    margin: 0;
  }

  form {
    gap: 7px;
  }

  label {
    gap: 4px;
    font-size: 13px;
  }

  input {
    padding: 8px 9px;
    font-size: 16px;
  }

  .sheet-buttons {
    gap: 6px;
  }

  .sheet-btn {
    padding: 7px 10px;
    font-size: 13px;
  }

  button[type='submit'],
  .save-button {
    padding: 9px 11px;
    font-size: 13px;
  }

  .status {
    min-height: 15px;
    font-size: 12px;
  }

  #calendarImage {
    flex: 1;
    min-height: 0;
  }
}

