* { box-sizing: border-box; }

:root {
  --gold: #d8b56a;
  --gold-dim: rgba(216, 181, 106, 0.35);
  --ink: #f2e4c9;
  --ink-dim: #b9a487;
  --panel: rgba(24, 12, 8, 0.62);
  --red: #8f2318;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #120906;
  color: var(--ink);
  font-family: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

#app { position: fixed; inset: 0; }
#app canvas { display: block; }

.hide { display: none !important; }

/* ---------- 加载 ---------- */
#loading {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: #120906; gap: 18px;
  transition: opacity .6s ease;
}
#loading p { margin: 0; letter-spacing: .3em; font-size: 13px; color: var(--ink-dim); }
.ring {
  width: 42px; height: 42px; border-radius: 50%;
  border: 2px solid rgba(216, 181, 106, .18);
  border-top-color: var(--gold);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 遮罩层 ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at 50% 45%, rgba(60, 26, 14, .72), rgba(10, 5, 3, .94));
  backdrop-filter: blur(3px);
}

.card {
  position: relative;
  width: 100%;
  max-width: 380px;
  padding: 34px 30px 26px;
  border-radius: 6px;
  background: linear-gradient(180deg, rgba(38, 20, 13, .96), rgba(26, 13, 9, .98));
  border: 1px solid var(--gold-dim);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .6), inset 0 0 0 1px rgba(255, 255, 255, .03);
  text-align: center;
}

.seal {
  display: inline-block;
  padding: 3px 9px;
  margin-bottom: 12px;
  font-size: 11px;
  letter-spacing: .2em;
  color: #f6e6c4;
  background: #9c2c1c;
  border: 1px solid #c9793f;
  border-radius: 3px;
}

h1 {
  margin: 0 0 6px;
  font-size: 25px;
  font-weight: 500;
  letter-spacing: .16em;
  color: #f6e7c8;
  text-shadow: 0 2px 18px rgba(216, 181, 106, .28);
}
h2 { margin: 0 0 16px; font-size: 17px; font-weight: 500; letter-spacing: .12em; color: #f4e3c2; }

.sub {
  margin: 0 0 24px;
  font-size: 12px;
  letter-spacing: .28em;
  color: var(--gold);
  opacity: .8;
}

.field {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px;
  padding: 0 12px;
  height: 42px;
  background: rgba(0, 0, 0, .3);
  border: 1px solid rgba(216, 181, 106, .2);
  border-radius: 4px;
  text-align: left;
}
.field span {
  flex: 0 0 34px;
  font-size: 12px;
  color: var(--gold);
  letter-spacing: .1em;
}
.field input {
  flex: 1;
  min-width: 0;
  height: 100%;
  background: none;
  border: 0;
  outline: none;
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  letter-spacing: .04em;
}
.field input::placeholder { color: rgba(242, 228, 201, .28); }
.field:focus-within { border-color: var(--gold-dim); background: rgba(0, 0, 0, .45); }

.btn {
  display: inline-block;
  margin-top: 12px;
  padding: 11px 30px;
  font-family: inherit;
  font-size: 14px;
  letter-spacing: .34em;
  color: #2a1409;
  background: linear-gradient(180deg, #e7c987, #c39a4d);
  border: 1px solid #f0d9a6;
  border-radius: 3px;
  cursor: pointer;
  transition: filter .2s, transform .12s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn.ghost {
  background: none;
  color: var(--ink-dim);
  border-color: rgba(216, 181, 106, .28);
}
.btn.ghost:hover { color: var(--ink); }

.note {
  margin: 16px 0 0;
  font-size: 11.5px;
  letter-spacing: 0;
  line-height: 1.9;
  color: rgba(203, 183, 152, .88);
  letter-spacing: .05em;
}

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 20; pointer-events: none; }

.panel {
  background: var(--panel);
  border: 1px solid rgba(216, 181, 106, .22);
  border-radius: 5px;
  backdrop-filter: blur(6px);
}

.top-left {
  position: absolute; top: 18px; left: 18px;
  padding: 10px 16px 10px 14px;
  border-left: 2px solid var(--gold);
}
.top-left .name { font-size: 15px; letter-spacing: .12em; color: #f6e7c8; }
.top-left .place { margin-top: 2px; font-size: 11px; letter-spacing: .1em; color: var(--gold); opacity: .75; }

.top-right {
  position: absolute; top: 18px; right: 18px;
  padding: 10px 14px;
  font-size: 11px;
  line-height: 2;
  color: var(--ink-dim);
  letter-spacing: .06em;
}
.top-right b {
  display: inline-block;
  min-width: 22px;
  margin-right: 6px;
  padding: 0 5px;
  font-weight: 400;
  font-size: 10px;
  color: #f0dcb4;
  background: rgba(216, 181, 106, .16);
  border: 1px solid rgba(216, 181, 106, .28);
  border-radius: 3px;
  text-align: center;
}

.side {
  position: absolute;
  right: 18px; bottom: 18px;
  width: 186px;
  padding: 12px 14px;
  max-height: 40vh;
  overflow: hidden;
}
.side-title {
  font-size: 11px;
  letter-spacing: .22em;
  color: var(--gold);
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(216, 181, 106, .18);
}
#logList { list-style: none; margin: 0; padding: 0; font-size: 11px; line-height: 1.85; color: var(--ink-dim); }
#logList li { display: flex; justify-content: space-between; gap: 8px; }
#logList li span:last-child { color: var(--gold); font-variant-numeric: tabular-nums; }
#logList li.empty { color: rgba(185, 164, 135, .45); display: block; }
#logList li.new { animation: flash .9s ease; }
@keyframes flash { from { color: #ffe9b8; } to { color: var(--ink-dim); } }

.prompt {
  position: absolute;
  left: 50%; bottom: 15%;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px;
  padding: 9px 18px;
  font-size: 13px;
  letter-spacing: .12em;
  color: #f7e8c9;
  background: rgba(28, 13, 8, .78);
  border: 1px solid rgba(216, 181, 106, .42);
  border-radius: 40px;
  backdrop-filter: blur(6px);
  animation: rise .28s ease;
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
.kbd {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  font-size: 11px;
  color: #2a1409;
  background: var(--gold);
  border-radius: 3px;
}

#crosshair {
  position: absolute;
  left: 50%; top: 50%;
  width: 5px; height: 5px;
  margin: -2.5px 0 0 -2.5px;
  border-radius: 50%;
  background: rgba(255, 240, 210, .55);
  box-shadow: 0 0 6px rgba(0, 0, 0, .8);
}

#touchAction {
  position: absolute;
  right: 26px; bottom: 96px;
  width: 74px; height: 74px;
  font-family: inherit;
  font-size: 14px;
  letter-spacing: .08em;
  color: #2a1409;
  background: radial-gradient(circle at 40% 35%, #f0d9a6, #c39a4d);
  border: 1px solid #f7e9c8;
  border-radius: 50%;
  pointer-events: auto;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
}

/* ---------- 形象选择 ---------- */
.avatar-pick {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.avatar-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px 8px;
  font-family: inherit;
  color: rgba(242, 228, 201, .55);
  background: rgba(0, 0, 0, .28);
  border: 1px solid rgba(216, 181, 106, .18);
  border-radius: 4px;
  cursor: pointer;
  transition: all .18s;
}
.avatar-opt svg { width: 22px; height: 32px; }
.avatar-opt span { font-size: 11px; letter-spacing: .06em; }
.avatar-opt:hover { color: rgba(242, 228, 201, .85); border-color: rgba(216, 181, 106, .42); }
.avatar-opt.on {
  color: #2a1409;
  background: linear-gradient(180deg, #e7c987, #c39a4d);
  border-color: #f0d9a6;
  box-shadow: 0 6px 18px rgba(216, 181, 106, .22);
}
.avatar-opt.on span { color: #2a1409; }

/* ---------- 摇杆 ---------- */
#joy {
  position: fixed;
  z-index: 25;
  width: 108px;
  height: 108px;
  margin: -54px 0 0 -54px;
  border-radius: 50%;
  border: 1px solid rgba(216, 181, 106, .35);
  background: rgba(20, 10, 6, .3);
  pointer-events: none;
}
#joyKnob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, rgba(240, 217, 166, .95), rgba(195, 154, 77, .85));
  box-shadow: 0 4px 12px rgba(0, 0, 0, .4);
}

/* ---------- 弹层 ---------- */
.modal-card { max-width: 430px; text-align: left; }
.modal-card h2 { text-align: center; }
.modal-card .close {
  position: absolute; top: 10px; right: 12px;
  width: 28px; height: 28px;
  font-size: 18px;
  line-height: 1;
  color: var(--ink-dim);
  background: none; border: 0; cursor: pointer;
}
.modal-card .close:hover { color: var(--ink); }

#modalBody { font-size: 13px; line-height: 1.85; color: rgba(238,222,196,.82); text-align: center; }
#modalBody p { margin: 0 0 10px; }
.wish-tags { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 2px 0 4px; }
.wish-tag {
  font-family: inherit;
  font-size: 11.5px;
  letter-spacing: .04em;
  padding: 5px 10px;
  color: rgba(242,228,201,.8);
  background: rgba(216,181,106,.1);
  border: 1px solid rgba(216,181,106,.28);
  border-radius: 20px;
  cursor: pointer;
  transition: all .16s;
}
.wish-tag:hover { color: #2a1409; background: #d8b56a; border-color: #f0d9a6; }
#modalBody .wish-input {
  width: 100%;
  min-height: 78px;
  margin-top: 10px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, .35);
  border: 1px solid rgba(216, 181, 106, .25);
  border-radius: 4px;
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.7;
  resize: none;
  outline: none;
  text-align: left;
}
#modalBody .wish-input:focus { border-color: var(--gold-dim); }

.amounts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0 6px; }
.amount {
  padding: 14px 0;
  font-family: inherit;
  font-size: 15px;
  color: #f0dcb4;
  background: rgba(0, 0, 0, .3);
  border: 1px solid rgba(216, 181, 106, .22);
  border-radius: 4px;
  cursor: pointer;
  transition: all .18s;
}
.amount small { display: block; margin-top: 4px; font-size: 10px; letter-spacing: .1em; color: rgba(185, 164, 135, .7); }
.amount:hover { border-color: var(--gold-dim); background: rgba(216, 181, 106, .08); }
.amount.on {
  color: #2a1409;
  background: linear-gradient(180deg, #e7c987, #c39a4d);
  border-color: #f0d9a6;
}
.amount.on small { color: rgba(42, 20, 9, .65); }

.wall-list {
  max-height: 46vh;
  overflow-y: auto;
  text-align: left;
  margin: 6px -4px 0;
  padding: 0 4px 10px;
  -webkit-mask-image: linear-gradient(180deg, #000 0, #000 calc(100% - 22px), transparent 100%);
  mask-image: linear-gradient(180deg, #000 0, #000 calc(100% - 22px), transparent 100%);
}
.wall-list::-webkit-scrollbar { width: 4px; }
.wall-list::-webkit-scrollbar-thumb { background: rgba(216,181,106,.35); border-radius: 2px; }
.wall-item {
  padding: 9px 12px;
  margin-bottom: 8px;
  background: rgba(140, 34, 24, .18);
  border-left: 2px solid rgba(216, 181, 106, .5);
  border-radius: 3px;
}
.wall-item .who { font-size: 11px; color: #e2c68c; letter-spacing: .08em; }
.wall-item .txt { margin-top: 3px; font-size: 13px; color: #f7ead2; line-height: 1.65; }

.modal-foot {
  display: flex; justify-content: center; gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(216, 181, 106, .12);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%; top: 12%;
  z-index: 80;
  transform: translateX(-50%);
  padding: 11px 24px;
  max-width: 82vw;
  font-size: 13px;
  letter-spacing: .1em;
  color: #2a1409;
  background: linear-gradient(180deg, #f2e0b4, #d3ab63);
  border: 1px solid #f7e9c8;
  border-radius: 3px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .5);
  animation: toastIn .32s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -10px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (max-width: 720px) {
  .side { display: none; }
  .top-right { display: none; }
  .card { padding: 26px 22px 20px; }
  h1 { font-size: 21px; }
  .prompt { bottom: 24%; }
}

/* 摄影感：暗角 + 极细颗粒 */
#vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  background: radial-gradient(ellipse at 50% 46%, rgba(0,0,0,0) 46%, rgba(0,0,0,0.16) 80%, rgba(0,0,0,0.34) 100%);
}
#grain {
  position: fixed;
  inset: -20%;
  pointer-events: none;
  z-index: 4;
  opacity: 0.045;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='160' height='160' filter='url(%23n)'/></svg>");
  background-size: 160px 160px;
  mix-blend-mode: overlay;
}
