:root {
  --fg: #ffffff;
  --bg: #000000;
  --fg-inverse: #000000;
  --bg-inverse: #ffffff;
  --accent: #38bdf8;
  --font-main: "DM Mono", "SFMono-Regular", "Roboto Mono", "Menlo", "Consolas", monospace;
  --clock-scale: 1;
  --panel-bg: rgba(0, 0, 0, 0.84);
  --overlay-top: 6rem;
  --overlay-bottom: 5rem;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-main);
  background: var(--bg);
  color: var(--fg);
  transition: background 0.2s ease, color 0.2s ease;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.header__logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.home-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  text-decoration: none;
  padding: 4px;
}

.home-link:hover {
  color: var(--accent);
}

.site-title-link {
  color: inherit;
  text-decoration: none;
  font-weight: 700;
}

body.theme-light {
  background: var(--bg-inverse);
  color: var(--fg-inverse);
  --panel-bg: rgba(255, 255, 255, 0.9);
}

body.is-fullscreen footer {
  display: none;
}

.app {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  gap: 1.5rem;
}

.app__header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.app__controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: inherit;
  border: 1px solid currentColor;
  border-radius: 8px;
  padding: 0.55rem 0.9rem;
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.btn svg {
  display: block;
  width: 18px;
  height: 18px;
}

.icon-cat {
  width: 24px;
  height: 24px;
}

.icon-cat__path {
  display: none;
  fill: currentColor !important;
  stroke: currentColor !important;
  stroke-width: 2 !important;
}

body.theme-light .icon-cat__path--dark {
  display: block;
}

body:not(.theme-light) .icon-cat__path--light {
  display: block;
}

.icon-hidden {
  display: none;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.16);
  box-shadow: 0 0 0 1px currentColor inset;
}

body.theme-light .btn:hover {
  background: rgba(0, 0, 0, 0.12);
  box-shadow: 0 0 0 1px currentColor inset;
}

/* btn-twitter: 通常時の配色のみ上書き、ホバーは共通 */
.btn.btn-twitter {
  gap: 0.4rem;
  font-weight: 600;
}

.btn.btn-twitter:not(:hover) {
  background: var(--bg);
  color: var(--fg);
  border-color: var(--fg);
}

body.theme-light .btn.btn-twitter:not(:hover) {
  background: #fff;
  color: #000;
  border-color: #000;
}

.btn-primary {
  border-color: var(--accent);
  color: var(--accent);
}

.panel {
  position: fixed;
  right: 1.25rem;
  top: var(--overlay-top);
  bottom: var(--overlay-bottom);
  max-width: min(420px, calc(100% - 2.5rem));
  width: 100%;
  line-height: 1.6;
  border: 1px solid currentColor;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  background: var(--panel-bg);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  z-index: 10;
  max-height: calc(100vh - (var(--overlay-top) + var(--overlay-bottom)));
  overflow: auto;
}

@media (max-width: 640px) {
  :root {
    --overlay-top: 5rem;
    --overlay-bottom: 4.5rem;
  }

  .panel {
    position: static;
    right: auto;
    top: auto;
    bottom: auto;
    max-width: 100%;
    width: auto;
    max-height: none;
    overflow: visible;
    padding: 0.85rem 1rem;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28);
    order: 2;
  }

  .panel h2 {
    font-size: 0.95rem;
  }

  .panel ol {
    font-size: 0.92rem;
  }
}

.panel h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.panel ol {
  margin: 0;
  padding-left: 1.2rem;
}

.display {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  text-align: center;
}

.display__time {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: center;
}

.time-text {
  font-size: clamp(calc(2.5rem * var(--clock-scale)), calc(14vw * var(--clock-scale)), calc(6rem * var(--clock-scale)));
  letter-spacing: 0.08em;
  margin: 0;
  padding: 0;
  -webkit-user-select: none;
  user-select: none;
}

.subms-text {
  font-size: clamp(calc(1rem * var(--clock-scale)), calc(4vw * var(--clock-scale)), calc(1.5rem * var(--clock-scale)));
  letter-spacing: 0.06em;
  margin: 0;
  padding: 0;
  -webkit-user-select: none;
  user-select: none;
}

.display__counter {
  margin-top: 0;
}

.counter-text {
  font-size: clamp(calc(1.4rem * var(--clock-scale)), calc(6vw * var(--clock-scale)), calc(2.8rem * var(--clock-scale)));
  letter-spacing: 0.08em;
  margin: 0;
  padding: 0;
  -webkit-user-select: none;
  user-select: none;
}

.hide-when-running .panel,
body.is-running .panel {
  display: none;
}

@media (max-width: 640px) {
  .app {
    padding: 1rem;
  }
  .app__controls {
    width: 100%;
  }
  .btn {
    flex: 1 1 auto;
    text-align: center;
  }
}
