:root {
  color-scheme: light;
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic", "Noto Sans JP", sans-serif;
  font-synthesis: none;
  --ink: #4a3b3f;
  --muted: #8b7478;
  --surface: rgba(255, 255, 255, 0.9);
  --accent: #df7194;
  --accent-deep: #b94f74;
  --accent-soft: #f9dbe5;
  --background-start: #fffaf4;
  --background-end: #fdebf1;
  --shadow: 0 24px 80px rgba(133, 80, 96, 0.16);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--background-start);
}

button {
  font: inherit;
}

.admin-body {
  background: #f6f1ef;
}

.access-app {
  display: grid;
  min-height: 100vh;
  padding: 20px;
  place-items: center;
}

.access-card {
  width: min(420px, 100%);
  padding: 24px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid white;
  border-radius: 18px;
  box-shadow: 0 10px 32px rgba(91, 63, 70, 0.09);
}
.access-card h1 { margin-top: 2px; font-size: 1.35rem; }
.access-card > p:not(.operator-context):not(.input-error) { color: var(--muted); font-size: 0.85rem; }
.access-form { display: grid; gap: 9px; margin-top: 18px; }
.access-form label { font-size: 0.8rem; font-weight: 800; }
.access-form .button { width: 100%; }

.admin-app {
  width: min(780px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.admin-header,
.token-list-heading,
.token-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.admin-header { margin-bottom: 16px; }
.admin-header h1 { font-size: clamp(1.5rem, 5vw, 2.25rem); }
.admin-card {
  margin-top: 14px;
  padding: 22px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid white;
  border-radius: 18px;
  box-shadow: 0 10px 32px rgba(91, 63, 70, 0.09);
}
.admin-card h2 { margin: 0; font-size: 1.05rem; }
.admin-help { margin: 5px 0 0; color: var(--muted); font-size: 0.8rem; }
.admin-form,
.issue-form { display: grid; gap: 8px; margin-top: 18px; }
.admin-form { max-width: 420px; }
.admin-form label,
.issue-form label { font-size: 0.8rem; font-weight: 800; }
.issue-form label:not(:first-child) { margin-top: 8px; }
.issue-form label span { color: var(--muted); font-size: 0.72rem; font-weight: 600; }
.admin-input {
  width: 100%;
  min-height: 46px;
  padding: 10px 13px;
  color: var(--ink);
  background: white;
  border: 2px solid #eadde0;
  border-radius: 10px;
  font: inherit;
}
.admin-input:focus { border-color: var(--accent-deep); outline: none; }
.admin-textarea { min-height: 82px; resize: vertical; }
.admin-form .button { width: fit-content; margin-top: 6px; }
.issue-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.issued-card { border-color: #e7b7c6; }
.admin-warning { color: #92344f; font-size: 0.8rem; font-weight: 750; }
.issued-links { display: grid; gap: 7px; }
.issued-links label { margin-top: 6px; font-size: 0.75rem; font-weight: 800; }
.copy-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.copy-row code { overflow-wrap: anywhere; padding: 10px; background: #f7f1f0; border-radius: 8px; font-size: 0.72rem; }
.copy-row button,
.text-button,
.revoke-button {
  padding: 7px 10px;
  color: var(--accent-deep);
  background: transparent;
  border: 1px solid currentColor;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 800;
}
.copy-status { min-height: 1.2em; margin: 8px 0 0; color: #2d6550; font-size: 0.75rem; }
.token-list { display: grid; margin-top: 15px; }
.token-item { align-items: flex-start; padding: 14px 0; border-top: 1px solid #eee3e5; }
.token-item h3 { margin: 0; font-size: 0.95rem; }
.token-item p { margin: 3px 0 0; color: var(--muted); font-size: 0.72rem; }
.token-item .token-memo { margin: 7px 0; padding: 7px 9px; color: var(--ink); background: #f8f3f2; border-radius: 7px; white-space: pre-wrap; }
.revoke-button { color: #9a3348; flex: 0 0 auto; }
.token-actions { display: flex; align-items: center; gap: 7px; flex: 0 0 auto; }
.copy-token-button {
  padding: 7px 10px;
  color: #2d6550;
  background: transparent;
  border: 1px solid currentColor;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 800;
}
.revoked-badge { padding: 6px 9px; color: var(--muted); background: #eee8e9; border-radius: 999px; font-size: 0.7rem; font-weight: 800; }
.empty-list { color: var(--muted); font-size: 0.85rem; }

.operator-body {
  background: #f6f1ef;
}

.operator-app {
  width: min(520px, calc(100% - 20px));
  margin: 0 auto;
  padding: 12px 0 28px;
}

.operator-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
  padding: 0 4px;
}

.operator-header h1 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.25;
}

.operator-header-actions { display: flex; align-items: center; gap: 8px; }
.operator-header-actions .text-button { padding: 5px 7px; font-size: 0.66rem; }

.operator-context {
  margin: 0 0 1px;
  color: var(--pink);
  font-size: 0.58rem;
  font-weight: 850;
  letter-spacing: 0.18em;
}

.preview-link {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-decoration: none;
}

.operator-card,
.obs-guide {
  padding: 16px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid white;
  border-radius: 16px;
  box-shadow: 0 10px 32px rgba(91, 63, 70, 0.09);
}

.operator-readout {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.readout-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.operator-time {
  margin: 2px 0 0;
  font-family: ui-rounded, "SF Pro Rounded", "Segoe UI", sans-serif;
  font-size: clamp(2.7rem, 13vw, 4.4rem);
  font-variant-numeric: tabular-nums;
  font-weight: 780;
  letter-spacing: -0.055em;
  line-height: 1;
}

.operator-state {
  display: flex;
  align-items: flex-end;
  flex-direction: column;
  gap: 5px;
  padding-bottom: 4px;
}

.phase-pill {
  padding: 5px 9px;
  color: #2d6550;
  background: #e3f1ea;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
}

.phase-pill[data-phase="overtime"] { color: #835515; background: #f9e8c8; }
.phase-pill[data-phase="deadline"] { color: white; background: #862d3d; }
.connection-status { color: var(--muted); font-size: 0.66rem; }
.operator-card .controls { justify-content: flex-start; margin-top: 14px; }
.operator-card .resume-panel {
  max-width: none;
  margin: 16px 0 0;
  padding-top: 14px;
}

.obs-guide {
  margin-top: 10px;
  padding: 0;
}

.obs-guide summary {
  padding: 12px 16px;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.obs-guide-content {
  display: grid;
  gap: 10px;
  padding: 4px 14px 14px;
}

.obs-guide ol { margin: 0; padding-left: 1.25em; font-size: 0.75rem; }
.obs-guide li + li { margin-top: 8px; }

.url-box {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
  background: #f7f1f0;
  border-radius: 12px;
}

.url-box span { flex: 0 0 auto; color: var(--muted); font-size: 0.8rem; font-weight: 700; }
.url-box code { overflow-wrap: anywhere; }

.obs-drag-source {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 66px;
  padding: 12px 16px;
  color: white;
  background: linear-gradient(135deg, #bd5277, #9d3e62);
  border: 2px dashed rgba(255, 255, 255, 0.58);
  border-radius: 16px;
  box-shadow: 0 10px 28px rgba(157, 62, 98, 0.22);
  cursor: grab;
  text-decoration: none;
  user-select: none;
}

.obs-drag-source:active { cursor: grabbing; }
.obs-drag-source:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.obs-drag-source strong { display: block; font-size: 0.9rem; }
.obs-drag-source small { display: block; margin-top: 2px; color: #f9dce6; }
.drag-grip { font-size: 1.5rem; line-height: 1; }
.obs-drag-help, .obs-note { margin: 0; color: var(--muted); font-size: 0.68rem; }

html:has(.overlay-body),
.overlay-body {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: transparent !important;
}

.display-access-gate {
  display: grid;
  width: 100%;
  height: 100%;
  padding: 12px;
  place-items: end center;
}

.display-access-card {
  width: min(100%, 560px);
  padding: 14px;
  color: #4a3b3f;
  background: rgba(255, 255, 255, 0.96);
  border: 2px solid rgba(203, 140, 61, 0.42);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(53, 33, 22, 0.2);
}
.display-access-card > p { min-height: 1.2em; margin: 0 0 7px; font-size: 0.75rem; font-weight: 800; }
.display-access-card > p:last-child { margin: 6px 0 0; color: #a42f43; font-weight: 600; }
.display-access-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.display-access-form input,
.display-access-form button { min-height: 38px; border-radius: 8px; font: inherit; }
.display-access-form input { min-width: 0; padding: 7px 10px; border: 1px solid #e0c8cf; }
.display-access-form button { padding: 7px 14px; color: white; background: var(--accent-deep); border: 0; font-weight: 800; }

.overlay {
  display: grid;
  width: 100%;
  height: 100%;
  align-items: end;
  padding: clamp(8px, 3vw, 20px);
}

.overlay-card {
  display: flex;
  align-items: stretch;
  flex-direction: column;
  gap: clamp(8px, 2vw, 12px);
  width: min(100%, 720px);
  min-width: 0;
  padding: clamp(12px, 3vw, 20px);
  color: #543d33;
  background: rgba(255, 247, 231, 0.94);
  border: 2px solid rgba(203, 140, 61, 0.42);
  border-radius: 20px;
  box-shadow: 0 12px 34px rgba(53, 33, 22, 0.22);
  opacity: 1;
  transform: translateY(0);
  transition: opacity 350ms ease, transform 350ms ease, background 350ms ease;
}

.overlay[data-phase="quiet"] .overlay-card {
  padding: clamp(5px, 1.5vw, 10px);
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.overlay[data-phase="quiet"] .overlay-time { display: none; }

.overlay[data-phase="quiet"] .overlay-progress {
  background: rgba(255, 255, 255, 0.34);
  box-shadow: 0 2px 8px rgba(53, 33, 22, 0.12);
}

.overlay[data-phase="quiet"] .overlay-progress-fill {
  background: linear-gradient(90deg, rgba(248, 201, 216, 0.9), rgba(219, 114, 148, 0.94));
}

.overlay-time {
  margin: 0;
  font-family: ui-rounded, "SF Pro Rounded", "Segoe UI", sans-serif;
  font-size: clamp(2rem, 9vw, 4.6rem);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  letter-spacing: -0.06em;
  line-height: 1;
}

.deadline-message {
  display: none;
  margin: 0;
  text-align: center;
  font-size: clamp(1rem, 4.2vw, 1.55rem);
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1.25;
}

.ending-message {
  display: none;
  margin: 0;
  color: #94601d;
  text-align: center;
  font-size: clamp(0.78rem, 3vw, 1rem);
  font-weight: 850;
  letter-spacing: 0.05em;
  line-height: 1.25;
}

.overlay[data-phase="overtime"] .ending-message,
.overlay[data-ending-stage="ten-minutes"] .ending-message,
.overlay[data-ending-stage="five-minutes"] .ending-message,
.overlay[data-ending-stage="soon"] .ending-message {
  display: block;
}

.overlay[data-phase="overtime"][data-ending-stage="none"] .ending-message {
  color: rgba(84, 61, 51, 0.68);
  font-size: clamp(0.68rem, 2.5vw, 0.84rem);
  font-weight: 750;
  letter-spacing: 0.04em;
}

.overlay[data-ending-stage="ten-minutes"] .overlay-card {
  border-color: rgba(202, 127, 40, 0.58);
}

.overlay[data-ending-stage="ten-minutes"] .overlay-progress-fill {
  background: linear-gradient(90deg, #eeb457, #cf7d27);
}

.overlay[data-ending-stage="five-minutes"] .overlay-card {
  background: rgba(255, 241, 214, 0.96);
  border-color: rgba(187, 91, 27, 0.68);
}

.overlay[data-ending-stage="five-minutes"] .ending-message { color: #a3471f; }
.overlay[data-ending-stage="five-minutes"] .overlay-progress-fill {
  background: linear-gradient(90deg, #e79a36, #c45f27);
}

.overlay[data-ending-stage="soon"] .overlay-card {
  background: rgba(255, 231, 220, 0.97);
  border-color: rgba(151, 46, 53, 0.72);
  box-shadow: 0 14px 38px rgba(89, 28, 35, 0.24);
  animation: ending-soon 1.8s ease-out 1;
}

.overlay[data-ending-stage="soon"] .ending-message { color: #94303d; }
.overlay[data-ending-stage="soon"] .overlay-progress-fill {
  background: linear-gradient(90deg, #d66b45, #a93242);
}

.overlay-progress {
  height: clamp(10px, 3vw, 18px);
  overflow: hidden;
  background: rgba(130, 93, 51, 0.18);
  border-radius: 999px;
}

.overlay-progress-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #efbb66, #d98c35);
  border-radius: inherit;
  transition: width 500ms linear, background 350ms ease;
}

.overlay[data-phase="deadline"] .overlay-card {
  color: white;
  background: rgba(119, 29, 43, 0.96);
  border-color: rgba(255, 223, 207, 0.66);
  box-shadow: 0 14px 38px rgba(55, 8, 18, 0.4);
  animation: deadline-arrival 2.4s ease-out 1;
}

.overlay[data-phase="deadline"] .deadline-message { display: block; }
.overlay[data-phase="deadline"] .overlay-time { text-align: center; }
.overlay[data-phase="deadline"] .overlay-progress { background: rgba(255, 255, 255, 0.2); }
.overlay[data-phase="deadline"] .overlay-progress-fill { background: #fff0dc; }

.overlay[data-deadline-stage="final"] .overlay-card {
  background: rgba(84, 13, 26, 0.98);
  border-color: rgba(255, 240, 220, 0.9);
  box-shadow: 0 0 0 4px rgba(134, 45, 61, 0.32), 0 16px 42px rgba(55, 8, 18, 0.52);
  animation: final-notice 1.8s ease-in-out 2;
}

@keyframes deadline-arrival {
  0% { opacity: 0; transform: translateY(12px) scale(0.97); }
  25% { opacity: 1; transform: translateY(0) scale(1.02); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes final-notice {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.025); }
}

@keyframes ending-soon {
  0% { transform: scale(1); }
  45% { transform: scale(1.018); }
  100% { transform: scale(1); }
}

.timer-app {
  position: relative;
  isolation: isolate;
  display: grid;
  min-height: 100vh;
  place-items: center;
  overflow: hidden;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 10%, rgba(255, 255, 255, 0.96), transparent 34%),
    linear-gradient(145deg, var(--background-start), var(--background-end));
  transition: background 500ms ease;
}

.timer-card {
  width: min(680px, 100%);
  padding: clamp(32px, 7vw, 68px);
  text-align: center;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 36px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.brand-mark {
  display: grid;
  width: 68px;
  height: 68px;
  margin: 0 auto 20px;
  place-items: center;
  color: white;
  background: var(--accent);
  border-radius: 22px 22px 22px 8px;
  font-family: Georgia, "Yu Mincho", serif;
  font-size: 34px;
  font-weight: 700;
  box-shadow: 0 12px 30px rgba(185, 79, 116, 0.24);
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--accent-deep);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.18em;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 7vw, 4.5rem);
  line-height: 1.15;
  letter-spacing: 0.02em;
}

.message {
  margin: 22px auto 0;
  color: var(--muted);
  font-size: clamp(1rem, 2.8vw, 1.35rem);
  line-height: 1.8;
}

.elapsed-time {
  margin: 28px 0 0;
  color: var(--accent-deep);
  font-family: ui-rounded, "SF Pro Rounded", "Segoe UI", sans-serif;
  font-size: clamp(4.5rem, 18vw, 9rem);
  font-variant-numeric: tabular-nums;
  font-weight: 750;
  letter-spacing: -0.05em;
  line-height: 0.95;
}

.status {
  min-height: 1.5em;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 24px;
}

.button {
  min-width: 120px;
  min-height: 48px;
  padding: 12px 22px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 150ms ease, box-shadow 150ms ease, opacity 150ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-2px);
}

.button:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.button--primary {
  color: white;
  background: var(--accent-deep);
  box-shadow: 0 8px 20px rgba(185, 79, 116, 0.22);
}

.button--secondary {
  color: var(--ink);
  background: var(--accent-soft);
}

.resume-panel {
  max-width: 460px;
  margin: 30px auto 0;
  padding-top: 24px;
  border-top: 1px solid rgba(74, 59, 63, 0.14);
  text-align: left;
}

.resume-label {
  display: block;
  font-weight: 800;
}

.resume-help {
  margin: 3px 0 10px;
  color: var(--muted);
  font-size: 0.8rem;
}

.resume-input-row {
  display: grid;
  grid-template-columns: minmax(110px, 0.7fr) minmax(180px, 1.3fr);
  gap: 10px;
}

.time-input {
  width: 100%;
  min-height: 48px;
  padding: 10px 16px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.86);
  border: 2px solid var(--accent-soft);
  border-radius: 12px;
  font-family: ui-rounded, "SF Pro Rounded", "Segoe UI", sans-serif;
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
}

.time-input:focus {
  border-color: var(--accent-deep);
  outline: 2px solid transparent;
}

.time-input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.input-error {
  min-height: 1.5em;
  margin: 7px 0 0;
  color: #a42f43;
  font-size: 0.8rem;
}

[data-phase="deadline"] .resume-panel {
  border-top-color: rgba(255, 255, 255, 0.24);
}

[data-phase="deadline"] .input-error {
  color: #fff0dc;
}

.ambient-shape {
  position: absolute;
  z-index: -1;
  border-radius: 50%;
  opacity: 0.52;
  filter: blur(2px);
}

.ambient-shape--one {
  top: -12vw;
  right: -8vw;
  width: 38vw;
  height: 38vw;
  background: #f5c5d5;
}

.ambient-shape--two {
  bottom: -18vw;
  left: -10vw;
  width: 46vw;
  height: 46vw;
  background: #ffe0b8;
}

[data-phase="overtime"] {
  --accent: #df9e4c;
  --accent-deep: #9b641e;
  --accent-soft: #f9e7c8;
  --background-start: #fffbf2;
  --background-end: #fcebd3;
}

[data-phase="deadline"] {
  --ink: #fff7f3;
  --muted: #ffd9cf;
  --surface: rgba(104, 29, 40, 0.88);
  --accent: #fff0dc;
  --accent-deep: #fff0dc;
  --accent-soft: rgba(255, 255, 255, 0.15);
  --background-start: #8d2634;
  --background-end: #42151f;
  --shadow: 0 28px 90px rgba(70, 12, 25, 0.45);
}

[data-phase="deadline"] .brand-mark {
  color: #8d2634;
}

[data-phase="deadline"] .button--primary {
  color: #6b1d2a;
  background: #fff0dc;
}

@media (max-width: 520px) {
  .timer-app {
    padding: 14px;
  }

  .timer-card {
    border-radius: 26px;
  }

  .controls {
    flex-direction: column;
  }

  .button {
    width: 100%;
  }

  .resume-input-row {
    grid-template-columns: 1fr;
  }

  .operator-card .controls { flex-direction: row; }
  .operator-card .resume-input-row {
    grid-template-columns: minmax(84px, 0.65fr) minmax(145px, 1.35fr);
  }
  .url-box { align-items: flex-start; flex-direction: column; }
  .issue-row, .copy-row { grid-template-columns: 1fr; }
  .issue-row .button, .copy-row button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
