/* エディタ画面 */
#editor-screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: #f5f5f5;
    z-index: 10;
}
.editor-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.editor-title-input {
    flex: 1;
    max-width: 400px;
    padding: 10px 14px;
    font-size: 1.1rem;
    border: 2px solid #ddd;
    border-radius: 8px;
}
.editor-header-actions {
    display: flex;
    gap: 10px;
}
.editor-body {
    flex: 1;
    display: flex;
    min-height: 0;
}
.editor-sidebar {
    width: 280px;
    background: #fff;
    border-right: 1px solid #e0e0e0;
    overflow-y: auto;
    padding: 12px;
}
.editor-panel {
    margin-bottom: 20px;
}
.editor-panel h3 {
    margin: 0 0 8px 0;
    font-size: 0.95rem;
    color: #333;
}
.editor-panel .hint {
    font-size: 0.8rem;
    color: #666;
    margin: 4px 0 8px 0;
}
.small-btn {
    padding: 8px 14px;
    background: #81c784;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
}
.small-btn:hover { background: #66bb6a; }
.color-palette {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-bottom: 10px;
}
.color-palette .palette-swatch {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 6px;
    border: 2px solid #ccc;
    cursor: pointer;
}
.color-palette .palette-swatch:hover { border-color: #333; }
.color-palette .palette-swatch.selected { border-color: #2196f3; box-shadow: 0 0 0 2px rgba(33,150,243,0.4); }
.color-rgb { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.color-rgb label { font-size: 0.85rem; }
.color-rgb input[type="number"] { width: 48px; padding: 4px; }
.effect-options { margin: 8px 0; }
.effect-options input, .effect-options select { margin: 4px 0; width: 100%; max-width: 200px; }
.cell-size-shape { margin-top: 10px; }
.cell-size-shape label { display: block; margin: 4px 0; }
.cell-size-shape input[type="number"] { width: 64px; }

/* グループ編集UI */
.editor-group-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    border-radius: 6px;
    background: #f7f7f7;
    margin-bottom: 6px;
    font-size: 0.85rem;
}
.editor-group-row .group-name {
    font-weight: bold;
}
.editor-group-row .group-meta {
    color: #666;
    margin-left: 8px;
}
.editor-group-editor {
    margin-top: 10px;
    padding: 8px;
    background: #f0f4ff;
    border-radius: 8px;
    font-size: 0.85rem;
}
.editor-group-editor h4 {
    margin: 0 0 6px 0;
    font-size: 0.9rem;
}
.editor-group-editor label {
    display: block;
    margin-bottom: 6px;
}
.editor-group-editor input[type="text"],
.editor-group-editor textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid #ccc;
    font-size: 0.85rem;
}
.editor-group-editor textarea {
    resize: vertical;
}
.editor-group-editor .group-flag {
    display: flex;
    align-items: center;
    gap: 6px;
}
.editor-group-editor .group-edit-actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}
.editor-group-editor .group-edit-delete {
    background: #f44336;
}

/* 進む順番UI */
.editor-order-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
    font-size: 0.85rem;
}
.order-index-label {
    min-width: 1.8em;
    text-align: right;
}
.order-move-btn {
    padding: 2px 6px;
    font-size: 0.7rem;
}
.order-cell-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.editor-order-row .order-index-input {
    width: 60px;
}

/* ゲームルール：1項目1行で改行位置を分かりやすく */
#editor-rules-form label {
    display: block;
    margin-bottom: 14px;
    line-height: 1.5;
}
#editor-rules-form label:last-child { margin-bottom: 0; }
#editor-rules-form input[type="number"],
#editor-rules-form select {
    display: block;
    margin-top: 4px;
    width: 100%;
    max-width: 200px;
}
.editor-canvas-wrap {
    flex: 1;
    overflow: auto;
    padding: 20px;
    background: #e8e8e8;
}
.editor-canvas {
    position: relative;
    width: 1200px;
    height: 800px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.editor-cell {
    position: absolute;
    border: 2px solid #333;
    cursor: move;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: bold;
    color: #333;
    user-select: none;
    box-sizing: border-box;
}
.editor-cell.selected { border-color: #2196f3; box-shadow: 0 0 0 3px rgba(33,150,243,0.4); z-index: 10; }
.editor-cell.shape-circle { border-radius: 50%; }
.editor-cell.shape-rounded { border-radius: 12px; }
.editor-order-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    min-width: 20px;
    height: 20px;
    background: #ff9800;
    color: #fff;
    border-radius: 10px;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}

/* 自分のすごろく一覧 */
#my-sugoroku-screen {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 20px;
    text-align: center;
}
#my-sugoroku-screen h2 { margin-bottom: 24px; color: #4db6ac; }
.map-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
    text-align: left;
}
.map-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.map-list-item .map-title { font-weight: bold; }
.map-list-item .map-meta { font-size: 0.85rem; color: #666; }
.map-list-item .map-actions { display: flex; gap: 8px; }
.map-list-item button { padding: 8px 14px; border-radius: 8px; border: none; cursor: pointer; font-size: 0.9rem; }
.map-list-item .btn-edit { background: #81c784; color: white; }
.map-list-item .btn-play { background: #2196f3; color: white; }
.map-list-item .btn-delete { background: #f44336; color: white; }
.map-list-empty { color: #666; padding: 40px 20px; }

/* オンライン・準備・ゲーム画面 */
#online-screen, #prep-screen {
    max-width: 640px;
    margin: 0 auto;
    padding: 40px 20px;
    text-align: center;
}
#online-screen h2, #prep-screen h2 { margin-bottom: 20px; color: #4db6ac; }
#online-host-area, #online-join-area, #online-wait-area { margin-bottom: 20px; }
#online-host-area select, #online-join-area input, #room-name-input {
    padding: 12px 16px;
    font-size: 1rem;
    border: 2px solid #4db6ac;
    border-radius: 10px;
    margin: 0 8px 8px 0;
}
#create-room-button, #join-room-button { padding: 12px 24px; background: #81c784; color: white; border: none; border-radius: 10px; cursor: pointer; }
#create-room-button:hover, #join-room-button:hover { background: #66bb6a; }
.connection-status { margin: 12px 0; font-weight: bold; }
#online-members-list { margin: 16px 0; text-align: left; }
.prep-body { display: flex; gap: 24px; flex-wrap: wrap; justify-content: center; text-align: left; }
.prep-self, .prep-others { flex: 1; min-width: 260px; }
.prep-self label, .prep-others label { display: block; margin: 8px 0; }
.prep-self input[type="text"], .prep-others input { width: 100%; max-width: 320px; padding: 8px 12px; }
#prep-ready-button, #prep-start-game-button { margin-top: 16px; padding: 12px 24px; border-radius: 10px; border: none; cursor: pointer; }
#prep-ready-button { background: #81c784; color: white; }
#prep-start-game-button { background: #ff9800; color: white; }

/* ゲーム画面 */
#game-screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: #e8e8e8;
    z-index: 10;
}
.game-header {
    padding: 12px 20px;
    background: #fff;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.game-main {
    flex: 1;
    display: flex;
    min-height: 0;
}
.game-board-wrap {
    flex: 1;
    overflow: auto;
    padding: 20px;
}
.game-board {
    position: relative;
    width: 100%;
    min-height: 400px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.game-cell {
    position: absolute;
    border: 2px solid #333;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: bold;
    color: #333;
    box-sizing: border-box;
}
.game-cell.shape-circle { border-radius: 50%; }
.game-cell.shape-rounded { border-radius: 12px; }
.game-cell.current-turn { box-shadow: 0 0 0 4px #ff9800; }
.game-piece {
    position: absolute;
    pointer-events: none;
    z-index: 20;
    transition: left 0.3s linear, top 0.3s linear;
}
.game-piece img { width: 100%; height: 100%; object-fit: contain; }
#game-side {
    width: 280px;
    background: #fff;
    border-left: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.log-box {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    font-size: 0.9rem;
}
.log-box p { margin: 4px 0; }
#game-dice-area { padding: 12px; }
#game-roll-dice {
    padding: 14px 24px;
    background: #81c784;
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1.1rem;
}
#game-roll-dice:hover { background: #66bb6a; }
#game-dice-result { margin-top: 10px; font-size: 1.2rem; font-weight: bold; }
.game-effect-panel {
    padding: 8px 12px;
    border-top: 1px solid #eee;
}
#game-effect-choice { padding: 12px; }

.action-button { background: #81c784; color: white; padding: 12px 24px; border: none; border-radius: 10px; cursor: pointer; font-size: 1rem; }
.action-button:hover { background: #66bb6a; }
.back-button { background: #9e9e9e; color: white; padding: 12px 24px; border: none; border-radius: 10px; cursor: pointer; }
.back-button:hover { background: #757575; }
.hidden { display: none !important; }

/* スマホ向けエディタ・ゲームレイアウト調整 */
@media (max-width: 768px) {
    #editor-screen {
        position: relative;
    }
    .editor-header {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    .editor-title-input {
        max-width: none;
        width: 100%;
        box-sizing: border-box;
    }
    .editor-body {
        flex-direction: column;
    }
    .editor-sidebar {
        width: 100%;
        max-height: 40vh;
        box-sizing: border-box;
    }
    .editor-canvas-wrap {
        padding: 8px;
    }
    .editor-canvas {
        width: 1000px;
        height: 600px;
    }

    #online-screen,
    #prep-screen {
        max-width: 100%;
        padding: 24px 12px;
        box-sizing: border-box;
    }
    .prep-body {
        flex-direction: column;
    }
    #game-screen {
        position: relative;
    }
    .game-main {
        flex-direction: column;
    }
    .game-board-wrap {
        padding: 8px;
        min-height: 260px;
    }
    .game-board {
        width: 100%;
        min-height: 260px;
    }
    #game-side {
        width: 100%;
        border-left: none;
        border-top: 1px solid #e0e0e0;
        min-height: 200px;
    }
}
