:root {
    --primary-color: #FF9F43;
    --secondary-color: #54a0ff;
}

body {
    all: initial;
    display: flex; flex-direction: column; align-items: center; margin: 0;
    background-color: #fff2e0 !important;
    color: #576574 !important;
    font-family: 'M PLUS Rounded 1c', sans-serif !important;
    text-align: center;
    padding: 20px; min-height: 100vh; box-sizing: border-box;
    width: 100%;
}

button {
    all: unset;
    font-family: inherit;
    cursor: pointer;
    box-sizing: border-box;
    display: inline-block;
    text-align: center;
}
:root {
    --primary-color: #FF9F43;
    --secondary-color: #54a0ff;
    --accent-color: #ff6b6b;
    --success-color: #1dd1a1;
    --bg-color: #fff2e0;
    --text-color: #576574;
}

body {
    display: flex; flex-direction: column; align-items: center; margin: 0;
    background-color: var(--bg-color); color: var(--text-color);
    font-family: 'M PLUS Rounded 1c', sans-serif; text-align: center;
    padding: 20px; min-height: 100vh; box-sizing: border-box;
}

/* 共通設定 */
button, input, textarea { font-family: inherit; outline: none; }

/* タイトル */
#main-title {
    cursor: pointer; color: #576574; margin: 10px auto 5px auto;
    font-size: 2.8em; font-weight: 800; letter-spacing: 2px;
    text-shadow: 2px 2px 0 #fff;
    transition: color 0.2s;
}
#main-title:hover { color: var(--secondary-color); }
.intro-text { color: #8395a7; margin-bottom: 30px; font-size: 0.9em; font-weight: bold; }

#main-container { width: 100%; max-width: 600px; }

/* --- メインメニュー --- */
.main-menu-grid { display: flex; flex-direction: column; gap: 15px; width: 100%; margin-bottom: 25px; }

.main-card {
    background: white; border-radius: 20px; padding: 15px 20px;
    text-align: center; position: relative; cursor: pointer;
    box-shadow: 0 4px 0 rgba(0,0,0,0.05); transition: all 0.2s;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-height: 90px; border: 2px solid transparent;
}
.main-card:hover { transform: translateY(-3px); box-shadow: 0 8px 15px rgba(0,0,0,0.1); }
.main-card:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,0.05); }

.card-content { display: flex; flex-direction: column; align-items: center; width: 100%; }
.card-header-row { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 5px; }
.card-title { font-size: 1.5em; font-weight: 800; }
.card-sub { font-size: 0.85em; opacity: 0.9; font-weight: bold; }
.card-count { 
    font-size: 1.0em; font-weight: 800; 
    background: #f1f2f6; padding: 4px 10px; border-radius: 20px; color: #576574;
    min-width: 40px; text-align: center;
}

.card-start { border-color: var(--secondary-color); color: var(--secondary-color); }
.card-start .card-count { color: var(--secondary-color); background: #eaf4ff; }
.card-continue { border-color: var(--primary-color); color: var(--primary-color); }
.card-continue .card-count { color: var(--primary-color); background: #fff0e0; }
.card-weak { border-color: var(--accent-color); color: var(--accent-color); }
.card-weak .card-count { color: var(--accent-color); background: #ffeaea; }

.list-btn-main {
    position: absolute; top: 10px; right: 10px; width: 26px; height: 26px;
    background: rgba(0,0,0,0.05); border-radius: 50%; color: #999;
    font-size: 0.8em; display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: 0.2s;
}
.list-btn-main:hover { background: var(--secondary-color); color: white; }

/* --- サブメニュー --- */
.sub-menu-label { text-align: left; font-size: 0.9em; font-weight: bold; color: #b2bec3; margin-bottom: 8px; margin-left: 5px; }
.sub-menu-grid { display: flex; gap: 10px; width: 100%; margin-bottom: 30px; }
.sub-card {
    flex: 1; background: white; border-radius: 15px; padding: 12px 5px;
    cursor: pointer; box-shadow: 0 3px 0 rgba(0,0,0,0.05); border: 2px solid white;
    transition: all 0.2s; display: flex; flex-direction: column; align-items: center; position: relative;
}
.sub-card:hover { transform: translateY(-2px); border-color: #eee; }
.sub-card:active { transform: translateY(2px); box-shadow: none; }
.sub-title { font-size: 0.85em; font-weight: bold; margin-bottom: 3px; color: #8395a7; }
.sub-count { font-size: 1.1em; font-weight: 800; color: var(--text-color); }
.sub-mem .sub-count { color: var(--success-color); }
.sub-rev .sub-count { color: #feca57; }
.sub-unk .sub-count { color: var(--accent-color); }
.list-btn-sub {
    position: absolute; top: 5px; right: 5px; width: 20px; height: 20px;
    background: rgba(0,0,0,0.05); border-radius: 50%; color: #999;
    font-size: 0.7em; display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: 0.2s;
}
.list-btn-sub:hover { background: var(--secondary-color); color: white; }

/* --- クイズ画面 --- */
#quiz-card {
    background-color: #fff; border: 3px solid #fff; border-radius: 20px;
    box-shadow: 0 8px 0 rgba(0,0,0,0.05); padding: 30px 20px;
    min-height: 220px; display: flex; flex-direction: column;
    justify-content: space-around; align-items: center; margin-bottom: 20px; position: relative; 
}
#quiz-edit-btn {
    position: absolute; top: 15px; right: 15px;
    background: #f1f2f6; border: none; border-radius: 50%;
    color: #ccc; cursor: pointer; width: 35px; height: 35px;
    font-size: 1.2em; transition: 0.2s;
}
#quiz-edit-btn:hover { background: #dfe4ea; color: #576574; }
#word-display {
    font-size: 3em; font-weight: 800; color: #2f3542;
    cursor: pointer; text-shadow: 1px 1px 0 #eee; margin-bottom: 5px;
}
#word-display:hover { color: var(--secondary-color); }
#speak-btn {
    background-color: #ffeaa7; color: #d35400; border: none; border-radius: 50%; 
    width: 40px; height: 40px; font-size: 1.2em; cursor: pointer; margin-bottom: 10px;
    display: flex; justify-content: center; align-items: center;
}
#search-buttons-group { display: flex; gap: 8px; justify-content: center; margin-bottom: 15px; }
.action-btn { 
    background-color: #f1f2f6; color: #576574; font-size: 0.85em; padding: 6px 12px;
    font-weight: bold; border: none; border-radius: 15px; cursor: pointer;
}
.action-btn:hover { background-color: #dfe4ea; }
#ipa-display { font-size: 1.2em; color: #a4b0be; margin-bottom: 10px; font-family: 'Times New Roman', serif; }
#meaning-display { font-size: 1.5em; color: var(--accent-color); font-weight: bold; min-height: 1.5em; }
.hidden { opacity: 0; visibility: hidden; }

/* コントロールエリア */
#control-area { width: 100%; margin-bottom: 20px; }
#show-meaning-btn {
    padding: 15px 0; width: 80%; max-width: 300px; font-size: 1.2em; cursor: pointer; font-weight: bold;
    background-color: var(--primary-color); color: white; border: none; border-radius: 50px;
    box-shadow: 0 5px 0 #e67e22; margin: 10px auto; display: block;
}
#show-meaning-btn:active { transform: translateY(5px); box-shadow: none; }
#choice-buttons { display: none; justify-content: center; margin-top: 15px; gap: 10px; }
#choice-buttons button {
    padding: 15px 0; font-size: 1em; cursor: pointer; color: white; font-weight: bold;
    border: none; border-radius: 12px; flex: 1; transition: transform 0.1s;
}
#btn-mem { background-color: var(--success-color); box-shadow: 0 4px 0 #10ac84; } 
#btn-rev { background-color: var(--primary-color); box-shadow: 0 4px 0 #e67e22; } 
#btn-unk { background-color: var(--accent-color); box-shadow: 0 4px 0 #ee5253; } 
#choice-buttons button:active { transform: translateY(4px); box-shadow: none; }
#home-btn {
    padding: 10px 20px; background-color: #a4b0be; color: white; border: none; 
    border-radius: 30px; cursor: pointer; font-weight: bold; margin: 30px auto 0; display: block;
}

/* ポイントメモ */
#quiz-notes-card {
    background-color: #fff; border: 2px dashed #ccc; border-radius: 15px;
    padding: 20px; min-height: 50px; margin-top: 20px; text-align: left; 
}
#notes-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; border-bottom: 1px solid #eee; padding-bottom: 5px; }
.add-note-header-btn { background-color: var(--primary-color); color: white; border: none; width: 24px; height: 24px; border-radius: 50%; cursor: pointer; font-weight: bold; line-height: 24px; text-align: center;}
#notes-list { list-style-type: none; padding: 0; margin: 0; }
.note-item { display: flex; justify-content: space-between; align-items: flex-start; padding: 8px 0; border-bottom: 1px dotted #eee; color: var(--text-color); font-size: 0.95em; position: relative; }
.note-item:before { content: '•'; margin-right: 8px; color: var(--accent-color); font-weight: bold; flex-shrink: 0; margin-top: 4px; }
.note-item.no-bullet:before { display: none; }
.note-text { flex-grow: 1; padding-right: 10px; cursor: pointer; word-break: break-all; white-space: pre-wrap; line-height: 1.3; min-height: 1.3em; display: block; }
.note-bold { font-weight: bold; }
.note-indent { padding-left: 1.5em; }
.note-hidden-placeholder {
    display: inline-block; background: #eaf4ff; color: var(--secondary-color);
    font-weight: bold; font-size: 0.85em; padding: 2px 8px; border-radius: 6px;
    cursor: pointer; text-decoration: underline; user-select: none;
}
.note-actions { flex-shrink: 0; display: flex; gap: 2px; align-items: center; margin-left: 5px; flex-wrap: nowrap; }
.point-tool-btn { border: 1px solid #ccc; border-radius: 4px; padding: 2px 6px; font-size: 0.75em; cursor: pointer; background: #f9f9f9; color: #555; font-weight: bold; height: 24px; box-sizing: border-box; }
.point-tool-btn.pt-plus { background: #dff9fb; color: #22a6b3; border-color: #22a6b3; }
.menu-wrapper { position: relative; display: inline-block; margin-left: 2px;}
.menu-btn { border: 1px solid #ccc; border-radius: 4px; padding: 0; width: 24px; height: 24px; font-size: 14px; cursor: pointer; background: #f1f2f6; color: #555; display: flex; align-items: center; justify-content: center; }
.menu-dropdown { display: none; position: absolute; right: 0; top: 100%; margin-top: 2px; background: white; border: 1px solid #ddd; border-radius: 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.1); z-index: 100; min-width: 100px; overflow: hidden; }
.menu-dropdown button { display: block; width: 100%; text-align: center; padding: 8px 12px; background: white; border: none; border-bottom: 1px solid #eee; font-size: 0.85em; cursor: pointer; color: #576574; font-weight: bold; }
.menu-dropdown button:last-child { border-bottom: none; }
.menu-dropdown button:hover { background: #f1f2f6; color: var(--secondary-color); }
.menu-dropdown button.menu-del:hover { background: #fff5f5; color: var(--accent-color); }
.note-textarea { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 8px; box-sizing: border-box; resize: vertical; line-height: 1.3; }

/* 単語追加・管理 */
#toggle-add-btn { background: none; border: none; color: #8395a7; cursor: pointer; font-weight: bold; text-decoration: underline; margin-top: 20px; }
#word-addition { display: none; flex-direction: column; gap: 10px; margin-top: 15px; background: white; padding: 25px; border-radius: 15px; }
#add-msg { text-align: center; font-weight: bold; height: 24px; margin-bottom: 10px; font-size: 0.95em; }
.input-row { display: flex; gap: 5px; }
input[type="text"] { flex: 1; padding: 10px; border: 2px solid #f1f2f6; border-radius: 10px; font-size: 1em; }
.flat-btn { background: #576574; color: white; border: none; padding: 10px; border-radius: 10px; cursor: pointer; font-weight: bold; white-space: nowrap; }

#backup-section { margin-top: 40px; }
.simple-btn { background: transparent; border: 1px solid #ccc; color: #888; padding: 5px 10px; border-radius: 15px; cursor: pointer; font-size: 0.8em; margin: 0 5px; }

/* モーダル */
#modal-overlay, #bulk-modal-overlay { position: fixed; top:0; left:0; width:100%; height:100%; background:rgba(0,0,0,0.5); display:none; justify-content:center; align-items:center; z-index:1000; }
#modal-box { background:white; padding:25px; border-radius:20px; width:90%; max-width:400px; text-align:left; position: relative;}
.full-input { width:100%; padding:10px; margin-bottom:10px; box-sizing:border-box; border:2px solid #eee; border-radius:8px; }
.save-btn { width:100%; padding:10px; background:var(--primary-color); color:white; border:none; border-radius:8px; font-weight:bold; cursor:pointer; font-size:1.1em; }

#bulk-box { background:white; padding:25px; border-radius:20px; width:90%; max-width:600px; text-align:left; max-height: 90vh; overflow-y: auto; }
#bulk-textarea { width: 100%; height: 150px; font-family: monospace; padding: 10px; box-sizing: border-box; border: 1px solid #ccc; }
#edit-meanings-container { max-height: 200px; overflow-y: auto; margin-bottom: 10px; }
.edit-meaning-row { display: flex; gap: 5px; margin-bottom: 5px; }
.add-row-btn { background: #eee; color: #555; border: none; width: 100%; padding: 5px; cursor: pointer; border-radius: 5px; font-weight: bold; }