@font-face { font-family: 'Fredericka'; src: url('assets/fonts/Fredericka.ttf') format('truetype'); font-display: block}
@font-face { font-family: 'Nosifer'; src: url('assets/fonts/Nosifer.ttf') format('truetype'); font-display: block}
@font-face { font-family: 'RubikIso'; src: url('assets/fonts/RubikIso.ttf') format('truetype'); font-display: block}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    overflow: hidden;
    background-color: black;
    font-family: 'Fredericka', sans-serif;
    color: white;
}
body {
    display: flex;
    justify-content: center;
    align-items: center;
}
#app-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 1rem rgba(255, 255, 255, 0.3);
    padding: 0.5rem;
    box-sizing: border-box;
    margin: auto;
    position: relative;
    overflow: hidden;
    aspect-ratio: 2 / 1;
    max-width: 97vw;
    max-height: 94vh;
    width: calc(min(97vw, 94vh * (2 / 1)));
    height: calc(min(97vw * (1 / 2), 94vh));
}
#app-container.overlay-active > #game-wrapper {
    pointer-events: none;
}
#app-container > #game-wrapper {
    pointer-events: auto;
}
#game-wrapper {
    width: 100%;
    height: 100%;
    min-height: 0;
    position: relative;
    border: 0.2rem solid white;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background-color: rgb(135, 206, 235);
}
#game-wrapper::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('assets/background.jpeg');
    background-repeat: no-repeat; background-position: center center;
    background-size: cover; opacity: 0.7; z-index: 0;
}
#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    position: relative;
    z-index: 1;
}
#top-ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    padding: 0.3rem;
    background-color: black;
    box-sizing: border-box;
    z-index: 51;
    gap: 0.3rem;
}
#top-ui-overlay::-webkit-scrollbar {
    display: none;
}
#top-ui-overlay {
    -ms-overflow-style: none;
    scrollbar-width: none;
}
#top-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 0.3rem;
}
.top-info-column {
    flex-basis: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-around;
    position: relative;
}
.top-info-column h2 {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    margin: 0;
    font-size: 1rem;
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.6);
    text-align: center;
    width: 100%;
    pointer-events: none;
}
.health-bar-container {
    height: 1.5rem;
    background-color: #222;
    border: 2px solid white;
    overflow: hidden;
    width: 100%;
    position: relative;
    z-index: 1;
    box-sizing: border-box;
}
.health-bar-fill {
    height: 100%;
    width: 100%;
    transition: width 0.2s ease-out;
}
#player-health-bar-fill {
    background-color: rgba(220, 40, 40, 0.7);
}
#portal-health-bar-fill {
    background-color: rgba(100, 100, 255, 0.7);
}
#timer-row {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 1.5rem;
    box-sizing: border-box;
}
#timer-bar-fill {
    background-color: rgba(80, 180, 80, 0.7);
}
#timer-text-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 3;
    font-size: 1rem;
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    pointer-events: none;
}
#epoch-overlay {
    position: absolute;
    top: 20%;
    left: 0;
    width: 100%;
    text-align: center;
    font-family: 'RubikIso', sans-serif;
    font-size: 3em;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.6);
    z-index: 50;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease-in-out, visibility 0s linear 0.5s;
    pointer-events: none;
}
#bottom-ui-overlay {
    position: absolute;
    bottom: 0rem;
    width: fit-content;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.3rem;
    background-color: black;
    box-sizing: border-box;
    z-index: 51;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    border-radius: 8px 8px 0 0;
}
#bottom-ui-overlay::-webkit-scrollbar {
    display: none;
}
#bottom-ui-overlay {
    -ms-overflow-style: none;
    scrollbar-width: none;
}
#item-selection-area {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
#inventory-boxes-container,
#weapon-slots-container {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 0.3rem;
    justify-content: center;
}
.item-box {
    width: clamp(2.2rem, 4.5vw, 2.8rem);
    aspect-ratio: 1 / 1;
    border: 0.0625rem solid white;
    border-radius: 4px;
    position: relative;
    background-color: #333;
    box-shadow: inset 0 0 4px rgba(0,0,0,0.4);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: clamp(14px, 2.2vw, 18px);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.item-box.active {
    border-color: yellow;
    box-shadow: 0 0 6px yellow;
    opacity: 1;
}
.item-box.disabled {
    opacity: 0.45;
    cursor: default;
    box-shadow: inset 0 0 5px rgba(0,0,0,0.8);
    border-color: #666;
}
.item-box.placeholder-slot { background-color: #2a2a2a;
    opacity: 0.3;
    cursor: default;
    border-color: #444;
    box-shadow: inset 0 0 3px rgba(0,0,0,0.6);
}
.item-box.material-half-box {
    position: relative;
}
/* MODIFIED: New system using ::before and ::after for slash and fill */
.item-box.material-half-box::before,
.item-box.material-half-box::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}
/* The always-visible, dark slash line */
.item-box.material-half-box::before {
    background: linear-gradient(to bottom right, transparent 48.5%, rgba(0, 0, 0, 0.4) 48.5%, rgba(0, 0, 0, 0.4) 51.5%, transparent 51.5%);
    display: block;
}
/* The illuminated half, hidden by default */
.item-box.material-half-box::after {
    background-color: rgba(255, 255, 255, 0.25);
    clip-path: polygon(100% 0, 0 0, 0 100%); /* Top-left triangle for a / slash */
    display: none;
}
/* Show the illuminated half when the class is present */
.item-box.material-half-box.half-collected::after {
    display: block;
}
.item-box .item-count,
.item-box .weapon-status-symbol {
    position: absolute;
    bottom: 0.0625rem;
    right: 0.125rem;
    font-size: 0.8em;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 1px black;
    pointer-events: none;
}
#boot-overlay,
#menu-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    text-align: center;
    color: white;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0s linear 0.3s;
}
#boot-overlay {
    background-color: black;
    z-index: 200;
}
#boot-overlay.show-title,
#boot-overlay.show-error {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 0.3s ease, visibility 0s linear 0s;
}
#menu-overlay {
    background-color: black;
    z-index: 100;
    transition: opacity 0.3s ease, visibility 0s linear 0.3s, background-color 0.3s ease;
}
#menu-overlay.menu-overlay--translucent {
    background-color: rgba(0, 0, 0, 0.75);
}
#menu-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 0.3s ease, visibility 0s linear 0s, background-color 0.3s ease;
}
#menu-overlay.active.show-cutscene #overlay-cutscene-content {
    width: 100%;
    height: 100%;
    max-width: none;
    position: relative;
}
.overlay-content {
    display: none;
    flex-direction: column;
    align-items: center;
    width: 80%;
    max-width: 500px;
    padding: 20px;
    box-sizing: border-box;
}
#overlay-mainmenu-content {
    display: none;
    flex-direction: column;
    width: 100%;
    height: 100%;
    max-width: none;
    box-sizing: border-box;
    justify-content: center; /* Modified to allow button group at bottom */
    align-items: center;
    position: relative; /* Added for absolute positioning of title card */
}
#overlay-settings-content,
#overlay-pause-content {
    display: none;
    flex-direction: column;
    width: 100%;
    height: 100%;
    max-width: none;
    box-sizing: border-box;
    justify-content: center;
    align-items: center;
}
#boot-overlay h1, #menu-overlay h1 {
    font-family: 'RubikIso', sans-serif;
    font-size: 3.5em;
    margin-bottom: 1.5rem;
    text-shadow: 2px 2px 6px rgba(255, 255, 255, 0.4);
}
#boot-overlay h2, #menu-overlay h2 {
    font-size: 2.5em;
    margin-bottom: 1.5rem;
}
#boot-overlay p, #menu-overlay p {
    font-size: 1.2em;
    margin-bottom: 1.5rem;
}
.button-hero-action {
    background-color: black;
    border: 2px solid white;
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.1s ease, color 0.2s ease, text-shadow 0.2s ease;
    border-radius: 8px;
    color: white;
    font-family: 'RubikIso', sans-serif;
    font-size: clamp(1.1em, 2.5vw, 1.5em);
    text-shadow: 1px 1px 3px rgba(255, 255, 255, 0.3);
    margin: 0.5rem;
    box-sizing: border-box;
    min-width: 200px;
    text-align: center;
}
.button-hero-action:hover {
    background-color: #1a1a1a;
    border-color: #f0f0f0;
    color: #f0f0f0;
    text-shadow: 2px 2px 6px rgba(255, 255, 255, 0.4);
}
.button-hero-action:active {
    background-color: #0d0d0d;
    border-color: #e0e0e0;
    transform: scale(0.97);
}
.button-hero-action.button-hero-action--destructive {
    border-color: darkred;
    text-shadow: 1px 1px 3px rgba(255,100,100,0.3);
}
.button-hero-action.button-hero-action--destructive:hover {
    background-color: #1a0000;
    border-color: red;
    color: white;
    text-shadow: 2px 2px 6px rgba(255,100,100,0.4);
}
.button-hero-action.button-hero-action--destructive:active {
    background-color: #330000;
    border-color: #cc0000;
}
.button-hero-action.button-hero-action--constructive {
    border-color: darkgreen;
    text-shadow: 1px 1px 3px rgba(100,255,100,0.3);
}
.button-hero-action.button-hero-action--constructive:hover {
    background-color: #001a00;
    border-color: green;
    color: white;
    text-shadow: 2px 2px 6px rgba(100,255,100,0.4);
}
.button-hero-action.button-hero-action--constructive:active {
    background-color: #003300;
    border-color: #006400;
}
.button-hero-action.button-hero-action--secondary {
    border-color: #aaa;
    color: #ccc;
}
.button-hero-action.button-hero-action--secondary:hover {
    background-color: #1a1a1a;
    border-color: #ccc;
    color: white;
}
.button-group-bottom-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    width: 100%;
    padding: 1rem;
    box-sizing: border-box;
    margin-top: auto;
}
.button-group-bottom-right .button-hero-action {
    margin-top: 0.5rem;
    margin-left: 0;
}
.button-group-bottom-right .button-hero-action:first-child {
    margin-top: 0;
}
#overlay-pause-content .button-group-bottom-right,
#overlay-settings-content .button-group-bottom-right {
    margin-top: 0;
    align-items: center;
}
#title-heading-button {
    background-color: black; 
    border: 2px solid white;
    width: clamp(12rem, 25vw, 18rem);
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: crosshair; 
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.1s ease;
    box-sizing: border-box;
}
#title-heading-button h1 {
    margin: 0; padding: 0; color: white;
    font-family: 'RubikIso', sans-serif;
    font-size: clamp(1.8rem, 3.5vw, 2.8rem);
    text-shadow: 2px 2px 8px rgba(255, 255, 255, 0.5);
    text-align: center;
    line-height: 1.1;
}
#title-heading-button:hover {
    background-color: #1a1a1a;
    border-color: #f0f0f0;
}
#title-heading-button:hover h1 {
    color: #f0f0f0;
    text-shadow: 2px 2px 8px rgba(255, 255, 255, 0.5);
}
#title-heading-button:active {
    background-color: #0d0d0d;
    border-color: #e0e0e0;
    transform: scale(0.97);
}
#boot-overlay.show-error {
    background-color: rgba(0, 0, 0, 0.95);
    color: red;
    padding: 20px;
}
#overlay-error-content h1 {
    font-family: 'RubikIso', sans-serif;
    font-size: 2.5em;
    margin-bottom: 1rem;
    color: red;
    text-shadow: 1px 1px 3px rgba(255, 100, 100, 0.5);
}
#overlay-error-content p {
    font-size: 1.2em;
    margin-bottom: 1.5rem;
    color: #ffdddd;
}
#overlay-error-content p#error-message-text {
    font-size: 1.1em;
    margin-bottom: 2rem;
    word-break: break-word;
    color: white;
    background-color: rgba(50,0,0,0.5);
    padding: 0.5rem;
    border-radius: 4px;
    border: 1px solid red;
}
#overlay-error-content p:last-child {
    font-size: 1em;
    color: #ffdddd;
}
.settings-options-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 35rem;
    margin-bottom: 1rem;
}
#settings-btn-weapon-highlight {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}
#highlight-color-preview {
    width: 2rem;
    height: 1.5rem;
    border: 1px solid white;
    border-radius: 4px;
    background-color: purple;
}
#color-picker-palette {
    position: absolute;
    background-color: rgba(0, 0, 0, 1);
    border: 2px solid white;
    padding: 1rem;
    z-index: 10;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.75rem;
    border-radius: 8px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: fit-content;
}
.color-swatch {
    width: 2.5rem;
    height: 2.5rem;
    border: 1px solid #555;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.1s ease, border-color 0.1s ease;
}
.color-swatch:hover {
    transform: scale(1.1);
    border-color: white;
}
.button-hero-action.settings-row__button--state-bad {
    border-color: red;
    color: lightcoral;
}
.button-hero-action.settings-row__button--state-bad:hover {
    border-color: #ff4d4d;
    color: #ff8080;
    background-color: #1a1a1a;
}
.button-hero-action.settings-row__button--state-good {
    border-color: limegreen;
    color: lightgreen;
}
.button-hero-action.settings-row__button--state-good:hover {
    border-color: #4dff4d;
    color: #80ff80;
    background-color: #1a1a1a;
}
.cutscene-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0;
    transition: opacity 1s ease-in-out; z-index: 1;
}
.cutscene-image.active {
    opacity: 1;
}
#cutscene-text-box,
#overlay-cutscene-content #cutscene-skip-button.button-hero-action {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.7s ease-in-out, visibility 0s linear 0.7s;
    pointer-events: none;
}
#menu-overlay.active.show-cutscene #cutscene-text-box {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    position: absolute;
    bottom: 5%;
    left: 50%;
    transform: translateX(-50%);
    width: 85%;
    max-width: 750px;
    min-height: 80px;
    background-color: black;
    border: 2px solid white;
    border-radius: 8px;
    padding: 15px 20px; box-sizing: border-box; z-index: 5;
    color: white;
    font-family: 'Fredericka', sans-serif;
    box-shadow: none;
}
#overlay-cutscene-content #cutscene-skip-button.button-hero-action {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    z-index: 10;
    margin-top: 0;
    font-size: 1.2em;
}
#cutscene-text-box.visible,
#overlay-cutscene-content #cutscene-skip-button.button-hero-action.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 0.7s ease-in-out, visibility 0s linear 0s;
}
#cutscene-text-content {
    margin: 0;
    font-size: 1.2em;
    line-height: 1.6;
    text-align: left;
    width: 100%;
    max-height: 100px;
    overflow-y: auto;
}
#overlay-pause-content .pause-epoch-info {
    font-size: 1.1rem;
    color: #cccccc;
    margin-bottom: 1rem;
    font-style: italic;
}
.pause-options-group {
    display: flex;
    flex-direction: column;
    align-items: center;
}
#overlay-gameover-content .button-hero-action,
#overlay-victory-content .button-hero-action {
    margin-left: auto;
    margin-right: auto;
}
#landscape-warning {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9); color: white;
    z-index: 101;
    justify-content: center;
    align-items: center;
    text-align: center;
    font-size: 1.5em;
}
noscript p { 
    color: white;
    text-align: center;
    padding: 1rem;
}
.mainmenu-title-card {
    font-family: 'Nosifer', sans-serif;
    font-size: clamp(2.2em, 6vw, 3em);
    color: #ffdddd;
    text-shadow: 1px 1px 0px #000, 2px 2px 3px rgba(255, 0, 0, 0.6);
    margin: 0;
    text-align: center;
    letter-spacing: 0.05em;
    white-space: nowrap;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
}
.flash-effect {
    background-color: white !important;
    transition: none !important;
}
.flash-effect > * {
    visibility: hidden !important;
}
@media (orientation: portrait) {
    #app-container { display: none; }
    #landscape-warning { display: flex; }
}