/* Nối từ – toàn bộ CSS của trò (mọi lớp dùng tiền tố noitu-, riêng ảnh trang chủ là .art-noitu). Nạp sau style.css.
   Khung cảnh: tường lớp học, bảng đen phấn trắng (chuỗi từ thành đoàn tàu), dưới là trang vở ô ly để gõ chữ. Không dùng đơn vị cqw. */
.art-noitu { background: #2a4536 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 96 96'%3E %3Crect width='96' height='96' fill='%238a5a32'/%3E %3Cpath d='M0 3h96M0 93h96' stroke='%236b4224' stroke-width='2'/%3E %3Crect x='5' y='5' width='86' height='78' rx='3' fill='%232a4536'/%3E %3Cellipse cx='30' cy='28' rx='26' ry='12' fill='%23fff' opacity='.05'/%3E %3Cellipse cx='70' cy='60' rx='22' ry='10' fill='%23fff' opacity='.04'/%3E %3Cg font-family='Mali, Patrick Hand, Comic Sans MS, cursive' font-weight='700' fill='%23f4f1e6'%3E %3Ctext x='11' y='24' font-size='12.5'%3Eh%E1%BB%8Dc %3Ctspan fill='%23f2d36b'%3Esinh%3C/tspan%3E%3C/text%3E %3Ctext x='34' y='42' font-size='12.5'%3E%3Ctspan fill='%23f2d36b'%3Esinh%3C/tspan%3E vi%C3%AAn%3C/text%3E %3C/g%3E %3Cpath d='M26 28c2 6 5 8 9 9' fill='none' stroke='%23f4f1e6' stroke-width='1.4' stroke-linecap='round' stroke-dasharray='2 2'/%3E %3Cpath d='M33 35l2.5 2-3 1' fill='none' stroke='%23f4f1e6' stroke-width='1.4' stroke-linecap='round'/%3E %3Cg fill='none' stroke='%23f4f1e6' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E %3Cpath d='M10 70V58h12v12M22 70v-8h9l3 8z'/%3E%3Cpath d='M14 58v-4h5v4'/%3E%3Cpath d='M27 62v-5h4'/%3E %3Cpath d='M15 52c1-3 5-3 6-1' opacity='.7'/%3E %3Crect x='38' y='58' width='20' height='12' rx='2'/%3E%3Crect x='62' y='58' width='20' height='12' rx='2' stroke='%23ffb3c7'/%3E %3Cpath d='M34 66h4M58 66h4'/%3E %3C/g%3E %3Cg fill='%23f4f1e6'%3E%3Ccircle cx='14' cy='72' r='2.4'/%3E%3Ccircle cx='28' cy='72' r='2.4'/%3E%3Ccircle cx='43' cy='72' r='2.4'/%3E%3Ccircle cx='53' cy='72' r='2.4'/%3E%3Ccircle cx='67' cy='72' r='2.4' fill='%23ffb3c7'/%3E%3Ccircle cx='77' cy='72' r='2.4' fill='%23ffb3c7'/%3E%3C/g%3E %3Cpath d='M4 76h88' stroke='%23f4f1e6' stroke-width='1' opacity='.5'/%3E %3Crect x='5' y='83' width='86' height='6' fill='%23a8754a'/%3E %3Crect x='62' y='81' width='14' height='4' rx='1.5' fill='%23f4f1e6'/%3E %3Crect x='18' y='80' width='16' height='6' rx='1.5' fill='%233a3a4a'/%3E%3Crect x='18' y='80' width='16' height='2.5' rx='1' fill='%23c9a46b'/%3E %3C/svg%3E") center/cover no-repeat; }

body[data-scene="noitu"] #app { max-width: 940px; }

/* ================= Màn chọn ================= */
.noitu-setup { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.noitu-setup > .back, .noitu-back { justify-self: start; font: 1.2rem var(--f-hand); color: var(--ink); text-decoration: none; background: #fffdf4; border: 2px solid #24233a; border-radius: 999px; padding: .15em .8em; box-shadow: 2px 3px 0 rgba(36, 35, 58, .3); cursor: pointer; min-height: 40px; }
.noitu-head { display: flex; gap: 14px; align-items: center; background: #2a4536; color: #f4f1e6; border: 6px solid #8a5a32; border-radius: 14px; padding: 10px 14px; box-shadow: 3px 4px 0 rgba(36, 35, 58, .3), inset 0 0 30px rgba(0, 0, 0, .35); }
.noitu-head .noitu-art { display: block; width: 72px; height: 72px; flex: none; border-radius: 10px; border: 2px solid #f4f1e6; }
.noitu-h1 { margin: 0; font: 700 clamp(1.8rem, 9vw, 2.5rem)/1.1 var(--f-chalk); color: #f4f1e6; text-shadow: 0 0 2px rgba(255, 255, 255, .5); letter-spacing: .02em; }
.noitu-head p { margin: 4px 0 0; color: #d9e3d6; font-size: .95rem; min-width: 0; }
.noitu-box { background: #fffdf4; border: 2px solid #24233a; border-radius: 16px; padding: 14px 16px 16px; display: grid; gap: 12px; box-shadow: 3px 4px 0 rgba(36, 35, 58, .3); min-width: 0; }
.noitu-box h2, .noitu-netbox h2 { margin: 0; font: 600 1.45rem/1.15 var(--f-hand); color: var(--ink); }
.noitu-netbox { max-width: none; }
.noitu-seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 2px solid var(--ink); border-radius: 10px; overflow: hidden; min-width: 0; flex: 1; }
.noitu-seg button { font: 600 clamp(.78rem, 3.5vw, .92rem)/1.15 var(--f-body); padding: .55em 2px; min-height: 42px; background: #fff; color: var(--ink); border: 0; border-left: 1.5px solid var(--ink); cursor: pointer; min-width: 0; text-wrap: balance; }
.noitu-seg button:first-child { border-left: 0; }
.noitu-seg button[aria-checked="true"] { background: var(--ink); color: #fff; }
.noitu-tabs { background: #fff; box-shadow: 2px 3px 0 rgba(36, 35, 58, .3); }
.noitu-row { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.noitu-row > span { flex: none; min-width: 5.2em; font-weight: 600; }
.noitu-names { display: grid; gap: 8px; }
.noitu-names label { display: flex; gap: 10px; align-items: center; }
.noitu-names input { flex: 1; min-width: 0; font: 1.05rem var(--f-body); padding: 8px 10px; border: 2px solid #24233a; border-radius: 10px; min-height: 44px; }
.noitu-load { margin: 0; font: 1.15rem var(--f-hand); color: var(--ink); }
.noitu-load:empty { display: none; }
.noitu-rules { background: #fffdf4; border: 2px solid #24233a; border-radius: 14px; padding: 10px 14px; }
.noitu-rules summary { cursor: pointer; font: 600 1.25rem var(--f-hand); color: var(--ink); min-height: 32px; }
.noitu-credit, .noitu-foot { color: var(--muted); font-size: .82rem; line-height: 1.45; overflow-wrap: anywhere; }
.noitu-foot { margin: 0; }
.noitu-foot a, .noitu-credit a { color: inherit; }
.noitu-av { display: inline-grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: 50%; background: #2a4536; color: var(--ch, #fff); border: 2px solid var(--ch, #fff); font: 700 .9rem/1 var(--f-chalk); }
.nt-seats .noitu-av { width: 30px; height: 30px; }

/* ================= Màn chơi ================= */
.noitu-play { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }
.noitu-bar { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.noitu-bt { font: 700 1.5rem/1 var(--f-chalk); color: #2a4536; }
.noitu-sub { font-size: .88rem; color: var(--text); background: rgba(255, 255, 255, .6); border-radius: 99px; padding: 2px 10px; }
.noitu-tools { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.noitu-tools .btn { min-height: 40px; }

.noitu-board { position: relative; display: grid; gap: 8px; padding: 12px 12px 22px; border: 10px solid #8a5a32; border-radius: 14px; color: #f4f1e6;
  background-color: #2a4536;
  background-image: radial-gradient(ellipse 40% 30% at 20% 25%, rgba(255, 255, 255, .06), transparent 70%), radial-gradient(ellipse 50% 30% at 75% 70%, rgba(255, 255, 255, .05), transparent 70%), radial-gradient(rgba(255, 255, 255, .025) 1px, transparent 1.5px);
  background-size: auto, auto, 6px 6px;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, .45), 0 4px 0 #5e3a1d, 3px 6px 10px rgba(36, 35, 58, .35); min-width: 0; }
.noitu-players { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.noitu-players li { display: flex; align-items: center; gap: 6px; padding: 3px 10px 3px 4px; border: 1.5px dashed rgba(244, 241, 230, .45); border-radius: 99px; font: 600 .9rem/1.2 var(--f-body); min-width: 0; max-width: 100%; }
.noitu-players li.on { border-style: solid; border-color: var(--ch); box-shadow: 0 0 0 2px rgba(242, 211, 107, .35); background: rgba(255, 255, 255, .08); }
.noitu-players li.out { opacity: .55; text-decoration: line-through; }
.noitu-players li.win { border-color: #f2d36b; border-style: solid; }
.noitu-players .noitu-pn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 9.5em; }
.noitu-players em { font-style: normal; font-size: .75rem; font-weight: 400; color: #c5ccbf; text-decoration: none; }
.noitu-players b { font: 700 .95rem var(--f-chalk); color: #f2d36b; }

.noitu-trainbox { max-height: min(46vh, 380px); min-height: 110px; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; padding: 4px 2px; scrollbar-width: thin; scrollbar-color: rgba(244, 241, 230, .4) transparent; }
.noitu-train { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 18px 16px; align-items: flex-end; }
.noitu-car { position: relative; display: grid; justify-items: center; padding: 6px 10px 12px; min-width: 0; max-width: 100%;
  border: 2.2px solid var(--ch, #f4f1e6); border-radius: 9px 9px 5px 5px; color: #f4f1e6; background: rgba(255, 255, 255, .04); }
.noitu-car::after { content: ""; position: absolute; left: 10%; right: 10%; bottom: -8px; height: 10px; pointer-events: none;
  background: radial-gradient(circle at 18% 50%, var(--ch, #f4f1e6) 0 3.4px, transparent 4px), radial-gradient(circle at 82% 50%, var(--ch, #f4f1e6) 0 3.4px, transparent 4px); }
.noitu-car + .noitu-car::before { content: ""; position: absolute; left: -17px; width: 15px; top: 60%; border-top: 2px dotted rgba(244, 241, 230, .7); }
.noitu-w { font: 700 clamp(1.05rem, 4.6vw, 1.35rem)/1.15 var(--f-chalk); white-space: nowrap; letter-spacing: .01em; }
.noitu-w i { font-style: normal; }
.noitu-w b { color: #f2d36b; font-weight: 700; }
.noitu-car small { font: .68rem/1.1 var(--f-body); color: #c5ccbf; max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.noitu-car.loco { padding-left: 46px; border-radius: 9px 16px 5px 5px; }
.noitu-loco-svg { position: absolute; left: 4px; top: 50%; width: 38px; height: 26px; transform: translateY(-55%); color: #f4f1e6; }
.noitu-car.in { animation: noitu-in .45s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes noitu-in { from { opacity: 0; transform: translateX(-26px); } to { opacity: 1; transform: none; } }
.noitu-tray { position: absolute; left: 6%; right: 6%; bottom: -10px; height: 10px; background: #a8754a; border-radius: 0 0 4px 4px; box-shadow: 0 2px 0 #6b4224; }
.noitu-chalk { position: absolute; left: 12%; top: -4px; width: 30px; height: 7px; border-radius: 3px; background: #f4f1e6; }
.noitu-eraser { position: absolute; right: 14%; top: -7px; width: 40px; height: 10px; border-radius: 3px; background: linear-gradient(#c9a46b 0 40%, #3a3a4a 40%); }

/* Trang vở ô ly để gõ */
.noitu-desk { display: grid; gap: 8px; padding: 12px 14px 12px 22px; border-radius: 6px; border: 1.5px solid #d6d2c4; position: relative; min-width: 0;
  background-color: var(--paper);
  background-image: linear-gradient(90deg, transparent 12px, var(--margin) 12px, var(--margin) 13.5px, transparent 13.5px), repeating-linear-gradient(180deg, transparent 0 7px, var(--rule) 7px 8px), repeating-linear-gradient(90deg, transparent 0 31px, var(--rule-strong) 31px 32px), repeating-linear-gradient(180deg, transparent 0 31px, var(--rule-strong) 31px 32px);
  box-shadow: 2px 3px 0 rgba(36, 35, 58, .2); }
.noitu-clock { position: relative; height: 16px; border-radius: 99px; background: #e9e4d2; border: 1.5px solid #24233a; overflow: hidden; }
.noitu-clockbar { position: absolute; inset: 0; transform-origin: left center; background: #2e9850; transition: transform .2s linear; }
.noitu-clock.hurry .noitu-clockbar { background: #c3262c; }
.noitu-clock::after { content: attr(data-left); position: absolute; right: 8px; top: 0; font: 700 .72rem/13px var(--f-body); color: #24233a; text-shadow: 0 0 3px #fff, 0 0 2px #fff; }
.noitu-status { margin: 0; font: 1.15rem/1.35 var(--f-hand); color: var(--text); min-height: 1.4em; }
.noitu-status b { color: var(--ink); }
.noitu-dots i { font-style: normal; animation: noitu-dot 1.2s infinite; }
.noitu-dots i:nth-child(2) { animation-delay: .2s; } .noitu-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes noitu-dot { 0%, 60%, 100% { opacity: .2; } 30% { opacity: 1; } }
.noitu-form { display: flex; align-items: stretch; gap: 0; min-width: 0; border: 2.5px solid var(--ink); border-radius: 12px; background: #fff; overflow: hidden; }
.noitu-form.wait { border-color: #9a98b0; }
.noitu-form.sending { opacity: .7; }
.noitu-pre { flex: none; display: flex; align-items: center; padding: 0 10px; font: 700 1.3rem var(--f-hand); color: #fff; background: var(--ink); max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.noitu-form.wait .noitu-pre { background: #9a98b0; }
.noitu-in { flex: 1; min-width: 0; width: 0; border: 0; outline: 0; padding: 8px 10px; font: 1.35rem var(--f-hand); color: var(--ink); background: transparent; min-height: 52px; }
.noitu-in::placeholder { color: #9a98b0; font-size: 1.05rem; }
.noitu-send { border-radius: 0; border: 0; border-left: 2.5px solid var(--ink); min-width: 4.2em; font-size: 1.1rem; }
.noitu-msg { margin: 0; min-height: 1.4em; font-size: .95rem; line-height: 1.35; }
.noitu-msg.warn { color: var(--red); font-weight: 600; }
.noitu-msg.info { color: var(--muted); }
.noitu-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.noitu-acts .btn { min-height: 42px; }

/* ================= Kết quả, luật ================= */
.noitu-modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgba(20, 24, 22, .55); overflow-y: auto; }
.noitu-dlg { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: #fffdf4; border: 2.5px solid #24233a; border-radius: 16px; padding: 18px 18px 16px; display: grid; gap: 10px; box-shadow: 4px 6px 0 rgba(36, 35, 58, .35); position: relative; }
.noitu-dlg h2 { margin: 0; font: 700 1.6rem/1.15 var(--f-chalk); color: #2a4536; padding-right: 70px; }
.noitu-dlg h3 { margin: 4px 0 0; font: 600 1.15rem var(--f-hand); color: var(--ink); }
.noitu-dlg p { margin: 0; }
.noitu-stamp { position: absolute; right: 14px; top: 12px; transform: rotate(8deg); font: 700 1.05rem var(--f-chalk); color: #2e9850; border: 2.5px solid currentColor; border-radius: 8px; padding: 2px 8px; }
.noitu-stamp.lose { color: var(--red); }
.noitu-rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.noitu-rank li { display: flex; gap: 8px; align-items: center; padding: 4px 8px; border-radius: 10px; background: #f3efe2; }
.noitu-rank li.win { background: #fff1b8; font-weight: 700; }
.noitu-rank li span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.noitu-rank em { font-style: normal; font-size: .85rem; color: var(--muted); }
.noitu-train.mini { background: #2a4536; border: 5px solid #8a5a32; border-radius: 10px; padding: 10px 10px 16px; gap: 14px 12px; max-height: 40vh; overflow-y: auto; }
.noitu-train.mini .noitu-w { font-size: 1rem; }
.noitu-train.mini .noitu-car + .noitu-car::before { left: -13px; width: 11px; }
.noitu-miss { display: flex; flex-wrap: wrap; gap: 6px; }
.noitu-miss span { padding: 2px 10px; border-radius: 99px; background: #e6f7e9; border: 1.5px solid #2b7640; font-weight: 600; }
.noitu-words { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.noitu-words li { display: grid; gap: 1px; padding: 6px 10px; border-left: 4px solid #f2d36b; background: #fbf7ea; border-radius: 6px; }
.noitu-words b { font: 700 1.1rem var(--f-hand); color: var(--ink); }
.noitu-mean { font-size: .9rem; color: var(--text); }
.noitu-src { color: var(--muted); }
.noitu-src a { color: inherit; }
.noitu-rbtns { display: flex; flex-wrap: wrap; gap: 8px; }
.noitu-rulesdlg ul { margin: 0; padding-left: 1.2em; }

@media (max-width: 520px) {
  .noitu-board { border-width: 7px; padding: 8px 8px 18px; }
  .noitu-train { gap: 16px 13px; }
  .noitu-car { padding: 5px 7px 11px; }
  .noitu-car + .noitu-car::before { left: -14px; width: 12px; }
  .noitu-car.loco { padding-left: 40px; }
  .noitu-loco-svg { width: 32px; height: 22px; }
  .noitu-trainbox { max-height: 34vh; min-height: 90px; }
  .noitu-desk { padding: 10px 10px 10px 20px; }
  .noitu-row > span { min-width: 0; }
}
@media (prefers-reduced-motion: reduce) { .noitu-car.in, .noitu-dots i { animation: none; } .noitu-clockbar { transition: none; } }
