:root {
    --bg: #1a1a2e;
    --bg-grad: radial-gradient(ellipse at top, #2a2a4e 0%, #1a1a2e 70%);
    --fg: #f4f4f8;
    --muted: #9a9ab0;
    --accent: #ffcc4d;
    --accent-dark: #d4a017;
    --slice-a: #c0392b;
    --slice-b: #ecf0f1;
    --slice-a-fg: #ffffff;
    --slice-b-fg: #2c3e50;
    --modal-bg: #25253f;
    --border: rgba(255, 255, 255, 0.1);
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}

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

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overscroll-behavior: none;
}

body {
    background: var(--bg-grad);
    color: var(--fg);
    font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
    font-size: 16px;
    line-height: 1.5;
    min-height: 100vh;
    min-height: 100dvh;
    user-select: none;
    -webkit-user-select: none;
}

.app {
    max-width: 480px;
    margin: 0 auto;
    padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border);
    color: var(--fg);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.1s;
    padding: 0;
    font-family: inherit;
    text-decoration: none;
}

.icon-btn:active {
    background: rgba(255, 255, 255, 0.16);
    transform: scale(0.94);
}

.back-link {
    font-size: 22px;
    line-height: 1;
}

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 8px;
    gap: 18px;
}

.wheel-wrap {
    position: relative;
    width: min(88vw, 380px);
    aspect-ratio: 1 / 1;
    margin-top: 4px;
}

.pointer {
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 18px solid transparent;
    border-right: 18px solid transparent;
    border-top: 28px solid var(--accent);
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
    z-index: 3;
    transform-origin: 50% 0;
    transition: transform 0.05s ease-out;
}

.pointer.tick {
    animation: pointerBounce 0.18s ease-out;
}

@keyframes pointerBounce {
    0%   { transform: translateX(-50%) rotate(0deg); }
    35%  { transform: translateX(-50%) rotate(-12deg); }
    70%  { transform: translateX(-50%) rotate(4deg); }
    100% { transform: translateX(-50%) rotate(0deg); }
}

.wheel {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 50%;
    background: #0f0f1f;
    box-shadow:
        0 0 0 4px var(--accent-dark),
        0 0 0 8px #1a1a2e,
        0 10px 30px rgba(0, 0, 0, 0.6),
        inset 0 0 30px rgba(0, 0, 0, 0.4);
}

#wheel-rot {
    transform-origin: 0 0;
    will-change: transform;
}

.hub {
    fill: var(--accent);
    stroke: var(--accent-dark);
    stroke-width: 2;
}

.slice-text {
    font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", sans-serif;
    font-weight: 700;
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
}

.result {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
    min-height: 1.4em;
    padding: 4px 24px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    letter-spacing: 0.06em;
    min-width: 120px;
    text-align: center;
}

.result.flash {
    animation: resultFlash 0.5s ease-out;
}

@keyframes resultFlash {
    0%   { transform: scale(0.6); opacity: 0; }
    60%  { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

.spin-btn {
    width: min(80%, 280px);
    height: 60px;
    border: none;
    border-radius: 30px;
    background: linear-gradient(180deg, var(--accent) 0%, var(--accent-dark) 100%);
    color: #1a1a2e;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.1em;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(255, 204, 77, 0.3), inset 0 1px 0 rgba(255,255,255,0.4);
    transition: transform 0.1s, box-shadow 0.15s;
}

.spin-btn:active:not(:disabled) {
    transform: translateY(2px);
    box-shadow: 0 3px 8px rgba(255, 204, 77, 0.25), inset 0 1px 0 rgba(255,255,255,0.4);
}

.spin-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.usage-list {
    padding-left: 1.4em;
    margin: 8px 0 12px;
    font-size: 14px;
    line-height: 1.6;
}

.usage-list li {
    margin: 6px 0;
}

.note {
    font-size: 12px;
    color: var(--muted);
    margin: 12px 0 4px;
    line-height: 1.5;
}

.kbd {
    display: inline-block;
    padding: 0 6px;
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
    font-family: monospace;
}

/* モーダル */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 16px;
    animation: fadeIn 0.15s ease-out;
}

.modal-backdrop[hidden] {
    display: none;
}

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

.modal {
    background: var(--modal-bg);
    color: var(--fg);
    border-radius: 16px;
    width: 100%;
    max-width: 360px;
    padding: 22px 22px 18px;
    box-shadow: var(--shadow);
    animation: modalIn 0.2s ease-out;
}

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

.modal-title {
    margin: 0 0 16px;
    font-size: 18px;
    font-weight: 600;
}

.field {
    margin-bottom: 16px;
}

.field label {
    display: block;
    font-size: 14px;
    margin-bottom: 6px;
}

.range-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.range-row input[type="range"] {
    flex: 1;
    accent-color: var(--accent);
}

.range-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
    min-width: 28px;
    text-align: right;
}

.hint {
    margin: 6px 0 0;
    font-size: 12px;
    color: var(--muted);
}

.toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 6px 0;
    font-size: 15px;
}

.toggle input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 44px;
    height: 26px;
    background: #555570;
    border-radius: 13px;
    position: relative;
    transition: background 0.18s;
    cursor: pointer;
    margin: 0;
    flex-shrink: 0;
}

.toggle input[type="checkbox"]::before {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.18s;
}

.toggle input[type="checkbox"]:checked {
    background: var(--accent);
}

.toggle input[type="checkbox"]:checked::before {
    transform: translateX(18px);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 20px;
}

.help-modal-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
}

.legal-link {
    font-size: 13px;
    color: var(--muted);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.legal-link:active {
    color: var(--accent);
}

.primary-btn {
    background: var(--accent);
    color: #1a1a2e;
    border: none;
    border-radius: 8px;
    padding: 10px 22px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.primary-btn:active {
    transform: scale(0.97);
}
