:root {
  color-scheme: dark;
  --hotbar-outer-height: 64px; /* ボタン高さ60px + 上下ボーダー各2px */
  --hotbar-bottom: 1rem;
}

html, body {
  margin: 0;
  padding: 0;
  background: #000;
  color: #e0e0e0;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

#game {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
  z-index: 0;
}

#wrap {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

#status {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  font-size: 0.8rem;
  background: rgba(10, 10, 18, 0.75);
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  border: 1px solid rgba(51, 51, 68, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

#status.open { color: #6f6; }
#status.closed { color: #f66; }

#me {
  position: absolute;
  top: 2.6rem;
  left: 0.75rem;
  font-size: 0.8rem;
  color: #9bf;
  background: rgba(10, 10, 18, 0.75);
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  border: 1px solid rgba(51, 51, 68, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

#me:empty { display: none; }

/* ── チャット・看板フォーム（ホットバーの上に浮かぶ） ── */
#chat,
#sign-form {
  position: absolute;
  bottom: calc(var(--hotbar-bottom) + var(--hotbar-outer-height) + 8px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.4rem;
  width: min(calc(100% - 2rem), 480px);
  pointer-events: auto;
}

#chat[hidden],
#sign-form[hidden] { display: none; }

#chat input,
#sign-form input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  font: inherit;
  border-radius: 6px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  -webkit-user-select: auto;
  user-select: auto;
}

#chat input {
  background: rgba(10, 10, 18, 0.85);
  color: #e0e0e0;
  border: 1px solid #334;
}

#chat button {
  padding: 0.5rem 0.9rem;
  font: inherit;
  background: rgba(34, 68, 102, 0.9);
  color: #fff;
  border: 1px solid #48a;
  border-radius: 6px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

#chat button:disabled { opacity: 0.5; cursor: not-allowed; }

#sign-form input {
  background: rgba(20, 12, 4, 0.9);
  color: #f0d090;
  border: 1px solid #8a5520;
}

#sign-form button {
  padding: 0.5rem 0.9rem;
  font: inherit;
  background: rgba(80, 48, 16, 0.9);
  color: #f0d090;
  border: 1px solid #8a5520;
  border-radius: 6px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* ── アクションバー：ホットバー ＋ 建築バーをまとめたコンテナ ── */
#action-bar {
  position: absolute;
  bottom: var(--hotbar-bottom);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

/* ── 建築ツールバー（⛏️ボタンで開閉） ── */
#build-toolbar {
  display: flex;
  flex-direction: row;
  gap: 4px;
  padding: 4px;
  background: rgba(10, 10, 18, 0.82);
  border: 2px solid #555;
  border-radius: 6px;
  pointer-events: auto;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

#build-toolbar[hidden] { display: none; }

.build-slot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  padding: 0;
  background: rgba(30, 30, 44, 0.7);
  border: 2px solid #444;
  border-bottom-color: #222;
  border-right-color: #222;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: inset 1px 1px 0 rgba(255,255,255,0.1);
  transition: filter 0.1s;
}

.build-slot:hover {
  filter: brightness(1.4);
  border-color: #aaa;
  border-bottom-color: #444;
  border-right-color: #444;
}

.build-slot.selected {
  background: rgba(60, 100, 60, 0.5);
  border-color: #8f8;
  border-bottom-color: #4a4;
  border-right-color: #4a4;
  box-shadow: 0 0 6px rgba(100,255,100,0.4), inset 1px 1px 0 rgba(255,255,255,0.2);
}

.build-icon {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
}

.build-key {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 0.55rem;
  color: #ccc;
  line-height: 1;
}

/* ── ホットバー本体（⛏️ / チャット / 看板） ── */
#hotbar {
  display: flex;
  flex-direction: row;
  gap: 0.4rem;
  pointer-events: auto;
}

#build-btn,
#chat-btn,
#sign-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 60px;
  height: 60px;
  padding: 0;
  font-family: inherit;
  background: rgba(10, 10, 18, 0.82);
  color: #e0e0e0;
  border: 2px solid #555;
  border-bottom-color: #222;
  border-right-color: #222;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: inset 1px 1px 0 rgba(255,255,255,0.15);
  transition: filter 0.1s;
}

#build-btn:hover,
#chat-btn:hover,
#sign-btn:hover {
  filter: brightness(1.3);
  border-color: #aaa;
  border-bottom-color: #444;
  border-right-color: #444;
}

#build-btn.active {
  background: rgba(40, 60, 30, 0.95);
  border-color: #8f8;
}

#chat-btn.active {
  background: rgba(16, 40, 80, 0.95);
  border-color: #60a0f0;
}

#sign-btn.active {
  background: rgba(80, 48, 16, 0.9);
  border-color: #f0c060;
}

.hotbar-icon {
  width: 28px;
  height: 28px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
}

.hotbar-label {
  font-size: 0.6rem;
  color: #aaa;
  letter-spacing: 0.03em;
}
