html, body, #root {
    height: 100%;
    margin: 0;
}

body {
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
    background: #0b1020;
    color: #eef2ff;
    -webkit-text-size-adjust: 100%;
}

header {
    padding: 24px;
    background: #111736;
    border-bottom: 1px solid #1d2450;
}

main {
    padding: 24px;
    max-width: 880px;
    margin: 0 auto;
}

.card {
    background: #121935;
    border: 1px solid #1e2a5a;
    border-radius: 12px;
    padding: 20px;
}

.card-lite {
    background: #0f1530;
    border: 1px solid #1a2252;
    border-radius: 10px;
    padding: 16px;
}

a {
    color: #7aa2ff;
}

code {
    background: #0e1533;
    padding: 2px 6px;
    border-radius: 6px;
}

.muted {
    color: #aab2d5;
}

.small {
    font-size: 12px;
}

.btn {
    background: #2a3b8f;
    border: none;
    color: white;
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
}

.btn.ghost {
    background: transparent;
    border: 1px solid #2a3b8f;
    color: #cfd8ff;
}

.btn:hover {
    background: #3449af;
}

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.tab {
    background: #0f1530;
    border: 1px solid #1a2252;
    color: #cfd8ff;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
}

.tab.active {
    background: #1a2252;
}

/* Drag & Drop common */
.dnd-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dnd-slot {
    background: #0e1533;
    border: 1px dashed #27306b;
    border-radius: 8px;
    padding: 6px;
}

.dnd-slot.placeholder {
    text-align: center;
    padding: 10px;
    opacity: 0.8;
}

.dnd-item {
    background: #161e45;
    border: 1px solid #2a3b8f;
    border-radius: 6px;
    padding: 10px 12px;
    user-select: none;
}

/* Bins */
.bins {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.bin {
    background: #0e1533;
    border: 1px solid #27306b;
    border-radius: 10px;
    padding: 10px;
    min-height: 120px;
}

.bin-title {
    font-weight: 600;
    margin-bottom: 8px;
}

.bin-items {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 80px;
}

/* MCQ */
.mcq .question {
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #1a2252;
}

.mcq .q {
    margin-bottom: 8px;
    font-weight: 600;
}

.options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.opt {
    background: #0f1530;
    border: 1px solid #27306b;
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.opt.selected {
    border-color: #4b61d1;
    background: #121c44;
}

.opt input {
    accent-color: #4b61d1;
}

/* Leaderboard */
.leaderboard {
    list-style: none;
    padding: 0;
    margin: 0;
}

.leaderboard li {
    display: grid;
    grid-template-columns: 32px 1fr 60px;
    gap: 8px;
    padding: 6px 8px;
    border-bottom: 1px solid #1a2252;
}

.leaderboard li.me {
    background: #0e1b46;
    border-left: 3px solid #4b61d1;
}

.result {
    margin-top: 10px;
    font-weight: 600;
}

/* Map drag game */
.map-wrap {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 16px;
    align-items: start;
}

@media (max-width: 820px) {
    .map-wrap {
        grid-template-columns: 1fr;
    }
}

/*noinspection ALL*/
.sweden-map {
    position: relative;
    width: 100%;
    padding-top: 160%; /* aspect ratio 10:16 */
    border: 1px solid #27306b;
    border-radius: 12px;
    overflow: hidden;

    background-image: url('/static/image/sverige.svg');
    background-repeat: no-repeat;
    background-position: top;
    background-size: cover;
}

/* The radial gradient at the top gives a subtle headland; this is just a stylized map silhouette to avoid assets. */
.dot {
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid #ff4d4f;
    background: rgba(255, 0, 0, 0.15);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dot::after {
    content: "";
    width: 6px;
    height: 6px;
    background: #ff4d4f;
    border-radius: 50%;
    opacity: 0.9;
}

.dot.filled {
    background: rgba(255, 77, 79, 0.25);
    box-shadow: 0 0 0 3px rgba(255, 77, 79, 0.15) inset;
}

.dot .dot-label {
    position: absolute;
    top: -8px;
    left: 12px;
    background: #161e45;
    border: 1px solid #2a3b8f;
    border-radius: 6px;
    padding: 4px 6px;
    font-size: 12px;
    white-space: nowrap;
    transform: translateY(-100%);
    max-width: 160px;
}

.pool {
    background: #0e1533;
    border: 1px solid #27306b;
    border-radius: 12px;
    padding: 10px;
    min-height: 160px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Correctness states (generic) */
.correct { color: #34d399; }
.incorrect { color: #f87171; }

/* MCQ correctness */
.opt.correct {
    border-color: #2ebd85;
    background: #0f2a22;
}
.opt.incorrect {
    border-color: #d94c53;
    background: #2a0f14;
}

/* Map correctness */
.dot.correct {
    border-color: #2ebd85;
    background: rgba(46, 189, 133, 0.18);
}
.dot.correct::after {
    background: #2ebd85;
}
.dot.incorrect {
    border-color: #ff4d4f;
    background: rgba(255, 77, 79, 0.22);
}
.dot-label.correct { color: #34d399; border-color: #2ebd85; }
.dot-label.incorrect { color: #f87171; border-color: #d94c53; }

/* Timeline correctness */
.drop-line.correct {
    background: linear-gradient(180deg, rgba(46, 189, 133, 0.9), rgba(46, 189, 133, 0.2));
    box-shadow: 0 0 0 3px rgba(46, 189, 133, 0.12) inset;
}
.drop-line.incorrect {
    background: linear-gradient(180deg, rgba(217, 76, 83, 0.9), rgba(217, 76, 83, 0.2));
    box-shadow: 0 0 0 3px rgba(217, 76, 83, 0.12) inset;
}
.drop-cap.correct { border-color: #2ebd85; }
.drop-cap.incorrect { border-color: #d94c53; }

/* Timeline game */
.timeline-wrap {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

@media (max-width: 820px) {
    .timeline-wrap {
        grid-template-columns: 1fr;
    }
}

.timeline-area {
    position: relative;
    width: 100%;
    height: 360px;
    background: #0e1533;
    border: 1px solid #27306b;
    border-radius: 12px;
    overflow-x: auto;
    overflow-y: hidden;
}

.timeline-inner {
    position: relative;
    width: 100%;
    min-width: 1200px;
    height: 100%;
    margin: 0 100px;
}

.timeline-bar {
    position: absolute;
    left: 6px;
    right: 6px;
    bottom: 50%;
    height: 4px;
    background: linear-gradient(90deg, #27306b, #4b61d1);
    border-radius: 2px;
}

.tick {
    position: absolute;
    bottom: calc(50% - 14px);
    transform: translateX(-50%);
    text-align: center;
}

.tick-line {
    width: 2px;
    height: 10px;
    background: #27306b;
    margin: 0 auto;
}

.tick-label {
    margin-top: 4px;
    font-size: 11px;
    color: #aab2d5;
    white-space: nowrap;
    transform: translateY(8px);
}

.drop-line {
    position: absolute;
    bottom: 50%;
    width: 2px;
    height: 160px;
    background: linear-gradient(180deg, rgba(75, 97, 209, 0.6), rgba(75, 97, 209, 0));
    transform: translateX(-50%);
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

/* Length variants (upwards) */
.drop-line.len-s {
    height: 30px;
}

.drop-line.len-m {
    height: 70px;
}

.drop-line.len-l {
    height: 110px;
}

.drop-line.down {
    bottom: auto;
    top: calc(100% - 50% + 4px);
    height: 120px;
}

/* Length variants (downwards) */
.drop-line.down.len-s {
    height: 30px;
}

.drop-line.down.len-m {
    height: 70px;
}

.drop-line.down.len-l {
    height: 110px;
}

.drop-line.filled {
    background: linear-gradient(180deg, rgba(122, 162, 255, 0.9), rgba(75, 97, 209, 0.2));
    box-shadow: 0 0 0 3px rgba(75, 97, 209, 0.12) inset;
}

.drop-cap {
    position: absolute;
    top: -10px;
    transform: translate(-50%, -100%);
    left: 50%;
    background: #161e45;
    border: 1px solid #2a3b8f;
    border-radius: 8px;
    padding: 6px 8px;
    min-width: 140px;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: left;
}

.drop-line.down .drop-cap {
    top: auto;
    bottom: -10px;
    transform: translate(-50%, 100%);
}

.cap-label {
    font-size: 12px;
    color: #eef2ff;
}

/* Mobile helper visibility */
.mobile-only { display: none; }
.desktop-only { display: block; }
@media (pointer: coarse), (max-width: 640px) {
  .mobile-only { display: block; }
  .desktop-only { display: none; }
}

/* Selected state for tap-to-place */
.dnd-item.selected {
  border-color: #7aa2ff;
  box-shadow: 0 0 0 2px rgba(122,162,255,0.25);
  background: #1a2454;
}

/* Long text handling */
.dnd-item, .bin-items, .drop-cap, .dot .dot-label {
  word-wrap: break-word;
  overflow-wrap: anywhere;
  hyphens: auto;
}

/* Small-screen typography tweaks */
@media (max-width: 480px) {
  header h1 { font-size: 20px; line-height: 1.2; }
  main { padding: 16px; }
  .card { padding: 14px; }
  .dot .dot-label { font-size: 11px; max-width: 120px; }
  .btn { padding: 9px 12px; }
}

/* Improve touch targets a bit on mobile */
@media (pointer: coarse) {
  .dnd-item { padding: 12px 14px; }
  .dot { width: 20px; height: 20px; }
  .dot::after { width: 8px; height: 8px; }
}