/* ---------- Base ---------- */
@font-face { font-family: "jjannon"; font-style: normal; src: url('../fonts/JJannon-Regular.otf'); }
@font-face { font-family: "jjannon"; font-style: italic; src: url('../fonts/JJannon-Italic.otf'); }
@font-face { font-family: "Xoesan Source Han Serif SC"; src: url('../fonts/SourceHanSerifSC-Regular.otf') format('opentype'); font-display: swap; }
@font-face {
  font-family: "Chinese Heiti";
  src: local("Heiti SC"), local("SimHei"), local("黑体");
  unicode-range: U+3000-303F, U+3400-4DBF, U+4E00-9FFF, U+FF00-FFEF;
}
:root {
  --page-background: #121211;
  --panel-background: #191918;
  --text: #000000;
  --muted-text: #aaa69c;
  --border: #060606;
  --card-border: #77736a;
  --card-height: 110px;
  --label-width: 110px;
}

* {
  box-sizing: border-box;
}

a, p, i, div, summary,th, td, button{
  -webkit-text-size-adjust: none;
  -moz-text-size-adjust: none;
  text-size-adjust: none;
  font-size-adjust: none;
  text-decoration: none;
  /*font-family: "jjannon","Songti SC","宋体",STSong, Simsun,"Noto Serif SC", 'Source Han Serif SC', ‘Source Han Serif’, source-han-serif-sc,TimesNewRoman,Times New Roman,Times,Baskerville,Georgia,serif;*/
  font-family: Helvetica, "Helvetica Neue", Arial, "Chinese Heiti", 'Noto Sans CJK SC', 'Source Han Sans SC', ‘Source Han Sans’, source-han-sans-sc, "黑体","Heiti SC",Hei, sans-serif;
  /*font-weight: 400;*/
  -moz-osx-font-smoothing: grayscale;
  -webkit-font-smoothing: antialiased;
  hyphens: auto;
  font-size: 13px;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--text);
  background-image: url("images/IMG_2978.jpg");
  background-size: 100%;
}

/* ---------- Page heading ---------- */
.app-shell {
  /*width: min(1180px, calc(100% - 38px));*/
  /*margin: 0 auto;*/
  /*padding: 48px 0 58px;*/
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 25px;
}

.eyebrow,
.info-category {
  margin: 0 0 5px;
  color: var(--muted-text);
  /*letter-spacing: 0.13em;*/
  /*font: 500 11px "DM Mono", monospace;*/
}


/*.reset-button {*/
/*  padding: 10px 13px;*/
/*  color: var(--text);*/
/*  border: 1px solid #56564f;*/
/*  border-radius: 2px;*/
/*  background: transparent;*/
/*  cursor: pointer;*/
/*}*/
.reset-button {
  color: var(--text);
  background: transparent;
  border: none;
  cursor: pointer;
}

.tier-controls {
  position: fixed;
  bottom: 0;
  right: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  /*gap: 7px;*/
}
.tier-controls button {
  color: white;
}

/*#upload-tierlisting {*/
/*  background: #000;*/
/*  min-height: 32px;*/
/*}*/

.uploaded-tierlistings {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  /*gap: 7px;*/
}

.uploaded-tierlisting-button {
  max-width: 190px;
  overflow: hidden;
  color: var(--text);
  border: none;
  background: transparent;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.tierlisting-current {
  text-decoration: underline;
}

.uploaded-tierlisting-entry {
  display: flex;
  /*gap: 8px;*/
}

.uploaded-tierlisting-delete {
  color: var(--text);
  border: none;
  background: transparent;
  font: inherit;
  line-height: inherit;
  cursor: pointer;
}

.upload-modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
}

.upload-modal[hidden] {
  display: none;
}

.upload-dialog {
  width: 90vw;
  height: 80vh;
  padding: 20px;
  overflow: auto;
  color: var(--text);
  background: #000;
  display: flex;
  flex-direction: column;
  font: inherit;
  line-height: inherit;
}

#upload-modal .upload-dialog {
  --text: #fff;
  color-scheme: dark;
}

.upload-dialog label {
  display: block;
  margin: 12px 0;
}

.upload-dialog input,
.upload-dialog textarea {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  color: var(--text);
  border: 0;
  background: #000;
  font: inherit;
  line-height: inherit;
}

.upload-dialog textarea {
  min-height: 80px;
}

#work-comment-select {
  width: 100%;
  padding: 0;
  color: var(--text);
  background: #000;
  border: 0;
  color-scheme: dark;
  font: inherit;
}

#work-comment-form input:disabled,
#work-comment-form textarea:disabled,
#work-comment-form button:disabled {
  opacity: 0.5;
}

#info-comments {
  margin-top: 1em;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

#info-comments .work-comment {
  color: #ffff00;
}

#info-comments .work-comment + .work-comment {
  margin-top: 1em;
}

.upload-dialog input:focus,
.upload-dialog textarea:focus {
  outline: none;
}

.tierlisting-comment {
  margin: 14px 0 0;
  white-space: pre-line;
}

.upload-dialog form {
  display: flex;
  flex: 1;
  flex-direction: column;
}

.upload-actions {
  display: flex;
  justify-content: space-between;
  margin-top: auto;
}

.upload-actions button {
  padding: 0;
  color: var(--text);
  border: 0;
  background: transparent;
  font: inherit;
  line-height: inherit;
  cursor: pointer;
}

.suggested-works {
  margin: 0 0 8px;
}

.suggested-works summary {
  cursor: pointer;
  text-decoration: underline;
}

#suggested-works-list {
  max-height: 180px;
  overflow-y: auto;
  overflow-wrap: anywhere;
}

#suggested-works-list article {
  margin: 16px 0;
}

#suggested-works-list p {
  margin: 4px 0;
  white-space: pre-wrap;
}

.upload-dialog.upload-unavailable label,
.upload-dialog.upload-unavailable #upload-error,
.upload-dialog.upload-unavailable #suggest-error,
.upload-dialog.upload-unavailable .upload-actions button[type="submit"] {
  opacity: 0.5;
  pointer-events: none;
}

.upload-dialog input:disabled,
.upload-dialog textarea:disabled,
.upload-dialog button:disabled {
  color: inherit;
  -webkit-text-fill-color: currentColor;
}

@media (min-width: 601px) {
  .upload-dialog {
    width: min(400px, 90vw);
    height: 60vh;
  }
}

.reset-button:hover {
  color: #151514;
  background: #fff;
}

/* ---------- Tier list ---------- */
.tier-board {
  width: max(90%, var(--tier-required-width, 0px));
  border: 2px solid var(--border);
}

.tier-row {
  position: relative;
  display: flex;
  height: calc(var(--card-height) + 2px);
  max-height: 90px;
  border-bottom: 2px solid var(--border);
  background: var(--panel-background);
}

.tier-row:last-child {
  border-bottom: 0;
}

.tier-label {
  display: flex;
  text-align: center;
  flex: 0 0 var(--label-width);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #000000;
  border-right: 2px solid var(--border);
}

.tier-label.s { background: #ff7d7f; }
.tier-label.a { background: #ffbd78; }
.tier-label.b { background: #fbdc75; }
.tier-label.c { background: #f5f77a; }
.tier-label.d { background: #acf475; }
.tier-label.e { background: #6eea85; }

.drop-zone {
  position: relative;
  flex: 1;
  height: var(--card-height);
  overflow: visible;
}

.drop-zone.over {
  /*outline: 2px dashed #d8d3ab;*/
  /*outline-offset: -2px;*/
}

/* ---------- Card library and cards ---------- */
.library {
  margin-top: auto;
  padding-top: 35px;
}



.card-pool {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  /*gap: 10px;*/
  min-height: 124px;
}

.tier-card {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  width: auto;
  height: var(--card-height);
  max-height: 90px;
  overflow: hidden;
  /*border: 1px solid var(--card-border);*/
  background: #fff;
  cursor: grab;
  touch-action: pan-x pan-y;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.tier-card,
.tier-card img,
.drag-ghost,
.drag-ghost img {
  -webkit-user-drag: none;
}

html.drag-active,
html.drag-active * {
  -webkit-user-select: none !important;
  user-select: none !important;
  -webkit-touch-callout: none !important;
}

.tier-card.dragging {
  opacity: 0.28;
}

.tier-card img,
.info-art,
.info-art img {
  display: block;
  width: 100%;
  /*height: 100%;*/
  /*object-fit: cover;*/
}

/* Keep every artwork fully visible inside its fixed-size card. */
.tier-card img {
  width: auto;
  height: 100%;
  object-fit: fill;
}

.drop-zone .tier-card {
  position: absolute;
  margin: 0;
}

.card-name {
  display: none;
  position: absolute;
  right: 5px;
  bottom: 7px;
  left: 7px;
  z-index: 1;
  color: #fff;
  line-height: 1.15;
}

.drag-ghost {
  position: fixed;
  z-index: 10;
  margin: 0;
  pointer-events: none;
  cursor: grabbing;
  opacity: 0.92;
}

/* ---------- Information panel ---------- */
.info-panel {
  position: fixed;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: none;
  width: 35vw;
  max-width: 400px;
  max-height: 80%;
  overflow-y: scroll;
  overflow-anchor: none;
  /*padding: 16px;*/
  /*border: 1px solid #777468;*/
  background: #ffffff;
}

.info-panel.visible {
  display: block;
}

.info-art {
  /*height: 140px;*/
  margin-bottom: 15px;
}


.info-panel p:not(.info-category) {
  margin: 0;
  color: #000000;
}

.info-hint {
  display: block;
  margin-top: 14px;
  color: #fff;
  font-size: 11px;
}

.close-info {
  position: fixed;
  bottom: 0;
  right: 0;
  z-index: 1;
  width: 50px;
  height: 40px;
  color: #ffffff;
  background: #000;
  border: 2px solid white;
  /*border-radius: 20px;*/
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}

.scrim {
  display: none;
}

/* ---------- Small screens ---------- */
@media (max-width: 600px) {
  body{
    background-size: cover;
  }
  :root {
    --card-height: 80px;
    --label-width: 70px;
  }

  .app-shell {
    width: 100%;
    padding: 0 0 36px;
  }

  .topbar {
    align-items: center;
    padding: 0 16px;
  }

  .tier-row{
    height: 80px;
  }
  .tier-card{
    max-height: 80px;
  }


  .tier-board,
  .tier-row,
  .tier-label {
    border-width: 1px;
  }

  .tier-board {
    width: max(100%, var(--tier-required-width, 0px));
  }

  .tier-label strong {
    /*font-size: 28px;*/
  }

  .tier-label span {
    /*margin-top: 7px;*/
    /*font-size: 11px;*/
  }


  .library {
    margin-top: 25px;
    padding: 0;
  }

  .library-heading small {
    display: none;
  }

  .card-pool {
  }

  .info-panel {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-height: none;
    max-width: none;
  }

  .scrim.visible {
    position: fixed;
    inset: 0;
    z-index: 4;
    display: block;
    background: #0008;
  }
}

.info-description,
#info-judgment,
#info-ratings,
#info-year {
  white-space: pre-line;
}

.info-description a,
#info-judgment a {
  color: inherit;
  text-decoration: underline;
}

.info-description iframe,
#info-judgment iframe {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  margin: 12px 0;
  border: 0;
}

#info-judgment,
#info-ratings {
  margin-top: 1em !important;
}

#info-judgment,
#info-suggested-by {
  color: lightpink !important;
}

#info-ratings {
  color: #00ff00 !important;
}

/* Text cards remain usable before images are supplied. */
.text-card { display:flex; align-items:center; justify-content:center; width:140px; height:100%; padding:10px; color:#000; text-align:center; white-space:normal; border:1px solid #aaa; }
.info-description mark { background:transparent; color:#00ff00; }
.info-panel { padding-bottom:50px; }
.tier-card:focus-visible { outline:3px solid #00ff00; outline-offset:-3px; }

#info-source { color: #fff; margin-top: 1em; white-space: pre-line; }
#info-source a { color: inherit; text-decoration: underline; }

body { background-size: cover; background-position: center; background-attachment: fixed; background-color: #121211; }

/* Complete text stays in source order. Only the selected excerpt is opaque. */
#info-description {
  font-family: "jjannon", "Xoesan Source Han Serif SC", "Songti SC", "宋体", STSong, Simsun, "Noto Serif SC", "Times New Roman", Times, Baskerville, Georgia, serif;
  font-weight: 400;
  font-size-adjust: none;
  text-size-adjust: none;
  -webkit-text-size-adjust: none;
  -moz-osx-font-smoothing: grayscale;
  -webkit-font-smoothing: antialiased;
  hyphens: auto;
}
#info-description i { font-family: inherit; }
#info-description p.bp { opacity: .5; overflow-wrap: anywhere; }
#info-description p.bp.is-related { opacity: 1; }
.tier-card.reader-selected { outline: 1px dashed #fff; outline-offset: -1px; }
.tier-card.reading-related { box-shadow: inset 0 0 0 3px #00ff00; outline: 3px solid #00ff00; outline-offset: -3px; }
.tier-card.reading-related::after { content: ''; position: absolute; inset: 0; border: 3px solid #00ff00; pointer-events: none; z-index: 3; }
/* Keep the board available while reading on narrow screens as well. */
@media (max-width: 600px) {
  body { --mobile-reader-height: 55vh; }
  .info-panel { inset: auto 0 0; height: var(--mobile-reader-height); max-height: var(--mobile-reader-height); border-top: 1px solid #777; }
  .scrim.visible { display: none; }
  body:has(.info-panel.visible) .app-shell { padding-bottom: 58vh; }
  body:has(.info-panel.visible) .tier-controls { bottom: var(--mobile-reader-height); }
}

/* Reserve room so cards can scroll clear of the fixed reading window. */
@media (min-width: 601px) {
  body:has(.info-panel.visible) .app-shell { padding-right: min(35vw, 400px); padding-bottom: 80vh; }
}

/* Compact labels and cards for phones and narrower browser windows. */
.tier-label { padding: 4px; min-width: 0; }
.tier-label strong { font-size: inherit; line-height: 1.15; overflow-wrap: anywhere; }
@media (max-width: 900px) {
  :root {
    --card-height: clamp(72px, 10vw, 90px);
    --label-width: clamp(72px, 12vw, 110px);
  }
  .tier-row { height: calc(var(--card-height) + 2px); max-height: none; }
  .tier-card { max-height: none; }
  .tier-label { font-size: clamp(10px, 1.55vw, 13px); }
  .text-card {
    width: clamp(100px, 17vw, 140px);
    padding: clamp(5px, 1vw, 10px);
    font-size: clamp(11px, 1.5vw, 13px);
    line-height: 1.2;
    overflow-wrap: anywhere;
  }
  .tier-controls button { font-size: clamp(11px, 1.5vw, 13px); line-height: 1.2; }
  .info-title { overflow-wrap: anywhere; }
}
@media (max-width: 600px) {
  .tier-row { height: calc(var(--card-height) + 1px); }
}

/* Keep the reading panel focused on the original text. */
#info-panel > :not(#close-info):not(#info-description) {
  display: none !important;
}
