/* ================================================================
   ENDLESS CRAFT — how the page looks
   ================================================================ */

body {
  font-family: "Trebuchet MS", sans-serif;
  background: #101a14;
  color: #e8f0e4;
  text-align: center;
  margin: 0;
  padding: 16px 12px 40px 12px;
}

h1 {
  font-size: 2.3rem;
  margin: 0;
  color: #8fe0a8;
  letter-spacing: 2px;
  text-shadow: 0 0 20px rgba(143, 224, 168, 0.35);
}

.sub {
  margin: 2px 0 14px 0;
  color: #6f9a84;
  font-size: 0.95rem;
}

/* ---- the bar along the top ---- */
.topbar {
  max-width: 960px;
  margin: 0 auto 10px auto;
}

.bag {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  font-size: 1.05rem;
  min-height: 26px;
}

.bag b { color: #d8f0c8; }
.bag .empty { color: #6f9a84; font-size: 0.95rem; }
.bag .tool {
  border-left: 2px solid #2f5c46;
  padding-left: 10px;
  margin-left: 4px;
  color: #ffd166;
}
.bag .tool b { color: #ffd166; }
.bag .tool i { color: #7f9c8b; font-style: normal; font-size: 0.85rem; }

.status {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 8px;
  color: #9dbcaa;
  font-size: 0.95rem;
}

/* ---- the game itself ---- */
.stage {
  position: relative;
  max-width: 960px;
  margin: 0 auto;
}

canvas {
  width: 100%;
  height: auto;
  display: block;
  border: 3px solid #2f5c46;
  border-radius: 10px;
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.6);
  background: #2a4a3a;
  cursor: crosshair;
  touch-action: none;      /* stop the phone scrolling when you tap the world */
}

#holding-hud {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  background: rgba(8, 22, 16, 0.86);
  border: 1px solid #4e8f6b;
  border-radius: 999px;
  padding: 6px 18px;
  font-size: 0.95rem;
  color: #9ce8b4;
  pointer-events: none;
  white-space: nowrap;
}

.hidden { display: none !important; }

/* ---- panels ---- */
.panel {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, 94%);
  max-height: 92%;
  overflow-y: auto;
  background: rgba(12, 28, 21, 0.975);
  border: 2px solid #4e8f6b;
  border-radius: 14px;
  padding: 18px 20px 20px 20px;
  text-align: left;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.75);
}

.panel h2 {
  margin: 0 0 10px 0;
  color: #8fe0a8;
  font-size: 1.4rem;
}

.panel h3 {
  margin: 16px 0 2px 0;
  color: #ffd166;
  font-size: 1rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  border-bottom: 1px solid #26473a;
  padding-bottom: 4px;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid #1e3a2e;
}

.row-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.row-text b { font-size: 1rem; }
.row-text .num { color: #ffd166; }
.row-text .blurb { color: #85a894; font-size: 0.82rem; margin-top: 1px; }
.row-text .needs { font-size: 0.85rem; margin-top: 3px; }

.needs .need { color: #a8d8b8; margin-right: 7px; }
.needs .need.short { color: #e07a7a; }
.needs .where {
  color: #6f9a84;
  font-size: 0.78rem;
  border: 1px solid #2f5c46;
  border-radius: 999px;
  padding: 1px 7px;
}
.needs .where.ok { color: #9ce8b4; border-color: #4e8f6b; }

button {
  font-family: inherit;
  font-size: 0.92rem;
  padding: 7px 14px;
  border-radius: 8px;
  border: 2px solid #4e8f6b;
  background: #1c3b2d;
  color: #e8f0e4;
  cursor: pointer;
  white-space: nowrap;
}

button:hover:not(:disabled) { background: #2b5943; }
button:disabled { opacity: 0.3; cursor: default; }

button.small { padding: 3px 11px; font-size: 0.88rem; }
button.quiet { border-color: #3a5c4a; color: #7f9c8b; }

button.place { border-color: #ffd166; color: #ffd166; }
button.place:hover:not(:disabled) { background: #4a3f1c; }

.panel .tip {
  color: #85a894;
  font-size: 0.85rem;
  margin: 8px 0;
  line-height: 1.45;
}

.close { width: 100%; margin-top: 12px; }

/* ---- goals ---- */
.goal {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid #1e3a2e;
  color: #85a894;
}
.goal.done { color: #9ce8b4; }
.goal .icon { font-size: 1.15rem; }
.goal .what { flex: 1; }

/* ---- the line under the game ---- */
#message {
  min-height: 24px;
  font-size: 1.05rem;
  color: #ffd166;
  margin: 12px 0 4px 0;
}

.help {
  color: #7f9c8b;
  font-size: 0.88rem;
  max-width: 900px;
  margin: 4px auto;
  line-height: 1.5;
}

.pad { color: #64907a; }

footer { margin-top: 16px; color: #4d6b5b; }

/* ---- back to the arcade ---- */
.arcade-back {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 9999;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(20, 27, 46, 0.85);
  border: 1px solid #3a4568;
  color: #e8ecf8;
  font-family: system-ui, sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  backdrop-filter: blur(4px);
}
.arcade-back:hover { background: #57e0a0; border-color: #57e0a0; color: #06210f; }


/* ================================================================
   THE ON-SCREEN CONTROLS

   Always there, because a tablet has no keyboard and a laptop trackpad
   is no fun either. On a big screen they sit neatly under the game; on
   a phone they spread out to the edges where your thumbs already are.
   ================================================================ */

.touch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  max-width: 960px;
  margin: 12px auto 0 auto;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

.touch-pad {
  display: grid;
  grid-template-columns: repeat(3, 56px);
  grid-template-rows: repeat(3, 56px);
  gap: 5px;
}

.tgap { }

.tbtn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #1c3b2d;
  border: 2px solid #3f7d5f;
  border-radius: 10px;
  color: #cfe8da;
  cursor: pointer;
  position: relative;
  transition: background 0.06s, transform 0.06s;
}

.tbtn .face { font-size: 20px; pointer-events: none; }
.tbtn .tlabel {
  font-size: 9px;
  letter-spacing: 1px;
  color: #7f9c8b;
  font-family: system-ui, sans-serif;
  pointer-events: none;
}

.tbtn.big {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: #3f2f5e;
  border-color: #8b5fb0;
}
.tbtn.big .face { font-size: 30px; }
.tbtn.big .tlabel { color: #d7b7f0; font-size: 11px; }

.touch-menu {
  display: grid;
  grid-template-columns: repeat(2, 62px);
  gap: 5px;
}
.tbtn.menu { height: 46px; }

.tbtn.on {
  background: #57e0a0;
  border-color: #9dffd0;
  color: #0d2018;
  transform: translateY(2px);
}
.tbtn.on .tlabel { color: #0d2018; }
.tbtn.big.on { background: #ffd166; border-color: #fff0c0; }

/* On a narrow screen the pad and buttons go big and hug the edges. */
@media (max-width: 700px) {
  h1 { font-size: 1.7rem; }
  .sub { display: none; }
  .touch { gap: 6px; }
  .touch-pad { grid-template-columns: repeat(3, 52px); grid-template-rows: repeat(3, 52px); }
  .touch-menu { grid-template-columns: repeat(2, 54px); }
  .tbtn.big { width: 80px; height: 80px; }
  .help { font-size: 0.8rem; }
}
