/* Elemath Academy: the class panel, the trade window, and the teacher's class log (starglyph-classui.js). Every selector starts with .cp.
   It uses the game's colors (--bg2, --card, --line, --ink, --dim, --hi, --goldink, --go, --bad; palette version 4) with fallbacks, and the game's .btn buttons.
   On a laptop the panel is a fixed column on the right of the map (set --cp-top to the height of the bar above it); on a phone it is a drawer
   that slides in from the right, opened by its tab. */
.cp-panel { position: fixed; top: var(--cp-top, 70px); right: 0; bottom: 0; width: var(--cp-width, 260px); z-index: 30; display: flex; flex-direction: column; background: rgba(251, 244, 226, .97); border-left: 2px solid var(--line, #d9c49a); color: var(--ink, #2b2233); font-size: .95rem; }
.cp-panel .cp-body { overflow-y: auto; padding: 10px 12px 16px; flex: 1; }
.cp-panel .cp-toggle { display: none; }
.cp-panel .cp-h { font-size: 1rem; margin: 12px 0 6px; display: flex; align-items: baseline; gap: 8px; }
.cp-panel .cp-h small { color: var(--dim, #5a4e63); font-weight: 400; font-size: .8rem; }
.cp-panel .cp-note, .cp-room .cp-note, .cp-tlog .cp-note { color: var(--dim, #5a4e63); font-size: .85rem; margin: 6px 0; }
.cp-panel .cp-mates, .cp-panel .cp-log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.cp-panel .cp-mate { border-radius: 12px; }
.cp-panel .cp-mate.cp-picked { background: var(--card, #fbf4e2); outline: 2px solid var(--hi, #8a5a34); }
.cp-panel .cp-who { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 6px 8px; background: none; border: 0; border-radius: 12px; color: inherit; text-align: left; cursor: pointer; }
.cp-panel .cp-who:hover { background: var(--card, #fbf4e2); }
.cp-panel .cp-away .cp-name { color: var(--dim, #5a4e63); }
.cp-panel .cp-dot { flex: none; width: 18px; height: 18px; border-radius: 50%; background: var(--cp-hc, #8a7f92); box-shadow: 0 0 0 2px rgba(255, 255, 255, .9), 0 0 0 3px var(--cp-hc, #8a7f92); display: inline-flex; align-items: center; justify-content: center; overflow: hidden; }
.cp-panel .cp-dot svg { width: 18px; height: 18px; }
.cp-panel .cp-name { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-panel .cp-pill { flex: none; font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; border: 1px solid currentColor; white-space: nowrap; }
.cp-panel .cp-st-menu { color: #2e6e05; } .cp-panel .cp-st-explore { color: #2a56b8; } .cp-panel .cp-st-battle { color: #9a4a0a; }
.cp-panel .cp-st-duel { color: #8c3441; } .cp-panel .cp-st-trade { color: var(--goldink, #7a5e02); } .cp-panel .cp-st-away { color: var(--faint, #665b70); }
.cp-panel .cp-acts { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 8px 8px 34px; }
.cp-panel .cp-acts .cp-note { flex-basis: 100%; margin: 2px 0 0; }
.cp-panel .cp-invite { background: var(--tint-gold, #fbe6b8); border: 2px solid var(--hi, #8a5a34); border-radius: 12px; padding: 8px 10px; margin-bottom: 8px; animation: cp-pop .3s ease-out; }
.cp-panel .cp-invite p { margin: 0 0 6px; }
.cp-panel .cp-row { display: flex; gap: 6px; flex-wrap: wrap; }
.cp-panel .cp-back { width: 100%; margin-bottom: 8px; }
.cp-panel .cp-log li { display: flex; gap: 6px; font-size: .84rem; line-height: 1.35; color: var(--dim, #5a4e63); padding: 4px 2px; border-bottom: 1px solid rgba(43, 34, 51, .1); animation: cp-pop .3s ease-out; }
.cp-panel .cp-ico { flex: none; }
@keyframes cp-pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* a phone: a drawer with a tab on its left edge */
@media (max-width: 760px) {
  .cp-panel { width: min(86vw, 320px); transform: translateX(100%); transition: transform .25s ease; box-shadow: none; }
  .cp-panel.cp-open { transform: none; box-shadow: -8px 0 24px rgba(43, 34, 51, .25); }
  .cp-panel .cp-toggle { display: flex; flex-direction: column; align-items: center; gap: 2px; position: absolute; left: -52px; top: 12px; width: 52px; min-height: 64px; padding: 8px 4px; background: rgba(251, 244, 226, .97); border: 2px solid var(--line, #d9c49a); border-right: 0; border-radius: 14px 0 0 14px; color: var(--ink, #2b2233); font-weight: 700; font-size: .78rem; cursor: pointer; }
  .cp-panel .cp-count { background: var(--go, #429f02); color: var(--ink, #2b2233); border-radius: 999px; min-width: 22px; padding: 0 6px; font-size: .75rem; text-align: center; }
}

/* the trade window */
.cp-room-wrap { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--veil, rgba(43, 34, 51, .55)); }
.cp-room { width: min(980px, 100%); max-height: 100%; overflow-y: auto; background: var(--bg2, #f3e7c9); border: 2px solid var(--line, #d9c49a); border-radius: 18px; padding: 14px 16px; color: var(--ink, #2b2233); }
.cp-room .cp-room-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cp-room .cp-room-top h2 { margin: 0; font-size: 1.25rem; }
.cp-room .cp-cols { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; margin-top: 10px; }
.cp-room .cp-col { background: var(--card, #fbf4e2); border: 2px solid var(--line, #d9c49a); border-radius: 14px; padding: 10px 12px; min-width: 0; }
.cp-room .cp-col-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.cp-room .cp-col-top h3 { margin: 0; }
.cp-room .cp-mark { font-size: .8rem; font-weight: 800; padding: 3px 10px; border-radius: 999px; border: 2px solid var(--line, #d9c49a); color: var(--dim, #5a4e63); white-space: nowrap; }
.cp-room .cp-mark.cp-on { background: var(--go, #429f02); border-color: var(--goink, #2e6e05); color: var(--ink, #2b2233); }
.cp-room .cp-mark.cp-flash { animation: cp-flash 1.2s ease-out 2; }
@keyframes cp-flash { 0% { border-color: var(--bad, #8c3441); color: var(--bad, #8c3441); } 100% { border-color: var(--line, #d9c49a); } }
.cp-room .cp-things { display: flex; flex-wrap: wrap; gap: 6px; min-height: 52px; padding: 6px; border-radius: 12px; background: rgba(43, 34, 51, .06); }
.cp-room .cp-thing { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 10px; background: var(--well, #fffaf0); border: 1px solid var(--line, #d9c49a); color: inherit; text-align: left; min-height: 44px; }
.cp-room button.cp-thing { cursor: pointer; } .cp-room button.cp-thing:hover { border-color: var(--bad, #8c3441); }
.cp-room .cp-thing b, .cp-room .cp-tile b { display: block; font-size: .85rem; } .cp-room .cp-thing small, .cp-room .cp-tile small { display: block; font-size: .75rem; color: var(--dim, #5a4e63); }
.cp-room .cp-x { color: var(--dim, #5a4e63); font-size: .8rem; }
.cp-room .cp-pic { flex: none; display: inline-flex; align-items: center; justify-content: center; }
.cp-room .cp-pic img, .cp-room .cp-pic svg { max-width: 44px; max-height: 44px; }
.cp-room .cp-glyph { font-size: 1.4rem; line-height: 1; color: var(--goldink, #7a5e02); }
.cp-room .cp-picks h4 { margin: 12px 0 6px; font-size: .9rem; }
.cp-room .cp-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 6px; }
.cp-room .cp-tile { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px; min-height: 44px; border-radius: 12px; background: var(--well, #fffaf0); border: 2px solid var(--line, #d9c49a); color: inherit; text-align: center; cursor: pointer; }
.cp-room .cp-tile:hover:not(:disabled) { border-color: var(--hi, #8a5a34); }
.cp-room .cp-tile:disabled { opacity: .5; cursor: default; }
.cp-room .cp-tile .cp-tag { color: var(--goldink, #7a5e02); }
.cp-room .cp-ess { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cp-room .cp-ess b { font-size: 1.2rem; min-width: 2ch; text-align: right; }
.cp-room .cp-room-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.cp-room .cp-room-foot .cp-note { flex-basis: 100%; }
.cp-room .cp-wait, .cp-room .cp-cleared, .cp-room .cp-warn { margin: 8px 0 0; padding: 8px 12px; border-radius: 10px; font-size: .9rem; }
.cp-room .cp-wait { background: var(--tint-blue, #d6e4fb); border: 1px solid #3971e4; }
.cp-room .cp-cleared { background: var(--tint-gold, #fbe6b8); border: 1px solid var(--wood, #8a5a34); color: var(--ink, #2b2233); animation: cp-pop .3s ease-out; }
.cp-room .cp-warn { background: var(--tint-rose, #f6d3d9); border: 1px solid var(--bad, #8c3441); color: var(--ink, #2b2233); }
.cp-room .cp-end { text-align: center; padding: 18px 8px 8px; }
.cp-room .cp-end h3 { font-size: 1.3rem; margin: 0 0 8px; }
.cp-room .cp-end p { margin: 0 0 14px; color: var(--dim, #5a4e63); }
@media (max-width: 760px) {
  .cp-room-wrap { padding: 0; align-items: stretch; }
  .cp-room { border-radius: 0; border: 0; max-height: none; height: 100%; }
  .cp-room .cp-cols { grid-template-columns: 1fr; }
  .cp-room .cp-get { order: -1; }
  .cp-room .cp-room-foot { position: sticky; bottom: -14px; background: var(--bg2, #f3e7c9); padding: 10px 0; }
}

/* the teacher's class log */
.cp-tlog .cp-tablewrap { overflow-x: auto; }
.cp-tlog .cp-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.cp-tlog .cp-table th, .cp-tlog .cp-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line, #d9c49a); vertical-align: top; }
.cp-tlog .cp-table th { color: var(--dim, #5a4e63); font-weight: 800; }
.cp-tlog .cp-table td:first-child { white-space: nowrap; color: var(--dim, #5a4e63); }
.cp-tlog .btn { margin-top: 10px; }
@media (prefers-reduced-motion: reduce) { .cp-panel, .cp-panel *, .cp-room-wrap, .cp-room-wrap * { animation: none !important; transition: none !important; } }
