/* ... (Mantieni root e body uguali) ... */
:root {
    --orange: #038c48;
    --dark: #111;
    --panel: #1a1a1a;
    --text: #dcd7d7;
    --lcd-bg: #000;
    --border: #333;
}

body {
    background-color: #111;
    display: flex; justify-content: center; align-items: center;
    height: 100vh; margin: 0;
    font-family: 'Courier New', Courier, monospace;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

#device {
    width: 100%; 
    height: 100%;
    background: var(--dark);
    border: 0px solid #252525;
    border-radius: 0px;
    display: flex;
    box-shadow: 0 50px 120px rgba(0,0,0,0.9);
    overflow: hidden;
}

/* ... (Sinistra, Top Bar, Menu, Game UI uguali) ... */
#device-left {
    flex: 1; display: flex; flex-direction: column;
    border-right: 0px solid #000;
    background: #080808; padding: 25px;
    min-width: 0;
}
#top-bar { height: 24px; display: flex; justify-content: space-between; font-size: 10px; color: #555; border-bottom: 1px solid #222; margin-bottom: 10px; text-transform: uppercase; }
#connection-icon { width: 12px; height: 12px; border: 2px solid #444; border-radius: 50%; border-top-color: #888; transform: rotate(45deg); }
#screen { flex: 1; position: relative; overflow: hidden; color: var(--text); }
.view-content { height: 100%; display: flex; flex-direction: column; }
.logo-area h1 { font-size: 60px; line-height: 0.8; margin-bottom: 30px; letter-spacing: -3px; color: #ddd; }
.menu-actions { display: flex; flex-direction: column; gap: 15px; align-items: center; padding: 0 20px; }
.mobile-floating-btn { display: none; }
.menu-btn { background: #000; border: 2px solid #ddd; border-radius: 6px; color: #ddd; padding: 15px 25px; font-weight: bold; cursor: pointer; text-transform: uppercase; transition: 0.2s; overflow: hidden; width: 100%; max-width: 400px; }
.menu-btn:hover { background: #1a1a1a; border-color: #ddd; }
.menu-btn.selected { background: var(--orange); color: #000; border-color: var(--orange); }
.menu-btn.disabled { border-color: #333; color: #333; cursor: default; background: #000; }
#story-list { display: flex; flex-direction: column; gap: 10px; align-items: center; padding: 0 20px; }
#ingame-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px dashed #333; padding-bottom: 10px; margin-bottom: 10px; }
.inv-btn { background: #000; border: 1px solid #444; color: #ddd; padding: 5px 10px; font-size: 10px; cursor: pointer; }
.inv-btn:hover { border-color: #ddd; color: #ddd; }
.zoom-btn { background: #000; border: 1px solid #444; color: #ddd; padding: 5px 8px; font-size: 11px; cursor: pointer; font-weight: bold; transition: 0.15s; min-width: 32px; }
.zoom-btn:hover { border-color: #ddd; color: #ddd; background: #111; }
.zoom-btn:active { background: var(--orange); color: #000; border-color: var(--orange); }
#scroll-container {
    flex: 1;
    overflow-y: auto;
    padding-right: 10px;
    padding-bottom: 20px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}
#scroll-container::-webkit-scrollbar { display: none; }
#story-text {
    font-size: 1.6rem;
    line-height: 1.05;
    color: #ddd;
    text-align: justify;
    hyphens: auto;
    padding-bottom: 20px;
    -webkit-user-select: text;
    user-select: text;
}

#continue-prompt {
    text-align: center;
    padding: 30px 20px;
    font-size: 14px;
    color: var(--orange);
    font-weight: bold;
    letter-spacing: 2px;
    border-top: 1px dashed #333;
    margin-top: 20px;
}

/* === CHOICES OVERLAY === */
#choices-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.97);
    z-index: 90;
    display: flex;
    flex-direction: column;
    padding: 40px;
    box-sizing: border-box;
    align-items: center;
}

#choices-overlay h3 {
    font-size: 1.8rem;
    color: var(--orange);
    text-transform: uppercase;
    letter-spacing: 3px;
    margin: 0 0 30px 0;
    padding-bottom: 15px;
    border-bottom: 2px solid #333;
    text-align: center;
}

#choices-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
    padding: 10px;
    align-items: center;
    width: 90%;
    align-items: center;
}

#choices-list .choice-option {
    background: #111;
    border: 2px solid #444;
    border-radius: 6px;
    color: #ccc;
    padding: 20px 25px;
    font-family: inherit;
    font-size: 1.6rem;
    transition: all 0.2s ease;
    cursor: pointer;
    width: 90%;
    max-width: 500px;
    text-align: center;
}

#choices-list .choice-option:hover {
    border-color: #666;
    background: #1a1a1a;
}

#choices-list .choice-option.selected {
    background: var(--orange);
    color: #000;
    border-color: var(--orange);
    font-weight: bold;
}

#choices-list .choice-option.locked {
    background: #0a0a0a;
    border-color: #333;
    color: #666;
    cursor: not-allowed;
    opacity: 0.6;
}

#choices-list .choice-option.locked:hover {
    background: #0a0a0a;
    border-color: #333;
}

.choice-help {
    text-align: center;
    padding: 20px;
    font-size: 12px;
    color: #666;
    font-weight: bold;
    letter-spacing: 2px;
    border-top: 1px solid #222;
    margin-top: 20px;
}

/* === INVENTORY OVERLAY === */
#inventory-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 100;
    padding: 40px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(8px);
}

#inventory-overlay h3 {
    font-size: 2rem;
    color: var(--orange);
    text-transform: uppercase;
    letter-spacing: 4px;
    margin: 0 0 30px 0;
    padding-bottom: 15px;
    border-bottom: 2px solid #333;
    text-align: center;
}

.inv-flex {
    display: flex;
    gap: 40px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Stats Section */
#inv-stats-grid {
    flex: 0 0 auto;
    width: 200px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid #444;
    border-radius: 4px;
}

#inv-stats-grid > div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 3px;
    font-size: 13px;
    color: #ddd;
}

#inv-stats-grid > div::after {
    content: attr(data-value);
    color: var(--orange);
    font-size: 16px;
    font-weight: bold;
}

/* Items Section */
#inv-items-list {
    flex: 1;
    border-left: 2px solid #444;
    padding-left: 30px;
    list-style: none;
    margin: 0;
    overflow-y: auto;
    padding-right: 10px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

#inv-items-list li {
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid #333;
    border-radius: 6px;
    color: #ddd;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s ease;
}

#inv-items-list li:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--orange);
    transform: translateX(5px);
}

#inv-items-list .empty-msg {
    color: #666;
    font-style: italic;
    text-align: center;
    padding: 40px;
    border: 1px dashed #333;
    background: transparent;
}

#inv-items-list .empty-msg:hover {
    transform: none;
    border-color: #333;
}

/* Scrollbar per la lista */
#inv-items-list::-webkit-scrollbar {
    width: 8px;
}

#inv-items-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

#inv-items-list::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 4px;
}

#inv-items-list::-webkit-scrollbar-thumb:hover {
    background: #666;
}

/* Footer */
.inv-footer {
    flex-shrink: 0;
    margin-top: 30px;
}

#btn-close-inv {
    background: #000;
    border: 2px solid #ddd;
    padding: 15px 25px;
    width: 100%;
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
    color: #ddd;
    text-transform: uppercase;
    letter-spacing: 2px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

#btn-close-inv:hover,
#btn-close-inv.selected {
    background: var(--orange);
    color: #000;
    border-color: var(--orange);
}

/* === DEVICE RIGHT === */
#device-right {
    width: 170px;
    background: var(--panel);
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: inset 5px 0 30px rgba(0,0,0,0.6);
    flex-shrink: 0;
}

/* === LCD DISPLAY === */
#secondary-display {
    background: #000;
    border: 2px solid #444;
    border-radius: 6px;
    padding: 15px;
    font-family: monospace;
    display: none;
    flex-direction: column;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.9);
    min-height: 180px;
}

.lcd-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 10px;
    color: #555;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 1px solid #1a1a1a;
}

#sys-time {
    font-weight: bold;
    letter-spacing: 1px;
}

.battery-icon {
    width: 24px;
    height: 10px;
    border: 1px solid #555;
    padding: 1px;
    position: relative;
    display: flex;
    align-items: center;
    border-radius: 1px;
}

.battery-level {
    height: 100%;
    width: 80%;
    background: #4caf50;
    border-radius: 1px;
}

.battery-tip {
    position: absolute;
    right: -3px;
    top: 3px;
    width: 2px;
    height: 4px;
    background: #555;
}

.lcd-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* LCD Message */
#lcd-message {
    text-align: center;
    color: var(--text);
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 2px;
    line-height: 1.6;
}

#lcd-game-data {
    display: flex;
    flex-direction: column;
    height: 100%;
    justify-content: space-between;
    gap: 12px;
}

#lcd-title-scroll {
    overflow: hidden;
    white-space: nowrap;
    font-size: 10px;
    color: #ddd;
    font-weight: bold;
    text-transform: uppercase;
    padding-bottom: 8px;
    border-bottom: 1px dashed #333;
}

.lcd-stats-grid {
    display: flex;
    justify-content: space-around;
    font-size: 11px;
    color: #777;
    padding: 8px 0;
    font-weight: bold;
    letter-spacing: 0.5px;
}

.lcd-stats-grid span {
    display: flex;
    align-items: baseline;
    gap: 3px;
}

.lcd-stats-grid b {
    color: var(--orange);
    font-size: 16px;
}

.hp-section {
    font-size: 10px;
    color: #666;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: auto;
}

.hp-section > span:first-child {
    font-weight: bold;
    color: #888;
    letter-spacing: 1px;
}

.hp-track {
    width: 100%;
    height: 10px;
    background: #0a0a0a;
    border: 1px solid #444;
    border-radius: 2px;
    overflow: hidden;
}

#hp-fill {
    height: 100%;
    background: linear-gradient(to right, #ff4500, #ff6600);
    width: 50%;
    transition: width 0.4s ease;
}

#lcd-hp-num {
    text-align: center;
    font-size: 11px;
    color: #ddd;
    font-weight: bold;
}

/* === CONTROLS AREA === */
#controls-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    gap: 20px;
    padding-top: 30px;
    padding-bottom: 380px;
}

#wheel-container {
    position: relative;
    text-align: center;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.wheel-label {
    font-size: 8px;
    color: #555;
    letter-spacing: 3px;
    font-weight: bold;
    text-transform: uppercase;
}

#scroll-wheel {
    width: 130px;
    height: 50px;
    background: linear-gradient(to right, #151515, #333 20%, #333 80%, #151515);
    border-radius: 5px;
    border: 2px solid #000;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5), inset 0 2px 5px rgba(255,255,255,0.1);
    background-image: repeating-linear-gradient(0deg, transparent, transparent 9px, #000 10px);
    cursor: pointer;
    display: none;
}

#scroll-wheel:active {
    transform: scale(0.95);
}

.wheel-hitbox {
    width: 100px;
    height: 60px;
    background: rgba(255,255,255,0.02);
    border: 1px  solid grey;
    cursor: pointer;
    display: block;
    border-radius: 4px;
    transition: background 0.15s ease;
}

.wheel-hitbox:hover {
    background: rgba(255,255,255,0.08);
}

.wheel-hitbox:active {
    background: var(--orange);
    opacity: 0.3;
}

#buttons-group {
    display: flex;
    gap: 6px;
    align-items: flex-end;
    justify-content: center;
    padding-top: 20px;
}

.hw-btn {
    border-radius: 50%;
    border: none;
    cursor: pointer;
    box-shadow: 0 5px 0 #000;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.hw-btn:hover {
    filter: brightness(1.1);
}

.hw-btn:active {
    transform: translateY(5px);
    box-shadow: none;
}

.hw-btn.small {
    width: 40px;
    height: 40px;
    background: #2a2a2a;
    color: #666;
    font-size: 1.2rem;
    border: 1px solid #444;
}

.hw-btn.large {
    width: 70px;
    height: 70px;
    background: var(--orange);
    color: #000;
    font-size: 1.5rem;
    font-weight: bold;
}

#hw-back {
  display: flex;
}

.hidden { display: none !important; }
.blink { 
    animation: blink 1s infinite; 
   
}
@keyframes blink { 50% { opacity: 0; } }

/* === FULLSCREEN DICE OVERLAY === */
#fullscreen-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 999;
    display: flex;
    justify-content: center;
    align-items: center;
}

#fs-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    max-width: 600px;
    width: 100%;
}

#fs-title {
    font-size: 1.5rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 3px;
    margin: 0;
}

#fs-target {
    font-size: 1rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 2px;
}

#fs-diff-val {
    color: var(--orange);
    font-weight: bold;
    font-size: 1.2rem;
}

#fs-dice {
    font-size: 8rem;
    font-weight: 900;
    color: #ddd;
    margin: 20px 0;
    display: inline-block;
    line-height: 1;
    min-width: 200px;
    will-change: transform, opacity;
    transform-origin: center center;
}

#fs-dice.rolling {
    animation: diceRollD20 0.12s ease-in-out infinite;
}

.result-success #fs-dice {
    color: #4caf50;
}

.result-fail #fs-dice {
    color: #f44336;
}

#fs-math {
    font-size: 1.8rem;
    color: #ddd;
    margin: 10px 0;
    min-height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

#fs-math.hidden {
    opacity: 0;
    visibility: hidden;
    display: flex !important;
}

#fs-math span {
    color: #ddd;
    font-weight: bold;
}

#fs-roll-val {
    color: #ddd !important;
}

#fs-stat-val {
    color: var(--orange) !important;
}

#fs-total-val {
    color: #4caf50 !important;
}

#fs-result-msg {
    font-size: 1.2rem;
    color: #ddd;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-top: 20px;
}
.creation-layout { display: flex; gap: 30px; align-items: center; height: 100%; }
.dice-box { border: 1px solid #333; padding: 30px; flex: 1; text-align: center; }
.dice-animation-large {
    font-size: 5rem;
    color: var(--orange);
    font-weight: bold;
}
.dice-animation-large.rolling {
    animation: diceShake 0.1s linear infinite;
}
.creation-info { flex: 1; font-size: 1.2rem; line-height: 1.5; color: #ddd; }

/* === DICE ANIMATIONS === */
@keyframes diceShake {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-2px, -1px); }
    20% { transform: translate(2px, 1px); }
    30% { transform: translate(-2px, 1px); }
    40% { transform: translate(2px, -1px); }
    50% { transform: translate(-1px, 2px); }
    60% { transform: translate(1px, -2px); }
    70% { transform: translate(-1px, -1px); }
    80% { transform: translate(1px, 1px); }
    90% { transform: translate(-1px, 1px); }
}

@keyframes diceRollD20 {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.85;
    }
}

/* === TRANSITION ANIMATIONS === */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInChoice {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* === MOBILE RESPONSIVE === */
@media (max-width: 800px) or (max-height: 600px) or (orientation: portrait) {
    body {
        height: 100vh;
        overflow: hidden;
    }

    #device {
        width: 100vw;
        height: 100vh;
        border: none;
        border-radius: 0;
        box-shadow: none;
        flex-direction: column;
        box-sizing: border-box;
    }

    #hw-back {
        display: inline-flex;
    }

    #device-left {
        flex: 1;
        border-right: none;
        border-bottom: 2px solid #000;
        padding: 15px;
        min-height: 0;
        box-sizing: border-box;
        overflow: hidden;
    }

    #main-menu { height: 100%; display: flex; flex-direction: column; padding-top: 40%;}

    #device-right {
        width: 100%;
        height: auto;
        padding: 8px 5px;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        flex-shrink: 0;
        gap: 5px;
        box-sizing: border-box;
    }

    #secondary-display {
        width: 50%;
        min-height: 105px;
        height: auto;
        padding: 8px;
        box-sizing: border-box;
    }

    .lcd-header {
        margin-bottom: 8px;
        padding-bottom: 5px;
    }

    #lcd-title-scroll {
        font-size: 9px;
        padding-bottom: 5px;
    }

    .lcd-stats-grid {
        font-size: 10px;
        padding: 5px 0;
    }

    .lcd-stats-grid b {
        font-size: 14px;
    }

    .hp-section {
        font-size: 9px;
        gap: 4px;
    }

    .hp-track {
        height: 8px;
    }

    #controls-area {
        width: 42%;
        flex-direction: row;
        gap: 8px;
        padding: 0;
        justify-content: center;
        box-sizing: border-box;
    }

    #wheel-container {
        flex-direction: column;
        gap: 4px;
    }

    .wheel-label {
        font-size: 6px;
        margin-bottom: 1px;
    }

    #scroll-wheel {
        width: 70px;
        height: 36px;
    }

    .wheel-hitbox {
        width: 70px;
        height: 18px;
    }

    #buttons-group {
        flex-direction: column;
        gap: 8px;
        padding-top: 0;
        align-items: center;
    }

    .hw-btn.small {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }

    .hw-btn.large {
        width: 55px;
        height: 55px;
        font-size: 1.2rem;
    }

    #story-text {
        font-size: 1.5rem;
        line-height: 1.05;
    }

    #continue-prompt {
        font-size: 12px;
        padding: 20px 15px;
    }

    .logo-area h1 {
        font-size: 48px;
        margin-bottom: 20px;
    }

    .menu-actions, #story-list {
        padding: 0 25px;
    }

    .menu-btn {
        padding: 14px 20px;
        font-size: 1rem;
        max-width: 85%;
    }

    #choices-overlay {
        padding: 30px 20px;
    }

    #choices-overlay h3 {
        font-size: 1.5rem;
        margin-bottom: 20px;
    }

    #choices-list .choice-option {
        text-align: center;
        padding: 15px 18px;
        font-size: 1.4rem;
        max-width: 80%;
    }

    #inventory-overlay {
        padding: 18px;
        box-sizing: border-box;
        overflow-y: auto;
    }

    #inventory-overlay h3 {
        font-size: 1.4rem;
        margin-bottom: 12px;
    }

    .inv-flex {
        flex-direction: column;
        gap: 12px;
        max-height: calc(100vh - 140px);
        overflow-y: auto;
    }

    #inv-stats-grid {
        width: 90%;
        align-self: center;
        font-size: 0.9rem;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    #inv-stats-grid > div {
        padding: 10px;
        background: rgba(255,255,255,0.03);
        border: 1px solid #333;
        border-radius: 4px;
        text-align: center;
    }

    #inv-items-list {
        border-left: none;
        align-items: center;
        border-top: 2px solid #444;
        padding-left: 0;
        padding-top: 12px;
        max-height: 250px;
        overflow-y: auto;
    }

    #inv-items-list li {
        padding: 10px 12px;
        font-size: 0.9rem;
    }

    #btn-close-inv {
        padding: 16px 20px;
        font-size: 14px;
        margin-top: 12px;
        min-height: 50px;
        width: 100%;
    }

    #fs-dice {
        font-size: 5rem;
        margin: 20px 0;
    }

    #fs-math {
        font-size: 1.4rem;
    }

    #fs-content {
        padding: 20px;
    }

    #fs-title {
        font-size: 1.3rem;
    }

    #fs-target {
        font-size: 0.9rem;
    }

    .dice-animation-large {
        font-size: 4rem;
    }

    .creation-layout {
        flex-direction: column;
        gap: 20px;
    }

    .dice-box, .creation-info {
        flex: none;
        width: 100%;
    }
}

/* Portrait mode specific adjustments */
@media (max-width: 900px) or (orientation: portrait) {
    #device {
        flex-direction: column;
    }

    #device-left {
        height: 85%;
        width: 100%;
        padding: 15px;
        border-bottom: 2px solid #000;
    }

    #hw-back {
        display: inline-flex;
    }

    #device-right {
        height: 15%;
        width: 100%;
        padding: 8px;
        gap: 8px;
        box-sizing: border-box;
        flex-direction: row;
        display: flex !important;
        align-items: center;
    }

    #story-text {
        font-size: 1.5rem;
        line-height: 1.05;
    }

    .choice-help {
        display: none;
    }

    #secondary-display {
        display: none;
    }

    .lcd-header {
        flex-shrink: 0;
        height: 18px;
        min-height: 18px;
    }

    .lcd-body {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
        overflow: hidden;
    }

    #lcd-message {
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #lcd-game-data {
        gap: 3px;
        display: flex;
        flex-direction: column;
        height: 100%;
    }

    #lcd-title-scroll {
        flex-shrink: 0;
        height: 14px;
        min-height: 14px;
        overflow: hidden;
    }

    .lcd-stats-grid {
        flex-direction: row;
        justify-content: space-around;
        gap: 8px;
        padding: 3px 0;
        flex-shrink: 0;
        height: 24px;
        min-height: 24px;
    }

    .lcd-stats-grid span {
        flex-direction: column;
        padding: 0;
        background: none;
        border: none;
        text-align: center;
        gap: 1px;
        font-size: 0.65rem;
    }

    .lcd-stats-grid b {
        font-size: 0.85rem;
    }

    .hp-section {
        flex-shrink: 0;
        padding: 2px 0;
        height: 28px;
        min-height: 28px;
    }

    .hp-section > span {
        font-size: 0.65rem;
    }

    .hp-track {
        height: 8px;
        min-height: 8px;
    }

    #lcd-hp-num {
        font-size: 0.65rem;
    }

    #lcd-title-scroll {
        font-size: 0.7rem;
    }

    .lcd-header {
        padding: 2px 4px;
    }

    #sys-time {
        font-size: 0.6rem;
    }

    #controls-area {
        width: 100%;
        display: flex !important;
        justify-content: center;
        align-items: center;
        padding: 0;
    }

    #wheel-container {
        display: none;
    }

    #buttons-group {
        flex-direction: row;
        gap: 20px;
        width: 100%;
        justify-content: center;
        align-items: center;
        display: flex !important;
    }

    .hw-btn.small {
        width: 65px;
        height: 65px;
        font-size: 1.3rem;
    }

    .hw-btn.large {
        width: 80px;
        height: 80px;
        font-size: 1.8rem;
    }

    #choices-overlay {
        padding: 25px 15px;
    }

    #choices-overlay h3 {
        font-size: 1.4rem;
        margin-bottom: 20px;
    }

    #choices-list {
        gap: 12px;
        width: 95%;
    }

    #choices-list .choice-option {
        text-align: center;
        padding: 10px 10px;
        font-size: 1.4rem;
        width: 95%;
        max-width: 100%;
    }

    #inventory-overlay {
        padding: 15px;
        box-sizing: border-box;
    }

    #inventory-overlay h3 {
        font-size: 1.2rem;
        margin-bottom: 10px;
    }

    .inv-flex {
        gap: 10px;
        max-height: calc(100vh - 140px);
    }

    #inv-stats-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        font-size: 0.85rem;
    }

    #inv-stats-grid > div {
        padding: 8px;
        background: rgba(255,255,255,0.03);
        border: 1px solid #333;
        border-radius: 4px;
        text-align: center;
    }

    #inv-items-list {
        max-height: 200px;
        padding-top: 10px;
    
    }

    #inv-items-list li {
        padding: 8px 10px;
        font-size: 0.85rem;
    }

    #btn-close-inv {
        padding: 15px 18px;
        font-size: 13px;
        margin-top: 10px;
        min-height: 48px;
        width: 100%;
    }
}



/* iPhone and very narrow portrait screens */
@media (max-width: 450px) and (orientation: portrait) {
    #device-left {
        height: 85%;
        width: 100%;
        padding: 12px;
        border-bottom: 2px solid #000;
    }

    #device-right {
        height: 15%;
        width: 100%;
        padding: 6px;
        gap: 6px;
        box-sizing: border-box;
        flex-direction: row;
        display: flex !important;
        align-items: center;
    }

    #story-text {
        font-size: 1.2rem;
        line-height: 1.05;
    }

    .choice-help {
        display: none;
    }

    #secondary-display {
        display: none;
    }

    .lcd-header {
        height: 16px;
        min-height: 16px;
        padding: 2px 3px;
    }

    #sys-time {
        font-size: 0.55rem;
    }

    .lcd-body {
        overflow: hidden;
    }

    #lcd-message {
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #lcd-title-scroll {
        font-size: 0.65rem;
        height: 13px;
        min-height: 13px;
        overflow: hidden;
    }

    .lcd-stats-grid {
        font-size: 8px;
        gap: 6px;
        height: 22px;
        min-height: 22px;
        padding: 2px 0;
    }

    .lcd-stats-grid span {
        font-size: 0.6rem;
    }

    .lcd-stats-grid b {
        font-size: 0.75rem;
    }

    .hp-section {
        height: 26px;
        min-height: 26px;
        padding: 2px 0;
    }

    .hp-section > span {
        font-size: 0.6rem;
    }

    .hp-track {
        height: 7px;
        min-height: 7px;
    }

    #lcd-hp-num {
        font-size: 0.6rem;
    }

    #controls-area {
        width: 100%;
        display: flex !important;
        justify-content: center;
        align-items: center;
        padding: 0;
    }

    #wheel-container {
        display: none;
    }

    #buttons-group {
        flex-direction: row;
        gap: 18px;
        width: 100%;
        justify-content: center;
        align-items: center;
        display: flex !important;
    }

    .hw-btn.small {
        width: 60px;
        height: 60px;
        font-size: 1.2rem;
    }

    .hw-btn.large {
        width: 75px;
        height: 75px;
        font-size: 1.7rem;
    }

    #choices-overlay {
        padding: 24px 12px 12px 12px;
    }

    #choices-overlay h3 {
        font-size: 1.3rem;
        margin-bottom: 18px;
    }

    #choices-list {
        gap: 10px;
    }

    #choices-list .choice-option {
        text-align: center;
        padding: 16px 18px;
        font-size: 1.2rem;
        width: 90%;
        max-width: 100%;
    }

    #inventory-overlay {
        padding: 8px;
        box-sizing: border-box;
    }

    #inventory-overlay h3 {
        font-size: 1.1rem;
        margin-bottom: 8px;
    }

    .inv-flex {
        gap: 8px;
        max-height: calc(100vh - 120px);
    }

    #inv-stats-grid {
        font-size: 0.8rem;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 2px;
    }

    #inv-stats-grid > div {
        padding: 6px;
        background: rgba(255,255,255,0.03);
        border: 1px solid #333;
        border-radius: 4px;
        text-align: center;
    }

    #inv-items-list {
        max-height: 180px;
        padding-top: 8px;
    }

    #inv-items-list li {
        padding: 6px 8px;
        font-size: 0.8rem;
    }

    #btn-close-inv {
        padding: 14px 16px;
        font-size: 12px;
        margin-top: 8px;
        min-height: 46px;
        width: 100%;
    }
}

@media (max-width: 450px) and (min-height: 820px) and (orientation: portrait) {
     #choices-overlay {
        padding: 70% 12px 12px 12px;
    }

}