/* Captain's log panels: crafting, buildings, growth, talents, settings. */

#game #panel[open] {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  width: min(740px, calc(100% - var(--edge-left) - var(--edge-right)));
  max-width: none;
  max-height: calc(100dvh - var(--edge-top) - var(--edge-bottom));
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 222, 160, .38);
  border-radius: 18px;
  background:
    radial-gradient(90% 70% at 82% 0%, rgba(38, 124, 138, .22), transparent 60%),
    linear-gradient(160deg, #0b3a4a 0%, #062a3b 58%, #041f2e 100%);
  box-shadow: 0 26px 60px rgba(0, 8, 16, .6), inset 0 1px rgba(255, 255, 255, .12);
  color: var(--ink, #f4fbf6);
}

#game #panel::backdrop {
  background: rgba(1, 14, 23, .72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

#panel-content {
  overflow: auto;
  padding: 18px 58px 16px 18px;
  overscroll-behavior: contain;
}

#game #panel h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  color: #fff8e8;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: .03em;
}

#game #panel h2::before {
  content: "";
  width: 4px;
  height: 20px;
  flex: none;
  border-radius: 99px;
  background: linear-gradient(#ffe6a1, #d99b43);
  box-shadow: 0 0 10px rgba(255, 213, 128, .4);
}

#panel h2 small {
  margin-left: 2px;
  color: var(--muted, #a8cbd0);
  font-size: 12px;
  font-weight: 500;
}

#game #close-panel {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid rgba(255, 220, 157, .24);
  border-radius: 50%;
  background: rgba(2, 20, 31, .55);
  color: #f4fbf6;
  transition: background .16s ease, transform .14s ease;
}

#game #close-panel .mp-icon { width: 19px; height: 19px; }
#game #close-panel:hover { background: rgba(28, 88, 100, .7); }
#game #close-panel:active { transform: scale(.93); }

#game #panel .supplies {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: 0 0 12px;
  padding: 6px 11px;
  border: 1px solid rgba(255, 220, 157, .16);
  border-radius: 9px;
  background: rgba(2, 20, 31, .42);
  color: var(--muted, #a8cbd0);
  font-size: 11px;
}

#game #panel-feedback {
  margin: 0;
  padding: 9px 18px;
  border-top: 1px solid rgba(255, 220, 157, .18);
  background: rgba(2, 20, 31, .4);
  color: #ffe1a0;
  font-size: 12px;
  min-height: 36px;
}

#panel-feedback:empty { display: none; }

.craft-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 168px), 1fr));
  gap: 9px;
}

.recipe-card {
  display: grid;
  align-content: start;
  gap: 6px;
  min-width: 0;
  padding: 11px;
  border: 1px solid rgba(160, 224, 218, .18);
  border-radius: 12px;
  background:
    linear-gradient(160deg, rgba(20, 74, 86, .72), rgba(3, 27, 40, .78));
  box-shadow: inset 0 1px rgba(255, 255, 255, .07);
  transition: border-color .16s ease, background .16s ease;
}

.recipe-card:hover { border-color: rgba(255, 220, 157, .32); }

.recipe-card strong {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #fdf8ec;
  font-size: 14px;
  line-height: 1.3;
}

.recipe-card .mp-icon {
  width: 19px;
  height: 19px;
  color: #ffe0a1;
}

.recipe-card small,
.ad-offer small {
  display: block;
  color: var(--muted, #a8cbd0);
  font-size: 11px;
  line-height: 1.55;
}

.recipe-card .craft-btn { margin-top: 3px; }

.recipe-card.equipped {
  border-color: rgba(143, 218, 185, .7);
  background:
    linear-gradient(160deg, rgba(26, 94, 91, .7), rgba(4, 32, 42, .8));
}

.recipe-card.equipped::after {
  content: "已启用";
  justify-self: start;
  padding: 1px 7px;
  border-radius: 99px;
  background: rgba(143, 218, 185, .16);
  color: #abedc9;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .08em;
}

.recipe-card:is(.grade-S, .grade-SS, .grade-SSS) {
  border-color: rgba(232, 200, 118, .72);
  box-shadow: 0 0 18px rgba(255, 196, 92, .1), inset 0 1px rgba(255, 255, 255, .08);
}

.recipe-card:is(.grade-S, .grade-SS, .grade-SSS) strong { color: #ffe1a0; }
.recipe-card.grade-SS { border-color: rgba(255, 172, 118, .8); }
.recipe-card.grade-SSS { border-color: rgba(255, 128, 150, .85); }

.talent-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); }

.craft-btn {
  min-height: 40px;
  padding: 5px 11px;
  border: 1px solid #fff0c3;
  border-radius: 10px;
  background: linear-gradient(160deg, #ffe9a8, #ffca63 54%, #eda63f);
  box-shadow: 0 3px 0 #96601f, inset 0 1px rgba(255, 255, 255, .8);
  color: #3e2910;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .02em;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}

.craft-btn:hover { filter: brightness(1.04); }
.craft-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #96601f, inset 0 1px rgba(255, 255, 255, .8); }

.craft-btn:disabled {
  border-color: rgba(123, 167, 164, .25);
  background: rgba(20, 60, 70, .62);
  box-shadow: none;
  color: #a9c4c4;
  cursor: default;
  filter: none;
  transform: none;
}

#panel-content > .craft-btn { margin-top: 10px; }

.ad-offer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid rgba(255, 220, 157, .16);
}

.ad-offer > .mp-icon {
  width: 22px;
  height: 22px;
  color: #ffe0a1;
}

.ad-offer strong { font-size: 13px; }
.ad-offer .craft-btn { margin-left: auto; }

/* the skip button added by playability.js */
#game #panel > .craft-btn {
  justify-self: start;
  margin: 0 58px 12px 18px;
  min-height: 38px;
  border-color: rgba(160, 224, 218, .35);
  background: rgba(8, 48, 60, .8);
  box-shadow: none;
  color: #e9f7f2;
}

#game #panel > .craft-btn:disabled { opacity: .5; }

/* ---------- settings ---------- */

#game #settings-dialog {
  position: fixed;
  inset: var(--edge-top) var(--edge-right) var(--edge-bottom) var(--edge-left);
  width: min(400px, calc(100% - var(--edge-left) - var(--edge-right)));
  max-height: calc(100dvh - var(--edge-top) - var(--edge-bottom));
  margin: auto;
  padding: 20px;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid rgba(255, 222, 160, .38);
  border-radius: 18px;
  background:
    radial-gradient(90% 70% at 82% 0%, rgba(38, 124, 138, .22), transparent 60%),
    linear-gradient(160deg, #0b3a4a 0%, #062a3b 58%, #041f2e 100%);
  box-shadow: 0 26px 60px rgba(0, 8, 16, .6), inset 0 1px rgba(255, 255, 255, .12);
  color: var(--ink, #f4fbf6);
}

#settings-dialog::backdrop {
  background: rgba(1, 14, 23, .72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

#settings-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 800;
}

#settings-title::before {
  content: "";
  width: 4px;
  height: 20px;
  border-radius: 99px;
  background: linear-gradient(#ffe6a1, #d99b43);
}

#restart-description {
  margin: 0 0 16px;
  color: #b8d7da;
  font-size: 12px;
  line-height: 1.7;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 9px;
}

.settings-actions .craft-btn { padding-inline: 16px; font-size: 13px; }

#cancel-restart {
  border-color: rgba(160, 224, 218, .3);
  background: rgba(8, 48, 60, .8);
  box-shadow: none;
  color: #e9f7f2;
}

#settings-feedback {
  margin: 10px 0 0;
  color: #ffe1a0;
  font-size: 12px;
}

#settings-feedback:empty { display: none; }

/* ---------- responsive ---------- */

@container raft-stage (max-width: 620px) {
  #panel-content { padding: 14px 50px 12px 14px; }
  #game #panel h2 { font-size: 17px; }
  .craft-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 138px), 1fr)); gap: 7px; }
  .recipe-card { padding: 9px; }
  #game #panel > .craft-btn { margin: 0 50px 10px 14px; }
}

@container raft-stage (max-height: 340px) {
  #panel-content { padding-top: 12px; padding-bottom: 10px; }
  #game #panel h2 { font-size: 16px; margin-bottom: 7px; }
  .recipe-card { padding: 8px; gap: 4px; }
  .recipe-card strong { font-size: 13px; }
  .recipe-card small { font-size: 10px; }
  .craft-btn { min-height: 36px; }
  #game #panel-feedback { padding: 6px 14px; min-height: 30px; }
}

/* previews are often portrait: keep the dialog inside the wide stage at the top */
@media (max-aspect-ratio: 1/1) {
  #game #panel[open] {
    bottom: auto;
    height: calc(min(100dvh, 56.25vw) - var(--edge-top) - var(--edge-bottom));
  }
  #game #settings-dialog {
    bottom: auto;
    max-height: calc(min(100dvh, 56.25vw) - var(--edge-top) - var(--edge-bottom));
  }
}
