/* 回転しりとり21 - スタイルシート（シンプル教育UI版） */
/* 修正: ネイビー＋ゴールドのシンプル教育UI骨格に全面刷新 */

.shiritori21-game * {
    box-sizing: border-box;
}

.shiritori21-game {
    --s21-navy: #1e3a5f;
    --s21-gold: #d4af37;
    --s21-white: #ffffff;
    --s21-bg: #f2f4f7;
    font-family: "BIZ UDGothic", "M PLUS Rounded 1c", "Hiragino Sans", "Yu Gothic Medium", "Meiryo", sans-serif;
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

/* ===== 全体コンテナ ===== */
.s21-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--s21-bg);
}

/* ===== ヘッダー ===== */
/* 修正: 高さ変動防止のため固定 height。文字見切れ対策で余裕を持たせて64pxに拡大 */
.s21-header {
    height: 64px;
    overflow: hidden;
    background: var(--s21-navy);
    color: var(--s21-white);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 16px;
}

.s21-title {
    font-size: 16px;
    font-weight: bold;
    flex-shrink: 0;
    white-space: nowrap;
}

.s21-status {
    font-size: 13px;
    color: var(--s21-gold);
    font-weight: bold;
    flex-shrink: 0;
    white-space: nowrap;
}

/* 修正: ヘッダー内 文字数（レベル）選択ボタン */
.s21-level-btn {
    flex-shrink: 0;
    font-size: 12px;
    font-weight: bold;
    color: var(--s21-navy);
    background: var(--s21-gold);
    border: none;
    border-radius: 20px;
    padding: 6px 12px;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
}

.s21-level-btn:hover {
    background: #c19d2e;
}

/* ===== ステージ ===== */
/* 修正: 背景画像を追加（httpsに修正済み）。可読性確保のため半透明の白オーバーレイを重ねる */
.s21-stage {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow-y: auto;
    text-align: center;
    background-image: url('https://ict-primaryschool-juniorhighschool.com/wp-content/uploads/2026/08/ChatGPT-Image-2026%E5%B9%B48%E6%9C%8819%E6%97%A5-13_59_20.jpg');
    background-size: cover;
    background-position: center;
}

.s21-stage::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.6);
    z-index: 0;
}

.s21-stage > * {
    position: relative;
    z-index: 1;
}

/* 円形配置コンテナ */
/* 修正: 画面の高さに応じて自動フィットするサイズ計算に変更（ヘッダー・入力欄分を差し引いた高さも上限に含める） */
.circle-container {
    position: relative;
    width: min(480px, 85vmin, calc(100dvh - 200px));
    height: min(480px, 85vmin, calc(100dvh - 200px));
    margin: 10px auto;
    border-radius: 50%;
    background: transparent;
    flex-shrink: 0;
}

/* 円形アイテム（実際のサイズはJSが実測したコンテナサイズを基に算出しインラインで指定） */
.circle-item {
    position: absolute;
    border-radius: 50%;
    background: var(--s21-white);
    color: var(--s21-navy);
    font-weight: bold;
    border: 3px solid var(--s21-navy);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.25);
    text-align: center;
    user-select: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 5;
    cursor: pointer;
}

.circle-item:hover {
    transform: scale(1.1);
}

.circle-item.filled {
    background: var(--s21-navy);
    color: var(--s21-white);
    border-color: var(--s21-navy);
    transform: scale(1.05);
}

/* 中央の残り数表示 */
/* 修正: サイズはJSがコンテナ実測値から算出してインラインで指定するため、CSSは初期値のみ */
.center-count {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: bold;
    background: var(--s21-white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 4px solid var(--s21-gold);
    color: var(--s21-navy);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

/* 入力エリア */
.input-area {
    width: min(500px, 92vw);
    margin: 12px auto 0 auto;
}

.input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.input-field {
    font-size: clamp(15px, 4vw, 18px);
    padding: 10px 14px;
    flex: 1;
    border-radius: 10px;
    border: 2px solid rgba(30, 58, 95, 0.3);
    text-align: center;
    background: var(--s21-white);
    transition: all 0.2s ease;
    font-family: inherit;
    min-width: 0;
}

.input-field:focus {
    outline: none;
    border-color: var(--s21-navy);
}

.input-field::placeholder {
    color: #999;
}

/* ボタン共通スタイル */
.btn {
    font-size: clamp(13px, 3vw, 15px);
    padding: 10px 18px;
    border-radius: 10px;
    border: none;
    font-weight: bold;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
}

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

.btn-primary {
    background: var(--s21-navy);
    color: var(--s21-white);
}

.btn-primary:hover:not(:disabled) {
    background: #274b78;
}

.btn-secondary {
    background: var(--s21-bg);
    color: var(--s21-navy);
    border: 2px solid var(--s21-navy);
}

.btn-secondary:hover:not(:disabled) {
    background: #e6e9ee;
}

.btn-danger {
    background: #c62828;
    color: var(--s21-white);
}

.btn-danger:hover:not(:disabled) {
    background: #a32020;
}

/* ヘッダー内の案内文（常に固定表示・JSでは変更しない） */
.s21-hint {
    flex: 1;
    min-width: 0;
    font-size: clamp(12px, 3vw, 14px);
    color: rgba(255, 255, 255, 0.9);
    font-weight: bold;
    line-height: 40px;
    height: 40px;
    max-height: 40px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* 修正: 動的な入力結果フィードバック（成功／エラー）を入力欄の下に新設 */
.input-feedback {
    width: min(500px, 92vw);
    margin: 8px auto 0 auto;
    font-size: clamp(12px, 3vw, 14px);
    font-weight: bold;
    color: var(--s21-navy);
    min-height: 20px;
    line-height: 1.4;
}

.input-feedback.error {
    color: #c62828;
}

.input-feedback.success {
    color: #2e7d32;
}

/* ===== 右下 フロートアイコンボタン ===== */
.s21-toolbar {
    position: absolute;
    bottom: 16px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 10;
}

.s21-icon-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--s21-white);
    border: 2px solid var(--s21-navy);
    color: var(--s21-navy);
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transition: transform 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.s21-icon-btn:hover {
    transform: scale(1.08);
}

/* ===== 共通モーダル ===== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(30, 58, 95, 0.7);
}

.modal.show {
    display: block;
}

.modal-content {
    background: var(--s21-white);
    margin: 8% auto;
    padding: 28px;
    border-radius: 16px;
    border-top: 6px solid var(--s21-navy);
    width: min(420px, 90vw);
    max-height: 80vh;
    overflow-y: auto;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    position: relative;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--s21-bg);
    color: var(--s21-navy);
    font-size: 16px;
    cursor: pointer;
}

.modal-title {
    font-size: 18px;
    font-weight: bold;
    color: var(--s21-navy);
    margin-bottom: 16px;
}

.modal-header {
    margin-bottom: 20px;
}

.modal-header h2 {
    color: var(--s21-navy);
    font-size: clamp(20px, 5vw, 26px);
    margin: 0;
}

/* 履歴エリア（モーダル内） */
.history-area {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 80px;
    max-height: 45vh;
    overflow-y: auto;
    padding: 4px;
}

.history-title {
    width: 100%;
    display: none; /* モーダルタイトルと重複するため非表示（JS互換のため要素自体は保持） */
}

.history-placeholder {
    color: #999;
    width: 100%;
    text-align: center;
}

.history-card {
    background: var(--s21-bg);
    border: 2px solid rgba(30, 58, 95, 0.25);
    border-radius: 10px;
    padding: 6px 12px;
    font-weight: bold;
    color: var(--s21-navy);
    cursor: pointer;
    font-size: clamp(12px, 3vw, 14px);
    min-width: 56px;
}

.history-card:hover {
    background: var(--s21-navy);
    color: var(--s21-white);
}

/* 修正: 文字数（レベル）選択オプション（モーダル内） */
.s21-level-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.s21-level-option {
    padding: 14px;
    border: 2px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    font-size: 15px;
    color: var(--s21-navy);
    background: var(--s21-bg);
    text-align: center;
    width: 100%;
    font-family: inherit;
}

.s21-level-option:hover {
    background: #e6e9ee;
}

.s21-level-option.active {
    background: var(--s21-navy);
    color: var(--s21-white);
    border-color: var(--s21-gold);
}

/* 遊び方エリア（モーダル内） */
.help-content-mini {
    text-align: left;
    font-size: 14px;
    line-height: 1.5;
}

.help-content-mini h4 {
    color: var(--s21-navy);
    margin: 12px 0 4px 0;
    font-size: 14px;
}

.help-content-mini h4:first-child {
    margin-top: 0;
}

.help-content-mini ul {
    margin: 4px 0;
    padding-left: 18px;
}

.help-content-mini li {
    margin: 3px 0;
}

/* ===== レスポンシブ ===== */
@media (max-width: 768px) {
    .s21-title { font-size: 14px; }
    .s21-status { font-size: 11px; }
    .s21-level-btn { font-size: 11px; padding: 5px 10px; }
    .s21-icon-btn { width: 42px; height: 42px; font-size: 16px; }
    .s21-hint { font-size: 12px; }

    .input-row {
        flex-wrap: wrap;
    }

    .btn {
        flex: 1;
        min-width: 70px;
    }
}

/* 修正: circle-containerのサイズは高さに応じて自動フィットする計算式に統一したため、
   個別の縦長画面向けメディアクエリは不要になり削除 */
