:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --max-width: 680px;
  --ad-clearance: 78px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-touch-callout: none;
}

a {
  color: inherit;
}

.app-shell {
  width: min(100%, var(--max-width));
  min-height: 100dvh;
  margin: 0 auto;
  padding:
    max(20px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    calc(var(--ad-clearance) + env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
}

.app-header {
  padding: 12px 2px 20px;
}

.brand {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(1.75rem, 8vw, 2.4rem);
  line-height: 1.15;
}

.subtitle {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

.tool-panel {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  background: var(--surface);
  box-shadow: var(--panel-shadow);
}

.tool-panel h2 {
  margin: 0;
  font-size: 1.15rem;
}

.panel-description {
  margin: 10px 0 20px;
  color: var(--muted);
  line-height: 1.65;
}

.primary-button {
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: var(--radius-button);
  padding: 12px 18px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 800;
  cursor: pointer;
}

.primary-button:active {
  background: var(--accent-active);
  transform: translateY(1px);
}

.primary-button:focus-visible,
.mrs-tools-link:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

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

.site-footer {
  display: flex;
  justify-content: center;
  padding: 24px 0 10px;
}

.mrs-tools-link {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
}

.mrs-tools-link:active {
  color: var(--text);
}

.ad-banner {
  position: fixed;
  z-index: 90;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  justify-content: center;
  width: 100%;
  padding: 1px 0 calc(1px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--ad-border);
  background: var(--ad-bg);
}

.ad-banner-inner {
  max-width: 100%;
  line-height: 0;
}

.ad-placeholder {
  color: var(--ad-placeholder);
  font-size: 0.75rem;
}

@media (min-width: 700px) {
  .app-shell {
    padding-top: 32px;
  }

  .tool-panel {
    padding: 26px;
  }
}

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



.timer-panel { text-align: center; }
#activity { margin: 0 0 12px; font-size: 1.25rem; font-weight: 700; }
.clock-wrap { max-width: 380px; margin: auto; }
#dial { display: block; width: 100%; touch-action: none; user-select: none; cursor: grab; }
#dial[aria-disabled="true"] { cursor: default; }
.clock-face { fill: #fffdf7; stroke: #e2dfd5; stroke-width: 2; }
#sector { fill: #ef8523; }
.tick { stroke: #b8b5ae; stroke-width: 1; }
.tick.major { stroke: #454841; stroke-width: 2; }
#labels { fill: #3b403b; font-size: 15px; font-weight: 700; }
#hand { stroke: #303a36; stroke-width: 4; stroke-linecap: round; }
.pin { fill: #303a36; }
.remaining-caption { color: var(--muted); margin: 16px 0 0; }
#remaining { margin: 0; font-size: clamp(3rem, 14vw, 4.5rem); font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.2; }
.status-message { margin-top: 10px; font-size: .82rem; }
.actions { display: grid; grid-template-columns: 1.6fr 1fr; gap: 10px; margin-top: 20px; }
button { min-height: 48px; padding: 10px 14px; color: var(--text); background: var(--surface-strong); border: 1px solid var(--border); border-radius: 12px; cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: .45; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible, #dial:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.settings-button { margin-top: 12px; width: 100%; background: transparent; }
.notice, .offline-status { font-size: .8rem; line-height: 1.65; color: var(--muted); }
.notice { margin: 18px 4px 0; }
.offline-status { margin: 10px 4px 0; }
body[data-phase="done"] #caption { color: var(--accent); font-size: 1.5rem; font-weight: 800; }
dialog { width: min(92vw, 440px); max-height: 90dvh; padding: 24px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 20px; z-index: 100; }
dialog::backdrop { background: #0009; }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 20px; }
.dialog-heading h2 { margin: 0; font-size: 1.3rem; }
.dialog-heading button { width: 48px; font-size: 1.5rem; }
label { display: block; font-size: .95rem; margin-top: 18px; text-align: left; }
input:not([type="checkbox"]), select { display: block; width: 100%; min-height: 48px; padding: 10px 12px; margin-top: 8px; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 10px; font-size: 16px; }
input:disabled { opacity: .5; }
.input-unit { display: flex; align-items: center; gap: 12px; }
.presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 10px; }
.presets button { padding: 8px 2px; }
.check-row { display: flex; gap: 12px; align-items: center; min-height: 48px; }
input[type="checkbox"] { width: 24px; height: 24px; accent-color: var(--accent); }
.field-help { color: var(--muted); font-size: .8rem; line-height: 1.6; }
@media (max-width: 370px) { .tool-panel { padding: 14px; } }
@media (orientation: landscape) and (max-height: 600px) { .app-shell { max-width: 900px; } .timer-panel { display: grid; grid-template-columns: minmax(220px, 1fr) 1fr; column-gap: 24px; align-items: center; } .clock-wrap { grid-column: 1; grid-row: 1 / 8; width: 100%; max-width: 320px; } #activity, #caption, #remaining, #status, .actions, .settings-button { grid-column: 2; } }
