* {
    box-sizing: border-box;
}

:root {
    /* force-pool border colours */
    /* europe */
    --german-bg: #d4dcd7;
    --american-bg: #d3d9b9;
    --russian-bg: #e1c4a9;
    /* mediterranean */
    --italian-bg: #d7eddd;
    --british-bg: #f0e0ca;
    --french-bg: #d4e3f4;
    /* pacific */
    --japanese-bg: #f2b9b2;
    --commonwealth-bg: #f7edd8;
    --us-bg: #e0d8aa;
    /* resistance */
    --partisan-bg: #f8f6c6;

    /* mobile colours (width <= 600px) */
    --narrow-bg: #efeff4;
    --menu-border: #c8c7cc;
    --setup-info: #8e8e93;
    --menu-heading: #6d6d72;

    /* desktop colours */
    --title-bg: #939598;
    --start-red: #ed1b23;
    --setup-border: #626466;
    --border-color: #221e1f;
    --situation-report: #fff6e4;

    --europe-header: #b5bd94;
}

/* todo: title-inner as a ::before pseudoelement */

html,
body {
    margin: 0;
}

#main-form {
    height: 100%;
    width: 100%;
}

body {
    padding: 23px;
    text-align: center;
}

#control {
    padding: 8px;
    text-align: left;
    font-family: "Eras Medium ITC", Tahoma, sans-serif;
}

input[type="submit"],
input[type="button"] {
    background-color: inherit;
    border: 2px solid grey;
    color: inherit;
    width: 100px;
    height: 24px;
    border-radius: 12px;
    font-weight: bold;
}

#force-button,
#support-button {
    position: absolute;
    top: 30px;
    left: 50%;
    translate: -50%;
    z-index: 1;
}

input[type="submit"]:hover:not(:disabled),
input[type="button"]:hover {
    background-color: lightgray;
}

input[type="submit"]:active,
input[type="button"]:active {
    translate: 2px 2px;
}

input:disabled {
    opacity: .33;
}

#grid-wrapper {
    display: inline-grid;
    grid-template:
        "title       title       title        title        title         title  title" min-content
        ".           .           .            .            .             .      ." 10px
        "cc-logo     .           battleground battleground battleground  .      situation-report" 230px
        ".           .           .            .            .             .      ." 13px
        "axis-forces axis-forces axis-forces  .            allies-forces .      setup-boxes" 1fr "axis-forces axis-forces axis-forces  .            allies-forces .      ." 15px "axis-forces axis-forces axis-forces  .            allies-forces .      special-rules" auto / 18px 12px 129px 8px 159px 22px minmax(min-content, 600px);
}

#title-outer {
    border: 0.667px solid var(--border-color);
    grid-area: title;
}

#title-inner {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: baseline;
    align-content: center;
    justify-content: space-between;
    border: 1.92px solid var(--border-color);
    background-color: var(--title-bg);
    color: white;
    margin: 5px;
    padding: 1px 5.5px;
    font-size: 14pt;
    font-family: "Eras Demi ITC", Tahoma, sans-serif;
    /* No effect on Eras Demi; backup weight if Eras not available */
    font-weight: bold;
}

input::placeholder {
    color: white;
}

#title {
    flex: 1 0 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: inherit;
    font-family: inherit;
    font-weight: inherit;
    text-align: left;
    background-color: inherit;
    color: inherit;
    border: none;
}

#subtitle {
    flex: 0 0 fit-content;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: inherit;
    font-family: inherit;
    font-weight: inherit;
    background-color: inherit;
    color: inherit;
    border: none;
    text-align: right;
}

#CC-picture {
    grid-area: cc-logo;
    align-self: center;
}

#CC-logo {
    display: block;
    height: 224px;
    width: 16px;
    margin: 0 auto;
}

#battlefield-container {
    grid-area: battleground;
}

#battlefield {
    border: 2px solid black;
    position: relative;
}

/* mobile view only (width <= 600px) */
#battlefield-menu,
#allies-troop-quality,
#axis-troop-quality,
#open-objectives,
#secret-objectives,
.ob-menu {
    display: none;
}

#orientation {
    position: absolute;
    height: 100%;
    width: 100%;
    top: 0;
    left: 0;
}

#map {
    width: 292px;
    height: 226px;
    display: block;
    opacity: .667;
}

#situation-report-container {
    grid-area: situation-report;
    position: relative;
}

#situation-report-folder {
    height: 25px;
    width: 163.3px;
    display: block;
}

#situation-report-label {
    font-family: "Eras Demi ITC", Tahoma, sans-serif;
    font-weight: bold;
    font-size: 9pt;
    position: absolute;
    top: 14px;
    left: 82px;
    translate: -50% -50%;
}

#situation-report {
    display: flex;
    flex-direction: column;
    border: 1px solid black;
    background-color: var(--situation-report);
    color: black;
    position: absolute;
    top: 24px;
    left: 0;
    bottom: 0;
    width: 100%;
    padding: 10px 6px;
    text-align: left;
}

#situation-report>textarea {
    display: block;
    width: 100%;
    background-color: inherit;
    color: inherit;
    border: none;
    resize: none;
}

#situation-report-heading {
    font-family: "Eras Demi ITC", Tahoma, sans-serif;
    font-weight: bold;
    font-size: 10pt;
    margin: 0;
}

#situation-report-paragraph {
    font-family: "Eras Medium ITC", Tahoma, sans-serif;
    font-size: 10pt;
    flex-grow: 1;
}

#axis-forces {
    grid-area: axis-forces;
}

#allies-forces {
    grid-area: allies-forces;
}

#forces-container {
    display: contents;
}

.forces {
    border: 2.667px solid black;
    position: relative;
}

.forces::before {
    display: block;
    background-color: white;
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 4px;
    right: 4px;
    border: 0.667px solid black;
    content: "";
}

.force-label {
    font-family: "Eras Demi ITC", Tahoma, sans-serif;
    font-weight: bold;
    font-size: 12pt;
    width: 133px;
    padding: 2.5px 0;
    position: absolute;
    top: 0;
    left: 50%;
    translate: -50% -8px;
    border: 1.333px solid black;
    background-color: inherit;
    text-align: center;
    z-index: 1;
}

.america-forces {
    background-color: var(--american-bg);
}

.russia-forces {
    background-color: var(--russian-bg);
}

.germany-forces {
    background-color: var(--german-bg);
}

.italy-forces {
    background-color: var(--italian-bg);
}

.france-forces {
    background-color: var(--french-bg);
}

.britain-forces {
    background-color: var(--british-bg);
}

.japan-forces {
    background-color: var(--japanese-bg);
}

.commonwealth-forces {
    background-color: var(--commonwealth-bg);
}

.us-forces {
    background-color: var(--us-bg);
}

.partisan-forces {
    background-color: var(--partisan-bg);
}

.force-panel {
    position: relative;
}

.force-panel>div {
    margin-bottom: 6px;
    position: relative;
}

/* unit label */
.force-panel>div>div:nth-of-type(2) {
    display: none;
}

.force-panel>div:hover>div:nth-of-type(2) {
    display: block;
    font-family: "Eras Demi ITC", Tahoma, sans-serif;
    font-weight: bold;
    background: rgba(255, 255, 255, .8);
    border-radius: 5px;
    border: 1px solid black;
    font-size: 10pt;
    color: black;
    padding: 5px 5px;
    position: absolute;
    top: 80%;
    left: 40%;
    z-index: 100;
}

.force-panel>div:first-of-type {
    margin-top: 23px;
}

.force-panel>div:last-of-type {
    margin-bottom: 10px;
}

/* 5/8" counter */
.lg {
    height: 60px;
    width: 60px;
    margin: auto;
    display: block;
}

/* 1/2" counter */
.sm {
    height: 48px;
    width: 48px;
    margin: auto;
    display: block;
}

/* unit count */
.lg+div,
.sm+div {
    font-family: "Eras Demi ITC", Tahoma, sans-serif;
    font-weight: bold;
    font-size: 12pt;
    position: absolute;
    bottom: -2px;
}

.lg+div {
    left: 112px;
}

.sm+div {
    left: 106px;
}

.roundel {
    position: absolute;
    bottom: 12px;
    left: 50%;
    translate: -50%;
    opacity: 25%;
}

#setup-boxes {
    grid-area: setup-boxes;
    align-content: space-around;
}

.setup {
    max-width: 420px;
}

.setup>div {
    position: relative;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-content: center;
    border: 0.667px solid var(--setup-border);
    border-radius: 2.9px;
    padding: 2px 7px;
    margin: 0 12px 5px 24px;
}

.setup>div:last-of-type {
    margin-bottom: 0;
}

.setup-start::before {
    font-family: "Eras Medium ITC", Tahoma, sans-serif;
    position: absolute;
    right: 100%;
    top: -6px;
    content: "start";
    color: var(--start-red);
    font-size: 8pt;
    translate: -2px;
}

.setup-icon {
    position: absolute;
    display: block;
    right: 100%;
    top: 50%;
    translate: 0 -50%;
}

/* setup label */
.setup>div>div:first-of-type {
    font-family: "Eras Demi ITC", Tahoma, sans-serif;
    font-weight: bold;
    font-size: 9pt;
    text-align: left;
    text-transform: uppercase;
}

/* setup info */
.setup>div>div:nth-of-type(2) {
    font-family: "Eras Medium ITC", Tahoma, sans-serif;
    font-size: 9pt;
    color: var(--border-color);
    text-align: right;
}

.squash {
    flex-grow: 1;
    flex-basis: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: wrap;
}

#special-rules-outer {
    grid-area: special-rules;
    border: .667px solid var(--border-color);
    border-radius: 5.2px;
    padding: 1.5px;
    text-align: left;
}

#special-rules-inner {
    padding: 0;
    border: 0.333px solid var(--border-color);
    border-radius: 3.333px;
    padding: 11px 5px;
}

#special-rules-inner>h1 {
    font-family: "Eras Demi ITC", Tahoma, sans-serif;
    font-weight: bold;
    margin: 0;
    font-size: 10pt;
    text-transform: uppercase;
}

#special-rules-inner>ol {
    font-family: "Eras Medium ITC", Tahoma, sans-serif;
    font-size: 10pt;
    padding-left: 15px;
    margin-bottom: 0;
}

#special-rules-inner>ol>li {
    margin-bottom: 15px;
}

#special-rules-inner>ol>li:last-child {
    margin-bottom: 0;
}

#special-rules-inner>ol>li::marker {
    font-family: "Eras Demi ITC", Tahoma, sans-serif;
    font-weight: bold;
}

.selection {
    background-color: white;
    font-family: "Eras Demi ITC", Tahoma, sans-serif;
    font-weight: bold;
    text-align: left;
    font-size: 14pt;
    border-style: solid none;
    border-width: 1px;
    border-color: darkgray;
    padding: 0;
    position: relative;
}

.modal-body>div:first-of-type:not(:last-child) {
    margin-bottom: 40px;
}

legend {
    position: absolute;
    bottom: 100%;
    left: 10px;
    text-transform: lowercase;
    font-variant: small-caps;
    translate: 0 -5px;
    color: #555;
}

/*.selection input {
    float: right;
}*/

.selection>div {
    position: relative;
    display: flex;
    max-width: 600px;
    flex-direction: row;
    align-content: center;
    align-items: center;
    padding: 10px 15px;
    margin: 0 auto;
}

.selection>div:not(:last-of-type)::after {
    content: "";
    position: absolute;
    clear: both;
    right: 15px;
    height: 1px;
    bottom: 0;
    border-bottom: 1px solid lightgray;
}

.label-selection>div:not(:last-of-type)::after {
    left: 55px;
}

.unit-selection>div:not(:last-of-type)::after {
    left: 85px;
}

.selection>div>div:first-of-type,
.selection>div>label {
    flex-grow: 1;
}

.selection>div>label {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-content: center;
    align-items: center;
}

.selection .setup-info {
    font-family: "Eras Medium ITC", Tahoma, sans-serif;
    font-weight: normal;
    color: var(--setup-info);
    text-align: right;
}

.selection .vp-cost {
    font-size: 16pt;
    font-weight: bold;
    color: black;
    font-family: "Eras Demi ITC", Tahoma, sans-serif;
    font-weight: bold;
}

.vertical-radio,
.horizontal-radio input {
    align-self: center;
    appearance: none;
}

.horizontal-radio input {
    width: 0;
    margin: 0;
}

.vertical-radio {
    margin-left: 10px;
}

.vertical-radio::after {
    display: block;
    border-style: none none solid solid;
    border-color: transparent;
    border-width: 2px;
    content: "";
    width: 15px;
    height: 7px;
    rotate: -45deg;
    text-align: center;
    transition: .2s;
    align-self: center;
}

.vertical-radio:checked:after {
    border-color: black;
}

.horizontal-radio {
    display: flex;
    justify-content: center;
}

.horizontal-radio>label {
    font-family: sans-serif;
    font-weight: bold;
    font-size: 10pt;
    background-color: inherit;
    border-color: grey;
    border-width: 2px;
    color: inherit;
    max-width: 100px;
    height: 24px;
    text-align: center;
    margin-top: 5px;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.horizontal-radio>label:not(:last-of-type) {
    border-style: solid none solid solid;
}

.horizontal-radio>label:first-of-type {
    border-radius: 12px 0 0 12px;
    margin-left: 60px;
}

.horizontal-radio>label:last-of-type {
    border-style: solid;
    border-radius: 0 12px 12px 0;
    margin-right: 60px;
}

.horizontal-radio>input:checked+label {
    background-color: grey;
    color: white;
}

.selection img.icon {
    height: 30px;
    width: 30px;
    vertical-align: middle;
    margin-right: 10px;
}

.selection img.unit {
    height: 60px;
    width: 60px;
    vertical-align: middle;
    margin-right: 10px;
}

.selection img.radio {
    height: 48px;
    width: 48px;
    vertical-align: middle;
    margin-right: 10px;
    margin-left: 6px;
}

.selection img.unit+img {
    height: 48px;
    width: 48px;
    position: absolute;
    left: 50px;
    top: 50%;
    translate: 0 -50%;
}

.selection img.unit+img+.multiplier {
    margin-left: 38px;
}

.selection .multiplier {
    align-self: flex-end;
    flex-grow: 0;
}

#unit-panel {
    font-family: "Eras Demi ITC", Tahoma, sans-serif;
    font-weight: bold;
    text-align: center;
    font-size: 14pt;
    padding: 25px 15px 0;
    white-space: nowrap;
    overflow-x: scroll;
}

#unit-panel>div {
    display: inline-block;
    max-width: 60px;
    margin: 0 5px;
}

.large-counter {
    height: 60px;
    width: 60px;
}

.small-counter {
    height: 48px;
    width: 48px;
    translate: 0 -6px;
}

.dialog-button {
    display: flex;
    font-family: sans-serif;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40px;
    background-color: var(--europe-header);
    align-items: center;
    justify-content: center;
}

.dialog-button>input {
    margin-left: 10px;
}

@media print {

    html,
    body {
        height: 100%;
        width: 100%;
    }

    #grid-wrapper {
        height: 100%;
    }

    input:not(#title)::placeholder,
    textarea::placeholder {
        opacity: 0;
    }

    #control,
    input[type="button"] {
        display: none;
    }

    .modal,
    .dialog-button {
        display: none;
    }
}

@media screen and (max-width: 600px) {

    body {
        padding: 0;
        background-color: var(--narrow-bg);
    }

    #grid-wrapper {
        width: 100%;
        grid-template:
            "cc-logo"
            "title"
            "battleground"
            "setup-boxes"
            "forces"
            "special-rules" / 100%;
    }

    #situation-report-container,
    #subtitle,
    #troop-quality,
    #objectives,
    .force-label,
    .roundel,
    .force-panel,
    .forces::before {
        display: none;
    }

    #CC-logo {
        width: 90%;
        height: auto;
        margin: 20px auto 20px;
    }

    #title-outer {
        display: contents;
    }

    #title-inner {
        border: none;
        border-top: 1px solid var(--menu-border);
        border-bottom: 1px solid var(--menu-border);
        height: 53px;
        width: 100%;
        background-color: white;
        color: black;
        margin: 0;
        padding: 0 15px;
        font-weight: normal;
    }

    #title-inner::before {
        content: "Title";
        margin-right: 20px;
    }

    #title {
        text-transform: uppercase;
        font-size: 80%;
        text-align: right;
    }

    input::placeholder {
        color: black;
    }

    #battlefield-container {
        position: relative;
        top: 0;
        left: 0;
        width: 100%;
        cursor: pointer;
    }

    #battlefield-menu,
    .ob-menu {
        display: block;
        margin-top: 20px;
    }

    .setup {
        background-color: white;
        margin-top: 30px;
        max-width: 600px;
    }

    #allies-troop-quality,
    #axis-troop-quality,
    #secret-objectives,
    #open-objectives {
        display: flex;
    }

    .setup>div {
        position: relative;
        width: 100%;
        height: 53px;
        padding: 0 15px;
        border: none;
        margin: 0;
        align-items: center;
    }

    .setup:not(.ob-menu)>div::after {
        display: block;
        position: absolute;
        height: 100%;
        right: 0;
        left: 60px;
        content: "";
        border-bottom: 1px solid var(--menu-border);
    }

    #allies-ob-menu>div::after {
        display: block;
        position: absolute;
        height: 100%;
        right: 0;
        left: 60px;
        content: "";
        border-top: 1px solid var(--menu-border);
        border-bottom: none;
    }

    .setup:not(#allies-ob-menu)>div:first-child {
        border-top: 1px solid var(--menu-border);
        left: 0;
    }

    .setup:not(.ob-menu)>div:last-child {
        border-bottom: 1px solid var(--menu-border);
        left: 0;
    }

    #allies-forces {
        border-bottom: 1px solid var(--menu-border);
    }

    .setup>.setup-start::before {
        position: absolute;
        top: -20px;
        left: 15px;
        font-size: 10pt;
        color: var(--menu-heading);
        text-transform: uppercase;
    }

    .setup>div>picture {
        align-self: center;
    }

    .setup-icon {
        display: block;
        height: 30px;
        width: 30px;
        position: relative;
        align-self: center;
        right: 0;
        top: 0;
        translate: 0;
        margin-right: 15px;
    }

    .setup>div>div:first-of-type {
        font-weight: normal;
        font-size: 14pt;
        text-transform: none;
    }

    .setup>div>div:nth-of-type(2) {
        font-size: 14pt;
        color: var(--setup-info);
    }

    #forces-container {
        display: block;
        grid-area: forces;
    }

    #axis-forces {
        display: block;
        grid-area: axis-forces;
        margin-top: 50px;
    }

    #axis-ob-menu::before {
        position: absolute;
        content: "ORDERS OF BATTLE";
        top: -20px;
        left: 15px;
        font-size: 10pt;
        color: var(--menu-heading);
        font-family: "Eras Medium ITC", Tahoma, sans-serif;
    }

    #allies-forces {
        display: block;
        grid-area: allies-forces;
    }

    .ob-menu {
        margin-top: 0;
    }

    .forces {
        border: none;
        background-color: white;
    }

    #allies-ob-menu {
        border-bottom: none;
    }

    #axis-ob-menu {
        border-top: none;
    }

    .force-panel {
        padding-bottom: 20px;
    }

    .force-panel>div {
        margin: 0;
        background-color: white;
        padding: 3px 20px;
    }

    .force-panel>div>.lg {
        margin-left: 0;
    }

    .force-panel>div>.sm {
        margin-left: 6px;
    }

    .force-panel>div>div {
        font-weight: normal;
        font-size: 12pt;
        position: absolute;
        bottom: 5px;
    }

    .force-panel>div>.lg+div {
        left: 90px;
    }

    .force-panel>div>.sm+div {
        left: 90px;
    }

    .force-panel>div {
        pointer-events: none;
    }

    .force-panel>div>div:nth-of-type(2) {
        display: block;
        font-family: "Eras Medium ITC", Tahoma, sans-serif;
        font-weight: normal;
        font-size: 14pt;
        color: var(--setup-info);
        position: absolute;
        right: 20px;
    }

    .force-panel>div:first-of-type {
        margin-top: 20px;
    }

    .force-panel>div:last-of-type {
        margin-bottom: 0px;
    }

    .menu-dropdown {
        display: inline;
        font-size: 14pt;
        margin-left: 15px;
        color: var(--setup-info);
        align-self: center;
    }

    #force-button {
        display: none;
    }

    .menu-dropdown::after {
        content: "\276f"
    }

    #battlefield {
        display: none;
        width: 100%;
        border: none;
    }

    #map {
        width: 100%;
        height: auto;
    }

    sup {
        font-size: 9pt;
        vertical-align: top;
    }

    #special-rules-outer {
        grid-area: special-rules;
        border: none;
        padding: 0;
    }

    #special-rules-inner>div {
        padding-top: 0;
        padding-bottom: 20px;
    }

    #special-rules-inner {
        border: none;
    }

    #special-rules-inner h1 {
        display: none;
    }

    #special-rules-inner ol {
        counter-reset: list;
        padding-left: 1em;
        font-size: 12pt;
    }

    #special-rules-inner ol>li {
        list-style: none;
    }

    #special-rules-inner ol>li::before {
        display: inline-block;
        margin-left: -1em;
        content: counter(list);
        margin-right: 5px;
        counter-increment: list;
        font-size: 9pt;
        vertical-align: top;
    }


}

/* modal dialog */

/* The Modal (background) */
.modal {
    display: none;
    position: fixed;
    z-index: 99;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.4);
    animation-name: fadeIn;
    animation-duration: 0.4s
}

.modal-content {
    position: fixed;
    bottom: 0;
    width: 100%;
    max-height: 100%;
    animation-name: slideIn;
    animation-duration: 0.4s;
    overflow-y: auto;
}

.close {
    display: inline-block;
    color: white;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    right: 20px;
    bottom: 50%;
    translate: 0 50%;
}

.close:hover,
.close:focus {
    color: #000;
    text-decoration: none;
    cursor: pointer;
}

.modal-header {
    position: relative;
    font-family: Tahoma, sans-serif;
    padding: 2px 16px;
    background-color: var(--europe-header);
    color: black;
    border-color: black;
    border-style: solid none;
    border-width: .5px;
    padding: 15px;
    font-size: larger;
}

.modal-body {
    background-color: var(--narrow-bg);
    font-family: Tahoma, sans-serif;
    padding: 20px 0;
}

.modal-footer {
    font-family: Tahoma, sans-serif;
    padding: 2px 16px;
    background-color: black;
    color: white;
    padding: 15px;
}

@keyframes slideIn {
    from {
        bottom: -300px;
        opacity: 0
    }

    to {
        bottom: 0;
        opacity: 1
    }
}

@keyframes fadeIn {
    from {
        opacity: 0
    }

    to {
        opacity: 1
    }
}