#execute at @s if block ~-4 ~1 ~2 daylight_detector[power=0] run scoreboard players add @s NightQ 1

execute as @s store result score @s KyuTime run time query daytime
execute if entity @s[scores={KyuTime=13670..18599}] run scoreboard players add @s NightQ 1

time add 10
execute if entity @s[scores={NightQ=10}] run tellraw @a[team=P] ["",{"text":"...and the world is plunged into darkness.","color":"dark_gray","italic":true}]
execute if entity @s[scores={NightQ=10}] run time add 500
execute if entity @s[scores={NightQ=10}] run data merge block ~ ~ ~ {auto:0b}
execute if entity @s[scores={NightQ=10}] run data merge block ~ ~1 ~ {auto:1b}