:root {
    --bg-color: #f0f7f4;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(120, 160, 131, 0.2);
    --accent-color: #78a083;
    --accent-gradient: linear-gradient(135deg, #a8e6cf 0%, #78a083 100%);
    --hit-color: #4b7f52;
    --blow-color: #bfa15a;
    --none-color: #d68c7a;
    --text-primary: #2f4538;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', 'Montserrat', sans-serif;
}

body {
    background-color: var(--bg-color);
    background-image:
        radial-gradient(circle at 20% 20%, rgba(168, 230, 207, 0.4) 0%, transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(120, 160, 131, 0.2) 0%, transparent 40%);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow-x: hidden;
}

.glass-container {
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 40px;
    width: 100%;
    max-width: 1100px;
    /* スロット15個を収めるために拡張 */
    box-shadow: 0 10px 40px rgba(120, 160, 131, 0.15);
    display: flex;
    flex-direction: column;
    gap: 30px;
}

header {
    text-align: center;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 2px;
}

.subtitle {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 5px;
}

/* 回答スロット */
.slots-container {
    display: flex;
    flex-wrap: nowrap;
    /* 横一列に固定 */
    justify-content: flex-start;
    /* 左寄せ（スクロール対応） */
    overflow-x: auto;
    /* はみ出した場合にスクロール可能にする */
    gap: 10px;
    padding: 20px 10px 40px 10px;
    /* 下部にマーカー用の余白を確保 */
    scrollbar-width: thin;
    /* スクロールバーを細く */
    scrollbar-color: var(--accent-color) transparent;
}

/* スクロールバーのカスタマイズ(Chrome/Safari用) */
.slots-container::-webkit-scrollbar {
    height: 6px;
}

.slots-container::-webkit-scrollbar-thumb {
    background: var(--accent-color);
    border-radius: 10px;
}

.slot {
    width: 55px;
    height: 80px;
    flex-shrink: 0;
    /* スロットが潰れないように固定 */
    background: rgba(255, 255, 255, 0.4);
    border: 2px dashed var(--glass-border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.slot.fixed {
    border-style: solid;
    border-color: rgba(120, 160, 131, 0.3);
    background: rgba(120, 160, 131, 0.1);
}

.slot.drag-over {
    background: rgba(0, 210, 255, 0.1);
    border-color: var(--accent-color);
    transform: scale(1.05);
}

.letter-top {
    font-size: 1.5rem;
    font-weight: 600;
    height: 60%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
}

.symbol-bottom {
    font-size: 1.2rem;
    height: 40%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    pointer-events: none;
}

.judge-marker {
    position: absolute;
    bottom: -25px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1px;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.4s ease;
}

.judge-marker.visible {
    opacity: 1;
    transform: translateY(0);
}

.judge-marker.hit {
    color: var(--hit-color);
    text-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
}

.judge-marker.blow {
    color: var(--blow-color);
    text-shadow: 0 0 10px rgba(255, 204, 0, 0.5);
}

.judge-marker.none {
    color: var(--none-color);
    text-shadow: 0 0 10px rgba(255, 77, 77, 0.5);
}

/* キーボード */
.keyboard {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    padding: 20px;
}

.key {
    width: 45px;
    height: 55px;
    background: white;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: grab;
    transition: all 0.2s ease;
    user-select: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.key:hover {
    background: var(--accent-gradient);
    color: white;
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(120, 160, 131, 0.3);
}

.key:active {
    cursor: grabbing;
}

.key.dragging {
    opacity: 0.5;
    transform: scale(0.9);
}

/* ボタンとメッセージ */
#control-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.btn-premium {
    padding: 15px 40px;
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    background: var(--accent-gradient);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(58, 123, 213, 0.4);
    transition: all 0.3s ease;
    letter-spacing: 1.5px;
}

.btn-premium:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(58, 123, 213, 0.6);
}

.btn-premium:active {
    transform: scale(0.98);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: rgba(255, 255, 255, 0.5);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.3s;
}

.btn-secondary:hover {
    border-color: var(--none-color);
    color: var(--none-color);
}

.message-area {
    min-height: 24px;
    font-size: 1rem;
    font-weight: 600;
}

/* 履歴エリア */
#history-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--glass-border);
}

#history-section h3 {
    font-size: 0.9rem;
    color: var(--accent-color);
    margin-bottom: 15px;
    text-align: center;
    letter-spacing: 2px;
}

.history-table-wrapper {
    overflow-x: auto;
    border-radius: 12px;
    background: rgba(120, 160, 131, 0.05);
}

#history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
    text-align: center;
}

#history-table th,
#history-table td {
    padding: 8px 4px;
    border: 1px solid var(--glass-border);
    min-width: 50px;
    vertical-align: middle;
}

.hist-letter {
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.2;
}

.hist-symbol {
    font-size: 0.9rem;
    opacity: 0.7;
    line-height: 1.2;
}

.hist-result {
    font-size: 0.65rem;
    font-weight: 800;
    margin-top: 2px;
    letter-spacing: 0.5px;
}

#history-table th {
    background: rgba(120, 160, 131, 0.1);
    color: var(--text-primary);
    font-weight: 600;
}

#history-table td.hit-cell {
    color: var(--hit-color);
    font-weight: 700;
    background: rgba(75, 127, 82, 0.05);
}

#history-table td.blow-cell {
    color: var(--blow-color);
    font-weight: 700;
    background: rgba(191, 161, 90, 0.05);
}

.attempt-col {
    background: rgba(120, 160, 131, 0.1) !important;
    font-weight: 600;
    min-width: 60px !important;
}

/* モーダル */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    padding: 50px;
    border-radius: 30px;
    text-align: center;
    border: 1px solid var(--accent-color);
    box-shadow: 0 0 50px rgba(120, 160, 131, 0.2);
}

.modal-content h2 {
    font-size: 2.5rem;
    margin-bottom: 20px;
    color: var(--hit-color);
}

.modal-content p {
    margin-bottom: 30px;
    font-size: 1.2rem;
    opacity: 0.8;
}

footer {
    display: flex;
    justify-content: center;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

.hit-anim {
    animation: pulse 0.5s ease-in-out;
}

/* パスワード画面 */
.password-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-color);
    background-image: var(--bg-image);
    /* 同じグラデーションを使いたい場合は指定 */
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.auth-box {
    max-width: 400px !important;
    text-align: center;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 20px 0;
}

#password-input {
    padding: 15px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: white;
    font-size: 1.2rem;
    text-align: center;
    letter-spacing: 5px;
}

.error-text {
    color: var(--none-color);
    font-size: 0.8rem;
    height: 1rem;
}