* {
    box-sizing: border-box;
    font-family: 'Poppins', arial, helvetica, sans-serif;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    background-color: #404040;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    color: white;
    min-height: 100%;
}

body {
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

[hidden] {
    display: none !important;
}

button {
    touch-action: manipulation;
}

main {
    padding-top: 1.2em;
}

/* ------------------------------------------------------------ the watch */

.WatchLabel {
    text-align: center;
    font-size: clamp(18px, 3vmax, 36px);
    min-height: 1.5em;
    padding: 0 3.5em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.DisplayCase {
    width: 100%;
    text-align: center;
}

.Display {
    padding: 20px 2vw;
    width: 85%;
    margin-left: auto;
    margin-right: auto;
    font-size: 13vw;
    font-family: 'Chivo Mono', ui-monospace, monospace;
    font-variant-numeric: tabular-nums;
    line-height: 1.3;
    white-space: nowrap;
    color: white;
    border: 2px solid;
    border-color: black gray gray black;
    background-color: darkred;
}

/* ------------------------------------------------------------ buttons and fields */

.Lobby {
    width: 80%;
    max-width: 400px;
    margin: 10px auto 0;
    text-align: center;
}

.Buttons {
    display: flex;
    justify-content: center;
    gap: 4%;
    margin-top: 1.2em;
}

.Btn {
    font-size: 25px;
    width: 40%;
    min-height: 52px;
    border-radius: 15px;
    border: 2px solid;
    border-color: #f4f4f4 #8a8a8a #8a8a8a #f4f4f4;
    background: #efefef;
    color: black;
    cursor: pointer;
}

.Btn:active:not(:disabled) {
    background: #d6d6d6;
    border-color: #8a8a8a #f4f4f4 #f4f4f4 #8a8a8a;
}

.Btn:disabled {
    color: #8d8d8d;
    background: #d8d8d8;
    cursor: default;
}

.Btn:focus-visible, .Field:focus-visible, .IDReadout:focus-visible, .WhosHere:focus-visible, .MenuBtn:focus-visible {
    outline: 3px solid cornflowerblue;
    outline-offset: 2px;
}

.Field {
    font-size: 25px;
    width: 80%;
    border-radius: 15px;
    border: 2px solid #8a8a8a;
    padding: 6px 12px;
    text-align: center;
    user-select: text;
    -webkit-user-select: text;
}

.Instructions {
    display: block;
    font-size: 3vmax;
    margin: 0.5em 0 0.8em;
}

/* ------------------------------------------------------------ corners */

.IDReadout, .WhosHere {
    position: fixed;
    bottom: calc(15px + env(safe-area-inset-bottom));
    background: none;
    border: none;
    padding: 4px;
    color: white;
    font-size: 3vmax;
    cursor: pointer;
}

.IDReadout {
    right: calc(10px + env(safe-area-inset-right));
    animation: SlideInFromRight 0.4s ease-in-out 1.4s backwards;
}

.WhosHere {
    left: calc(10px + env(safe-area-inset-left));
    animation: RevealWord 0.4s ease-in-out 0.4s backwards;
}

.MenuBtn {
    position: fixed;
    top: calc(6px + env(safe-area-inset-top));
    right: calc(6px + env(safe-area-inset-right));
    width: 44px;
    height: 44px;
    font-size: 28px;
    line-height: 1;
    color: white;
    background: none;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0.7;
}

.MenuBtn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
}

/* ------------------------------------------------------------ menu */

.context {
    width: 170px;
    margin: 0;
    padding-left: 0;
    box-shadow: 5px 10px 8px rgba(0, 0, 0, 0.3);
    background: #ffffff;
    border: 1px solid;
    border-color: darkgray gray gray darkgray;
    border-radius: 8px;
    position: fixed;
    top: 0;
    left: 0;
    color: black;
    font-size: 16px;
    visibility: hidden;
    z-index: 10;
}

.context.open {
    visibility: visible;
}

.context-link {
    list-style-type: none;
    padding: 0.75em 1em;
    font-size: 0.95em;
    border-radius: 8px;
    cursor: pointer;
    outline: none;
}

.context-link:hover, .context-link:focus {
    background: #eeeeee;
}

@media (prefers-color-scheme: dark) {
    .context {
        color: white;
        background: #171717;
        box-shadow: 5px 10px 8px rgba(0, 0, 0, 0.4);
    }

    .context-link:hover, .context-link:focus {
        background: #363636;
    }
}

/* ------------------------------------------------------------ dialogs */

.Dialog {
    width: min(450px, 92vw);
    padding: 10px 0;
    color: white;
    background-color: #4d4d4d;
    border: 1px solid;
    border-color: silver gray gray silver;
    border-radius: 20px;
    text-align: center;
}

.Dialog[open] {
    animation: OpenDlgBox 0.3s ease-out;
}

.Dialog::backdrop {
    background: rgba(0, 0, 0, 0.55);
}

.DialogSection {
    padding: 12px 20px;
    width: 100%;
    font-size: 24px;
}

.DialogSection.Buttons {
    margin-top: 0;
}

.DialogSection .Btn {
    font-size: 22px;
}

.Small {
    font-size: 16px;
    color: #dcdcdc;
}

.TimeFields {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.TimeFields label {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 14px;
    color: #dcdcdc;
}

.TimeFields input {
    width: 80px;
    font-size: 24px;
    text-align: center;
    border-radius: 15px;
    border: 2px solid #8a8a8a;
    padding: 4px;
    user-select: text;
    -webkit-user-select: text;
}

/* ------------------------------------------------------------ toasts */

.Toast {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(70px + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    pointer-events: none;
    z-index: 20;
}

.ToastMsg {
    background-color: cornflowerblue;
    min-width: 100px;
    max-width: 90vw;
    padding: 5px 15px;
    text-align: center;
    border-radius: 5px;
    opacity: 0;
    overflow-wrap: anywhere;
    animation: ToastAni 4.5s ease-in-out 0.2s backwards;
}

/* ------------------------------------------------------------ animations */

.WordReveal {
    animation: RevealWord 0.4s ease-in-out 0.1s backwards;
}

@keyframes RevealWord {
    0% { transform: rotateX(-90deg); }
}

@keyframes SlideInFromRight {
    0% { opacity: 0; transform: translateX(9rem); }
}

@keyframes OpenDlgBox {
    0% { opacity: 0; transform: scale(0.9); }
}

@keyframes ToastAni {
    0% { opacity: 0; transform: translateY(10px); }
    8% { opacity: 1; transform: none; }
    85% { opacity: 1; }
    100% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-delay: 0s !important;
    }
}

/* ------------------------------------------------------------ small screens */

@media (max-width: 500px) {
    .Display {
        width: 94%;
        font-size: 14vw;
        padding: 16px 1vw;
    }

    .Lobby {
        width: 95%;
    }

    .Btn {
        width: 45%;
    }
}

/* Phones on their side: keep the buttons on screen. */
@media (max-height: 500px) and (orientation: landscape) {
    main {
        padding-top: 0.3em;
    }

    .Display {
        font-size: min(13vw, 22vh);
        padding: 8px 2vw;
    }

    .Buttons {
        margin-top: 0.6em;
    }

    .IDReadout, .WhosHere {
        font-size: 18px;
        bottom: calc(6px + env(safe-area-inset-bottom));
    }
}
