:root {
  --sea: #2e5f80;
  --sea-deep: #24485f;
  --ink: #21303a;
  --paper: #fdf6e6;
  --paper-2: #f3e7cd;
  --line: #c9b58c;
  --accent: #f2a33c;
  --good: #62b56a;
  --bad: #d9605a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background:
    radial-gradient(120% 90% at 50% 0%, #3d7b9e 0%, var(--sea) 45%, var(--sea-deep) 100%);
  color: var(--paper);
  font: 14px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  display: flex;
  justify-content: center;
  padding: 16px 12px 24px;
}

#shell {
  width: 100%;
  max-width: 1200px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
}

#topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

#topbar h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.28);
}

.spacer { flex: 1 1 auto; }

.pill {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(253, 246, 230, 0.16);
  border: 1px solid rgba(253, 246, 230, 0.28);
  white-space: nowrap;
}

.pill-on { background: rgba(98, 181, 106, 0.32); border-color: rgba(98, 181, 106, 0.6); }
.pill-off { background: rgba(217, 96, 90, 0.28); border-color: rgba(217, 96, 90, 0.55); }

.btn {
  font: inherit;
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  color: var(--ink);
  background: var(--paper-2);
  border: 1px solid var(--line);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
}

.btn:hover { background: #fff6e2; }
.btn:active { transform: translateY(1px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25); }
.btn:disabled { opacity: 0.5; cursor: default; box-shadow: none; transform: none; }

.btn-go { background: var(--accent); border-color: #b9762a; }
.btn-go:hover:enabled { background: #ffb857; }

#stage {
  position: relative;
  display: flex;
  justify-content: center;
}

#mapwrap {
  position: relative;
  display: inline-block;
  line-height: 0;
}

#island {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #1d3d52;
  border-radius: 6px;
  border: 3px solid rgba(253, 246, 230, 0.22);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  touch-action: manipulation;
}

#labels {
  position: absolute;
  left: 3px;
  top: 3px;
  right: 3px;
  bottom: 3px;
  width: auto;
  height: auto;
  pointer-events: none;
  overflow: hidden;
}

.nametag {
  position: absolute;
  transform: translate(-50%, -100%);
  font: 700 12px/1.2 ui-sans-serif, system-ui, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  white-space: nowrap;
  padding: 2px 8px 3px;
  border-radius: 999px;
  letter-spacing: 0.02em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.nametag {
  color: #fff8ee;
  background: rgba(28, 24, 30, 0.78);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.nametag.on {
  color: #2b2118;
  background: rgba(255, 196, 92, 0.96);
  text-shadow: none;
}


#card {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 236px;
  display: flex;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  color: var(--ink);
  background: rgba(253, 246, 230, 0.96);
  border: 2px solid var(--line);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4);
}

#card[hidden] { display: none; }

#cardPfp {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  image-rendering: pixelated;
  background: #e6d7b4;
  border: 2px solid var(--line);
  flex: 0 0 auto;
}

.cardbody { min-width: 0; }
.cardname { font-weight: 700; font-size: 14px; }
.cardtitle { font-size: 11px; opacity: 0.72; }
.carddoing {
  margin-top: 4px;
  font-size: 11px;
  font-weight: 700;
  color: #6a4a12;
}
.carddesc {
  margin: 5px 0 0;
  font-size: 11px;
  line-height: 1.35;
  opacity: 0.85;
  max-height: 54px;
  overflow: hidden;
}

.cardclose {
  position: absolute;
  top: 3px;
  right: 6px;
  border: 0;
  background: none;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  color: #7a6a4c;
}

#promptbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid rgba(253, 246, 230, 0.16);
}

#promptWho {
  font-size: 12px;
  min-width: 120px;
  opacity: 0.85;
}

#promptInput {
  flex: 1 1 260px;
  min-width: 180px;
  font: inherit;
  font-size: 13px;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
}

#promptInput:disabled { opacity: 0.55; }

.status { font-size: 12px; min-width: 88px; }
.status.ok { color: #9fe0a4; }
.status.err { color: #ffb0ac; }

#hint {
  font-size: 11px;
  opacity: 0.6;
  text-align: center;
}

@media (max-width: 620px) {
  #card { position: static; width: auto; margin-top: 10px; }
  #stage { flex-direction: column; align-items: center; }
}
