:root {
    --bg-color: #050505;
    --text-color: #e0e0e0;
    --accent-color: #ff0055;
    /* Neon Pink */
    --accent-color-2: #00f2ff;
    /* Cyan */
    --panel-bg: rgba(20, 20, 20, 0.8);
    --font-main: 'Kaisei Decol', serif;
    --font-poem: 'Yuji Syuku', serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-main);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background-image:
        radial-gradient(circle at 50% 50%, #1a0b14 0%, #000000 100%);
    overflow-x: hidden;
}

.container {
    width: 100%;
    max-width: 800px;
    /* 600pxから800pxに拡大 */
    text-align: center;
}

/* Header */
header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    text-shadow: 0 0 10px rgba(255, 0, 85, 0.5);
}

.glitch {
    color: var(--accent-color);
    position: relative;
}

header p {
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 2rem;
}

/* Input Area */
.input-area {
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

input[type="text"] {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #333;
    color: #fff;
    padding: 12px 20px;
    font-size: 1rem;
    border-radius: 5px;
    width: 100%;
    max-width: 300px;
    text-align: center;
    transition: 0.3s;
    font-family: var(--font-main);
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-color-2);
    box-shadow: 0 0 10px rgba(0, 242, 255, 0.3);
}

/* Buttons */
.neon-btn {
    background: transparent;
    color: var(--accent-color);
    border: 2px solid var(--accent-color);
    padding: 12px 30px;
    font-size: 1.2rem;
    border-radius: 50px;
    cursor: pointer;
    font-family: var(--font-main);
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 2px;
    transition: 0.3s;
    box-shadow: 0 0 10px rgba(255, 0, 85, 0.2);
    width: 100%;
    max-width: 300px;
}

.neon-btn:hover {
    background: var(--accent-color);
    color: #fff;
    box-shadow: 0 0 20px rgba(255, 0, 85, 0.6);
    transform: scale(1.02);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #ccc;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    transition: 0.3s;
    font-size: 0.9rem;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* Result Area */
.hidden {
    display: none;
}

.poem-container {
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid #333;
    padding: 40px;
    margin-bottom: 20px;
    border-radius: 10px;
    position: relative;
    min-height: 200px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.8);
}

.poem-content p {
    font-family: var(--font-poem);
    font-size: 1.35rem;
    /* 1.5remから少し縮小 */
    line-height: 1.8;
    /* 2から少し詰める */
    white-space: pre-wrap;
    text-align: center;
    background: linear-gradient(45deg, #fff, #ccc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    overflow-wrap: anywhere;
    word-break: normal;
    text-wrap: balance;
}

.phrase {
    display: inline-block;
}

@media (max-width: 480px) {
    .poem-content p {
        font-size: 1.1rem;
        line-height: 1.6;
    }

    .poem-container {
        padding: 20px;
    }
}

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
}

footer {
    margin-top: 3rem;
    font-size: 0.7rem;
    color: #444;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.8s ease-out forwards;
}

/* Whiteout Effect */
.whiteout-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    pointer-events: none;
    z-index: 9999;
    opacity: 0;
}

.whiteout-overlay.active {
    animation: whiteoutAnim 0.8s cubic-bezier(0.1, 0, 0.9, 1) forwards;
}

@keyframes whiteoutAnim {
    0% {
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

/* Screen Shake Effect */
.shake {
    animation: shakeAnim 0.5s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes shakeAnim {

    10%,
    90% {
        transform: translate3d(-1px, -1px, 0);
    }

    20%,
    80% {
        transform: translate3d(2px, 2px, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-4px, -4px, 0);
    }

    40%,
    60% {
        transform: translate3d(4px, 4px, 0);
    }
}

/* Decoding Glitch Text */
.decoding {
    position: relative;
    color: var(--accent-color-2) !important;
    text-shadow: 0 0 8px rgba(0, 242, 255, 0.8);
}

.decoding::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(transparent, rgba(0, 242, 255, 0.1), transparent);
    animation: scanline 0.2s linear infinite;
    pointer-events: none;
}

@keyframes scanline {
    0% {
        transform: translateY(-100%);
    }

    100% {
        transform: translateY(100%);
    }
}

/* Magic Circle Flash Effect */
.magic-circle-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1.2);
    /* 終了状態のスケールをデフォルトに */
    width: 100vw;
    height: 100vh;
    z-index: 10000;
    /* 最前面 */
    pointer-events: none;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    mix-blend-mode: screen;
    /* 発光感 */
    transition: opacity 1.2s ease-out, transform 1.2s ease-out;
    /* transformも滑らかに */
    /* フェードアウトを滑らかに */
    filter: drop-shadow(0 0 30px rgba(255, 255, 255, 0.4));
}

.magic-circle-container.active {
    opacity: 1;
    animation: flashPulse 0.8s ease-out forwards;
}

@keyframes flashPulse {
    0% {
        transform: translate(-50%, -50%) scale(0.8);
        filter: brightness(1);
    }

    10% {
        transform: translate(-50%, -50%) scale(1.1);
        filter: brightness(2);
    }

    100% {
        transform: translate(-50%, -50%) scale(1.2);
        filter: brightness(1.5);
    }
}

#magicCircleCanvas {
    max-width: 100vw;
    max-height: 100vh;
}