body {
    background: #222;
    margin: 0; padding: 0;
    color: #aaa;
    -webkit-text-size-adjust: 100%;
    touch-action: manipulation;
}
#header {
    width: 640px;
    max-width: calc(100vw - 20px);
    margin: 0px auto;
    padding-bottom: 10px;
}
h1 {
    color: #444;
    text-shadow: 2px 2px 0px #000;
    font-weight: normal;
    font-size: 28px;
    font-family: georgia;
    cursor: pointer;
    margin: 0;
}
h1.active {
    color: #e69d1e;
    cursor: default;
}
#score {
    float: right;
    font-size: 28px;
    color: #999;
    text-shadow: 2px 2px 0px #000;
    font-family: georgia;
}
#content {
    padding: 10px;
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
    box-sizing: border-box;
}
#network {
    width: 640px;
    max-width: calc(100vw - 20px);
    margin: 0 auto 10px auto;
    padding: 8px;
    background: rgba(0,0,0,0.18);
    border: 1px solid #333;
    border-radius: 8px;
    color: #aaa;
    font-family: monospace;
    font-size: 12px;
    box-sizing: border-box;
}
#net-controls {
    display: flex;
    align-items: stretch;
    gap: 8px;
}
#network:not(.online) #net-controls {
    display: block;
}
#network:not(.online) .online-only {
    display: none;
}
#network button {
    background: #333;
    color: #eee;
    border: 1px solid #555;
    padding: 6px 10px;
    cursor: pointer;
    min-height: 34px;
}
#network button:hover {
    background: #500;
}
#network input {
    flex: 1 1 auto;
    width: auto;
    max-width: 100%;
    background: #111;
    color: #e69d1e;
    border: 1px solid #444;
    padding: 6px;
    box-sizing: border-box;
    min-height: 34px;
    min-width: 0;
    cursor: text;
    user-select: text;
    -webkit-user-select: text;
}
#net-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    color: #777;
    line-height: 1.35em;
    overflow-wrap: anywhere;
}
#net-room, #net-players, #net-route {
    display: inline-block;
    padding: 2px 6px;
    border: 1px solid #3d3d3d;
    border-radius: 999px;
    background: #1b1b1b;
    color: #aaa;
    white-space: nowrap;
}
#net-status {
    color: #777;
    flex: 1 1 180px;
}
#game {
    width: 640px;
    max-width: calc(100vw - 20px);
    aspect-ratio: 4 / 3;
    height: auto;
    margin: 0 auto;
    background: #000;
    border: 5px solid #292929;
    position: relative;
    box-sizing: border-box;
    overflow: hidden;
    touch-action: none;
}
#game > * {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
}
#game canvas {
    image-rendering: auto;
}
#hud {
    color: #eee;
    z-index: 3;
}
#hud #packs {
    width: 440px;
    max-width: calc(100% - 40px);
    height: auto;
    max-height: calc(100% - 40px);
    overflow-y: auto;
    margin: 10px auto;
    padding: 10px;
    background: rgba(0,0,0,0.7);
    box-sizing: border-box;
}
#hud h2 {
    font-family: sans-serif;
    letter-spacing: 4px;
    text-align: center;
    color: #9e0000;
    font-weight: normal;
    margin: 10px 0;
}
#hud ol {
    padding: 0;
    margin: 0;
    list-style: none;
}
#hud #packs li {
    margin: 6px 40px;
    padding: 6px 10px;
    border: 2px solid #500;
    outline: 2px solid #300;
    background: #220000;
    font-family: monospace;
    font-size: 16px;
    color: #ffe4e4;
    text-shadow: 2px 2px 0px #000;
}
#hud #packs li:hover, #hud #packs li.selected {
    background: #300;
    cursor: pointer;
}
#hud #description {
    width: calc(100% - 20px);
    position: absolute;
    bottom: 0;
    margin: 10px;
    padding: 10px 20px;
    background: rgba(0,0,0,0.6);
    border: 2px solid rgba(0,0,0,0.2);
    color: #e69d1e;
    font-size: 12px;
    font-family: sans-serif;
    text-shadow: 1px 1px 0px #000;
    text-align: center;
    box-sizing: border-box;
}

#messages {
    color: #e69d1e;
    text-shadow: 2px 2px 0px #000;
    font-size: 28px;
    font-family: monospace;
    text-align: center;

    width: 640px;
    max-width: calc(100vw - 20px);
    margin: 14px auto;
    min-height: 34px;
}
#messages:empty {
    min-height: 0;
    margin-top: 0;
    margin-bottom: 0;
}
#touch-controls {
    width: 640px;
    max-width: calc(100vw - 20px);
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}
.touch-button {
    min-height: 64px;
    border: 2px solid #555;
    border-radius: 12px;
    background: #333;
    color: #eee;
    font-size: 28px;
    font-family: monospace;
    text-shadow: 1px 1px 0 #000;
    box-shadow: 0 4px 0 #111;
}
.touch-button:active {
    background: #500;
    transform: translateY(2px);
    box-shadow: 0 2px 0 #111;
}
.touch-start {
    font-size: 18px;
    color: #e69d1e;
}
.inactive {
    opacity: 0.3;
}
.inactive input:hover {
    background: #666;
    pointer: default;
}
#timer {
    font-family: monospace;
    letter-spacing: -0.1em;
    text-align: center;
    color: #555;
    text-shadow: -1px -1px 0px #666;
    font-size: 60px;
    line-height: 100px;
}
#players {
    font-family: sans-serif;
    list-style: none;
    font-size: 12px;
    line-height: 16px;
    color: #888;
    padding: 5px;
    margin-bottom: 20px;
    text-shadow: 1px 1px 1px #000;
}
#players li {
    margin-top: 10px;
}
#players .color {
    display: block;
    float: left;
    width: 15px;
    height: 15px;
    margin-right: 5px;
    border: 1px solid #000;
}
#players .name {
    color: #ccc;
    font-weight: bold;
}
.controls {
    margin-left: 23px;
    margin-top: 5px;
    color: #555;
}
.controls .button {
    color: #aaa;
    background: #444;
    border: 1px solid #555;
    padding: 1px 5px;
    cursor: default;

    -moz-border-radius: 3px;
    -webkit-border-radius: 3px;
    border-radius: 3px;
}

@media (max-width: 700px) {
    #content {
        width: 100vw;
        max-width: 100vw;
        padding-top: max(6px, env(safe-area-inset-top));
        padding-right: env(safe-area-inset-right);
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: env(safe-area-inset-left);
        overflow-x: hidden;
        box-sizing: border-box;
    }
    #header {
        width: calc(100vw - 16px);
        max-width: none;
        padding-bottom: 6px;
    }
    h1, #score {
        font-size: 22px;
    }
    #network {
        width: calc(100vw - 16px);
        max-width: none;
        padding: 6px;
        border-radius: 6px;
    }
    #net-controls {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }
    #net-meta {
        gap: 4px;
        margin-top: 6px;
        font-size: 11px;
    }
    #net-status {
        flex-basis: 100%;
    }
    #net-host, #net-copy {
        width: 100%;
    }
    #net-controls #net-link {
        grid-column: 1 / -1;
        width: 100%;
        max-width: none;
        justify-self: stretch;
        display: block;
    }
    #network input#net-link {
        width: 100%;
        min-width: 100%;
        max-width: none;
    }
    #game {
        width: 100vw;
        max-width: 100vw;
        border: 0;
        border-radius: 0;
        box-sizing: border-box;
        box-shadow: inset 0 0 0 2px #292929;
    }
    #messages {
        width: calc(100vw - 16px);
        max-width: none;
        font-size: 18px;
        margin: 8px auto;
        min-height: 24px;
    }
    #touch-controls {
        width: calc(100vw - 16px);
        max-width: none;
    }
    #hud #packs {
        max-width: calc(100% - 20px);
        margin: 6px auto;
        padding: 8px;
    }
    #hud #packs li {
        margin: 6px 8px;
        padding: 8px 10px;
        font-size: 14px;
    }
    #hud h2 {
        font-size: 18px;
        letter-spacing: 2px;
        margin: 6px 0;
    }
    #hud #description {
        margin: 6px;
        padding: 8px;
        width: calc(100% - 12px);
        font-size: 11px;
    }
    #timer {
        font-size: 42px;
        line-height: 70px;
    }
    #players {
        font-size: 11px;
        line-height: 14px;
        margin-bottom: 8px;
    }
}
