* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    color: #2a1820;
    font-family: Arial, "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
    background:
        radial-gradient(circle at 50% 16%, rgba(255, 239, 157, .55), transparent 34rem),
        linear-gradient(135deg, #fff6d8 0%, #ffd3df 42%, #bef0ea 100%);
}

button,
input {
    font: inherit;
}

.lottery-app {
    width: 100%;
    min-height: 100vh;
    padding: clamp(14px, 3vw, 36px);
    display: grid;
    place-items: center;
}

.wheel-stage {
    min-width: 0;
    display: grid;
    place-items: center;
}

.wheel-wrap {
    position: relative;
    width: min(86vmin, 760px);
    aspect-ratio: 1;
}

.wheel-img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
    filter: drop-shadow(0 22px 38px rgba(127, 54, 18, .26));
}

.pointer-img {
    width: 100%;
    display: block;
    transform: rotate(var(--pointer-angle));
    transform-origin: 50% 66.2%;
    transition: transform 5.8s cubic-bezier(.08, .72, .12, 1);
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
    backface-visibility: hidden;
    transform-style: preserve-3d;
    will-change: transform;
}

.pointer-button {
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 5;
    width: 21%;
    aspect-ratio: 210 / 310;
    border: 0;
    padding: 0;
    background: transparent;
    cursor: pointer;
    transform: translate3d(-50%, -66.2%, 0);
}

.pointer-button:disabled {
    cursor: wait;
}

.pointer-button:focus-visible {
    outline: none;
}

.pointer-button:focus-visible .pointer-img {
    filter: drop-shadow(0 0 0.35rem rgba(217, 41, 95, .8));
}

.wheel-wrap.is-spinning .pointer-img {
    transition-duration: 5.6s;
}

.play-panel {
    display: none;
}

.input-row {
    display: flex;
    gap: 10px;
}

.input-row input {
    min-width: 0;
    height: 52px;
    flex: 1;
    border: 2px solid rgba(77, 43, 54, .22);
    border-radius: 8px;
    padding: 0 14px;
    background: rgba(255, 255, 255, .82);
    outline: none;
    text-transform: uppercase;
}

.input-row input:focus {
    border-color: #d9295f;
    box-shadow: 0 0 0 4px rgba(217, 41, 95, .14);
}

.input-row button,
.modal-ok,
.admin-form button {
    min-height: 52px;
    border: 0;
    border-radius: 8px;
    padding: 0 22px;
    color: #fff;
    font-weight: 800;
    cursor: pointer;
    background: linear-gradient(135deg, #f04455, #ff8b1f);
    box-shadow: 0 12px 24px rgba(196, 59, 25, .25);
}

.input-row button:disabled {
    cursor: wait;
    opacity: .62;
}

.status-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    margin: 0;
}

.modal[hidden]:not(.is-open) {
    display: none;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 18px;
}

.modal.is-open {
    display: grid !important;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(40, 18, 22, .58);
}

.modal-dialog {
    position: relative;
    z-index: 1;
    width: min(440px, 100%);
    border-radius: 8px;
    padding: 24px;
    background: #fffaf0;
    box-shadow: 0 24px 70px rgba(40, 18, 22, .35);
    text-align: center;
}

.modal-dialog h2 {
    margin: 0 0 12px;
    font-size: 24px;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    font-size: 26px;
    line-height: 1;
}

.result-pic {
    max-width: min(220px, 70%);
    max-height: 220px;
    object-fit: contain;
    margin: 4px auto 14px;
    display: block;
}

.result-desc {
    margin: 0 0 18px;
    line-height: 1.7;
    overflow-wrap: anywhere;
}

.code-dialog {
    display: grid;
    gap: 14px;
}

.code-dialog input {
    width: 100%;
    height: 52px;
    border: 2px solid rgba(77, 43, 54, .22);
    border-radius: 8px;
    padding: 0 14px;
    outline: none;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.code-dialog input:focus {
    border-color: #d9295f;
    box-shadow: 0 0 0 4px rgba(217, 41, 95, .14);
}

.admin-page {
    background: #f6f7fb;
}

.admin-layout {
    width: min(1380px, 100%);
    min-height: 100vh;
    margin: 0 auto;
    padding: 18px;
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 18px;
}

.admin-sidebar,
.admin-panel {
    border: 1px solid #dfe3eb;
    border-radius: 8px;
    background: #fff;
}

.admin-sidebar {
    align-self: start;
    position: sticky;
    top: 18px;
    padding: 18px;
}

.admin-sidebar h1 {
    margin: 0 0 18px;
    font-size: 24px;
}

.admin-sidebar nav {
    display: grid;
    gap: 8px;
}

.admin-sidebar a,
.text-link,
.primary-link,
.actions a {
    color: #26324a;
    text-decoration: none;
}

.admin-sidebar a {
    border-radius: 8px;
    padding: 10px 12px;
    font-weight: 700;
}

.admin-sidebar a.active,
.admin-sidebar a:hover {
    background: #edf3ff;
    color: #1655c7;
}

.admin-main {
    min-width: 0;
    display: grid;
    gap: 16px;
}

.admin-panel {
    min-width: 0;
    padding: 20px;
}

.admin-panel h1,
.admin-panel h2 {
    margin: 0 0 16px;
}

.panel-title {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.panel-title h2 {
    margin: 0;
}

.primary-link {
    border-radius: 8px;
    padding: 10px 14px;
    color: #fff;
    font-weight: 800;
    background: linear-gradient(135deg, #f04455, #ff8b1f);
}

.text-link,
.actions a {
    font-weight: 700;
}

.notice {
    padding: 10px 12px;
    border-radius: 8px;
    background: #fff5cf;
}

.notice.success {
    background: #e9f9ef;
    color: #176434;
}

.notice.error,
#probabilityTotal.is-error {
    background: #ffe8eb;
    color: #ba1d36;
}

.created-code {
    margin-bottom: 16px;
    padding: 14px;
    border-radius: 8px;
    background: #151923;
    color: #fff;
    font-size: 30px;
    font-weight: 800;
    letter-spacing: 3px;
    text-align: center;
}

.admin-form {
    display: grid;
    gap: 14px;
}

.admin-form > label,
.form-grid label {
    display: grid;
    gap: 6px;
    font-weight: 700;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 180px;
    gap: 14px;
}

.admin-form input[type="number"],
.admin-form input[type="text"],
.admin-form textarea {
    width: 100%;
    height: 42px;
    border: 1px solid #cfd5df;
    border-radius: 8px;
    padding: 0 10px;
    background: #fff;
}

.admin-form textarea {
    height: auto;
    padding: 10px;
    resize: vertical;
}

.admin-form input:disabled,
.admin-form textarea:disabled,
.admin-form button:disabled {
    opacity: .62;
    cursor: not-allowed;
}

.probability-head {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
}

.probability-head h2 {
    margin: 0;
    font-size: 20px;
}

.probability-head strong {
    border-radius: 8px;
    padding: 8px 10px;
    background: #f3f6fb;
}

.prize-table {
    display: grid;
    gap: 8px;
}

.prize-row {
    display: grid;
    grid-template-columns: auto 48px minmax(0, 1fr) 78px;
    gap: 10px;
    align-items: center;
    border: 1px solid #edf0f5;
    border-radius: 8px;
    padding: 8px;
}

.probability-row {
    grid-template-columns: 56px minmax(0, 1fr) 110px auto;
}

.prize-row img {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.prize-row span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.admin-table-wrap {
    width: 100%;
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    min-width: 920px;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    border-bottom: 1px solid #edf0f5;
    padding: 10px;
    text-align: left;
    vertical-align: top;
}

.admin-table th {
    color: #5b6475;
    font-size: 13px;
    white-space: nowrap;
    background: #f8fafd;
}

.code-table td:nth-child(7) {
    min-width: 260px;
}

.admin-prize-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.admin-prize-badges span {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    border: 1px solid #e5eaf2;
    border-radius: 999px;
    padding: 4px 8px;
    background: #fff;
    font-size: 12px;
    white-space: nowrap;
}

.admin-prize-badges img,
.log-prize img,
.win-tip img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.actions {
    min-width: 150px;
}

.actions,
.actions form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.actions button {
    border: 0;
    border-radius: 8px;
    padding: 6px 10px;
    color: #fff;
    cursor: pointer;
    background: #1655c7;
}

.empty-cell {
    padding: 28px !important;
    color: #788295;
    text-align: center !important;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin: 0 0 16px;
}

.detail-grid div {
    border: 1px solid #edf0f5;
    border-radius: 8px;
    padding: 12px;
    background: #fbfcff;
}

.detail-grid dt {
    color: #667085;
    font-size: 13px;
}

.detail-grid dd {
    margin: 6px 0 0;
    font-weight: 800;
    overflow-wrap: anywhere;
}

.log-prize {
    display: inline-flex;
    gap: 8px;
    align-items: center;
}

.win-tip {
    display: flex;
    gap: 12px;
    border: 1px solid #ffe1a8;
    border-radius: 8px;
    margin-top: 12px;
    padding: 12px;
    background: #fffaf0;
}

.win-tip img {
    width: 58px;
    height: 58px;
}

.win-tip p {
    margin: 6px 0 0;
    line-height: 1.7;
}

@media (max-width: 820px) {
    .lottery-app,
    .admin-layout,
    .form-grid,
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .lottery-app {
        place-items: center;
    }

    .wheel-wrap {
        width: min(92vmin, 560px);
    }

    .admin-sidebar {
        position: static;
    }

    .admin-sidebar nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 460px) {
    .input-row {
        display: grid;
    }

    .input-row input,
    .input-row button {
        width: 100%;
    }

    .modal-dialog {
        padding: 22px 16px;
    }
}
