* { margin: 0; padding: 0; box-sizing: border-box; user-select: none; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; overflow: hidden; font-family: -apple-system, 'Microsoft YaHei', sans-serif; background: #1a1a2e; color: #eee; }

#app {
  display: flex; flex-direction: column; height: 100%; width: 100%;
  max-width: 500px; margin: 0 auto;
}

/* Header */
#header { text-align: center; padding: 10px 0 4px; flex-shrink: 0; }
#header h1 { font-size: 20px; font-weight: 700; color: #e2b268; letter-spacing: 4px; margin-bottom: 6px; }

#mode-menu { display: flex; gap: 0; background: #16213e; border-radius: 8px; overflow: hidden; margin: 0 12px; }
.mode-btn {
  flex: 1; padding: 8px 0; border: none; background: transparent; color: #888;
  font-size: 13px; cursor: pointer; transition: all .2s;
}
.mode-btn.active { background: #e2b268; color: #1a1a2e; font-weight: 600; }
.mode-btn:not(.active):active { background: #2a2a4e; }

/* Game Area */
#game-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

#status-bar {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 6px 12px; flex-shrink: 0;
}
#status-text { font-size: 15px; font-weight: 500; color: #ccc; }
#btn-undo, #btn-restart {
  padding: 4px 14px; border: 1px solid #444; border-radius: 6px;
  background: #16213e; color: #ddd; font-size: 13px; cursor: pointer;
}
#btn-undo { font-size: 16px; padding: 4px 10px; }

#board-wrapper {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 8px; min-height: 0;
}
#board { width: 100%; height: 100%; cursor: pointer; touch-action: none; }

#ai-train-info {
  text-align: center; font-size: 12px; color: #888; padding: 2px 0; flex-shrink: 0;
}

/* Overlay */
.overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7); display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.overlay-content {
  background: #1a1a2e; border: 1px solid #333; border-radius: 16px;
  padding: 28px 24px; width: 85%; max-width: 360px; text-align: center;
}
.overlay-content h2 { color: #e2b268; margin-bottom: 20px; font-size: 20px; }

.online-btns { display: flex; gap: 12px; justify-content: center; margin-bottom: 16px; }
.primary-btn {
  padding: 10px 24px; border: none; border-radius: 8px; background: #e2b268;
  color: #1a1a2e; font-size: 14px; font-weight: 600; cursor: pointer;
}
.primary-btn:active { opacity: .8; }
.secondary-btn {
  padding: 8px 20px; border: 1px solid #555; border-radius: 8px;
  background: transparent; color: #aaa; font-size: 13px; cursor: pointer; margin-top: 12px;
}

#room-area p { font-size: 14px; color: #ccc; margin: 8px 0; }
#room-input {
  padding: 8px 12px; border: 1px solid #444; border-radius: 6px;
  background: #16213e; color: #eee; font-size: 14px; width: 160px; text-align: center;
  outline: none;
}
#room-input:focus { border-color: #e2b268; }
#join-area { display: flex; gap: 8px; align-items: center; justify-content: center; }
#conn-status { color: #e2b268; font-size: 13px; min-height: 20px; }

@media (max-width: 360px) {
  #header h1 { font-size: 17px; }
  .mode-btn { font-size: 12px; padding: 6px 0; }
  #status-text { font-size: 13px; }
}
