:root {
    --bg-color: #111;
    --brand-yellow: #ffea00;
    --brand-white: #ffffff;
    --text-dark: #000;
}

body {
    font-family: 'Noto Sans JP', sans-serif;
    background-color: var(--bg-color);
    color: var(--brand-white);
    margin: 0; padding: 20px; text-align: center;
    background-image: radial-gradient(rgba(255,255,255,0.1) 1px, transparent 1px);
    background-size: 30px 30px;
}

.container { max-width: 1100px; margin: 0 auto; padding-bottom: 100px; }
.header-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.history-link { color: var(--brand-yellow); text-decoration: none; border: 1px solid var(--brand-yellow); padding: 5px 10px; font-size: 0.8em; }

/* 参加者リスト */
.online-users-bar {
    background: rgba(255,255,255,0.1); padding: 5px 10px; border-radius: 4px; font-size: 0.8em; text-align: left;
    margin-bottom: 20px; white-space: nowrap; overflow-x: auto; border-left: 3px solid var(--brand-yellow);
}
.user-tag { margin-right: 10px; color: #ccc; }
.user-tag.me { color: var(--brand-yellow); font-weight: bold; }

/* タイトル */
h1 {
    font-family: 'Anton', sans-serif; font-size: 3.5em; color: var(--brand-yellow);
    text-shadow: 0 0 10px rgba(255, 234, 0, 0.5); margin: 0 0 20px 0; letter-spacing: 2px; font-style: italic;
}

#login-view { background: #222; padding: 40px; border: 2px solid var(--brand-yellow); display: inline-block; }
#login-view input { font-size: 1.5em; padding: 10px; width: 250px; text-align: center; }

/* コントロール */
.control-panel { background: #222; padding: 10px; margin-bottom: 20px; border-radius: 8px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;}

/* お題 */
.odai-box {
    background: #000; border: 6px solid var(--brand-yellow); padding: 30px 20px; margin-bottom: 30px;
    position: relative; box-shadow: 0 0 20px rgba(255, 234, 0, 0.3);
}
.odai-label {
    position: absolute; top: -18px; left: 50%; transform: translateX(-50%);
    background: var(--brand-yellow); color: #000; padding: 2px 30px; font-weight: 900;
}
#odai-area { font-size: 2em; font-weight: 900; line-height: 1.4; color: #fff; }

/* レイアウト */
.game-main-area { display: flex; justify-content: center; align-items: flex-start; gap: 20px; flex-wrap: wrap; }
.flip-section { flex: 1; min-width: 300px; max-width: 800px; }
.side-panel { width: 200px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding-top: 20px; }
@media (max-width: 700px) { .side-panel { width: 100%; padding-top: 0; } }

/* 入力フリップ */
.input-wrapper { background: #222; padding: 15px; border-radius: 8px; width: 100%; box-sizing: border-box; }
.canvas-container { background: #fff; padding: 10px; border: 10px solid var(--brand-yellow); cursor: crosshair; }
canvas { display: block; width: 100%; height: auto; background: #fff; }
.toolbar { margin-top: 10px; display: flex; justify-content: center; gap: 10px; }
.tool-btn { padding: 8px 15px; cursor: pointer; font-weight: bold; border: none; }
.tool-btn.active { background: var(--brand-yellow); color: #000; }

/* 早押しボタン */
.btn-push {
    width: 140px; height: 140px; border-radius: 50%;
    background: radial-gradient(circle, #ff5e5e 0%, #d00000 100%);
    border: 6px solid #fff; color: #fff; font-weight: 900; font-size: 1.5em;
    cursor: pointer; box-shadow: 0 10px 20px rgba(0,0,0,0.5); transition: transform 0.1s;
}
.btn-push:active { transform: scale(0.95); }
.btn-push:disabled { filter: grayscale(100%); cursor: not-allowed; opacity: 0.3; box-shadow: none; }

/* 勝者パネル */
.winner-controls {
    width: 100%; display: none; flex-direction: column; align-items: center; gap: 15px;
    animation: flash 0.5s infinite alternate;
}
@keyframes flash { from { box-shadow: 0 0 5px var(--brand-yellow); } to { box-shadow: 0 0 20px var(--brand-yellow); } }

.btn-read {
    background: #fff; color: #000; border: none; padding: 15px; width: 100%;
    font-weight: bold; cursor: pointer; border-radius: 8px; font-size: 1.1em;
    display: flex; align-items: center; justify-content: center; gap: 5px; border: 2px solid #ccc;
}
.btn-reveal {
    background: var(--brand-yellow); color: #000; width: 100%;
    font-size: 1.5em; font-weight: 900; padding: 20px 0;
    border: none; cursor: pointer; box-shadow: 0 5px 0 #b3a300;
    transform: skew(-5deg); border-radius: 4px;
}
.btn-reveal:active { transform: skew(-5deg) translateY(3px); box-shadow: 0 2px 0 #b3a300; }

.locked-msg {
    color: #aaa; font-size: 1.2em; font-weight: bold; display: none; padding: 20px;
    background: rgba(255,255,255,0.05); border-radius: 10px; width: 100%; box-sizing: border-box;
}
.locked-user { color: var(--brand-yellow); font-size: 1.3em; display: block; margin-bottom: 5px; }

/* 回答リスト */
.answers-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; margin-top: 40px; }
.flip-card {
    background: #fff; border: 8px solid var(--brand-yellow); color: #000;
    padding: 0; min-height: 200px; display: flex; flex-direction: column;
    transform: rotate(-1deg); box-shadow: 0 5px 15px rgba(0,0,0,0.5);
}
.flip-card:nth-child(even) { transform: rotate(1deg); }
.flip-card .header { background: #eee; padding: 5px 10px; font-size: 0.8em; font-weight: bold; display: flex; justify-content: space-between; }

/* ★ここを修正：改行対応 */
.flip-card .content {
    flex-grow: 1; display: flex; align-items: center; justify-content: center;
    font-size: 2em; font-weight: 900; padding: 10px;
    white-space: pre-wrap; /* 改行を反映 */
    word-break: break-all; /* 長い単語で崩れないように */
    line-height: 1.2;
    text-align: center;
}
.flip-card img { width: 100%; display: block; }
.zabuton-btn { background: var(--brand-yellow); border: none; padding: 10px; font-weight: bold; cursor: pointer; font-size: 1.2em; }

.hidden { display: none !important; }
textarea { width: 100%; height: 200px; font-size: 2em; padding: 10px; border: none; font-weight: bold; box-sizing: border-box; }

/* --- Big Answer Overlay --- */
#big-answer-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.9); z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    perspective: 1000px;
}
.big-card-container {
    background: #fff; border: 15px solid var(--brand-yellow);
    width: 90%; max-width: 900px; min-height: 60vh;
    box-shadow: 0 0 50px rgba(255, 234, 0, 0.5);
    display: flex; flex-direction: column;
    transform: rotateX(90deg); /* 初期状態 */
    animation: popIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
.big-card-name {
    background: #000; color: #fff; font-size: 2em; font-weight: 900; padding: 10px 20px; text-align: left;
}

/* ★ここを修正：改行対応 */
.big-card-content {
    flex-grow: 1; display: flex; align-items: center; justify-content: center;
    color: #000; font-size: 5em; font-weight: 900; padding: 20px;
    white-space: pre-wrap; /* 改行を反映 */
    word-break: break-all;
    line-height: 1.1;
    text-align: center;
}
.big-card-content img { max-width: 100%; max-height: 70vh; display: block; }

@keyframes popIn {
    0% { transform: rotateX(90deg) scale(0.5); opacity: 0; }
    100% { transform: rotateX(0deg) scale(1); opacity: 1; }
}