* { margin: 0; padding: 0; box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  background: transparent;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Maru Gothic ProN", "Hiragino Sans", sans-serif;
  overflow: hidden;
}

body {
  display: grid;
  align-items: center;
  justify-items: center;
  gap: 0;
  padding: 0;
  min-width: 0;
  min-height: 0;
}

.phone {
  width: min(430px, calc(50vw - 32px));
  align-self: center;
  justify-self: center;
  border-radius: 56px;
  padding: 16px;
  background: linear-gradient(160deg, #ffd9ec, #e2d4ff 50%, #d4ecff);
  box-shadow:
    0 28px 46px rgba(180,150,210,.38),
    inset 0 4px 10px rgba(255,255,255,.9),
    inset 0 -6px 14px rgba(190,160,220,.4);
  position: relative;
}

body[data-phone-theme="mint"] .phone {
  background: linear-gradient(160deg, #d9fff0, #d9f1ff 50%, #e8e0ff);
}

body[data-phone-theme="blue"] .phone {
  background: linear-gradient(160deg, #d7ecff, #dfe6ff 50%, #f2e2ff);
}

body[data-phone-theme="lavender"] .phone {
  background: linear-gradient(160deg, #eadbff, #d8dfff 50%, #ffe4f2);
}

body[data-phone-theme="peach"] .phone {
  background: linear-gradient(160deg, #ffe0d1, #ffeccf 50%, #ffd7e9);
}

body[data-phone-theme="sunset"] .phone {
  background: linear-gradient(160deg, #ffd0a8, #ffb7c8 50%, #d5c4ff);
}

body[data-phone-theme="aqua"] .phone {
  background: linear-gradient(160deg, #c5fff3, #cdefff 50%, #d9ddff);
}

body[data-phone-theme="mono"] .phone {
  background: linear-gradient(160deg, #f4f5f7, #dfe3ea 50%, #cdd4df);
}

body[data-phone-theme="night"] .phone {
  background: linear-gradient(160deg, #16182e, #2a2149 50%, #0e3550);
  box-shadow:
    0 28px 46px rgba(8,10,24,.58),
    inset 0 4px 10px rgba(255,255,255,.2),
    inset 0 -6px 14px rgba(0,0,0,.42);
}

body[data-phone-theme="deepsea"] .phone {
  background: linear-gradient(160deg, #06252d, #073f4a 50%, #102a5a);
  box-shadow:
    0 28px 46px rgba(0,20,35,.55),
    inset 0 4px 10px rgba(255,255,255,.18),
    inset 0 -6px 14px rgba(0,0,0,.38);
}

body[data-phone-theme="neon"] .phone {
  background: linear-gradient(160deg, #17122a, #3b185f 50%, #063d45);
  box-shadow:
    0 28px 46px rgba(20,8,44,.56),
    inset 0 4px 10px rgba(255,255,255,.18),
    inset 0 -6px 14px rgba(0,0,0,.38);
}

body[data-phone-theme="graphite"] .phone {
  background: linear-gradient(160deg, #171b22, #2b3039 50%, #101318);
  box-shadow:
    0 28px 46px rgba(0,0,0,.55),
    inset 0 4px 10px rgba(255,255,255,.16),
    inset 0 -6px 14px rgba(0,0,0,.42);
}

.phone::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 48px;
  border: 1px solid rgba(255,255,255,.65);
  pointer-events: none;
}

.screen {
  border-radius: 46px;
  background:
    radial-gradient(circle at 20% 15%, #ffd6ee, transparent 45%),
    radial-gradient(circle at 80% 25%, #d9ddff, transparent 50%),
    radial-gradient(circle at 50% 90%, #cfeaff, transparent 55%),
    linear-gradient(160deg, #ffe9f6, #e9e4ff 55%, #e0f1ff);
  padding: 18px 18px 24px;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 2px 8px rgba(255,255,255,.8);
  display: flex;
  flex-direction: column;
}

.screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--screen-wallpaper, none);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: .42;
  pointer-events: none;
  z-index: 0;
}

.screen > * {
  position: relative;
  z-index: 1;
}

body[data-phone-theme="mint"] .screen {
  background:
    radial-gradient(circle at 20% 15%, #d7ffe9, transparent 45%),
    radial-gradient(circle at 80% 25%, #d2f2ff, transparent 50%),
    radial-gradient(circle at 50% 90%, #eee5ff, transparent 55%),
    linear-gradient(160deg, #ecfff7, #e4f6ff 55%, #efe9ff);
}

body[data-phone-theme="blue"] .screen {
  background:
    radial-gradient(circle at 20% 15%, #d7edff, transparent 45%),
    radial-gradient(circle at 80% 25%, #dfe3ff, transparent 50%),
    radial-gradient(circle at 50% 90%, #f5e7ff, transparent 55%),
    linear-gradient(160deg, #edf7ff, #e8ecff 55%, #f6edff);
}

body[data-phone-theme="lavender"] .screen {
  background:
    radial-gradient(circle at 20% 15%, #f0dcff, transparent 45%),
    radial-gradient(circle at 80% 25%, #dde2ff, transparent 50%),
    radial-gradient(circle at 50% 90%, #ffe6f3, transparent 55%),
    linear-gradient(160deg, #f6edff, #e9ecff 55%, #ffeef7);
}

body[data-phone-theme="peach"] .screen {
  background:
    radial-gradient(circle at 20% 15%, #ffe1d4, transparent 45%),
    radial-gradient(circle at 80% 25%, #fff0cf, transparent 50%),
    radial-gradient(circle at 50% 90%, #ffdced, transparent 55%),
    linear-gradient(160deg, #fff1e9, #fff6df 55%, #ffe9f4);
}

body[data-phone-theme="sunset"] .screen {
  background:
    radial-gradient(circle at 20% 15%, #ffd4a6, transparent 45%),
    radial-gradient(circle at 80% 25%, #ffb6c8, transparent 50%),
    radial-gradient(circle at 50% 90%, #d8c8ff, transparent 55%),
    linear-gradient(160deg, #ffe4c8, #ffd5df 55%, #ece1ff);
}

body[data-phone-theme="aqua"] .screen {
  background:
    radial-gradient(circle at 20% 15%, #c7fff5, transparent 45%),
    radial-gradient(circle at 80% 25%, #cdefff, transparent 50%),
    radial-gradient(circle at 50% 90%, #e6e6ff, transparent 55%),
    linear-gradient(160deg, #e6fff9, #e5f7ff 55%, #eeeaff);
}

body[data-phone-theme="mono"] .screen {
  background:
    radial-gradient(circle at 20% 15%, #ffffff, transparent 45%),
    radial-gradient(circle at 80% 25%, #e8ebef, transparent 50%),
    linear-gradient(160deg, #f8f9fb, #eef1f5 55%, #e2e7ee);
}

body[data-phone-theme="night"] .screen {
  background:
    radial-gradient(circle at 20% 15%, rgba(90,78,150,.68), transparent 44%),
    radial-gradient(circle at 80% 25%, rgba(24,98,140,.62), transparent 50%),
    radial-gradient(circle at 50% 90%, rgba(9,28,54,.72), transparent 55%),
    linear-gradient(160deg, #20213d, #231a3d 55%, #0b2b42);
  box-shadow: inset 0 2px 8px rgba(255,255,255,.16);
}

body[data-phone-theme="deepsea"] .screen {
  background:
    radial-gradient(circle at 20% 15%, rgba(36,128,126,.62), transparent 45%),
    radial-gradient(circle at 80% 25%, rgba(20,75,139,.68), transparent 50%),
    radial-gradient(circle at 50% 90%, rgba(4,24,38,.75), transparent 55%),
    linear-gradient(160deg, #08323b, #073744 55%, #0d234e);
  box-shadow: inset 0 2px 8px rgba(255,255,255,.15);
}

body[data-phone-theme="neon"] .screen {
  background:
    radial-gradient(circle at 18% 12%, rgba(255,79,151,.45), transparent 42%),
    radial-gradient(circle at 82% 24%, rgba(0,210,255,.45), transparent 48%),
    radial-gradient(circle at 46% 92%, rgba(196,77,255,.4), transparent 54%),
    linear-gradient(160deg, #1d1734, #2c1248 55%, #07333b);
  box-shadow: inset 0 2px 8px rgba(255,255,255,.14);
}

body[data-phone-theme="graphite"] .screen {
  background:
    radial-gradient(circle at 20% 15%, rgba(92,105,128,.48), transparent 45%),
    radial-gradient(circle at 80% 25%, rgba(48,58,76,.62), transparent 50%),
    linear-gradient(160deg, #20252d, #252b35 55%, #11151b);
  box-shadow: inset 0 2px 8px rgba(255,255,255,.12);
}

.status-bar {
  order: 1;
  height: 16px;
  margin: 1px 9px 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--clock-color, #fff);
  filter: drop-shadow(0 1px 2px rgba(145,110,175,.22));
}

.signal-bars {
  width: 19px;
  height: 11px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
}

.signal-bars span {
  width: 3px;
  border-radius: 3px;
  background: currentColor;
}

.signal-bars span:nth-child(1) { height: 4px; opacity: .72; }
.signal-bars span:nth-child(2) { height: 6px; opacity: .8; }
.signal-bars span:nth-child(3) { height: 8px; opacity: .9; }
.signal-bars span:nth-child(4) { height: 11px; }

.status-icons {
  display: flex;
  align-items: center;
  gap: 7px;
}

.wifi-mark {
  width: 17px;
  height: 13px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.battery-mark {
  width: 27px;
  height: 13px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.battery-frame {
  stroke-width: 1.8;
}

.battery-cap {
  stroke-width: 2.4;
}

.battery-fill {
  fill: currentColor;
  stroke: none;
}

.notch {
  order: 2;
  width: 96px;
  height: 7px;
  background: rgba(190,160,220,.45);
  border-radius: 8px;
  margin: 2px auto 15px;
}

.clock {
  grid-column: span 2;
  text-align: center;
  color: var(--clock-color, #fff);
  margin-bottom: 20px;
  text-shadow: 0 2px 8px rgba(160,120,190,.4);
}

.screen[data-clock-position="bottom"] .clock {
  margin: 18px 0 0;
}

.clock .date {
  font-size: var(--clock-date-size, 15px);
  font-weight: 800;
  opacity: .96;
  letter-spacing: 1px;
}

.clock .time {
  font-size: var(--clock-size, 62px);
  font-weight: 900;
  line-height: 1;
  margin-top: 2px;
}

.grid {
  order: 4;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-flow: row;
  gap: var(--card-gap, 16px);
}

.cards {
  display: contents;
}

.widget {
  background: transparent;
  border: 1.5px solid rgba(255,255,255,.85);
  border-radius: 26px;
  padding: 16px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow:
    0 12px 28px rgba(150,120,190,.22),
    inset 0 2px 4px rgba(255,255,255,.7);
  position: relative;
  overflow: hidden;
}

.widget::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--widget-bg, rgba(255,255,255,.72));
  opacity: var(--card-opacity, 1);
  pointer-events: none;
  z-index: 0;
}

.widget > * {
  position: relative;
  z-index: 1;
}

.widget.bump { animation: bump .42s ease; }
@keyframes bump {
  0%, 100% { transform: scale(1); }
  45% { transform: scale(1.04); }
}

.full-card {
  grid-column: span 2;
}

.live-card {
  min-height: max(var(--card-height, 110px), var(--card-min-height, 100px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  --widget-bg: var(--live-card-bg, linear-gradient(135deg, rgba(255,150,200,.86), rgba(190,160,255,.82)));
  border-color: rgba(255,255,255,.65);
}

.live-card.full-card {
  height: max(var(--card-height, 110px), var(--card-min-height, 100px));
  flex-direction: column;
  align-items: stretch;
  justify-content: space-between;
  gap: 10px;
  padding: 15px 18px;
}

.live-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.live-card.full-card .badge {
  margin-bottom: 0;
}

.live-card.full-card .timer {
  align-self: flex-end;
  text-align: right;
}

.live-card.full-card.live-compact {
  height: auto;
  min-height: 62px;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 18px;
}

.live-card.full-card.live-compact .live-main {
  flex: 1 1 auto;
}

.live-card.full-card.live-compact .timer {
  align-self: center;
  flex: 0 0 auto;
}

.live-card.full-card.live-compact:not(.live-has-main) {
  justify-content: flex-end;
}

.live-card.half-card {
  grid-column: span 1;
  min-height: max(var(--card-height, 110px), var(--card-min-height, 100px));
  padding: 13px 15px;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 10px;
}

.live-card.half-card .timer {
  align-self: flex-end;
  text-align: right;
}

.live-card.half-card .live-main {
  width: 100%;
}

.clock.is-hidden,
.live-card.is-hidden,
.marquee-card.is-hidden,
.badge.is-hidden,
.timer.is-hidden,
.live-title.is-hidden { display: none; }

.live-main { color: #fff; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,.3);
  padding: 5px 13px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.live-dot {
  width: 8px;
  height: 8px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 0 6px #fff;
  animation: blink 1.2s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: .3; }
}

.timer {
  font-size: var(--timer-size, 30px);
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 2px 6px rgba(160,80,140,.4);
  color: #fff;
  white-space: nowrap;
}

.live-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  color: #fff;
  font-size: var(--live-title-size, 18px);
  font-weight: 900;
  text-shadow: 0 2px 6px rgba(160,80,140,.4);
  white-space: nowrap;
}

.live-title-track {
  display: inline-flex;
  width: max-content;
  will-change: transform;
  animation: marquee-loop var(--live-title-duration, 12s) linear infinite;
}

.live-title.is-static .live-title-track {
  display: block;
  width: 100%;
  animation: none;
  transform: none;
}

.live-title-item {
  flex: 0 0 auto;
  padding-right: var(--marquee-gap, 3.5em);
}

.live-title.is-static .live-title-item {
  display: none;
  padding-right: 0;
}

.live-title.is-static .live-title-item:first-child {
  display: block;
  overflow: hidden;
  text-overflow: clip;
}

.live-card.half-card .timer {
  font-size: var(--timer-size, 30px);
}

.summary-line {
  font-size: 12px;
  font-weight: 800;
  opacity: .92;
  margin-top: 4px;
}

#summaryValue {
  font-size: 16px;
  margin-left: 4px;
}

.small {
  height: max(var(--card-height, 110px), var(--card-min-height, 100px));
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px 14px;
}

.counter-card {
  --widget-bg: var(--counter-bg, rgba(255,255,255,.72));
  position: relative;
  overflow: hidden;
}

.small.full-card {
  grid-column: span 2;
}

.blank-card {
  min-height: var(--card-height, 110px);
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  padding: 0;
  pointer-events: none;
}

.blank-card::before {
  display: none;
}

.marquee-card {
  --widget-bg: var(--marquee-bg, rgba(255,255,255,.72));
  height: 46px;
  min-height: 0;
  padding: 0;
  display: flex;
  align-items: center;
  overflow: hidden;
}

.marquee-stack {
  display: contents;
}

.marquee-stack.is-stacked {
  display: flex;
  flex-direction: column;
  gap: var(--card-gap, 16px);
  grid-column: span 1;
  min-width: 0;
}

.marquee-stack.is-stacked .marquee-card {
  width: 100%;
  min-width: 0;
}

.marquee-card.half-card {
  grid-column: span 1;
}

.marquee-card.stack-half {
  grid-column: auto;
}

.marquee-track {
  width: 100%;
  min-width: 0;
  overflow: hidden;
  color: var(--marquee-color, #8a5fb6);
  font-size: var(--marquee-font-size, 15px);
  font-weight: 900;
  white-space: nowrap;
}

.marquee-inner {
  display: inline-flex;
  width: max-content;
  will-change: transform;
  animation: marquee-loop var(--marquee-duration, 12s) linear infinite;
}

.marquee-item {
  flex: 0 0 auto;
  padding-right: var(--marquee-gap, 3.5em);
}

@keyframes marquee-loop {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

.small .top {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: max(var(--icon-size, 38px), calc(var(--label-size, 13px) * 2.36));
}

.small .bottom {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "meta value";
  align-items: end;
  column-gap: 8px;
  width: 100%;
  text-align: right;
  min-width: 0;
}

.counter-icon {
  width: var(--icon-size, 38px);
  height: var(--icon-size, 38px);
  border-radius: 50%;
  background: var(--counter-icon-bg, linear-gradient(145deg,#ffabd4,#ff6fae));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  box-shadow:
    inset 0 2px 4px rgba(255,255,255,.6),
    inset 0 -3px 6px rgba(0,0,0,.1),
    0 3px 8px rgba(0,0,0,.1);
}

.counter-icon::after {
  content: "";
  position: absolute;
  top: 6px;
  left: 9px;
  width: 11px;
  height: 7px;
  background: rgba(255,255,255,.7);
  border-radius: 50%;
  filter: blur(1px);
}

.counter-icon img {
  width: 58%;
  height: 58%;
  object-fit: contain;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 1px 2px rgba(120,70,130,.18));
}

.counter-label {
  min-width: 0;
  height: calc(var(--label-size, 13px) * 2.36);
  font-size: var(--label-size, 13px);
  line-height: 1.18;
  font-weight: 800;
  color: var(--counter-accent, #8a7aa0);
  display: flex;
  align-items: center;
}

.counter-label-text {
  min-width: 0;
  max-height: calc(var(--label-size, 13px) * 2.36);
  white-space: normal;
  overflow: hidden;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.counter-left {
  grid-area: meta;
  justify-self: start;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  max-width: 100%;
}

.counter-goal {
  min-height: 1em;
  margin-top: 3px;
  font-size: var(--goal-size, max(10px, calc(var(--value-size, 30px) * .34)));
  font-weight: 900;
  line-height: 1;
  color: var(--counter-accent, #ff4f97);
  opacity: .72;
  text-align: left;
  white-space: nowrap;
}

.counter-goal:empty {
  display: none;
}

.counter-value {
  grid-area: value;
  justify-self: end;
  font-size: var(--value-size, 30px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: .5px;
  max-width: 100%;
  white-space: nowrap;
  color: var(--counter-accent, #ff4f97);
}

.counter-clear-badge {
  position: absolute;
  top: 5px;
  right: -26px;
  width: 104px;
  padding: 4px 8px;
  background: linear-gradient(135deg, rgba(255,255,255,.96), rgba(255,247,180,.92));
  border: 1px solid rgba(255,255,255,.9);
  color: var(--counter-accent, #ff4f97);
  font-size: 11px;
  font-weight: 1000;
  line-height: 1;
  text-align: center;
  letter-spacing: .06em;
  transform: rotate(28deg);
  box-shadow: 0 5px 12px rgba(120,80,140,.18);
  opacity: 0;
  pointer-events: none;
}

.counter-card.goal-cleared .counter-clear-badge {
  opacity: 1;
}

.counter-meta {
  margin-top: 0;
  font-size: var(--sub-size, 11px);
  font-weight: 800;
  line-height: 1;
  min-height: 1em;
  opacity: .72;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--counter-accent, #ff4f97);
}

.counter-meta:empty {
  visibility: hidden;
}

.dots {
  order: 5;
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 22px;
}

.dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,.6);
}

.dots span.active { background: #fff; }

.connect-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  pointer-events: none;
  opacity: 0;
  transition: opacity .5s ease;
}

.settings-overlay > .connect-overlay {
  position: absolute;
}

.connect-overlay.visible { opacity: 1; }

.connect-overlay-box {
  background: rgba(255,255,255,.72);
  color: #8a7aa0;
  border: 1px solid rgba(255,255,255,.85);
  border-radius: 18px;
  padding: 12px 16px;
  text-align: center;
  font-size: 14px;
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(180,150,210,.22);
  backdrop-filter: blur(12px);
}

.connect-overlay-sub { font-size: 12px; margin-top: 4px; opacity: .72; }

@media (max-width: 380px) {
  body { padding: 0; }
  .phone { padding: 12px; border-radius: 46px; }
  .screen { border-radius: 36px; padding: 15px 12px 20px; }
  .clock .time { font-size: 52px; }
  .grid { gap: 12px; }
  .widget { border-radius: 22px; padding: 13px; }
  .timer { font-size: 25px; }
  .marquee-card { height: 42px; padding: 0; }
  .small {
    height: max(var(--card-height, 98px), var(--card-min-height, 100px));
    padding: 11px 12px;
  }
  .counter-value { font-size: 25px; }
}

@media (orientation: portrait) {
  body {
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  }

  .phone {
    grid-row: 2;
    width: min(430px, calc(100vw - 32px));
    max-height: calc(50vh - 24px);
    transform: scale(.82);
    transform-origin: top center;
  }
}

@media (orientation: landscape) {
  body {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: minmax(0, 100%);
  }

  .phone {
    grid-column: 1;
    transform: scale(.94);
    transform-origin: center;
  }
}
