body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #1a1a1a;
    color: #e0e0e0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
}

.main-wrapper {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    margin-top: 60px;
    margin-bottom: 60px;
}

.content-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 100%;
}

.container {
    background-color: #2c2c2c;
    padding: 30px 40px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    text-align: center;
    width: 100%;
    max-width: 500px;
    position: relative;
    box-sizing: border-box;
}

h1 {
    color: #66bb6a; /* Green */
    margin-bottom: 30px;
    font-size: clamp(1.5rem, 4vw, 2rem); /* Responsive font size */
    line-height: 1.2;
}

button {
    background-color: #66bb6a;
    color: #1a1a1a;
    border: none;
    padding: 15px 30px;
    font-size: 18px;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
    margin-bottom: 30px;
    min-height: 48px; /* Touch target minimum size */
}

button:hover {
    background-color: #5cb85c;
}

button:active {
    transform: scale(0.98);
}

.result-container {
    background-color: #333;
    padding: 20px;
    border-radius: 8px;
    text-align: left;
    min-height: 200px; /* Reduced for mobile */
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Changed from center to flex-start */
    align-items: flex-start;
    position: relative;
    width: 100%;
    box-sizing: border-box;
}

.result-item {
    margin-bottom: 15px;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.result-item:last-child {
    margin-bottom: 0;
}

.result-text-content {
    flex-grow: 1;
    text-align: left;
}

.result-label {
    font-weight: bold;
    color: #66bb6a;
    display: block;
    margin-bottom: 5px;
    font-size: clamp(0.9rem, 3vw, 1rem);
}

.result-value {
    font-size: clamp(1rem, 3.5vw, 1.1em);
    color: #fff;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

ul {
    list-style-type: none;
    padding-left: 0;
    margin: 0;
    width: 100%;
}

li {
    padding: 8px 12px;
    border-radius: 4px;
    margin-top: 5px;
    font-size: clamp(0.9rem, 3vw, 1rem);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.footer {
    text-align: center;
    margin-top: 30px;
    font-size: 0.9em;
    color: #aaa;
}

.coffee-link {
    margin-top: 10px;
}

.coffee-link a {
    color: #66bb6a;
    text-decoration: none;
    font-weight: bold;
    transition: color 0.3s;
}

.coffee-link a:hover {
    color: #5cb85c;
    text-decoration: underline;
}

.reroll-button {
    background-color: #4a4a4a;
    color: #e0e0e0;
    padding: 6px;
    font-size: 14px;
    border-radius: 5px;
    cursor: pointer;
    border: none;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 10px;
    flex-shrink: 0;
}

.reroll-button:hover {
    background-color: #5a5a5a;
}

/* Mobile Portrait Orientation - Primary Fix */
@media (max-width: 768px) and (orientation: portrait) {
    body {
        padding: 10px;
        min-height: 100vh;
        justify-content: flex-start;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .main-wrapper {
        margin-top: 10px;
        margin-bottom: 10px;
    }
    
    .container {
        padding: 15px 12px;
        max-width: calc(100% - 4px);
        margin: 0;
    }
    
    h1 {
        font-size: 1.3rem;
        margin-bottom: 15px;
        line-height: 1.3;
    }
    
    button {
        padding: 12px 20px;
        font-size: 16px;
        margin-bottom: 15px;
        width: 100%;
        max-width: 280px;
    }
    
    .result-container {
        padding: 12px;
        min-height: auto;
    }
    
    .result-item {
        margin-bottom: 18px;
        width: 100%;
        padding-right: 40px;
    }
    
    .result-label {
        font-size: 0.9rem;
        margin-bottom: 8px;
    }
    
    .result-value {
        font-size: 0.95rem;
        line-height: 1.4;
    }
    
    li {
        padding: 6px 8px;
        font-size: 0.85rem;
        line-height: 1.3;
    }
    
    .reroll-button {
        width: 28px !important;
        height: 28px !important;
        padding: 4px !important;
        font-size: 12px !important;
        right: 8px !important;
        top: 0px !important;
        min-width: 28px !important;
        min-height: 28px !important;
        max-width: 28px !important;
        max-height: 28px !important;
    }
    
    .footer {
        margin-top: 15px;
        font-size: 0.8em;
    }
}

/* Small Mobile Devices */
@media (max-width: 480px) {
    body {
        padding: 8px;
        font-size: 16px; /* Prevent zoom */
    }
    
    .container {
        padding: 12px 8px;
    }
    
    h1 {
        font-size: 1.2rem;
        margin-bottom: 12px;
    }
    
    button {
        padding: 10px 15px;
        font-size: 16px;
        margin-bottom: 12px;
    }
    
    .result-container {
        padding: 10px;
    }
    
    .result-item {
        margin-bottom: 15px;
        padding-right: 35px;
    }
    
    .result-label {
        font-size: 0.85rem;
    }
    
    .result-value {
        font-size: 0.9rem;
    }
    
    li {
        padding: 5px 6px;
        font-size: 0.8rem;
    }
    
    .reroll-button {
        width: 24px !important;
        height: 24px !important;
        padding: 3px !important;
        font-size: 11px !important;
        right: 5px !important;
        top: 0px !important;
        min-width: 24px !important;
        min-height: 24px !important;
        max-width: 24px !important;
        max-height: 24px !important;
    }
}

/* Tablet and Small Desktop */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        max-width: 600px;
        padding: 35px 45px;
    }
}

/* Large Desktop */
@media (min-width: 1025px) {
    .container {
        max-width: 650px;
        padding: 40px 50px;
    }
}

/* Landscape Mobile - Optimize for horizontal space */
@media (max-width: 768px) and (orientation: landscape) {
    body {
        padding: 10px 20px;
        justify-content: center;
    }
    
    .main-wrapper {
        margin-top: 20px;
        margin-bottom: 20px;
    }
    
    .container {
        padding: 20px 25px;
        max-width: 90%;
    }
    
    h1 {
        font-size: 1.3rem;
        margin-bottom: 20px;
    }
    
    .result-container {
        min-height: 180px;
        padding: 15px;
    }
    
    .result-item {
        margin-bottom: 12px;
        width: 100%;
        padding-right: 40px;
    }
    
    .reroll-button {
        width: 28px !important;
        height: 28px !important;
        padding: 4px !important;
        font-size: 12px !important;
        right: 8px !important;
        top: 0px !important;
        min-width: 28px !important;
        min-height: 28px !important;
        max-width: 28px !important;
        max-height: 28px !important;
    }
}

/* Very small screens - aggressive optimization */
@media (max-width: 320px) {
    body {
        padding: 6px;
        font-size: 16px; /* Prevent zoom */
    }
    
    .container {
        padding: 10px 6px;
    }
    
    h1 {
        font-size: 1.1rem;
        margin-bottom: 10px;
    }
    
    button {
        padding: 8px 12px;
        font-size: 16px;
        margin-bottom: 10px;
    }
    
    .result-container {
        padding: 8px;
    }
    
    .result-item {
        margin-bottom: 12px;
        padding-right: 33px;
    }
    
    .result-label {
        font-size: 0.8rem;
    }
    
    .result-value {
        font-size: 0.85rem;
    }
    
    li {
        padding: 4px 5px;
        font-size: 0.75rem;
    }
    
    .reroll-button {
        width: 22px;
        height: 22px;
        padding: 2px;
        font-size: 10px;
        right: calc(100% + 3px);
        top: 0px;
    }
}

/* High-resolution screens */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* No specific high-res styles needed for this design */
}

@media (max-width: 768px) {
    .result-item {
        display: block;
        position: relative;
        padding-right: 45px;
    }

    .reroll-button {
        position: absolute;
        right: 8px;
        top: 0px;
        margin-left: 0;
    }
}
