* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  font-family: "Segoe UI", "Yu Gothic UI", "Meiryo", sans-serif;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: radial-gradient(circle at center, #17243a 0%, #070b12 60%, #000 100%);
  color: #f7f9ff;
}

button {
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

.timer-page {
  width: min(1920px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(14px, 2vw, 32px);
}

.page-header {
  margin-bottom: clamp(18px, 2vw, 30px);
  text-align: center;
}

.page-header h1,
.page-header p,
.section-heading h2 {
  margin: 0;
}

.page-header h1 {
  font-size: clamp(1.7rem, 3vw, 3rem);
}

.page-header p {
  margin-top: 6px;
  color: #aebfd8;
}

.timer-section {
  margin-bottom: clamp(22px, 3vw, 42px);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.section-heading h2 {
  font-size: clamp(1.4rem, 2.2vw, 2.2rem);
}

.timer-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(10px, 1.2vw, 22px);
}

.timer-grid-lower {
  justify-content: start;
}

.timer-panel {
  min-width: 0;
  perspective: 1200px;
  transition: opacity 0.35s ease;
}

.timer-panel-inner {
  display: grid;
  width: 100%;
  min-height: clamp(245px, 22vw, 390px);
  transform-style: preserve-3d;
  transition: transform 0.7s ease-in-out;
}

.timer-panel.is-finished {
  opacity: 0.7;
}

.timer-panel.is-finished .timer-panel-inner {
  transform: rotateY(180deg);
}

.timer-face {
  grid-area: 1 / 1;
  display: grid;
  width: 100%;
  padding: clamp(12px, 1.4vw, 24px);
  border: 1px solid rgba(182, 211, 255, 0.55);
  border-radius: clamp(18px, 2vw, 32px);
  background: linear-gradient(145deg, rgba(32, 50, 78, 0.92), rgba(6, 12, 23, 0.96));
  box-shadow: 0 0 24px rgba(116, 168, 255, 0.16), inset 0 0 24px rgba(158, 200, 255, 0.08);
  text-align: center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.timer-face-front {
  align-content: center;
}

.timer-face-back {
  align-content: center;
  justify-items: center;
  gap: clamp(16px, 2vw, 30px);
  transform: rotateY(180deg);
}

.timer-title {
  max-width: 100%;
  margin: 0 auto 4px;
  padding: 3px 8px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: #eef5ff;
  font-size: clamp(1.15rem, 2vw, 2.15rem);
  font-weight: 700;
  line-height: 1.15;
  cursor: text;
  text-shadow: 0 0 14px rgba(159, 198, 255, 0.32);
  overflow-wrap: anywhere;
}

.timer-title:hover,
.timer-title:focus-visible {
  border-bottom-color: rgba(164, 202, 255, 0.7);
  outline: none;
}

.error-message {
  min-height: 1.4em;
  margin: 0;
  color: #ff9a9a;
  font-size: clamp(0.7rem, 0.9vw, 0.95rem);
  font-weight: 700;
}

.time-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 2px;
  width: 100%;
}

.time-unit {
  display: grid;
  min-width: 0;
  justify-items: center;
}

.time-number {
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff;
  font-family: Consolas, "Roboto Mono", "Courier New", monospace;
  font-size: clamp(3.2rem, 7vw, 7.2rem);
  font-weight: 700;
  line-height: 0.9;
  letter-spacing: -0.08em;
  cursor: text;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.48), 0 0 24px rgba(153, 194, 255, 0.2);
}

.time-number:hover,
.time-number:focus-visible {
  outline: none;
  text-shadow: 0 0 14px rgba(255, 255, 255, 0.72), 0 0 30px rgba(125, 177, 255, 0.34);
}

.time-colon {
  padding-bottom: clamp(12px, 2vw, 26px);
  font-family: Consolas, "Roboto Mono", "Courier New", monospace;
  font-size: clamp(2.7rem, 4vw, 5rem);
  font-weight: 700;
  line-height: 1;
}

.adjust-button {
  width: 42px;
  min-height: 30px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #91a8c8;
  font-size: clamp(0.85rem, 1.2vw, 1.2rem);
  cursor: pointer;
  opacity: 0.72;
}

.adjust-button:hover,
.adjust-button:focus-visible {
  color: #d9e8ff;
  opacity: 1;
  outline: none;
  transform: scale(1.12);
}

.timer-panel.is-running .adjust-button {
  visibility: hidden;
}

.timer-title:disabled,
.time-number:disabled,
.adjust-button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.finished-message {
  display: grid;
  justify-items: center;
  gap: 8px;
  width: 100%;
}

.finished-title,
.finished-text {
  max-width: 100%;
  margin: 0;
  color: #fff;
  font-weight: 700;
  line-height: 1.05;
  overflow-wrap: anywhere;
  text-shadow: 0 0 14px rgba(255, 255, 255, 0.4), 0 0 28px rgba(153, 194, 255, 0.24);
}

.finished-title {
  font-size: clamp(1.45rem, 2.6vw, 2.8rem);
}

.finished-text {
  font-size: clamp(3.3rem, 6vw, 6.5rem);
  letter-spacing: 0.08em;
}

.section-start-button,
.section-reset-button,
.start-all-button,
.reset-all-button {
  min-height: 48px;
  padding: 10px 18px;
  border: 1px solid #84b6ff;
  border-radius: 15px;
  background: linear-gradient(145deg, #376cff, #1541b8);
  color: #eaf2ff;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 0 18px rgba(71, 126, 255, 0.35), inset 0 0 10px rgba(255, 255, 255, 0.1);
}

.section-start-button:hover:not(:disabled),
.section-start-button:focus-visible:not(:disabled),
.section-reset-button:hover,
.section-reset-button:focus-visible,
.start-all-button:hover:not(:disabled),
.start-all-button:focus-visible:not(:disabled),
.reset-all-button:hover,
.reset-all-button:focus-visible {
  filter: brightness(1.14);
  outline: 3px solid rgba(155, 198, 255, 0.32);
  outline-offset: 3px;
}

.section-start-button:disabled,
.start-all-button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.section-controls {
  display: flex;
  gap: 10px;
}

.section-reset-button,
.reset-all-button {
  border-color: rgba(151, 184, 227, 0.58);
  background: rgba(21, 34, 54, 0.9);
  box-shadow: inset 0 0 10px rgba(122, 169, 236, 0.08);
}

.overall-controls {
  display: flex;
  justify-content: center;
  gap: 14px;
  padding-bottom: 18px;
}

.start-all-button,
.reset-all-button {
  min-width: min(300px, 46%);
  min-height: 64px;
  font-size: clamp(1.2rem, 2vw, 1.8rem);
}

@media (max-width: 980px) {
  .timer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .timer-grid-lower .timer-panel:nth-child(3) {
    grid-column: 1;
  }

  .time-number {
    font-size: clamp(3.8rem, 13vw, 7rem);
  }
}

@media (max-width: 560px) {
  .timer-page {
    padding: 10px;
  }

  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .section-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .section-start-button,
  .section-reset-button {
    width: 100%;
  }

  .overall-controls {
    display: grid;
    grid-template-columns: 1fr;
  }

  .start-all-button,
  .reset-all-button {
    width: 100%;
    min-width: 0;
  }

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

  .timer-panel-inner {
    min-height: 300px;
  }

  .time-number {
    font-size: clamp(5rem, 28vw, 8.5rem);
  }

  .time-colon {
    font-size: clamp(3.4rem, 14vw, 5rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
