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

:root {
  --online: #00b894;
  --online-light: #00cec9;
  --online-glow: rgba(0, 184, 148, 0.35);
  --offline: #e17055;
  --offline-light: #d63031;
  --offline-glow: rgba(214, 48, 49, 0.35);
  --bg: #0a0a1a;
  --card-bg: rgba(255, 255, 255, 0.04);
  --border: rgba(255, 255, 255, 0.08);
  --text: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-muted: rgba(255, 255, 255, 0.4);
  --speed: 0.5s;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  transition: background var(--speed) ease;
  position: relative;
}

body.online {
  background: linear-gradient(160deg, #0a0a1a 0%, #0a1f1a 50%, #0a0a1a 100%);
}

body.offline {
  background: linear-gradient(160deg, #0a0a1a 0%, #1f0e0a 50%, #0a0a1a 100%);
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  transition: opacity var(--speed) ease;
}

body.online::before {
  background: radial-gradient(ellipse 80% 40% at 50% 0%, rgba(0, 184, 148, 0.12) 0%, transparent 70%);
}

body.offline::before {
  background: radial-gradient(ellipse 80% 40% at 50% 0%, rgba(214, 48, 49, 0.12) 0%, transparent 70%);
}

.header {
  text-align: center;
  padding: 2.5rem 1rem 0.5rem;
  position: relative;
  z-index: 1;
}

.header h1 {
  font-size: clamp(1.8rem, 5vw, 2.5rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff 30%, rgba(255, 255, 255, 0.6));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.2rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

main {
  flex: 1;
  width: 100%;
  max-width: 480px;
  padding: 1.25rem;
  position: relative;
  z-index: 1;
}

.status-card {
  background: var(--card-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 2.5rem 2rem;
  text-align: center;
  margin-bottom: 1.25rem;
  position: relative;
  overflow: hidden;
  transition: border-color var(--speed) ease, box-shadow var(--speed) ease;
}

body.online .status-card {
  border-color: rgba(0, 184, 148, 0.2);
  box-shadow: 0 0 40px rgba(0, 184, 148, 0.05);
}

body.offline .status-card {
  border-color: rgba(214, 48, 49, 0.2);
  box-shadow: 0 0 40px rgba(214, 48, 49, 0.05);
}

.status-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  transition: background var(--speed) ease;
}

body.online .status-card::before {
  background: linear-gradient(90deg, var(--online), var(--online-light));
}

body.offline .status-card::before {
  background: linear-gradient(90deg, var(--offline), var(--offline-light));
}

.indicator {
  position: relative;
  width: 88px;
  height: 88px;
  margin: 0 auto 1.5rem;
}

.indicator-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid;
  transition: border-color var(--speed) ease, box-shadow var(--speed) ease;
}

body.online .indicator-ring {
  border-color: var(--online);
  box-shadow: 0 0 30px var(--online-glow);
  animation: pulse-ring 2.5s ease-in-out infinite;
}

body.offline .indicator-ring {
  border-color: var(--offline);
  box-shadow: 0 0 30px var(--offline-glow);
  animation: pulse-ring-offline 1.8s ease-in-out infinite;
}

.indicator-ring::after {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 1.5px solid;
  opacity: 0.3;
  transition: border-color var(--speed) ease;
}

body.online .indicator-ring::after {
  border-color: var(--online);
  animation: pulse-ring 2.5s ease-in-out infinite 0.3s;
}

body.offline .indicator-ring::after {
  border-color: var(--offline);
  animation: pulse-ring-offline 1.8s ease-in-out infinite 0.3s;
}

.indicator-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  transition: background var(--speed) ease, box-shadow var(--speed) ease;
}

body.online .indicator-dot {
  background: var(--online);
  box-shadow: 0 0 24px var(--online), 0 0 60px var(--online-glow);
  animation: dot-pulse 2.5s ease-in-out infinite;
}

body.offline .indicator-dot {
  background: var(--offline);
  box-shadow: 0 0 24px var(--offline), 0 0 60px var(--offline-glow);
  animation: dot-shake 1.2s ease-in-out infinite;
}

@keyframes pulse-ring {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.08); opacity: 1; }
}

@keyframes pulse-ring-offline {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.12); opacity: 1; }
}

@keyframes dot-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  50% { transform: translate(-50%, -50%) scale(1.15); opacity: 0.85; }
}

@keyframes dot-shake {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  15% { transform: translate(-50%, -50%) scale(1.1) rotate(-8deg); }
  30% { transform: translate(-50%, -50%) scale(1.1) rotate(8deg); }
  45% { transform: translate(-50%, -50%) scale(1.05) rotate(-4deg); }
  60% { transform: translate(-50%, -50%) scale(1.05) rotate(4deg); }
  75% { transform: translate(-50%, -50%) scale(1) rotate(0); }
}

#status {
  font-size: clamp(1.3rem, 4vw, 1.75rem);
  font-weight: 700;
  margin-bottom: 0.4rem;
  transition: color var(--speed) ease;
}

body.online #status {
  color: var(--online);
}

body.offline #status {
  color: var(--offline);
}

#message {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 0.15rem;
}

.detail {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.history {
  background: var(--card-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 1.25rem 1.5rem;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.history-header h3 {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.clear-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.clear-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
}

.history-list {
  list-style: none;
  max-height: 320px;
  overflow-y: auto;
}

.history-list::-webkit-scrollbar {
  width: 3px;
}

.history-list::-webkit-scrollbar-track {
  background: transparent;
}

.history-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.history-entry {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  animation: slide-in 0.35s ease both;
}

.history-entry:last-child {
  border-bottom: none;
}

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.history-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
  transition: background 0.3s, color 0.3s;
}

.online-entry .history-icon {
  background: rgba(0, 184, 148, 0.15);
  color: var(--online);
}

.offline-entry .history-icon {
  background: rgba(214, 48, 49, 0.15);
  color: var(--offline);
}

.history-text {
  flex: 1;
  font-size: 0.9rem;
  color: var(--text);
}

.history-time {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

.footer {
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  position: relative;
  z-index: 1;
}

.heart {
  color: #e17055;
  display: inline-block;
  animation: heartbeat 1.8s ease infinite;
}

@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  15% { transform: scale(1.2); }
  30% { transform: scale(1); }
  45% { transform: scale(1.1); }
  60% { transform: scale(1); }
}

@media (max-width: 480px) {
  .header { padding: 1.5rem 1rem 0.25rem; }
  .status-card { padding: 1.75rem 1.25rem; }
  .indicator { width: 72px; height: 72px; }
  .indicator-dot { width: 18px; height: 18px; }
  .history { padding: 1rem 1.25rem; }
}
