/* 俐方體 11 號（繁中像素字體，OFL 授權）→ 備援 DotGothic16 */
@font-face {
  font-family: 'Cubic11';
  src: url('https://cdn.jsdelivr.net/gh/ACh-K/Cubic-11@main/fonts/web/Cubic_11.woff2') format('woff2');
  font-display: swap;
}

:root {
  --panel: #c6c6c6;
  --panel-hi: #ffffff;
  --panel-lo: #555555;
  --ink: #3f3f3f;
  --btn: #8b8b8b;
  --btn-on: #7c87be;
  --green: #80ff20;
  --gold: #ffd800;
  --yellow: #ffff55;
  --red: #b02e26;
  --emerald: #3c8527;
  color-scheme: light;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  margin: 0;
}
body {
  font-family: 'Cubic11', 'DotGothic16', monospace;
  font-size: 16px;
  line-height: 1.5;
  color: #fff;
  background-color: #3a281b;
  background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), var(--dirt, none);
  background-size:
    auto,
    64px 64px;
  image-rendering: pixelated;
  min-height: 100vh;
  padding: 0 0 calc(96px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: none;
}
img.px {
  image-rendering: pixelated;
  height: 32px;
  width: auto;
  vertical-align: middle;
}
img.px.sm {
  height: 18px;
}
img.px.md {
  height: 24px;
}
a {
  color: inherit;
}

/* ===== 標題（草方塊） ===== */
.top {
  background-image: var(--grass, none);
  background-size: 64px 64px;
  border-bottom: 4px solid #000;
  padding: calc(14px + env(safe-area-inset-top)) 16px 14px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.logo {
  text-decoration: none;
  display: inline-block;
  position: relative;
  font-size: 34px;
  letter-spacing: 3px;
  color: #e8e8e8;
  text-shadow:
    3px 3px 0 #3f3f3f,
    -2px -2px 0 #000,
    2px -2px 0 #000,
    -2px 2px 0 #000,
    5px 5px 0 #000;
}
.splash {
  position: absolute;
  right: -40px;
  bottom: -8px;
  font-size: 14px;
  letter-spacing: 0;
  white-space: nowrap;
  color: var(--yellow);
  text-shadow: 2px 2px 0 #3f3f00;
  transform: rotate(-16deg);
  animation: splash 0.45s ease-in-out infinite alternate;
}
@keyframes splash {
  to {
    transform: rotate(-16deg) scale(1.12);
  }
}

.sound-btn {
  position: absolute;
  top: calc(8px + env(safe-area-inset-top));
  right: 8px;
  width: 40px;
  min-height: 40px;
  height: 40px;
  padding: 0;
}
.sound-btn[aria-pressed='true'] {
  background: #5a5a5a;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 8px 16px;
}

h2.title {
  font-size: 20px;
  font-weight: normal;
  margin: 14px 0 6px;
  text-shadow: 2px 2px 0 #3f3f3f;
  display: flex;
  align-items: center;
  gap: 8px;
}
h3 {
  font-size: 17px;
  font-weight: normal;
  margin: 4px 0 8px;
  color: var(--ink);
}

/* ===== GUI 面板 ===== */
.panel {
  display: block;
  background: var(--panel);
  color: var(--ink);
  border: 2px solid #000;
  box-shadow:
    inset 4px 4px 0 var(--panel-hi),
    inset -4px -4px 0 var(--panel-lo);
  padding: 14px;
  margin: 12px 0;
  text-decoration: none;
}
a.panel:active {
  filter: brightness(0.93);
}
.dark-panel {
  background: rgba(0, 0, 0, 0.65);
  border: 2px solid #000;
  box-shadow: inset 0 0 0 2px #555;
  padding: 12px;
  margin: 12px 0;
}

/* ===== 按鈕（石頭按鈕） ===== */
.btn {
  font: inherit;
  font-size: 16px;
  color: #fff;
  text-shadow: 2px 2px 0 #3f3f3f;
  background: var(--btn);
  border: 2px solid #000;
  border-radius: 0;
  box-shadow:
    inset 2px 2px 0 #c6c6c6,
    inset -2px -4px 0 #565656;
  padding: 8px 14px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  text-decoration: none;
  user-select: none;
}
.btn:active,
.btn.on {
  background: var(--btn-on);
  box-shadow:
    inset 2px 2px 0 #bfc6ef,
    inset -2px -4px 0 #4b5280;
}
.btn.green {
  background: #3c8527;
  box-shadow:
    inset 2px 2px 0 #6fc24a,
    inset -2px -4px 0 #1f4f12;
}
.btn.red {
  background: #a8322a;
  box-shadow:
    inset 2px 2px 0 #e06a5f,
    inset -2px -4px 0 #5c1510;
}
.btn.gold {
  background: #c79a00;
  box-shadow:
    inset 2px 2px 0 #ffe066,
    inset -2px -4px 0 #6e5500;
}
.btn.block {
  width: 100%;
}
.btn.sm {
  min-height: 36px;
  padding: 4px 10px;
  font-size: 14px;
}
.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.btn-row > .btn {
  flex: 1 1 0;
}

/* ===== 表單 ===== */
.field {
  margin-bottom: 12px;
}
.field > label,
.lbl {
  display: block;
  color: var(--ink);
  margin-bottom: 4px;
  font-size: 15px;
}
.field small,
.hint {
  color: #5c5c5c;
  font-size: 13px;
}
input,
select,
textarea {
  font: inherit;
  font-size: 16px; /* 避免 iOS 自動放大 */
  color: #fff;
  background: #000;
  border: 2px solid #a0a0a0;
  border-radius: 0;
  padding: 8px 10px;
  width: 100%;
  min-height: 44px;
  -webkit-appearance: none;
  appearance: none;
}
select {
  background-image: linear-gradient(45deg, transparent 50%, #fff 50%), linear-gradient(135deg, #fff 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 12px) 50%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
  padding-right: 30px;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #fff;
}
input[type='date'],
input[type='datetime-local'] {
  min-width: 0;
}
textarea {
  min-height: 70px;
  resize: vertical;
}
.grid2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0 10px;
}
.grid2 > * {
  min-width: 0;
}
.stepper {
  display: flex;
}
.stepper input {
  min-width: 0;
  text-align: center;
  border-left: 0;
  border-right: 0;
}
.stepper .btn {
  flex: none;
  width: 48px;
  padding: 0;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  cursor: pointer;
  margin: 8px 0;
}
.check input {
  display: none;
}
.check .box {
  width: 26px;
  height: 26px;
  flex: none;
  background: #8b8b8b;
  box-shadow:
    inset 2px 2px 0 #373737,
    inset -2px -2px 0 #fff;
  display: grid;
  place-items: center;
}
.check input:checked + .box::after {
  content: '';
  width: 12px;
  height: 12px;
  background: var(--green);
  box-shadow: 0 0 0 2px #000;
}

.seg {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.seg input {
  display: none;
}
.seg label {
  margin: 0;
}
.seg span {
  width: 100%;
}
.seg input:checked + span {
  background: var(--btn-on);
  box-shadow:
    inset 2px 2px 0 #bfc6ef,
    inset -2px -4px 0 #4b5280;
}

.hearts {
  display: flex;
  gap: 2px;
}
.hearts button {
  background: none;
  border: 0;
  padding: 4px;
  cursor: pointer;
}
.hearts img.px {
  height: 28px;
}

/* ===== 物品格 ===== */
.slot {
  width: 52px;
  height: 52px;
  flex: none;
  background: #8b8b8b;
  box-shadow:
    inset 2px 2px 0 #373737,
    inset -2px -2px 0 #fff;
  display: grid;
  place-items: center;
  position: relative;
}
.slot .cnt {
  position: absolute;
  right: 2px;
  bottom: -2px;
  font-size: 13px;
  color: #fff;
  text-shadow: 2px 2px 0 #3f3f3f;
  white-space: nowrap;
}
.slot.big {
  width: 72px;
  height: 72px;
}
.slot.big img.px {
  height: 44px;
}

/* ===== 卡片 ===== */
.card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.grow {
  flex: 1;
  min-width: 0;
}
.name {
  font-size: 18px;
  color: #222;
  overflow-wrap: anywhere;
}
.sub {
  font-size: 14px;
  color: #5c5c5c;
}
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0;
}
.tag {
  display: inline-block;
  padding: 0 6px;
  font-size: 13px;
  color: #fff;
  text-shadow: 1px 1px 0 #222;
  border: 2px solid #000;
  background: #6b6b6b;
}
.recipe {
  font-size: 14px;
  color: #6b4e00;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.xp {
  height: 12px;
  background: #1f1f1f;
  border: 2px solid #000;
  margin-top: 6px;
  position: relative;
}
.xp > i {
  display: block;
  height: 100%;
  background: var(--green);
  box-shadow:
    inset 0 -3px 0 #4caf10,
    inset 0 2px 0 #d0ffa0;
}
.xp-label {
  font-size: 13px;
  color: #3c6b10;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-top: 6px;
}
.stats div {
  background: rgba(0, 0, 0, 0.08);
  padding: 4px;
  text-align: center;
}
.stats small {
  display: block;
  font-size: 12px;
  color: #666;
}
.stats b {
  font-weight: normal;
  font-size: 15px;
  color: #222;
  overflow-wrap: anywhere;
}
.row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.between {
  justify-content: space-between;
}

.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  font-size: 15px;
}
.kv dt {
  color: #666;
}
.kv dd {
  margin: 0;
  color: #222;
  overflow-wrap: anywhere;
}

/* ===== 建議框 ===== */
.advice {
  padding: 10px 12px;
  border: 2px solid #000;
  margin: 8px 0;
  font-size: 15px;
  color: #fff;
  text-shadow: 1px 1px 0 #222;
}
.advice.info {
  background: #4a4a4a;
}
.advice.good {
  background: #3c8527;
}
.advice.finer {
  background: #2e5e9e;
}
.advice.coarser {
  background: #8a4b16;
}
.advice.warn {
  background: #8f2a2a;
}
.advice b {
  color: var(--yellow);
  font-weight: normal;
}

/* ===== 合成台 ===== */
.craft {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 6px 0 14px;
}
.craft .g3 {
  display: grid;
  grid-template-columns: repeat(3, 52px);
}
.craft .arrow {
  height: 26px;
}

/* ===== 圖表 ===== */
canvas.chart {
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  border: 2px solid #000;
  display: block;
}
.legend {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #555;
  margin-top: 4px;
}

/* ===== 計時器 ===== */
.timer {
  font-size: 22px;
  min-height: 56px;
}

/* ===== 快捷列（Hotbar） ===== */
.hotbar {
  position: fixed;
  z-index: 50;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(8px + env(safe-area-inset-bottom));
  display: flex;
  gap: 2px;
  background: rgba(0, 0, 0, 0.72);
  border: 3px solid #000;
  box-shadow: inset 0 0 0 2px #7a7a7a;
  padding: 4px;
}
.hotbar[hidden] {
  display: none;
}
.hotbar a {
  /* 分頁越多格子越小，確保手機寬度放得下 */
  width: min(60px, calc((100vw - 40px) / var(--n, 5)));
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 12px;
  text-decoration: none;
  color: #ddd;
  text-shadow: 1px 1px 0 #000;
  background: rgba(139, 139, 139, 0.25);
  box-shadow:
    inset 2px 2px 0 rgba(0, 0, 0, 0.6),
    inset -2px -2px 0 rgba(255, 255, 255, 0.25);
}
.hotbar a img.px {
  height: 26px;
}
.hotbar a.active {
  color: #fff;
  box-shadow:
    0 0 0 3px #fff,
    inset 0 0 0 2px #000;
  background: rgba(255, 255, 255, 0.12);
  position: relative;
  z-index: 1;
}

/* ===== 成就通知 ===== */
.toasts {
  position: fixed;
  z-index: 99;
  top: calc(10px + env(safe-area-inset-top));
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #212121;
  border: 2px solid #000;
  box-shadow: inset 0 0 0 2px #5a5a5a;
  padding: 8px 14px 8px 10px;
  min-width: 200px;
  max-width: 80vw;
  font-size: 14px;
  animation:
    tin 0.25s ease-out,
    tout 0.3s ease-in 2.8s forwards;
}
.toast b {
  display: block;
  color: var(--yellow);
  font-weight: normal;
}
@keyframes tin {
  from {
    transform: translateX(120%);
  }
}
@keyframes tout {
  to {
    transform: translateX(120%);
  }
}

.empty {
  text-align: center;
  padding: 24px 14px;
}
.empty img.px {
  height: 64px;
  margin-bottom: 8px;
}
.muted {
  color: #bbb;
  font-size: 14px;
}
.center {
  text-align: center;
}
hr.px {
  border: 0;
  border-top: 2px solid #8b8b8b;
  border-bottom: 2px solid #fff;
  margin: 12px 0;
}

/* ===== 首頁選單（Minecraft 標題畫面） ===== */
.menu {
  max-width: 420px;
  margin: 24px auto 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tool-btn {
  justify-content: flex-start;
  text-align: left;
  gap: 12px;
  padding: 10px 14px;
  min-height: 64px;
}
.tool-btn .tool-name {
  display: block;
  font-size: 18px;
}
.tool-btn small {
  display: block;
  font-size: 13px;
  color: #e8e8e8;
}
.btn.disabled {
  background: #5a5a5a;
  box-shadow:
    inset 2px 2px 0 #777,
    inset -2px -4px 0 #333;
  color: #aaa;
  cursor: not-allowed;
}
.menu-row {
  display: flex;
  justify-content: center;
  margin-top: 6px;
}

/* ===== 白名單 ===== */
.member {
  padding: 8px 0;
  border-bottom: 2px solid #b0b0b0;
}
.member:last-child {
  border-bottom: 0;
}
.chip {
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  padding: 2px 8px;
  border: 2px solid #000;
  background: #6b6b6b;
  color: #ddd;
  text-shadow: 1px 1px 0 #222;
}
.chip.on {
  background: #3c8527;
  color: #fff;
}
.nick-row {
  margin-top: 8px;
  gap: 6px;
}
.nick-row input {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  padding: 4px 8px;
}
.nick-row .btn {
  flex: none;
  white-space: nowrap;
}
