html, body {
    padding:0px;
    margin:0px;
    position: absolute;
    background:black;
    /* Sized to the viewport so hiding overflow can't clip the scaled frame */
    width: 100%;
    height: 100%;
    overflow: hidden;
    /* Touch: no double-tap zoom, pull-to-refresh, text selection or long-press menus */
    touch-action: manipulation;
    overscroll-behavior: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

div {
    margin:0px;
    padding:0px;
}

#mainFrame {
    height:1080px;
    width:1920px;
    background-color: darkslategray;
    position:absolute;
    text-align: center;
    scale:1;
}

#controlArrows {
    position: absolute;
    width:360px;
    height:240px;
    bottom:10px;
    right:10px;
    background-color: aqua;
}

#controlArrows > .arrow {
    width:118px;
    height:118px;
    float:left;
    margin:0px;
    background-color: blueviolet;
    background-size: cover;
    border: 1px solid gold;
}

#miniMap {
    position: absolute;
    width:360px;
    height:360px;
    top:10px;
    right:10px;
    background-color: green;
}

#miniMap  > div {
    height:18px;
    width:18px;
    float:left;
    font-size: 8px;
}

.grass {
    background-color: green;
}

.player img{
    max-width: 100%;
}

.wall {
    background-color: grey;
}

.door-horizontal-closed {
    background-color: #8B4513;
    position: relative;
}

.door-horizontal-closed::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background-color: #654321;
    transform: translateY(-50%);
}

.door-horizontal-open {
    background-color: green;
    position: relative;
}

.door-horizontal-open::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 4px;
    background-color: #8B4513;
    transform: translateX(-50%);
}

.door-vertical-closed {
    background-color: #8B4513;
    position: relative;
}

.door-vertical-closed::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: #654321;
    transform: translateX(-50%);
}

.door-vertical-open {
    background-color: green;
    position: relative;
}

.door-vertical-open::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 4px;
    background-color: #8B4513;
    transform: translateY(-50%);
}

.stairs-tile {
    background-color: green;
    color: #ffff00;
    font-weight: bold;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

#actions {
    position: absolute;
    width:360px;
    height:360px;
    bottom:260px;
    right:10px;
    background-color: blueviolet;
}

#actions > .action {
    width:118px;
    height:118px;
    float:left;
    margin:0px;
    background-color: blueviolet;
    background-size: cover;
    border: 1px solid gold;
    text-align: center;
}

#status {
    position: absolute;
    width:360px;
    height:70px;
    top:380px;
    right:10px;
    background-color: firebrick;
    display: flex;
    align-items: center;
    padding: 0 15px;
    box-sizing: border-box;
}

#characters {
    position: absolute;
    width: 1530px;
    height:240px;
    bottom:10px;
    left:10px;
    background-color: plum;
}

#characters > .character {
    width:255px;
    height:240px;
    float:left;
    margin:0px;
    background-color: bisque;
    background-size: cover;
}

.character.active {
    border:2px solid gold;
    width:251px !important;
    height:236px !important;
}

#viewPort {
    position: absolute;
    top:10px;
    left:10px;
    width: 1530px;
    height: 810px;
    overflow: hidden;
}

#viewPort > div > div {
    width: 1530px;
    height: 810px;
    position: absolute;
    background-color: #3a3a3a;
}

#eventLog {
    position: absolute;
    bottom:270px;
    left:20px;
    background-color: rgba(0,0,0,0.5);
    color:white;
    width:1490px;
    text-align: left;
    height:5em;
    padding:10px;
    box-shadow: 0px 0px 10px 5px rgba(0,0,0,0.6);
    overflow-x:auto;
}

#eventLog > p {
    padding:0px;
    margin: 0px;
}

#eventLog > p.dev {
    color:#30ff30;
    font-style: italic;
}

.key-status-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    background-color: rgba(0, 0, 0, 0.5);
    border: 2px solid #FFD700;
    border-radius: 8px;
    margin-left: auto;
}

.key-icon-small {
    font-size: 14px;
    font-weight: bold;
    color: #FFD700;
    text-shadow: 0 0 8px #FFD700;
    font-family: monospace;
}
/* ---------- Combat ---------- */

#eventLog > p.combat {
    color: #e8dcc0;
}

#eventLog > p.hurt {
    color: #ff6a5a;
    font-weight: bold;
}

#eventLog > p.victory {
    color: #ffd700;
    font-weight: bold;
}

#actions.combat-menu {
    background-color: #3a0d0d;
}

#actions > .combat-actor {
    width: 100%;
    height: 40px;
    line-height: 40px;
    float: left;
    color: #ffd700;
    font-weight: bold;
    letter-spacing: 1px;
    background-color: rgba(0, 0, 0, 0.4);
}

#actions > .action.combat {
    background-color: #6b1a1a;
    color: white;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    box-sizing: border-box;
    padding: 4px;
}

#actions > .action.combat:hover {
    background-color: #8f2626;
}

#actions > .action.disabled {
    opacity: 0.35;
    cursor: default;
}

#actions > .action.disabled:hover {
    background-color: #6b1a1a;
}

#combatBanner {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 1510px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    pointer-events: none;
    color: white;
    font-weight: bold;
    text-shadow: 1px 1px 3px black;
}

.combat-round {
    background-color: rgba(80, 0, 0, 0.75);
    border: 1px solid gold;
    padding: 6px 20px;
    letter-spacing: 2px;
}

.combat-foe {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: rgba(0, 0, 0, 0.55);
    padding: 4px 12px;
    border: 1px solid transparent;
    pointer-events: auto;
    cursor: pointer;
}

.combat-foe > span {
    width: 110px;
    text-align: right;
}

.combat-foe.targeted {
    border-color: gold;
}

.combat-hint {
    font-size: 12px;
    font-weight: normal;
    color: #ccc;
}

#gameOver {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 1530px;
    height: 810px;
    background-color: rgba(40, 0, 0, 0.85);
    color: #ff6a5a;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.restart-button {
    border: 2px solid gold;
    color: gold;
    padding: 14px 40px;
    font-size: 24px;
    cursor: pointer;
    background-color: #3a0d0d;
}

.gold-status {
    color: #ffd700;
    font-weight: bold;
    margin-right: 10px;
}

.monster-tile {
    background-color: #c0392b;
}

/* ---------- Party portraits ---------- */

#characters > .character {
    position: relative;
    overflow: hidden;
}

.character.active {
    box-shadow: inset 0 0 20px 4px rgba(255, 215, 0, 0.6);
}

.character.unconscious {
    filter: grayscale(0.9) brightness(0.7);
}

.character.dead {
    filter: grayscale(1) brightness(0.4) sepia(0.6) hue-rotate(-40deg);
}

.character-info {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 6px 8px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.85) 30%);
    color: white;
    text-align: left;
}

.character-name {
    font-weight: bold;
    margin-bottom: 4px;
}

.character-name > span {
    font-weight: normal;
    font-size: 12px;
    color: #ccc;
}

.character-condition,
.character-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 2px 8px;
    font-weight: bold;
    font-size: 13px;
    background-color: rgba(0, 0, 0, 0.7);
    border: 1px solid #ff6a5a;
    color: #ff6a5a;
}

.character-badge {
    left: auto;
    right: 8px;
    border-color: #6ab0ff;
    color: #6ab0ff;
}

.stat-bar {
    position: relative;
    height: 14px;
    background-color: rgba(255, 255, 255, 0.15);
    margin-top: 3px;
}

.stat-bar.foe {
    width: 240px;
}

.stat-bar-fill {
    height: 100%;
    transition: width 0.3s ease-out;
}

.stat-bar.hp .stat-bar-fill {
    background-color: #3fae4a;
}

.stat-bar.hp.low .stat-bar-fill,
.stat-bar.foe .stat-bar-fill {
    background-color: #d0392b;
}

.stat-bar.sp .stat-bar-fill {
    background-color: #3a6fd0;
}

.stat-bar-label {
    position: absolute;
    top: 0;
    left: 6px;
    font-size: 11px;
    line-height: 14px;
}

.hit-flash {
    position: absolute;
    inset: 0;
    background-color: rgba(255, 0, 0, 0.6);
    animation: hit-flash 0.5s ease-out forwards;
    pointer-events: none;
}

@keyframes hit-flash {
    from { opacity: 1; }
    to { opacity: 0; }
}

.cast-glow,
.heal-glow {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.cast-glow {
    box-shadow: inset 0 0 30px 8px rgba(190, 110, 255, 0.8);
    animation: cast-glow 0.6s ease-in-out infinite alternate;
}

.heal-glow {
    background: radial-gradient(circle at 50% 70%, rgba(96, 255, 144, 0.45), transparent 70%);
    box-shadow: inset 0 0 30px 8px rgba(96, 255, 144, 0.7);
    animation: heal-glow 1s ease-out forwards;
}

@keyframes cast-glow {
    from { opacity: 0.5; }
    to { opacity: 1; }
}

@keyframes heal-glow {
    0% { opacity: 0; }
    30% { opacity: 1; }
    100% { opacity: 0; }
}

/* ---------- Spellcasting selection ---------- */

#actions > .spell-prompt {
    width: 100%;
    float: left;
    padding: 20px 10px;
    box-sizing: border-box;
    color: #e8dcc0;
}

.character.selectable {
    cursor: pointer;
}

.character.selectable:hover {
    box-shadow: inset 0 0 25px 6px rgba(96, 200, 255, 0.8);
}

.character:not(.selectable) > .select-number {
    opacity: 0.3;
}

.select-number {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 36px;
    line-height: 36px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.75);
    border: 2px solid #60c8ff;
    color: #60c8ff;
    font-weight: bold;
    font-size: 20px;
}

/* ---------- Fullscreen prompt (touch devices) ---------- */

#fullscreenPrompt {
    position: absolute;
    inset: 0;
    z-index: 100;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 40px;
}

.fullscreen-button {
    border: 4px solid gold;
    color: gold;
    background-color: #3a0d0d;
    padding: 40px 80px;
    font-size: 64px;
    font-weight: bold;
    cursor: pointer;
}

.fullscreen-skip {
    color: #ccc;
    font-size: 40px;
    text-decoration: underline;
    cursor: pointer;
}

/* ---------- Compact mode: small screens where the frame is scaled below 50% ---------- */

#mainFrame.compact #eventLog {
    font-size: 34px;
    height: 3.3em;
    line-height: 1.1;
}

#mainFrame.compact #actions > .action {
    font-size: 24px;
    line-height: 1.1;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: 4px;
}

#mainFrame.compact #actions > .combat-actor {
    font-size: 26px;
}

#mainFrame.compact #actions > .spell-prompt {
    font-size: 28px;
}

#mainFrame.compact #controlArrows > .arrow {
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

#mainFrame.compact #status {
    font-size: 28px;
}

#mainFrame.compact .character-name {
    font-size: 30px;
}

#mainFrame.compact .character-name > span {
    font-size: 22px;
}

#mainFrame.compact .character-info .stat-bar {
    height: 30px;
}

#mainFrame.compact .character-info .stat-bar-label {
    font-size: 24px;
    line-height: 30px;
}

#mainFrame.compact .character-condition,
#mainFrame.compact .character-badge {
    font-size: 24px;
}

#mainFrame.compact .combat-round,
#mainFrame.compact .combat-foe {
    font-size: 32px;
}

#mainFrame.compact .combat-foe > span {
    width: 240px;
}

#mainFrame.compact .combat-hint {
    font-size: 24px;
}

#mainFrame.compact .stat-bar.foe {
    width: 360px;
    height: 24px;
}

/* Hover highlights stick after a tap on touch screens, so only use them with a mouse */
@media (hover: none) {
    #actions > .action.combat:hover {
        background-color: #6b1a1a;
    }
    .character.selectable:hover {
        box-shadow: none;
    }
}
