:root {
    color-scheme: dark;
}

html,
body {
    margin: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #05070c;
}

body {
    font-family: "Iowan Old Style", Georgia, serif;
}

canvas {
    position: fixed;
    inset: 0;
    display: block;
    z-index: 0;
}

#title-screen {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px;
    transition: opacity 0.6s ease, visibility 0.6s ease;
}

#title-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

#title-screen-backdrop {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at center, rgba(8, 12, 18, 0.18), rgba(4, 6, 10, 0.82) 58%, rgba(2, 3, 7, 0.96) 100%),
        linear-gradient(180deg, rgba(10, 14, 20, 0.4), rgba(4, 7, 12, 0.76));
    backdrop-filter: blur(8px);
}

#title-card {
    position: relative;
    width: min(720px, calc(100vw - 40px));
    padding: 34px 36px 30px;
    border: 1px solid rgba(244, 212, 167, 0.18);
    border-radius: 28px;
    background:
        linear-gradient(180deg, rgba(15, 18, 27, 0.9), rgba(6, 8, 14, 0.82)),
        radial-gradient(circle at top, rgba(193, 126, 62, 0.18), transparent 64%);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.46);
    text-align: center;
}

.title-kicker {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.42em;
    text-transform: uppercase;
    color: rgba(171, 195, 222, 0.72);
}

#title-logo {
    margin: 14px 0 10px;
    font-size: clamp(44px, 9vw, 82px);
    font-weight: 600;
    line-height: 0.95;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #f6e4c2;
    text-shadow: 0 6px 22px rgba(0, 0, 0, 0.5);
}

#title-copy {
    width: min(560px, 100%);
    margin: 0 auto;
    font-size: 17px;
    line-height: 1.6;
    letter-spacing: 0.04em;
    color: rgba(226, 220, 209, 0.86);
}

#title-actions {
    margin-top: 28px;
    display: grid;
    justify-items: center;
    gap: 12px;
}

#start-button {
    min-width: 190px;
    height: 52px;
    padding: 0 26px;
    border: 1px solid rgba(255, 224, 180, 0.26);
    border-radius: 999px;
    background:
        linear-gradient(180deg, rgba(214, 157, 89, 0.3), rgba(115, 68, 28, 0.46)),
        rgba(18, 12, 8, 0.94);
    box-shadow: inset 0 1px 0 rgba(255, 236, 206, 0.1), 0 12px 30px rgba(0, 0, 0, 0.34);
    color: #ffe6be;
    font-family: "Iowan Old Style", Georgia, serif;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    cursor: pointer;
}

#start-button:hover {
    filter: brightness(1.08);
}

#title-hint {
    font-size: 12px;
    letter-spacing: 0.06em;
    color: rgba(192, 205, 221, 0.68);
}

#bottom-left-ui {
    position: fixed;
    left: 22px;
    bottom: 22px;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(300px, calc(100vw - 32px));
    pointer-events: none;
}

#bottom-left-ui,
#hud,
#waypoint-layer {
    transition: opacity 0.35s ease;
}

body.prestart #bottom-left-ui,
body.prestart #hud,
body.prestart #waypoint-layer {
    opacity: 0;
}

#controls-panel {
    position: relative;
    width: 100%;
    width: min(300px, calc(100vw - 32px));
    padding: 12px 14px 14px;
    border: 1px solid rgba(243, 217, 182, 0.18);
    border-radius: 16px;
    background:
        linear-gradient(180deg, rgba(18, 20, 27, 0.82), rgba(8, 10, 15, 0.68)),
        radial-gradient(circle at top, rgba(196, 108, 57, 0.14), transparent 55%);
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(10px);
}

#controls-panel h1 {
    margin: 0 0 6px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: #f4d9bb;
}

.control-list {
    display: grid;
    gap: 6px;
}

.control-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 8px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.02);
}

.control-keys {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 102px;
}

.keycap,
.mouse-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 24px;
    padding: 0 8px;
    border-radius: 7px;
    border: 1px solid rgba(243, 217, 182, 0.28);
    background: linear-gradient(180deg, rgba(251, 230, 195, 0.14), rgba(255, 255, 255, 0.04));
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.2);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: #f6d4a0;
    text-transform: uppercase;
}

.keycap.wide {
    min-width: 48px;
}

.keycap.subtle,
.mouse-chip {
    color: rgba(232, 224, 210, 0.76);
    border-color: rgba(204, 212, 224, 0.18);
}

.control-action {
    flex: 1;
    text-align: right;
    margin: 0;
    font-size: 11px;
    line-height: 1.4;
    letter-spacing: 0.04em;
    color: rgba(234, 226, 214, 0.82);
}

#tip-panel {
    position: relative;
    width: 100%;
    padding: 10px 12px 11px;
    border: 1px solid rgba(130, 160, 200, 0.18);
    border-radius: 14px;
    background:
        linear-gradient(180deg, rgba(10, 14, 21, 0.84), rgba(5, 8, 13, 0.76)),
        radial-gradient(circle at top left, rgba(78, 132, 170, 0.2), transparent 68%);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(10px);
}

.tip-label {
    margin-bottom: 4px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: rgba(166, 197, 226, 0.72);
}

.tip-text {
    font-size: 11px;
    line-height: 1.45;
    letter-spacing: 0.04em;
    color: rgba(224, 231, 238, 0.86);
}

#vignette {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background:
        radial-gradient(circle at center, rgba(0, 0, 0, 0) 34%, rgba(4, 6, 11, 0.38) 74%, rgba(1, 2, 5, 0.72) 100%),
        linear-gradient(180deg, rgba(9, 10, 18, 0.16), rgba(6, 7, 11, 0.34));
}

#hud {
    position: fixed;
    top: 22px;
    left: 22px;
    z-index: 2;
    width: 320px;
    pointer-events: none;
}

#health-panel {
    padding: 12px 14px 10px;
    border: 1px solid rgba(243, 217, 182, 0.16);
    border-radius: 16px;
    background:
        linear-gradient(180deg, rgba(16, 19, 26, 0.82), rgba(7, 9, 14, 0.7)),
        radial-gradient(circle at top, rgba(171, 84, 45, 0.16), transparent 60%);
    box-shadow: 0 18px 36px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
}

#health-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 11px;
    letter-spacing: 0.26em;
    text-transform: uppercase;
    color: #f0d6b7;
}

#health-track {
    height: 12px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(37, 44, 54, 0.9);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

#health-fill {
    width: 100%;
    height: 100%;
    transform-origin: left center;
    background:
        linear-gradient(90deg, #7f1f19 0%, #bd5335 34%, #f6c27f 100%);
    box-shadow: 0 0 18px rgba(246, 171, 103, 0.32);
}

#health-status {
    margin-top: 8px;
    font-size: 11px;
    letter-spacing: 0.12em;
    color: rgba(228, 221, 208, 0.8);
    text-align: left;
}

#objective-panel {
    margin-bottom: 12px;
    padding: 10px 14px;
    border: 1px solid rgba(130, 160, 200, 0.22);
    border-radius: 14px;
    background:
        linear-gradient(180deg, rgba(8, 12, 18, 0.82), rgba(4, 6, 12, 0.7)),
        radial-gradient(circle at top, rgba(60, 100, 150, 0.2), transparent 70%);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(10px);
    text-align: left;
}

#objective-compass {
    margin-bottom: 12px;
    padding: 10px 14px 12px;
    border: 1px solid rgba(130, 160, 200, 0.22);
    border-radius: 14px;
    background:
        linear-gradient(180deg, rgba(8, 12, 18, 0.82), rgba(4, 6, 12, 0.7)),
        radial-gradient(circle at top, rgba(60, 100, 150, 0.2), transparent 70%);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(10px);
    text-align: center;
}

#compass-title {
    margin-bottom: 8px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: rgba(160, 190, 220, 0.6);
}

#compass-ring {
    position: relative;
    width: 78px;
    height: 78px;
    margin: 0 auto 8px;
    border: 2px solid rgba(255, 209, 118, 0.75);
    border-radius: 999px;
    background:
        radial-gradient(circle at center, rgba(255, 210, 120, 0.08), rgba(0, 0, 0, 0.0) 60%),
        rgba(4, 8, 12, 0.42);
    box-shadow: inset 0 0 18px rgba(255, 204, 102, 0.08), 0 0 18px rgba(0, 0, 0, 0.25);
}

#compass-needle {
    position: absolute;
    left: 50%;
    top: 8px;
    width: 4px;
    height: 30px;
    margin-left: -2px;
    border-radius: 999px;
    background: linear-gradient(180deg, #ffd26b 0%, #ff8f42 100%);
    box-shadow: 0 0 12px rgba(255, 178, 76, 0.55);
    transform-origin: 50% 31px;
}

#compass-center {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 12px;
    height: 12px;
    margin-left: -6px;
    margin-top: -6px;
    border-radius: 999px;
    background: #fff0ca;
    box-shadow: 0 0 8px rgba(255, 220, 140, 0.55);
}

#compass-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.16em;
    color: #ffd27b;
    text-transform: uppercase;
}

#objective-title {
    margin-bottom: 4px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: rgba(160, 190, 220, 0.6);
}

#objective-text {
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.08em;
    color: #c4d6ee;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.waypoint-marker {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 1000;
}

.waypoint-icon {
    width: 48px;
    height: 48px;
    border: 3px solid #ffcc00;
    border-radius: 8px;
    background: rgba(255, 180, 0, 0.45);
    transform: rotate(45deg);
    box-shadow: 0 0 30px rgba(255, 180, 0, 0.8), inset 0 0 10px rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    animation: marker-pulse 1.5s infinite alternate ease-in-out;
}

@keyframes marker-pulse {
    from { transform: rotate(45deg) scale(0.9); box-shadow: 0 0 15px rgba(255, 180, 0, 0.6); }
    to { transform: rotate(45deg) scale(1.1); box-shadow: 0 0 40px rgba(255, 180, 0, 1.0); }
}

.waypoint-icon::after {
    content: '';
    width: 14px;
    height: 14px;
    background: #ffffff;
    border-radius: 2px;
}

.waypoint-arrow {
    position: absolute;
    top: -30px;
    width: 0;
    height: 0;
    border-left: 14px solid transparent;
    border-right: 14px solid transparent;
    border-bottom: 22px solid #ffcc00;
    display: none;
    filter: drop-shadow(0 0 10px rgba(255, 180, 0, 1));
    transform-origin: center 46px;
}

.waypoint-marker.off-screen .waypoint-arrow {
    display: block;
}

.waypoint-label {
    margin-top: 22px;
    font-size: 14px;
    font-weight: 900;
    letter-spacing: 0.2em;
    color: #ffcc00;
    text-shadow: 0 0 15px rgba(0,0,0,1), 0 0 5px rgba(255, 204, 0, 0.5), 2px 2px 0px rgba(0,0,0,1);
    text-transform: uppercase;
    white-space: nowrap;
}

.waypoint-dist {
    font-size: 11px;
    font-weight: 800;
    color: #ffffff;
    background: rgba(0,0,0,0.6);
    padding: 2px 8px;
    border-radius: 4px;
    margin-top: 4px;
    text-shadow: 1px 1px 2px black;
}

#damage-flash {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background: radial-gradient(circle at center, rgba(214, 92, 57, 0.08), rgba(127, 14, 12, 0.26) 70%, rgba(18, 0, 0, 0.42) 100%);
    opacity: 0;
    transition: opacity 80ms linear;
}

#interaction-prompt {
    position: fixed;
    bottom: 38px;
    left: 50%;
    transform: translateX(-50%) translateY(12px);
    z-index: 10;
    padding: 10px 22px 10px 16px;
    border: 1px solid rgba(243, 217, 182, 0.22);
    border-radius: 999px;
    background:
        linear-gradient(180deg, rgba(18, 20, 28, 0.92), rgba(8, 10, 16, 0.85)),
        radial-gradient(circle at top, rgba(186, 118, 55, 0.18), transparent 60%);
    box-shadow: 0 8px 32px rgba(0,0,0,0.45);
    backdrop-filter: blur(14px);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-family: "Iowan Old Style", Georgia, serif;
    letter-spacing: 0.1em;
    color: #f2dbbf;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

#interaction-prompt.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

#interaction-prompt .prompt-key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: 1px solid rgba(243, 217, 182, 0.35);
    background: rgba(243, 217, 182, 0.1);
    font-size: 11px;
    font-weight: 700;
    color: #f6c97a;
    flex-shrink: 0;
}

#interaction-prompt .prompt-icon {
    font-size: 18px;
    flex-shrink: 0;
}

#shark-cargo {
    position: fixed;
    bottom: 100px;
    right: 24px;
    z-index: 5;
    padding: 10px 16px;
    border: 1px solid rgba(243, 217, 182, 0.18);
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(16,19,26,0.88), rgba(7,9,14,0.78));
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    font-family: "Iowan Old Style", Georgia, serif;
    letter-spacing: 0.12em;
    color: rgba(240, 220, 190, 0.9);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
}

#shark-cargo.visible {
    opacity: 1;
}

#subtitle-container {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 15;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
    width: min(72vw, 920px);
}

#subtitle-text {
    display: inline-block;
    font-size: 22px;
    font-family: "Iowan Old Style", Georgia, serif;
    font-style: italic;
    color: rgba(250, 240, 230, 0.95);
    line-height: 1.35;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.95), 0 0 20px rgba(0, 0, 0, 0.72);
    letter-spacing: 0.06em;
    background: radial-gradient(ellipse at center, rgba(0,0,0,0.62) 0%, rgba(0,0,0,0.18) 56%, rgba(0,0,0,0) 78%);
    padding: 16px 54px;
    border-radius: 999px;
}

#mission-complete {
    position: fixed;
    left: 50%;
    top: 50%;
    z-index: 20;
    width: min(560px, calc(100vw - 48px));
    padding: 28px 32px 30px;
    border: 1px solid rgba(255, 226, 165, 0.26);
    border-radius: 22px;
    background:
        linear-gradient(180deg, rgba(12, 16, 24, 0.92), rgba(4, 6, 12, 0.88)),
        radial-gradient(circle at top, rgba(194, 146, 67, 0.22), transparent 70%);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(12px);
    text-align: center;
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.94);
    transition: opacity 0.45s ease, transform 0.45s ease;
}

#mission-complete.visible {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

#mission-failed {
    position: fixed;
    left: 50%;
    top: 50%;
    z-index: 21;
    width: min(520px, calc(100vw - 48px));
    padding: 28px 32px 30px;
    border: 1px solid rgba(218, 120, 92, 0.28);
    border-radius: 22px;
    background:
        linear-gradient(180deg, rgba(20, 12, 14, 0.94), rgba(8, 5, 7, 0.9)),
        radial-gradient(circle at top, rgba(167, 64, 41, 0.22), transparent 70%);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.52);
    backdrop-filter: blur(12px);
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -50%) scale(0.94);
    transition: opacity 0.45s ease, transform 0.45s ease;
}

#mission-failed.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

#mission-complete .mission-kicker {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.38em;
    text-transform: uppercase;
    color: rgba(190, 208, 228, 0.68);
}

#mission-complete .mission-title {
    margin-top: 10px;
    font-size: 32px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #fff2cf;
    text-transform: uppercase;
    text-shadow: 0 4px 18px rgba(0, 0, 0, 0.55);
}

#mission-failed .mission-kicker {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.38em;
    text-transform: uppercase;
    color: rgba(244, 166, 146, 0.74);
}

#mission-failed .mission-title {
    margin-top: 10px;
    font-size: 30px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #ffd5c9;
    text-transform: uppercase;
    text-shadow: 0 4px 18px rgba(0, 0, 0, 0.58);
}

#mission-stars {
    margin-top: 16px;
    font-size: 42px;
    letter-spacing: 0.2em;
    color: #ffd36e;
    text-shadow: 0 0 18px rgba(255, 187, 72, 0.42);
}

#mission-grade {
    margin-top: 8px;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: #f4d9a6;
}

#mission-detail {
    margin-top: 12px;
    font-size: 14px;
    line-height: 1.45;
    letter-spacing: 0.05em;
    color: rgba(228, 223, 213, 0.82);
}

#retry-button {
    margin-top: 18px;
    min-width: 148px;
    height: 44px;
    padding: 0 18px;
    border: 1px solid rgba(255, 210, 186, 0.28);
    border-radius: 999px;
    background:
        linear-gradient(180deg, rgba(214, 117, 86, 0.28), rgba(118, 38, 28, 0.44)),
        rgba(22, 11, 13, 0.94);
    box-shadow: inset 0 1px 0 rgba(255, 232, 220, 0.08), 0 8px 22px rgba(0, 0, 0, 0.28);
    color: #ffe4d8;
    font-family: "Iowan Old Style", Georgia, serif;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    cursor: pointer;
}

#retry-button:hover {
    filter: brightness(1.08);
}
#shark-cargo .cargo-icon { font-size: 22px; }
