* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    color: #333;
}

#app { width: 100%; display: flex; flex-direction: column; align-items: center; }

.header { color: white; text-align: center; margin-bottom: 20px; text-shadow: 2px 2px 4px rgba(0,0,0,0.3); }
.header h1 { font-size: 2.6em; margin-bottom: 6px; }
.header p { font-size: 1.15em; }

.panel {
    background: white;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    padding: 30px;
    width: min(680px, 94vw);
    margin-bottom: 18px;
}
.panel h2 { margin-bottom: 16px; color: #764ba2; }
.panel h3 { margin: 18px 0 10px; color: #555; font-size: 1.05em; }

.field { display: block; margin-bottom: 14px; font-weight: bold; color: #555; font-size: 0.95em; }
.field input, .field select, .field textarea {
    display: block; width: 100%; margin-top: 6px; padding: 12px 14px;
    border: 2px solid #ddd; border-radius: 12px; font-family: inherit; font-size: 1em; font-weight: normal;
}
.field textarea { min-height: 140px; resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.9em; }
.field input:focus, .field textarea:focus { outline: none; border-color: #764ba2; }
/* Hidden inputs carry the picker values; don't let the input rule give them a box. */
.field input[type=hidden] { display: none; }

button {
    padding: 14px 26px; font-size: 1.1em; font-family: inherit; font-weight: bold;
    border: none; border-radius: 15px; cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}
button:hover:not(:disabled) { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0,0,0,0.3); }
button:active { transform: translateY(0); }
button:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-primary { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; }
.btn-got { background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%); color: #14532d; }
.btn-tricky { background: linear-gradient(135deg, #fa8231 0%, #f7b731 100%); color: #5c2e00; }
.btn-speak { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); color: #063a52; }
.btn-plain { background: #eee; color: #555; box-shadow: none; }
.btn-danger { background: #fee; color: #b00; box-shadow: none; }
.btn-small { padding: 8px 14px; font-size: 0.9em; }

.row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin-bottom: 14px; }
.row.left { justify-content: flex-start; }
.spacer { flex: 1; }

.link { background: none; border: none; color: white; text-decoration: underline; cursor: pointer;
        font-family: inherit; font-size: 1em; box-shadow: none; padding: 6px; }
.link:hover { transform: none; box-shadow: none; }

.error { background: #fee; color: #b00; padding: 12px 16px; border-radius: 12px; margin-bottom: 14px; font-weight: bold; }
.notice { background: #eef6ff; color: #24507a; padding: 12px 16px; border-radius: 12px; margin-bottom: 14px; }

/* --- profile picker --- */
.profile-grid { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }
.profile-tile {
    background: white; border: none; border-radius: 24px; padding: 24px 20px;
    width: 150px; cursor: pointer; box-shadow: 0 10px 30px rgba(0,0,0,0.25);
    display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.profile-tile .avatar { font-size: 3.6em; line-height: 1; }
.profile-tile .name { font-size: 1.3em; font-weight: bold; }
.profile-tile .sub { font-size: 0.85em; color: #777; font-weight: normal; }
.profile-tile.add { background: rgba(255,255,255,0.25); color: white; border: 3px dashed rgba(255,255,255,0.6); box-shadow: none; }
.profile-tile .avatar.plus { color: white; font-weight: bold; line-height: 0.75; }
.profile-tile.add .sub { color: rgba(255,255,255,0.85); }

/* --- avatar / color pickers --- */
.picker { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }

.swatch {
    width: 52px; height: 52px; border-radius: 50%; padding: 0;
    border: 4px solid transparent; box-shadow: 0 3px 8px rgba(0,0,0,0.2); cursor: pointer;
}
.swatch:hover:not(:disabled) { transform: scale(1.08); }
.swatch.selected { border-color: #333; box-shadow: 0 0 0 3px white inset, 0 3px 10px rgba(0,0,0,0.35); }

.avatar-choice {
    width: 52px; height: 52px; border-radius: 14px; padding: 0;
    font-size: 1.7em; line-height: 1; background: #f6f4fb;
    border: 3px solid transparent; box-shadow: none; cursor: pointer;
}
.avatar-choice:hover:not(:disabled) { transform: scale(1.08); box-shadow: 0 3px 8px rgba(0,0,0,0.18); }
.avatar-choice.selected { border-color: #764ba2; background: #efe9fa; }

/* --- session setup --- */
.list-picker { display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
.list-option {
    display: flex; align-items: center; gap: 14px; text-align: left;
    background: #f6f4fb; color: #333; border: 3px solid transparent; border-radius: 16px;
    padding: 16px 18px; box-shadow: none; font-size: 1em; width: 100%;
}
.list-option:hover:not(:disabled) { transform: none; box-shadow: 0 4px 12px rgba(0,0,0,0.12); }
.list-option.selected { border-color: #764ba2; background: #efe9fa; }
.list-option .tick {
    width: 28px; height: 28px; flex: 0 0 28px; border-radius: 50%;
    border: 2px solid #bbb; display: flex; align-items: center; justify-content: center;
    color: white; font-size: 0.9em;
}
.list-option.selected .tick { background: #764ba2; border-color: #764ba2; }
.list-option .meta { display: flex; flex-direction: column; }
.list-option .name { font-weight: bold; font-size: 1.1em; }
.list-option .sub { font-size: 0.85em; color: #777; font-weight: normal; }

.count-readout { text-align: center; font-size: 2.6em; font-weight: bold; color: #764ba2; line-height: 1.1; }
.count-readout .muted { font-size: 0.32em; display: block; font-weight: normal; }

input[type=range].slider {
    -webkit-appearance: none; appearance: none;
    width: 100%; height: 14px; border-radius: 999px; margin: 14px 0 4px;
    background: #e6e1f2; outline: none;
}
input[type=range].slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 40px; height: 40px; border-radius: 50%; cursor: pointer; border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 3px 10px rgba(0,0,0,0.3);
}
input[type=range].slider::-moz-range-thumb {
    width: 40px; height: 40px; border-radius: 50%; cursor: pointer; border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 3px 10px rgba(0,0,0,0.3);
}
input[type=range].slider:disabled { opacity: 0.5; }
input[type=range].slider:disabled::-webkit-slider-thumb { cursor: not-allowed; }
.slider-ends { display: flex; justify-content: space-between; color: #999; font-size: 0.85em; margin-bottom: 8px; }
.btn-start { font-size: 1.25em; padding: 16px 34px; }

/* --- practice --- */
.progress-line { color: white; font-size: 1.3em; margin-bottom: 12px; text-shadow: 1px 1px 2px rgba(0,0,0,0.3); }
/* The word itself is the exercise, so it gets the big card. */
.word-card {
    background: white; border-radius: 28px; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    padding: 50px 40px; width: min(700px, 92vw); min-height: 210px;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 16px; position: relative; overflow: hidden; cursor: pointer;
}
.word-text {
    font-size: 5.5em; font-weight: bold; color: #764ba2;
    letter-spacing: 3px; line-height: 1.1; text-align: center; word-break: break-word;
}

.sentence-card {
    background: rgba(255,255,255,0.94); border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    padding: 22px 30px; width: min(700px, 92vw);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 12px; position: relative; overflow: hidden; cursor: pointer;
}
.sentence-card.pop, .word-card.pop { animation: pop 0.35s ease; }
@keyframes pop { 0%, 100% { transform: scale(1); } 40% { transform: scale(1.04); } }
.sentence-text { font-size: 1.5em; text-align: center; line-height: 1.5; font-weight: 500; }
.highlight { background: #FFE033; color: #222; border-radius: 8px; padding: 2px 6px; font-weight: bold; }
.sentence-counter { color: rgba(255,255,255,0.85); font-size: 0.95em; margin-bottom: 12px; }

.emoji-celebration { position: absolute; font-size: 3.5em; animation: float 1.8s ease-out forwards; pointer-events: none; }
@keyframes float {
    0%   { opacity: 1; transform: translateY(0) scale(0); }
    40%  { opacity: 1; transform: translateY(-80px) scale(1); }
    100% { opacity: 0; transform: translateY(-180px) scale(0.5); }
}

.badge-new { background: #43e97b; color: #14532d; font-size: 0.75em; padding: 4px 10px;
             border-radius: 999px; margin-left: 10px; vertical-align: middle; }

/* --- summary --- */
.stars { font-size: 3em; text-align: center; margin-bottom: 10px; word-break: break-word; }
.stat-row { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-bottom: 18px; }
.stat { background: #f6f4fb; border-radius: 16px; padding: 16px 22px; text-align: center; min-width: 110px; }
.stat .n { font-size: 2em; font-weight: bold; color: #764ba2; }
.stat .l { font-size: 0.85em; color: #777; }

/* --- dashboard --- */
table { width: 100%; border-collapse: collapse; font-size: 0.95em; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid #eee; }
th { color: #888; font-size: 0.8em; text-transform: uppercase; letter-spacing: 0.05em; }
td.num, th.num { text-align: right; }

.boxbar { display: flex; height: 26px; border-radius: 8px; overflow: hidden; margin: 6px 0 4px; background: #eee; }
.boxbar span { display: block; }
.boxlegend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.85em; color: #777; }
.boxlegend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.set-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid #eee; }
.set-row .meta { flex: 1; }
.set-row .meta .name { font-weight: bold; }
.set-row .meta .sub { font-size: 0.85em; color: #888; }

.tabs { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.tabs button { background: rgba(255,255,255,0.25); color: white; box-shadow: none; padding: 10px 20px; }
.tabs button.active { background: white; color: #764ba2; }

.muted { color: #888; font-size: 0.9em; }

@media (max-width: 600px) {
    .header h1 { font-size: 1.9em; }
    .sentence-text { font-size: 1.2em; }
    .word-text { font-size: 3.4em; }
    .word-card { padding: 36px 20px; min-height: 160px; }
    .sentence-card { padding: 18px 16px; }
    button { padding: 12px 18px; font-size: 1em; }
    .panel { padding: 22px 18px; }
    .profile-tile { width: 130px; }
}
