body {
    margin: 0;
    min-height: 100vh;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    /* align-items: center; */
    background: url('background.jpg') center/cover no-repeat fixed;
    font-family: Arial, sans-serif;
    /* overf low: hidden; */
}

h1 {
    color: white;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    margin-bottom: 2rem;
    font-size: 8em;
    text-align: center;
}

h2 {
    font-size: 6em;
}
h3 {
    font-size: 1.2em;;
}

h2, h3 {
    color: white;
}

.main-container {
    margin: auto 0; /* 세로 중앙 유지 */
    width: 100%;
    max-width: 1920px;
    height: 100vh;
    position: relative;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    padding: 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.screen {
    display: none;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    padding: 1rem;
    box-sizing: border-box;
}

.screen.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-evenly;
    padding-top: 80px;
    padding-bottom: 80px;
}

.setup-container {
    background: rgba(255, 255, 255, 0.1);
    padding: 2rem;
    border-radius: 15px;
    backdrop-filter: blur(5px);
    max-width: 600px;
}

.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    margin-right: 1rem;
    display: block;
    color: #fff;
    margin-bottom: 0.5rem;
    font-size: 1.1em;
}

.input-group input {
    padding: 0.8rem;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 1.1em;
}

.header, .footer {
    position: fixed;
    left: 0;
    width: 100%;
    padding: 0.8rem 1rem;
    box-sizing: border-box;
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
}

.header {
    top: 0;
    background: rgba(0, 0, 0, 0.8);
}

.footer {
   
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
    padding-bottom: calc(0.8rem + env(safe-area-inset-bottom)); 
}
@media screen and (max-device-width: 768px) and (-webkit-min-device-pixel-ratio: 2) {
    .footer {
      position: absolute;
      bottom: 0;
      width: 100%;
    }
  }


.round-info {
    font-size: 1.5em;
    color: #fff;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.card-container {
    width: 100%;
    padding: 2rem;
    box-sizing: border-box;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    overflow-y: auto;
    align-items: flex-start;
    justify-content: center;
    /* flex: 1; */
}

.results-container {
    background: rgba(255, 255, 255, 0.1);
    padding: 2rem;
    border-radius: 15px;
    margin: 2rem;
    width: 80%;
    max-height: 60vh;
    overflow-y: auto;
    color: #fff;
    font-family: monospace;
    font-size: 2rem;
    white-space: pre-wrap;
}

.main-button,
.control-button {
    padding: 12px 24px;
    border: none;
    cursor: pointer;
    font-size: 1.1em;
    transition: all 0.3s ease;
}

.main-button {
    background: linear-gradient(135deg, #c42f7f, #6d2feb);
    color: white;
    font-weight: bold;
    border-radius: 8px;
}

.control-button {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    backdrop-filter: blur(5px);
}

.button-group {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    margin-bottom: 1rem;
}

.card {
    perspective: 1000px;
    cursor: pointer;
    aspect-ratio: 1 / 1;
    width: 100%;
    max-width: 180px;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.card.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front,
.card-back {
    user-select: none;
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4em;
    font-weight: bold;
    border-radius: 10px;
    filter: drop-shadow(0 0 7px rgba(0, 0, 0, 0.3));
}

.card-front {
    background: linear-gradient(45deg, #c42f7f, #6d2feb);
    color: white;
}

.card-back {
    background: linear-gradient(45deg, #2f86c4, #2feb8c);
    transform: rotateY(180deg);
    color: white;
}

.card.reveal {
    animation: glow 1s ease-in-out;
}

@keyframes glow {
    0% {
        filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.5));
    }
    50% {
        filter: drop-shadow(0 0 7px rgba(255, 255, 255, 0.8));
    }
    100% {
        filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.5));
    }
}
.prize-title {
    color: white;
    text-align: center;
    margin-bottom: 2rem;
    font-size: 2.5em;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.connection-status {
    font-size: 0.9em;
    color: #f44336; /* Default to red (disconnected) */
    padding: 5px 10px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.5);
    margin-right: auto; /* Align to the left */
    margin-left: 1rem; /* Add some left margin */
}

.connection-status.connected {
    color: #4CAF50; /* Green when connected */
}


.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.lightbox.hidden {
    opacity: 0;
    pointer-events: none;
}

.lightbox-content {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 2rem;
    border-radius: 15px;
    width: 90%;
    max-width: 400px;
    color: white;
}

.lightbox h3 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    text-align: center;
    font-size: 1.5em;
}

.lightbox .input-group {
    margin-bottom: 1.5rem;
}

.lightbox .input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 1.1em;
    color: white;
}

.lightbox .input-group input {
    width: 90%;
    padding: 0.8rem;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 1.1em;
}

.lightbox .button-group {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

/* Mobile Optimization */
@media (max-width: 768px) {
    h1 {
        font-size: 2em;
        margin: 0.5rem 0;
    }

    h2 {
        font-size: 1.5em;
    }

    h3 {
        font-size: 1em;
    }

    .screen.active {
        padding-top: 60px;
        padding-bottom: 70px;
    }

    .setup-container {
        padding: 1rem;
        margin: 0.5rem;
        width: 95%;
    }

    .footer {
        padding: 0.6rem 0.8rem;
        font-size: 0.9em;
    }

    .card-container {
        margin-bottom: 60px;
    }

    .card {
        max-width: 80px;
    }

    .card-front,
    .card-back {
        font-size: 2em;
    }

    .button-group {
        gap: 0.5rem;
        margin: 0.5rem 0;
    }

    .main-button,
    .control-button {
        padding: 8px 16px;
        font-size: 0.9em;
    }

    .modal-content {
        padding: 1rem;
        width: 95%;
    }

    .input-group {
        margin-bottom: 0.8rem;
    }

    .input-group label {
        font-size: 0.9em;
        margin-bottom: 0.3rem;
    }

    .input-group input,
    .input-group textarea {
        padding: 0.6rem;
        font-size: 0.9em;
    }

    .results-container {
        padding: 1rem;
        margin: 0.5rem;
        font-size: 1.2em;
    }

    .prize-display {
        font-size: 1.2em;
        margin: 0.5rem 0;
    }
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background-color: #222222;
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 80vw;
    min-width: 50vw;
    max-height: 90vh;
    overflow-y: auto;
}

.button-group {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.control-button {
    background-color: #666;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
}

.control-button:hover {
    background-color: #555;
}

.control-button:disabled {
    background-color: #444;
    color: #888;
    cursor: not-allowed;
    opacity: 0.7;
}

.control-button:disabled:hover {
    background-color: #444;
}

.title-input {
    width: 100%;
    max-width: 300px;
    padding: 8px;
    font-size: 1em;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.prize-display {
    color: white;
    text-align: center;
    margin: 1rem 0;
    font-size: 5em;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.history-container {
    background: rgba(255, 255, 255, 0.1);
    padding: 1rem;
    border-radius: 15px;
    margin: 1rem;
    width: 90%;
    max-height: 70vh;
    overflow-y: auto;
    color: #fff;
}

.history-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.history-item .delete-btn {
    background: rgba(255, 0, 0, 0.2);
    color: #ff4444;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.history-item .delete-btn:hover {
    background: rgba(255, 0, 0, 0.3);
}

.history-content {
    white-space: pre-wrap;
    font-family: monospace;
    font-size: 1.1em;
    line-height: 1.5;
}

@media (max-width: 768px) {
    .history-container {
        width: 95%;
        margin: 0.5rem;
        padding: 0.8rem;
    }

    .history-item {
        padding: 0.8rem;
        margin-bottom: 0.8rem;
    }

    .history-content {
        font-size: 0.9em;
    }
}

/* --------------------------------------------------------------------------
   2026 visual refresh: stage-like, mobile-first lucky draw interface
   -------------------------------------------------------------------------- */
:root {
    --bg-deep: #0b0520;
    --panel: rgba(19, 12, 45, 0.68);
    --panel-strong: rgba(255, 255, 255, 0.13);
    --line: rgba(255, 255, 255, 0.22);
    --text: #fff8ff;
    --muted: rgba(255, 255, 255, 0.72);
    --pink: #ff4fd8;
    --violet: #7c3cff;
    --cyan: #55e7ff;
    --mint: #55ffbe;
    --gold: #ffe45c;
    --danger: #ff6978;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    min-height: 100%;
    background: var(--bg-deep);
}

body {
    min-height: 100svh;
    align-items: stretch;
    color: var(--text);
    background:
        radial-gradient(circle at 12% 16%, rgba(255, 79, 216, 0.42) 0 12%, transparent 32%),
        radial-gradient(circle at 86% 10%, rgba(85, 231, 255, 0.34) 0 10%, transparent 30%),
        radial-gradient(circle at 76% 86%, rgba(255, 228, 92, 0.18) 0 12%, transparent 32%),
        linear-gradient(145deg, #0b0520 0%, #191148 46%, #360945 100%);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    overflow-x: hidden;
}

body::before,
body::after {
    content: "";
    position: fixed;
    inset: auto;
    border-radius: 999px;
    pointer-events: none;
    filter: blur(4px);
    opacity: 0.75;
    z-index: 0;
}

body::before {
    width: 42vw;
    height: 42vw;
    min-width: 280px;
    min-height: 280px;
    left: -110px;
    bottom: 7%;
    background: radial-gradient(circle, rgba(85, 255, 190, 0.24), transparent 68%);
}

body::after {
    width: 35vw;
    height: 35vw;
    min-width: 240px;
    min-height: 240px;
    right: -80px;
    top: 18%;
    background: radial-gradient(circle, rgba(124, 60, 255, 0.38), transparent 70%);
}

.main-container {
    position: relative;
    z-index: 1;
    width: min(100%, 1920px);
    height: 100svh;
    margin: 0 auto;
    overflow: hidden;
    background:
        linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
        rgba(4, 2, 16, 0.42);
    background-size: 42px 42px;
    backdrop-filter: blur(18px);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.12);
}

.screen {
    padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
}

.screen.active {
    justify-content: center;
    gap: clamp(20px, 5vh, 56px);
    padding-top: max(24px, env(safe-area-inset-top));
    padding-bottom: max(24px, env(safe-area-inset-bottom));
}

.hero-copy {
    width: min(920px, 100%);
    text-align: center;
    display: grid;
    gap: 12px;
    justify-items: center;
}

.eyebrow {
    margin: 0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 13px;
    border: 1px solid rgba(255,255,255,.2);
    border-radius: 999px;
    color: #f8e7ff;
    background: rgba(255,255,255,.1);
    backdrop-filter: blur(12px);
    font-size: clamp(0.72rem, 1.5vw, 0.9rem);
    font-weight: 900;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.eyebrow::before {
    content: "✦";
    color: var(--gold);
    text-shadow: 0 0 12px rgba(255, 228, 92, .75);
}

h1 {
    margin: 0;
    max-width: 10ch;
    color: #fff;
    font-size: clamp(3.4rem, 11vw, 9.5rem);
    line-height: .86;
    letter-spacing: -0.09em;
    font-weight: 950;
    text-shadow:
        0 6px 0 rgba(58, 0, 88, .28),
        0 0 38px rgba(255, 255, 255, .35),
        0 0 70px rgba(255, 79, 216, .28);
}

.hero-subtitle {
    margin: 0;
    max-width: 620px;
    color: var(--muted);
    font-size: clamp(1rem, 2vw, 1.35rem);
    line-height: 1.55;
    font-weight: 650;
}

.setup-container {
    width: min(720px, 100%);
    padding: clamp(14px, 3vw, 26px);
    border: 1px solid var(--line);
    border-radius: 30px;
    background: linear-gradient(180deg, rgba(255,255,255,.16), rgba(255,255,255,.075));
    box-shadow: 0 26px 80px rgba(0,0,0,.36), inset 0 1px 0 rgba(255,255,255,.24);
    backdrop-filter: blur(24px);
}

.button-group {
    flex-wrap: wrap;
    align-items: stretch;
    justify-content: center;
    gap: 12px;
    margin: 0;
}

.main-button,
.control-button {
    min-height: 54px;
    border: 1px solid rgba(255,255,255,.2);
    border-radius: 18px;
    padding: 14px 20px;
    color: #fff;
    font-weight: 900;
    letter-spacing: -0.02em;
    box-shadow: 0 16px 34px rgba(0,0,0,.26), inset 0 1px 0 rgba(255,255,255,.24);
    transform: translateY(0);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, background .18s ease;
}

.main-button {
    background: linear-gradient(135deg, var(--pink), var(--violet) 52%, #3bdcff);
}

.control-button {
    background: rgba(255,255,255,.13);
    backdrop-filter: blur(16px);
}

.main-button:hover,
.control-button:hover,
.main-button:focus-visible,
.control-button:focus-visible {
    transform: translateY(-2px);
    border-color: rgba(255,255,255,.5);
    box-shadow: 0 22px 42px rgba(0,0,0,.32), 0 0 24px rgba(255,79,216,.2);
    outline: none;
}

#startGameButton {
    flex: 1 1 230px;
    font-size: clamp(1.15rem, 2.5vw, 1.55rem);
}

#settingsButton {
    flex: 0 1 190px;
}

#shortcutsHelp,
#historyButton {
    width: 64px;
    flex: 0 0 64px;
    padding-inline: 0;
    font-size: 1.25rem;
}

.header,
.footer {
    padding: 14px 18px;
    background: rgba(7, 4, 24, 0.72);
    border-color: rgba(255,255,255,.13);
    backdrop-filter: blur(20px);
}

.header {
    border-bottom: 1px solid rgba(255,255,255,.13);
}

.footer {
    border-top: 1px solid rgba(255,255,255,.13);
}

.round-info,
.card-count,
.connection-status {
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 999px;
    padding: 8px 12px;
    background: rgba(255,255,255,.09);
    font-weight: 900;
}

.prize-display {
    margin-top: 82px;
    margin-bottom: 10px;
    font-size: clamp(1.4rem, 5vw, 4rem);
    line-height: 1.05;
    text-align: center;
    color: #fff;
    text-shadow: 0 0 28px rgba(255,255,255,.22);
}

.card-container {
    width: min(1320px, 100%);
    margin: 0 auto;
    padding: 18px 18px 92px;
    gap: clamp(10px, 1.4vw, 18px);
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.34) transparent;
}

.card {
    max-width: clamp(98px, 13vw, 178px);
    border-radius: 24px;
}

.card-front,
.card-back {
    border: 1px solid rgba(255,255,255,.26);
    border-radius: 24px;
    font-size: clamp(2.3rem, 5vw, 4.8rem);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.34), 0 18px 32px rgba(0,0,0,.28);
}

.card-front {
    background:
        radial-gradient(circle at 30% 20%, rgba(255,255,255,.34), transparent 34%),
        linear-gradient(145deg, var(--pink), var(--violet));
}

.card-back {
    background:
        radial-gradient(circle at 30% 20%, rgba(255,255,255,.34), transparent 34%),
        linear-gradient(145deg, #23d7ff, #19d18f);
    text-shadow: 0 4px 16px rgba(0,0,0,.28);
}

.modal,
.lightbox {
    background: rgba(5, 2, 19, .72);
    backdrop-filter: blur(12px);
}

.modal-content,
.lightbox-content,
.results-container,
.history-container,
.history-content {
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 26px;
    background: linear-gradient(180deg, rgba(255,255,255,.16), rgba(255,255,255,.08));
    box-shadow: 0 28px 90px rgba(0,0,0,.46), inset 0 1px 0 rgba(255,255,255,.22);
    backdrop-filter: blur(24px);
}

.modal-content,
.lightbox-content {
    width: min(720px, calc(100vw - 28px));
    max-height: min(82svh, 820px);
    overflow: auto;
    color: var(--text);
}

.modal-content h2,
.lightbox h3,
#resultsScreen h1,
#historyScreen h1 {
    color: #fff;
    font-size: clamp(2rem, 5vw, 4rem);
    line-height: 1;
    letter-spacing: -0.06em;
    text-align: center;
}

.input-group label {
    color: rgba(255,255,255,.78);
    font-weight: 800;
}

.input-group input,
.input-group textarea,
.lightbox .input-group input,
.title-input,
#numberRanges,
#presetRounds {
    width: 100%;
    border: 1px solid rgba(255,255,255,.22);
    border-radius: 16px;
    background: rgba(255,255,255,.1);
    color: #fff;
    outline: none;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.16);
}

.input-group input:focus,
.input-group textarea:focus {
    border-color: rgba(85, 231, 255, .75);
    box-shadow: 0 0 0 4px rgba(85, 231, 255, .14);
}

.results-container,
.history-container {
    width: min(980px, calc(100vw - 32px));
    margin: 12px auto 20px;
    color: #fff;
}

@media (max-width: 768px) {
    body {
        background-attachment: scroll;
    }

    .main-container {
        min-height: 100svh;
    }

    .screen.active {
        justify-content: center;
        gap: 22px;
        padding-inline: 14px;
    }

    h1 {
        max-width: 9ch;
        font-size: clamp(4.1rem, 19vw, 5.6rem);
    }

    .hero-subtitle {
        max-width: 320px;
        font-size: .98rem;
    }

    .setup-container {
        border-radius: 24px;
    }

    .button-group {
        display: grid;
        grid-template-columns: minmax(0, 1.7fr) minmax(0, .65fr) minmax(0, .65fr);
        width: 100%;
    }

    #startGameButton {
        grid-column: 1 / -1;
        width: 100%;
        min-height: 64px;
        font-size: 1.25rem;
    }

    #settingsButton,
    #shortcutsHelp,
    #historyButton {
        width: 100%;
        min-width: 0;
        flex: auto;
    }

    #settingsButton,
    #shortcutsHelp,
    #historyButton {
        grid-column: auto;
    }

    #shortcutsHelp,
    #historyButton {
        width: auto;
        flex-basis: auto;
    }

    .header,
    .footer {
        padding-inline: 10px;
        gap: 8px;
    }

    .header .control-button,
    .footer .control-button {
        min-height: 42px;
        padding: 10px 12px;
        border-radius: 14px;
        font-size: .9rem;
    }

    .round-info,
    .card-count,
    .connection-status {
        font-size: .78rem;
        padding: 7px 9px;
        white-space: nowrap;
    }

    .connection-status {
        max-width: 108px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .prize-display {
        margin-top: 68px;
        font-size: clamp(1.35rem, 7vw, 2.4rem);
    }

    .card-container {
        padding: 8px 10px 86px;
        gap: 10px;
        align-content: flex-start;
    }

    .card {
        max-width: none;
        width: min(29vw, 116px);
    }

    .card-front,
    .card-back {
        border-radius: 20px;
        font-size: clamp(2rem, 10vw, 3.4rem);
    }

    .modal-content,
    .lightbox-content {
        width: calc(100vw - 22px);
        max-height: 84svh;
        padding: 18px;
        border-radius: 22px;
    }

    .modal-content .button-group,
    .lightbox-content .button-group,
    #resultsScreen .button-group,
    #historyScreen .button-group {
        grid-template-columns: 1fr;
    }

    .results-container,
    .history-container {
        width: calc(100vw - 22px);
        margin-inline: auto;
        padding: 16px;
        font-size: 1rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
    }
}
